Skip to content

Commit

Permalink
Minswap v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Sluder committed Jul 18, 2024
1 parent 5c6d6ad commit 59ea629
Show file tree
Hide file tree
Showing 12 changed files with 484 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to Dexter will be documented in this file.

## [UNRELEASED]
- Minswap v2 integration

## [v5.2.0]
- Add `withMinimumReceive(minReceive: bigint)` to SwapRequest

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<p align="center">Customizable Typescript SDK for interacting with Cardano DEXs.</p>
<img src="https://raw.githubusercontent.com/IndigoProtocol/dexter/master/src/dex/logo/sundaeswap.png" width="30" />
<img src="https://raw.githubusercontent.com/IndigoProtocol/dexter/master/src/dex/logo/minswap.png" width="30" />
<img src="https://raw.githubusercontent.com/IndigoProtocol/dexter/master/src/dex/logo/minswapv2.png" width="30" />
<img src="https://raw.githubusercontent.com/IndigoProtocol/dexter/master/src/dex/logo/muesliswap.png" width="30" />
<img src="https://raw.githubusercontent.com/IndigoProtocol/dexter/master/src/dex/logo/wingriders.png" width="30" />
<img src="https://raw.githubusercontent.com/IndigoProtocol/dexter/master/src/dex/logo/vyfinance.png" width="30" />
Expand Down
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export enum DatumParameterKey {
Action = 'Action',
TokenPolicyId = 'TokenPolicyId',
TokenAssetName = 'TokenAssetName',
ReserveA = 'ReserveA',
ReserveB = 'ReserveB',

/**
* Swap/wallet info.
Expand All @@ -34,6 +36,8 @@ export enum DatumParameterKey {
BatcherFee = 'BatcherFee',
DepositFee = 'DepositFee',
ScooperFee = 'ScooperFee',
BaseFee = 'BaseFee',
FeeSharingNumerator = 'FeeSharingNumerator',

/**
* LP info.
Expand Down
2 changes: 2 additions & 0 deletions src/definition-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export class DefinitionBuilder {
* Recursively pull parameters from datum using definition template.
*/
private extractParameters(definedDefinition: DefinitionField, templateDefinition: DefinitionField, foundParameters: DatumParameters = {}): DatumParameters {
if (! templateDefinition) return foundParameters;

if (templateDefinition instanceof Function) {
templateDefinition(definedDefinition, foundParameters);

Expand Down
130 changes: 130 additions & 0 deletions src/dex/definitions/minswap-v2/order.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import { DatumParameterKey } from '@app/constants';

/**
* https://github.com/minswap/minswap-dex-v2/blob/main/src/types/order.ts
*/
export default {
constructor: 0,
fields: [
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.SenderPubKeyHash,
}
]
},
{
constructor: 0,
fields: [
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.SenderPubKeyHash,
}
]
},
{
constructor: 0,
fields: [
{
constructor: 0,
fields: [
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.SenderStakingKeyHash,
}
]
}
]
}
]
}
]
},
{
constructor: 0,
fields: []
},
{
constructor: 0,
fields: [
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.SenderPubKeyHash,
}
]
},
{
constructor: 0,
fields: [
{
constructor: 0,
fields: [
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.SenderPubKeyHash,
}
]
}
]
}
]
}
]
},
{
constructor: 0,
fields: []
},
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.LpTokenPolicyId
},
{
bytes: DatumParameterKey.LpTokenAssetName
}
]
},
{
constructor: 0,
fields: [
{
constructor: 1,
fields: []
},
{
constructor: 0,
fields: [
{
int: DatumParameterKey.SwapInAmount
}
]
},
{
int: DatumParameterKey.MinReceive
},
{
constructor: 0,
fields: []
}
]
},
{
int: DatumParameterKey.BatcherFee
},
{
constructor: 1,
fields: []
}
]
}
59 changes: 59 additions & 0 deletions src/dex/definitions/minswap-v2/pool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { DatumParameterKey } from '@app/constants';
import { DatumParameters, DefinitionField } from '@app/types';

/**
* https://github.com/minswap/minswap-dex-v2/blob/main/src/types/pool.ts
*/
export default {
constructor: 0,
fields: [
{
constructor: 0,
fields: [
(field: DefinitionField, parameters: DatumParameters, shouldExtract: boolean = true) => {
return;
},
]
},
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.PoolAssetAPolicyId
},
{
bytes: DatumParameterKey.PoolAssetAAssetName
}
]
},
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.PoolAssetBPolicyId
},
{
bytes: DatumParameterKey.PoolAssetBAssetName
}
]
},
{
int: DatumParameterKey.TotalLpTokens
},
{
int: DatumParameterKey.ReserveA
},
{
int: DatumParameterKey.ReserveB
},
{
int: DatumParameterKey.BaseFee
},
{
int: DatumParameterKey.FeeSharingNumerator
},
(field: DefinitionField, parameters: DatumParameters, shouldExtract: boolean = true) => {
return;
},
]
}
2 changes: 1 addition & 1 deletion src/dex/definitions/minswap/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default {
constructor: 0,
fields: [
{
bytes: DatumParameterKey.SenderStakingKeyHash,
bytes: DatumParameterKey.SenderPubKeyHash,
}
]
}
Expand Down
Binary file added src/dex/logo/minswapv2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 59ea629

Please sign in to comment.