Skip to content

Commit

Permalink
Splash
Browse files Browse the repository at this point in the history
  • Loading branch information
Sluder committed Jul 25, 2024
1 parent 59ea629 commit 446a6e6
Show file tree
Hide file tree
Showing 7 changed files with 495 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export enum DatumParameterKey {
MinReceive = 'MinReceive',
Expiration = 'Expiration',
AllowPartialFill = 'AllowPartialFill',
FireOrKill = 'FireOrKill',

/**
* Trading fees.
Expand All @@ -38,6 +39,7 @@ export enum DatumParameterKey {
ScooperFee = 'ScooperFee',
BaseFee = 'BaseFee',
FeeSharingNumerator = 'FeeSharingNumerator',
FeePaymentKeyHash = 'FeePaymentKeyHash',

/**
* LP info.
Expand All @@ -62,6 +64,8 @@ export enum DatumParameterKey {
RequestScriptHash = 'RequestScriptHash',
StakeAdminPolicy = 'StakeAdminPolicy',
LqBound = 'LqBound',

Unknown = 'Unknown',
}

export enum TransactionStatus {
Expand Down
2 changes: 1 addition & 1 deletion src/dex/definitions/minswap-v2/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default {
int: DatumParameterKey.MinReceive
},
{
constructor: 0,
constructor: DatumParameterKey.FireOrKill,
fields: []
}
]
Expand Down
128 changes: 128 additions & 0 deletions src/dex/definitions/splash/order.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { DatumParameterKey } from '@app/constants';
import { DatumParameters, DefinitionField } from '@app/types';

export default {
constructor: 0,
fields: [
{
bytes: DatumParameterKey.Action
},
{
bytes: DatumParameterKey.Unknown
},
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.SwapInTokenPolicyId
},
{
bytes: DatumParameterKey.SwapInTokenAssetName
}
]
},
{
int: DatumParameterKey.SwapInAmount
},
{
int: DatumParameterKey.BaseFee
},
{
int: DatumParameterKey.MinReceive
},
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.SwapOutTokenPolicyId
},
{
bytes: DatumParameterKey.SwapOutTokenAssetName
}
]
},
{
constructor: 0,
fields: [
{
int: DatumParameterKey.LpFeeNumerator,
},
{
int: DatumParameterKey.LpFeeDenominator,
}
]
},
{
int: DatumParameterKey.Unknown
},
{
constructor: 0,
fields: [
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.SenderPubKeyHash
}
]
},
{
constructor: 0,
fields: [
{
constructor: 0,
fields: [
(field: DefinitionField, parameters: DatumParameters, shouldExtract: boolean = true) => {
if (! shouldExtract) {
const stakeKeyHash: string = parameters[DatumParameterKey.SenderStakingKeyHash] as string ?? null;

if (! stakeKeyHash) return;

return {
constructor: 0,
fields: [
{
bytes: stakeKeyHash,
}
],
};
}

if ('fields' in field) {
if (field.constructor === 1) return;

if (field.fields.length > 0 && 'bytes' in field.fields[0]) {
parameters[DatumParameterKey.SenderStakingKeyHash] = field.fields[0].bytes;
}
}

return;
},
]
}
]
}
]
},
{
bytes: DatumParameterKey.SenderPubKeyHash
},
(field: DefinitionField, parameters: DatumParameters, shouldExtract: boolean = true) => {
if (! shouldExtract) {
const stakeKeyHash: string = parameters[DatumParameterKey.FeePaymentKeyHash] as string ?? null;

if (! stakeKeyHash) return;

return [
{
bytes: DatumParameterKey.FeePaymentKeyHash
}
];
}

parameters[DatumParameterKey.FeePaymentKeyHash] = (field as any)[0].bytes;

return;
},
]
}
81 changes: 81 additions & 0 deletions src/dex/definitions/splash/pool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { DatumParameterKey } from '@app/constants';

export default {
constructor: 0,
fields: [
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.TokenPolicyId // Pool NFT
},
{
bytes: DatumParameterKey.TokenAssetName
}
]
},
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.PoolAssetAPolicyId
},
{
bytes: DatumParameterKey.PoolAssetAAssetName
}
]
},
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.PoolAssetBPolicyId
},
{
bytes: DatumParameterKey.PoolAssetBAssetName
}
]
},
{
constructor: 0,
fields: [
{
bytes: DatumParameterKey.LpTokenPolicyId
},
{
bytes: DatumParameterKey.LpTokenAssetName
}
]
},
{
int: "99000"
},
{
int: "100"
},
{
int: "3050507335"
},
{
int: "19927279036"
},
[
{
constructor: 0,
fields: [
{
constructor: 1,
fields: [
{
bytes: "03511ad08fb2b9db4c2212a66830a3b5e54a082aad2b805bd3583b05"
}
]
}
]
}
],
{
bytes: "75c4570eb625ae881b32a34c52b159f6f3f3f2c7aaabf5bac4688133"
}
]
}
Binary file modified src/dex/logo/spectrum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/dex/minswap-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export class MinswapV2 extends BaseDex {
[DatumParameterKey.BatcherFee]: batcherFee.value,
[DatumParameterKey.LpTokenPolicyId]: liquidityPool.lpToken.policyId,
[DatumParameterKey.LpTokenAssetName]: liquidityPool.lpToken.nameHex,
[DatumParameterKey.FireOrKill]: 0,
};

const datumBuilder: DefinitionBuilder = new DefinitionBuilder();
Expand Down
Loading

0 comments on commit 446a6e6

Please sign in to comment.