@shogun-sdk/intents-sdk 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/constants.js +24 -8
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/core/evm/intent-provider.js +55 -2
- package/dist/esm/core/evm/intent-provider.js.map +1 -1
- package/dist/esm/core/evm/order-signature.js +12 -1
- package/dist/esm/core/evm/order-signature.js.map +1 -1
- package/dist/esm/core/evm/permit2.js +24 -1
- package/dist/esm/core/evm/permit2.js.map +1 -1
- package/dist/esm/core/evm/sdk.js +9 -4
- package/dist/esm/core/evm/sdk.js.map +1 -1
- package/dist/esm/core/evm/validator.js +21 -0
- package/dist/esm/core/evm/validator.js.map +1 -1
- package/dist/esm/core/orders/cross-chain.js +4 -1
- package/dist/esm/core/orders/cross-chain.js.map +1 -1
- package/dist/esm/core/orders/dca-single-chain.js +169 -0
- package/dist/esm/core/orders/dca-single-chain.js.map +1 -0
- package/dist/esm/core/orders/single-chain.js +6 -1
- package/dist/esm/core/orders/single-chain.js.map +1 -1
- package/dist/esm/core/sdk.js +55 -81
- package/dist/esm/core/sdk.js.map +1 -1
- package/dist/esm/core/solana/dca/cancel-order.js +61 -0
- package/dist/esm/core/solana/dca/cancel-order.js.map +1 -0
- package/dist/esm/core/solana/dca/create-order.js +82 -0
- package/dist/esm/core/solana/dca/create-order.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/errors/sourceChainGuard.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/cancelOrder.js +5 -20
- package/dist/esm/core/solana/generated/cross-chain/instructions/cancelOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/claimTokens.js +4 -16
- package/dist/esm/core/solana/generated/cross-chain/instructions/claimTokens.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/collectProtocolFees.js +4 -16
- package/dist/esm/core/solana/generated/cross-chain/instructions/collectProtocolFees.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/createGuard.js +14 -56
- package/dist/esm/core/solana/generated/cross-chain/instructions/createGuard.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/createOrder.js +6 -24
- package/dist/esm/core/solana/generated/cross-chain/instructions/createOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/preStartOrderExecution.js +4 -16
- package/dist/esm/core/solana/generated/cross-chain/instructions/preStartOrderExecution.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/setAdmin.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/setAuctioneerPubKey.js +1 -4
- package/dist/esm/core/solana/generated/cross-chain/instructions/setAuctioneerPubKey.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/startOrderExecution.js +2 -8
- package/dist/esm/core/solana/generated/cross-chain/instructions/startOrderExecution.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/startOrderExecutionAfterSwap.js +3 -12
- package/dist/esm/core/solana/generated/cross-chain/instructions/startOrderExecutionAfterSwap.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/shared/index.js +2 -5
- package/dist/esm/core/solana/generated/cross-chain/shared/index.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/types/auctioneerPubkeyUpdated.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/types/tokenInSwapped.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/errors/singleChainGuard.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelDcaOrder.js +2 -8
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelDcaOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelLimitOrder.js +2 -8
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelLimitOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/collectProtocolFees.js +6 -24
- package/dist/esm/core/solana/generated/single-chain/instructions/collectProtocolFees.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/createDcaOrder.js +6 -24
- package/dist/esm/core/solana/generated/single-chain/instructions/createDcaOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/createGuard.js +4 -16
- package/dist/esm/core/solana/generated/single-chain/instructions/createGuard.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/createLimitOrder.js +6 -24
- package/dist/esm/core/solana/generated/single-chain/instructions/createLimitOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.js +9 -36
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillLimitOrder.js +8 -32
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillLimitOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/setAdmin.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.js +1 -4
- package/dist/esm/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/shared/index.js +2 -5
- package/dist/esm/core/solana/generated/single-chain/shared/index.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/types/auctioneerPubkeyUpdated.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/types/guardCreated.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/types/limitOrderFulfilled.js.map +1 -1
- package/dist/esm/core/solana/inspect.js +43 -0
- package/dist/esm/core/solana/inspect.js.map +1 -0
- package/dist/esm/core/solana/sdk.js +36 -0
- package/dist/esm/core/solana/sdk.js.map +1 -1
- package/dist/esm/core/solana/utils.js.map +1 -1
- package/dist/esm/core/solana/validator.js +3 -0
- package/dist/esm/core/solana/validator.js.map +1 -1
- package/dist/esm/core/sui/sdk.js +0 -3
- package/dist/esm/core/sui/sdk.js.map +1 -1
- package/dist/esm/core/sui/validator.js +4 -0
- package/dist/esm/core/sui/validator.js.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/base-validator.js +28 -0
- package/dist/esm/utils/base-validator.js.map +1 -1
- package/dist/esm/utils/order-validator.js +31 -0
- package/dist/esm/utils/order-validator.js.map +1 -1
- package/dist/esm/utils/quote/aggregator.js +2 -2
- package/dist/esm/utils/quote/aggregator.js.map +1 -1
- package/dist/esm/utils/quote/liquidswap.js.map +1 -1
- package/dist/types/constants.d.ts +10 -7
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/core/evm/intent-provider.d.ts +5 -2
- package/dist/types/core/evm/intent-provider.d.ts.map +1 -1
- package/dist/types/core/evm/order-signature.d.ts +5 -0
- package/dist/types/core/evm/order-signature.d.ts.map +1 -1
- package/dist/types/core/evm/permit2.d.ts +90 -0
- package/dist/types/core/evm/permit2.d.ts.map +1 -1
- package/dist/types/core/evm/sdk.d.ts +3 -1
- package/dist/types/core/evm/sdk.d.ts.map +1 -1
- package/dist/types/core/evm/validator.d.ts +4 -0
- package/dist/types/core/evm/validator.d.ts.map +1 -1
- package/dist/types/core/orders/cross-chain.d.ts.map +1 -1
- package/dist/types/core/orders/dca-single-chain.d.ts +47 -0
- package/dist/types/core/orders/dca-single-chain.d.ts.map +1 -0
- package/dist/types/core/orders/single-chain.d.ts.map +1 -1
- package/dist/types/core/sdk.d.ts +15 -10
- package/dist/types/core/sdk.d.ts.map +1 -1
- package/dist/types/core/solana/dca/cancel-order.d.ts +5 -0
- package/dist/types/core/solana/dca/cancel-order.d.ts.map +1 -0
- package/dist/types/core/solana/dca/create-order.d.ts +8 -0
- package/dist/types/core/solana/dca/create-order.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/errors/sourceChainGuard.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/acceptAdmin.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/acceptAdmin.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/cancelOrder.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/cancelOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/claimTokens.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/claimTokens.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/collectProtocolFees.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/collectProtocolFees.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/createGuard.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/createOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/initialize.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/initialize.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/preStartOrderExecution.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/preStartOrderExecution.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/setAdmin.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/setAuctioneerPubKey.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/startOrderExecution.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/startOrderExecution.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/startOrderExecutionAfterSwap.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/shared/index.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/types/auctioneerPubkeyUpdated.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/types/tokenInSwapped.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/errors/singleChainGuard.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/acceptAdmin.d.ts +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/acceptAdmin.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/cancelDcaOrder.d.ts +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/cancelDcaOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/cancelLimitOrder.d.ts +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/cancelLimitOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/collectProtocolFees.d.ts +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/collectProtocolFees.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/createDcaOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/createGuard.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/createLimitOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/fulfillLimitOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/initialize.d.ts +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/initialize.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/setAdmin.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/shared/index.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/types/auctioneerPubkeyUpdated.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/types/guardCreated.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/types/limitOrderFulfilled.d.ts.map +1 -1
- package/dist/types/core/solana/inspect.d.ts +14 -0
- package/dist/types/core/solana/inspect.d.ts.map +1 -0
- package/dist/types/core/solana/sdk.d.ts +4 -1
- package/dist/types/core/solana/sdk.d.ts.map +1 -1
- package/dist/types/core/solana/utils.d.ts +2 -1
- package/dist/types/core/solana/utils.d.ts.map +1 -1
- package/dist/types/core/solana/validator.d.ts +1 -0
- package/dist/types/core/solana/validator.d.ts.map +1 -1
- package/dist/types/core/sui/sdk.d.ts +1 -2
- package/dist/types/core/sui/sdk.d.ts.map +1 -1
- package/dist/types/core/sui/validator.d.ts +1 -0
- package/dist/types/core/sui/validator.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/intent.d.ts +22 -0
- package/dist/types/types/intent.d.ts.map +1 -1
- package/dist/types/utils/base-validator.d.ts +7 -0
- package/dist/types/utils/base-validator.d.ts.map +1 -1
- package/dist/types/utils/order-validator.d.ts +15 -0
- package/dist/types/utils/order-validator.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/auth/siwe.ts +1 -1
- package/src/constants.ts +72 -39
- package/src/core/evm/connectors/hyperevm.ts +1 -1
- package/src/core/evm/intent-provider.ts +88 -4
- package/src/core/evm/order-signature.ts +23 -1
- package/src/core/evm/permit2.ts +47 -1
- package/src/core/evm/sdk.ts +20 -7
- package/src/core/evm/validator.ts +32 -0
- package/src/core/orders/api/fetch.ts +0 -1
- package/src/core/orders/api/index.ts +4 -4
- package/src/core/orders/cross-chain.ts +5 -1
- package/src/core/orders/dca-single-chain.ts +143 -0
- package/src/core/orders/single-chain.ts +8 -1
- package/src/core/sdk.ts +72 -100
- package/src/core/solana/cancel-order.ts +1 -1
- package/src/core/solana/dca/cancel-order.ts +91 -0
- package/src/core/solana/dca/create-order.ts +142 -0
- package/src/core/solana/generated/cross-chain/errors/sourceChainGuard.ts +1 -3
- package/src/core/solana/generated/cross-chain/instructions/acceptAdmin.ts +1 -1
- package/src/core/solana/generated/cross-chain/instructions/cancelOrder.ts +6 -21
- package/src/core/solana/generated/cross-chain/instructions/claimTokens.ts +5 -17
- package/src/core/solana/generated/cross-chain/instructions/collectProtocolFees.ts +6 -20
- package/src/core/solana/generated/cross-chain/instructions/createGuard.ts +14 -56
- package/src/core/solana/generated/cross-chain/instructions/createOrder.ts +6 -24
- package/src/core/solana/generated/cross-chain/instructions/initialize.ts +1 -1
- package/src/core/solana/generated/cross-chain/instructions/preStartOrderExecution.ts +6 -20
- package/src/core/solana/generated/cross-chain/instructions/setAdmin.ts +1 -4
- package/src/core/solana/generated/cross-chain/instructions/setAuctioneerPubKey.ts +2 -7
- package/src/core/solana/generated/cross-chain/instructions/startOrderExecution.ts +4 -12
- package/src/core/solana/generated/cross-chain/instructions/startOrderExecutionAfterSwap.ts +3 -12
- package/src/core/solana/generated/cross-chain/shared/index.ts +2 -5
- package/src/core/solana/generated/cross-chain/types/auctioneerPubkeyUpdated.ts +1 -4
- package/src/core/solana/generated/cross-chain/types/tokenInSwapped.ts +1 -5
- package/src/core/solana/generated/single-chain/errors/singleChainGuard.ts +1 -3
- package/src/core/solana/generated/single-chain/instructions/acceptAdmin.ts +1 -1
- package/src/core/solana/generated/single-chain/instructions/cancelDcaOrder.ts +4 -12
- package/src/core/solana/generated/single-chain/instructions/cancelLimitOrder.ts +4 -12
- package/src/core/solana/generated/single-chain/instructions/collectProtocolFees.ts +8 -28
- package/src/core/solana/generated/single-chain/instructions/createDcaOrder.ts +6 -24
- package/src/core/solana/generated/single-chain/instructions/createGuard.ts +5 -20
- package/src/core/solana/generated/single-chain/instructions/createLimitOrder.ts +6 -24
- package/src/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.ts +9 -36
- package/src/core/solana/generated/single-chain/instructions/fulfillLimitOrder.ts +8 -32
- package/src/core/solana/generated/single-chain/instructions/initialize.ts +1 -1
- package/src/core/solana/generated/single-chain/instructions/setAdmin.ts +1 -4
- package/src/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.ts +2 -7
- package/src/core/solana/generated/single-chain/shared/index.ts +2 -5
- package/src/core/solana/generated/single-chain/types/auctioneerPubkeyUpdated.ts +1 -4
- package/src/core/solana/generated/single-chain/types/guardCreated.ts +1 -5
- package/src/core/solana/generated/single-chain/types/limitOrderFulfilled.ts +1 -4
- package/src/core/solana/inspect.ts +50 -0
- package/src/core/solana/order-instructions.ts +1 -1
- package/src/core/solana/sdk.ts +65 -2
- package/src/core/solana/utils.ts +2 -1
- package/src/core/solana/validator.ts +4 -0
- package/src/core/sui/sdk.ts +2 -6
- package/src/core/sui/validator.ts +5 -0
- package/src/index.ts +12 -1
- package/src/types/api.ts +1 -1
- package/src/types/intent.ts +27 -0
- package/src/utils/base-validator.ts +40 -0
- package/src/utils/order-validator.ts +38 -0
- package/src/utils/quote/aggregator.ts +2 -2
- package/src/utils/quote/liquidswap.ts +2 -2
|
@@ -71,11 +71,9 @@ export type CollectProtocolFeesInstruction<
|
|
|
71
71
|
]
|
|
72
72
|
>;
|
|
73
73
|
|
|
74
|
-
export type CollectProtocolFeesInstructionData = {
|
|
75
|
-
discriminator: ReadonlyUint8Array;
|
|
76
|
-
};
|
|
74
|
+
export type CollectProtocolFeesInstructionData = { discriminator: ReadonlyUint8Array };
|
|
77
75
|
|
|
78
|
-
export type CollectProtocolFeesInstructionDataArgs =
|
|
76
|
+
export type CollectProtocolFeesInstructionDataArgs = object;
|
|
79
77
|
|
|
80
78
|
export function getCollectProtocolFeesInstructionDataEncoder(): Encoder<CollectProtocolFeesInstructionDataArgs> {
|
|
81
79
|
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({
|
|
@@ -161,18 +159,9 @@ export async function getCollectProtocolFeesInstructionAsync<
|
|
|
161
159
|
adminSingleton: { value: input.adminSingleton ?? null, isWritable: false },
|
|
162
160
|
guard: { value: input.guard ?? null, isWritable: true },
|
|
163
161
|
feeTokenMint: { value: input.feeTokenMint ?? null, isWritable: false },
|
|
164
|
-
adminFeeTokenAccount: {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
guardFeeTokenAccount: {
|
|
169
|
-
value: input.guardFeeTokenAccount ?? null,
|
|
170
|
-
isWritable: true,
|
|
171
|
-
},
|
|
172
|
-
feeTokenProgram: {
|
|
173
|
-
value: input.feeTokenProgram ?? null,
|
|
174
|
-
isWritable: false,
|
|
175
|
-
},
|
|
162
|
+
adminFeeTokenAccount: { value: input.adminFeeTokenAccount ?? null, isWritable: true },
|
|
163
|
+
guardFeeTokenAccount: { value: input.guardFeeTokenAccount ?? null, isWritable: true },
|
|
164
|
+
feeTokenProgram: { value: input.feeTokenProgram ?? null, isWritable: false },
|
|
176
165
|
};
|
|
177
166
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedAccount>;
|
|
178
167
|
|
|
@@ -275,18 +264,9 @@ export function getCollectProtocolFeesInstruction<
|
|
|
275
264
|
adminSingleton: { value: input.adminSingleton ?? null, isWritable: false },
|
|
276
265
|
guard: { value: input.guard ?? null, isWritable: true },
|
|
277
266
|
feeTokenMint: { value: input.feeTokenMint ?? null, isWritable: false },
|
|
278
|
-
adminFeeTokenAccount: {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
},
|
|
282
|
-
guardFeeTokenAccount: {
|
|
283
|
-
value: input.guardFeeTokenAccount ?? null,
|
|
284
|
-
isWritable: true,
|
|
285
|
-
},
|
|
286
|
-
feeTokenProgram: {
|
|
287
|
-
value: input.feeTokenProgram ?? null,
|
|
288
|
-
isWritable: false,
|
|
289
|
-
},
|
|
267
|
+
adminFeeTokenAccount: { value: input.adminFeeTokenAccount ?? null, isWritable: true },
|
|
268
|
+
guardFeeTokenAccount: { value: input.guardFeeTokenAccount ?? null, isWritable: true },
|
|
269
|
+
feeTokenProgram: { value: input.feeTokenProgram ?? null, isWritable: false },
|
|
290
270
|
};
|
|
291
271
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedAccount>;
|
|
292
272
|
|
|
@@ -227,19 +227,10 @@ export async function getCreateDcaOrderInstructionAsync<
|
|
|
227
227
|
order: { value: input.order ?? null, isWritable: true },
|
|
228
228
|
guard: { value: input.guard ?? null, isWritable: false },
|
|
229
229
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
230
|
-
associatedTokenProgram: {
|
|
231
|
-
value: input.associatedTokenProgram ?? null,
|
|
232
|
-
isWritable: false,
|
|
233
|
-
},
|
|
230
|
+
associatedTokenProgram: { value: input.associatedTokenProgram ?? null, isWritable: false },
|
|
234
231
|
tokenInMint: { value: input.tokenInMint ?? null, isWritable: false },
|
|
235
|
-
userTokenInAccount: {
|
|
236
|
-
|
|
237
|
-
isWritable: true,
|
|
238
|
-
},
|
|
239
|
-
guardTokenInAccount: {
|
|
240
|
-
value: input.guardTokenInAccount ?? null,
|
|
241
|
-
isWritable: true,
|
|
242
|
-
},
|
|
232
|
+
userTokenInAccount: { value: input.userTokenInAccount ?? null, isWritable: true },
|
|
233
|
+
guardTokenInAccount: { value: input.guardTokenInAccount ?? null, isWritable: true },
|
|
243
234
|
tokenInProgram: { value: input.tokenInProgram ?? null, isWritable: false },
|
|
244
235
|
};
|
|
245
236
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedAccount>;
|
|
@@ -381,19 +372,10 @@ export function getCreateDcaOrderInstruction<
|
|
|
381
372
|
order: { value: input.order ?? null, isWritable: true },
|
|
382
373
|
guard: { value: input.guard ?? null, isWritable: false },
|
|
383
374
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
384
|
-
associatedTokenProgram: {
|
|
385
|
-
value: input.associatedTokenProgram ?? null,
|
|
386
|
-
isWritable: false,
|
|
387
|
-
},
|
|
375
|
+
associatedTokenProgram: { value: input.associatedTokenProgram ?? null, isWritable: false },
|
|
388
376
|
tokenInMint: { value: input.tokenInMint ?? null, isWritable: false },
|
|
389
|
-
userTokenInAccount: {
|
|
390
|
-
|
|
391
|
-
isWritable: true,
|
|
392
|
-
},
|
|
393
|
-
guardTokenInAccount: {
|
|
394
|
-
value: input.guardTokenInAccount ?? null,
|
|
395
|
-
isWritable: true,
|
|
396
|
-
},
|
|
377
|
+
userTokenInAccount: { value: input.userTokenInAccount ?? null, isWritable: true },
|
|
378
|
+
guardTokenInAccount: { value: input.guardTokenInAccount ?? null, isWritable: true },
|
|
397
379
|
tokenInProgram: { value: input.tokenInProgram ?? null, isWritable: false },
|
|
398
380
|
};
|
|
399
381
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedAccount>;
|
|
@@ -79,10 +79,7 @@ export type CreateGuardInstructionData = {
|
|
|
79
79
|
guardVersion: number;
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
export type CreateGuardInstructionDataArgs = {
|
|
83
|
-
auctioneerPubKey: Address;
|
|
84
|
-
guardVersion: number;
|
|
85
|
-
};
|
|
82
|
+
export type CreateGuardInstructionDataArgs = { auctioneerPubKey: Address; guardVersion: number };
|
|
86
83
|
|
|
87
84
|
export function getCreateGuardInstructionDataEncoder(): Encoder<CreateGuardInstructionDataArgs> {
|
|
88
85
|
return transformEncoder(
|
|
@@ -184,16 +181,10 @@ export async function getCreateGuardInstructionAsync<
|
|
|
184
181
|
guard: { value: input.guard ?? null, isWritable: true },
|
|
185
182
|
adminSingleton: { value: input.adminSingleton ?? null, isWritable: false },
|
|
186
183
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
187
|
-
associatedTokenProgram: {
|
|
188
|
-
value: input.associatedTokenProgram ?? null,
|
|
189
|
-
isWritable: false,
|
|
190
|
-
},
|
|
184
|
+
associatedTokenProgram: { value: input.associatedTokenProgram ?? null, isWritable: false },
|
|
191
185
|
feeTokenMint: { value: input.feeTokenMint ?? null, isWritable: false },
|
|
192
186
|
feeTokenAccount: { value: input.feeTokenAccount ?? null, isWritable: true },
|
|
193
|
-
feeTokenProgram: {
|
|
194
|
-
value: input.feeTokenProgram ?? null,
|
|
195
|
-
isWritable: false,
|
|
196
|
-
},
|
|
187
|
+
feeTokenProgram: { value: input.feeTokenProgram ?? null, isWritable: false },
|
|
197
188
|
};
|
|
198
189
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedAccount>;
|
|
199
190
|
|
|
@@ -327,16 +318,10 @@ export function getCreateGuardInstruction<
|
|
|
327
318
|
guard: { value: input.guard ?? null, isWritable: true },
|
|
328
319
|
adminSingleton: { value: input.adminSingleton ?? null, isWritable: false },
|
|
329
320
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
330
|
-
associatedTokenProgram: {
|
|
331
|
-
value: input.associatedTokenProgram ?? null,
|
|
332
|
-
isWritable: false,
|
|
333
|
-
},
|
|
321
|
+
associatedTokenProgram: { value: input.associatedTokenProgram ?? null, isWritable: false },
|
|
334
322
|
feeTokenMint: { value: input.feeTokenMint ?? null, isWritable: false },
|
|
335
323
|
feeTokenAccount: { value: input.feeTokenAccount ?? null, isWritable: true },
|
|
336
|
-
feeTokenProgram: {
|
|
337
|
-
value: input.feeTokenProgram ?? null,
|
|
338
|
-
isWritable: false,
|
|
339
|
-
},
|
|
324
|
+
feeTokenProgram: { value: input.feeTokenProgram ?? null, isWritable: false },
|
|
340
325
|
};
|
|
341
326
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedAccount>;
|
|
342
327
|
|
|
@@ -217,19 +217,10 @@ export async function getCreateLimitOrderInstructionAsync<
|
|
|
217
217
|
order: { value: input.order ?? null, isWritable: true },
|
|
218
218
|
guard: { value: input.guard ?? null, isWritable: false },
|
|
219
219
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
220
|
-
associatedTokenProgram: {
|
|
221
|
-
value: input.associatedTokenProgram ?? null,
|
|
222
|
-
isWritable: false,
|
|
223
|
-
},
|
|
220
|
+
associatedTokenProgram: { value: input.associatedTokenProgram ?? null, isWritable: false },
|
|
224
221
|
tokenInMint: { value: input.tokenInMint ?? null, isWritable: false },
|
|
225
|
-
userTokenInAccount: {
|
|
226
|
-
|
|
227
|
-
isWritable: true,
|
|
228
|
-
},
|
|
229
|
-
guardTokenInAccount: {
|
|
230
|
-
value: input.guardTokenInAccount ?? null,
|
|
231
|
-
isWritable: true,
|
|
232
|
-
},
|
|
222
|
+
userTokenInAccount: { value: input.userTokenInAccount ?? null, isWritable: true },
|
|
223
|
+
guardTokenInAccount: { value: input.guardTokenInAccount ?? null, isWritable: true },
|
|
233
224
|
tokenInProgram: { value: input.tokenInProgram ?? null, isWritable: false },
|
|
234
225
|
};
|
|
235
226
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedAccount>;
|
|
@@ -369,19 +360,10 @@ export function getCreateLimitOrderInstruction<
|
|
|
369
360
|
order: { value: input.order ?? null, isWritable: true },
|
|
370
361
|
guard: { value: input.guard ?? null, isWritable: false },
|
|
371
362
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
372
|
-
associatedTokenProgram: {
|
|
373
|
-
value: input.associatedTokenProgram ?? null,
|
|
374
|
-
isWritable: false,
|
|
375
|
-
},
|
|
363
|
+
associatedTokenProgram: { value: input.associatedTokenProgram ?? null, isWritable: false },
|
|
376
364
|
tokenInMint: { value: input.tokenInMint ?? null, isWritable: false },
|
|
377
|
-
userTokenInAccount: {
|
|
378
|
-
|
|
379
|
-
isWritable: true,
|
|
380
|
-
},
|
|
381
|
-
guardTokenInAccount: {
|
|
382
|
-
value: input.guardTokenInAccount ?? null,
|
|
383
|
-
isWritable: true,
|
|
384
|
-
},
|
|
365
|
+
userTokenInAccount: { value: input.userTokenInAccount ?? null, isWritable: true },
|
|
366
|
+
guardTokenInAccount: { value: input.guardTokenInAccount ?? null, isWritable: true },
|
|
385
367
|
tokenInProgram: { value: input.tokenInProgram ?? null, isWritable: false },
|
|
386
368
|
};
|
|
387
369
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedAccount>;
|
|
@@ -125,10 +125,7 @@ export function getFulfillDcaOrderIntervalInstructionDataEncoder(): Encoder<Fulf
|
|
|
125
125
|
['promisedMainAmountOut', getU64Encoder()],
|
|
126
126
|
['mainAmountOutToTransfer', getU64Encoder()],
|
|
127
127
|
]),
|
|
128
|
-
(value) => ({
|
|
129
|
-
...value,
|
|
130
|
-
discriminator: FULFILL_DCA_ORDER_INTERVAL_DISCRIMINATOR,
|
|
131
|
-
}),
|
|
128
|
+
(value) => ({ ...value, discriminator: FULFILL_DCA_ORDER_INTERVAL_DISCRIMINATOR }),
|
|
132
129
|
);
|
|
133
130
|
}
|
|
134
131
|
|
|
@@ -310,46 +307,22 @@ export function getFulfillDcaOrderIntervalInstruction<
|
|
|
310
307
|
guard: { value: input.guard ?? null, isWritable: true },
|
|
311
308
|
ixSysvar: { value: input.ixSysvar ?? null, isWritable: false },
|
|
312
309
|
tokenInMint: { value: input.tokenInMint ?? null, isWritable: false },
|
|
313
|
-
solverTokenInAccount: {
|
|
314
|
-
|
|
315
|
-
isWritable: true,
|
|
316
|
-
},
|
|
317
|
-
guardTokenInAccount: {
|
|
318
|
-
value: input.guardTokenInAccount ?? null,
|
|
319
|
-
isWritable: true,
|
|
320
|
-
},
|
|
310
|
+
solverTokenInAccount: { value: input.solverTokenInAccount ?? null, isWritable: true },
|
|
311
|
+
guardTokenInAccount: { value: input.guardTokenInAccount ?? null, isWritable: true },
|
|
321
312
|
tokenInProgram: { value: input.tokenInProgram ?? null, isWritable: false },
|
|
322
313
|
feeTokenMint: { value: input.feeTokenMint ?? null, isWritable: false },
|
|
323
|
-
solverFeeTokenAccount: {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
},
|
|
327
|
-
guardFeeTokenAccount: {
|
|
328
|
-
value: input.guardFeeTokenAccount ?? null,
|
|
329
|
-
isWritable: true,
|
|
330
|
-
},
|
|
331
|
-
feeTokenProgram: {
|
|
332
|
-
value: input.feeTokenProgram ?? null,
|
|
333
|
-
isWritable: false,
|
|
334
|
-
},
|
|
335
|
-
nativeTokenOutReceiver: {
|
|
336
|
-
value: input.nativeTokenOutReceiver ?? null,
|
|
337
|
-
isWritable: false,
|
|
338
|
-
},
|
|
314
|
+
solverFeeTokenAccount: { value: input.solverFeeTokenAccount ?? null, isWritable: true },
|
|
315
|
+
guardFeeTokenAccount: { value: input.guardFeeTokenAccount ?? null, isWritable: true },
|
|
316
|
+
feeTokenProgram: { value: input.feeTokenProgram ?? null, isWritable: false },
|
|
317
|
+
nativeTokenOutReceiver: { value: input.nativeTokenOutReceiver ?? null, isWritable: false },
|
|
339
318
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
340
319
|
tokenOutMint: { value: input.tokenOutMint ?? null, isWritable: false },
|
|
341
|
-
solverTokenOutAccount: {
|
|
342
|
-
value: input.solverTokenOutAccount ?? null,
|
|
343
|
-
isWritable: true,
|
|
344
|
-
},
|
|
320
|
+
solverTokenOutAccount: { value: input.solverTokenOutAccount ?? null, isWritable: true },
|
|
345
321
|
destinationTokenOutAccount: {
|
|
346
322
|
value: input.destinationTokenOutAccount ?? null,
|
|
347
323
|
isWritable: true,
|
|
348
324
|
},
|
|
349
|
-
tokenOutProgram: {
|
|
350
|
-
value: input.tokenOutProgram ?? null,
|
|
351
|
-
isWritable: false,
|
|
352
|
-
},
|
|
325
|
+
tokenOutProgram: { value: input.tokenOutProgram ?? null, isWritable: false },
|
|
353
326
|
};
|
|
354
327
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedAccount>;
|
|
355
328
|
|
|
@@ -304,46 +304,22 @@ export function getFulfillLimitOrderInstruction<
|
|
|
304
304
|
guard: { value: input.guard ?? null, isWritable: true },
|
|
305
305
|
ixSysvar: { value: input.ixSysvar ?? null, isWritable: false },
|
|
306
306
|
tokenInMint: { value: input.tokenInMint ?? null, isWritable: false },
|
|
307
|
-
solverTokenInAccount: {
|
|
308
|
-
|
|
309
|
-
isWritable: true,
|
|
310
|
-
},
|
|
311
|
-
guardTokenInAccount: {
|
|
312
|
-
value: input.guardTokenInAccount ?? null,
|
|
313
|
-
isWritable: true,
|
|
314
|
-
},
|
|
307
|
+
solverTokenInAccount: { value: input.solverTokenInAccount ?? null, isWritable: true },
|
|
308
|
+
guardTokenInAccount: { value: input.guardTokenInAccount ?? null, isWritable: true },
|
|
315
309
|
tokenInProgram: { value: input.tokenInProgram ?? null, isWritable: false },
|
|
316
310
|
feeTokenMint: { value: input.feeTokenMint ?? null, isWritable: false },
|
|
317
|
-
solverFeeTokenAccount: {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
},
|
|
321
|
-
guardFeeTokenAccount: {
|
|
322
|
-
value: input.guardFeeTokenAccount ?? null,
|
|
323
|
-
isWritable: true,
|
|
324
|
-
},
|
|
325
|
-
feeTokenProgram: {
|
|
326
|
-
value: input.feeTokenProgram ?? null,
|
|
327
|
-
isWritable: false,
|
|
328
|
-
},
|
|
329
|
-
nativeTokenOutReceiver: {
|
|
330
|
-
value: input.nativeTokenOutReceiver ?? null,
|
|
331
|
-
isWritable: false,
|
|
332
|
-
},
|
|
311
|
+
solverFeeTokenAccount: { value: input.solverFeeTokenAccount ?? null, isWritable: true },
|
|
312
|
+
guardFeeTokenAccount: { value: input.guardFeeTokenAccount ?? null, isWritable: true },
|
|
313
|
+
feeTokenProgram: { value: input.feeTokenProgram ?? null, isWritable: false },
|
|
314
|
+
nativeTokenOutReceiver: { value: input.nativeTokenOutReceiver ?? null, isWritable: false },
|
|
333
315
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
334
316
|
tokenOutMint: { value: input.tokenOutMint ?? null, isWritable: false },
|
|
335
|
-
solverTokenOutAccount: {
|
|
336
|
-
value: input.solverTokenOutAccount ?? null,
|
|
337
|
-
isWritable: true,
|
|
338
|
-
},
|
|
317
|
+
solverTokenOutAccount: { value: input.solverTokenOutAccount ?? null, isWritable: true },
|
|
339
318
|
destinationTokenOutAccount: {
|
|
340
319
|
value: input.destinationTokenOutAccount ?? null,
|
|
341
320
|
isWritable: true,
|
|
342
321
|
},
|
|
343
|
-
tokenOutProgram: {
|
|
344
|
-
value: input.tokenOutProgram ?? null,
|
|
345
|
-
isWritable: false,
|
|
346
|
-
},
|
|
322
|
+
tokenOutProgram: { value: input.tokenOutProgram ?? null, isWritable: false },
|
|
347
323
|
};
|
|
348
324
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedAccount>;
|
|
349
325
|
|
|
@@ -65,7 +65,7 @@ export type InitializeInstruction<
|
|
|
65
65
|
|
|
66
66
|
export type InitializeInstructionData = { discriminator: ReadonlyUint8Array };
|
|
67
67
|
|
|
68
|
-
export type InitializeInstructionDataArgs =
|
|
68
|
+
export type InitializeInstructionDataArgs = object;
|
|
69
69
|
|
|
70
70
|
export function getInitializeInstructionDataEncoder(): Encoder<InitializeInstructionDataArgs> {
|
|
71
71
|
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({
|
|
@@ -56,10 +56,7 @@ export type SetAdminInstruction<
|
|
|
56
56
|
]
|
|
57
57
|
>;
|
|
58
58
|
|
|
59
|
-
export type SetAdminInstructionData = {
|
|
60
|
-
discriminator: ReadonlyUint8Array;
|
|
61
|
-
newAdmin: Address;
|
|
62
|
-
};
|
|
59
|
+
export type SetAdminInstructionData = { discriminator: ReadonlyUint8Array; newAdmin: Address };
|
|
63
60
|
|
|
64
61
|
export type SetAdminInstructionDataArgs = { newAdmin: Address };
|
|
65
62
|
|
|
@@ -64,9 +64,7 @@ export type SetAuctioneerPubKeyInstructionData = {
|
|
|
64
64
|
auctioneerPubKey: Address;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
export type SetAuctioneerPubKeyInstructionDataArgs = {
|
|
68
|
-
auctioneerPubKey: Address;
|
|
69
|
-
};
|
|
67
|
+
export type SetAuctioneerPubKeyInstructionDataArgs = { auctioneerPubKey: Address };
|
|
70
68
|
|
|
71
69
|
export function getSetAuctioneerPubKeyInstructionDataEncoder(): Encoder<SetAuctioneerPubKeyInstructionDataArgs> {
|
|
72
70
|
return transformEncoder(
|
|
@@ -74,10 +72,7 @@ export function getSetAuctioneerPubKeyInstructionDataEncoder(): Encoder<SetAucti
|
|
|
74
72
|
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
|
|
75
73
|
['auctioneerPubKey', getAddressEncoder()],
|
|
76
74
|
]),
|
|
77
|
-
(value) => ({
|
|
78
|
-
...value,
|
|
79
|
-
discriminator: SET_AUCTIONEER_PUB_KEY_DISCRIMINATOR,
|
|
80
|
-
}),
|
|
75
|
+
(value) => ({ ...value, discriminator: SET_AUCTIONEER_PUB_KEY_DISCRIMINATOR }),
|
|
81
76
|
);
|
|
82
77
|
}
|
|
83
78
|
|
|
@@ -102,17 +102,14 @@ export function getAccountMetaFactory(programAddress: Address, optionalAccountSt
|
|
|
102
102
|
return (account: ResolvedAccount): IAccountMeta | IAccountSignerMeta | undefined => {
|
|
103
103
|
if (!account.value) {
|
|
104
104
|
if (optionalAccountStrategy === 'omitted') return;
|
|
105
|
-
return Object.freeze({
|
|
106
|
-
address: programAddress,
|
|
107
|
-
role: AccountRole.READONLY,
|
|
108
|
-
});
|
|
105
|
+
return Object.freeze({ address: programAddress, role: AccountRole.READONLY });
|
|
109
106
|
}
|
|
110
107
|
|
|
111
108
|
const writableRole = account.isWritable ? AccountRole.WRITABLE : AccountRole.READONLY;
|
|
112
109
|
return Object.freeze({
|
|
113
110
|
address: expectAddress(account.value),
|
|
114
111
|
role: isTransactionSigner(account.value) ? upgradeRoleToSigner(writableRole) : writableRole,
|
|
115
|
-
...(isTransactionSigner(account.value) ? { signer: account.value } :
|
|
112
|
+
...(isTransactionSigner(account.value) ? { signer: account.value } : Object),
|
|
116
113
|
});
|
|
117
114
|
};
|
|
118
115
|
}
|
|
@@ -18,10 +18,7 @@ import {
|
|
|
18
18
|
type Encoder,
|
|
19
19
|
} from '@solana/kit';
|
|
20
20
|
|
|
21
|
-
export type AuctioneerPubkeyUpdated = {
|
|
22
|
-
guardId: Address;
|
|
23
|
-
auctioneerPubKey: Address;
|
|
24
|
-
};
|
|
21
|
+
export type AuctioneerPubkeyUpdated = { guardId: Address; auctioneerPubKey: Address };
|
|
25
22
|
|
|
26
23
|
export type AuctioneerPubkeyUpdatedArgs = AuctioneerPubkeyUpdated;
|
|
27
24
|
|
|
@@ -18,11 +18,7 @@ import {
|
|
|
18
18
|
type Encoder,
|
|
19
19
|
} from '@solana/kit';
|
|
20
20
|
|
|
21
|
-
export type GuardCreated = {
|
|
22
|
-
guardId: Address;
|
|
23
|
-
feeTokenMint: Address;
|
|
24
|
-
auctioneerPubKey: Address;
|
|
25
|
-
};
|
|
21
|
+
export type GuardCreated = { guardId: Address; feeTokenMint: Address; auctioneerPubKey: Address };
|
|
26
22
|
|
|
27
23
|
export type GuardCreatedArgs = GuardCreated;
|
|
28
24
|
|
|
@@ -22,10 +22,7 @@ import {
|
|
|
22
22
|
|
|
23
23
|
export type LimitOrderFulfilled = { orderId: Address; mainAmountOut: bigint };
|
|
24
24
|
|
|
25
|
-
export type LimitOrderFulfilledArgs = {
|
|
26
|
-
orderId: Address;
|
|
27
|
-
mainAmountOut: number | bigint;
|
|
28
|
-
};
|
|
25
|
+
export type LimitOrderFulfilledArgs = { orderId: Address; mainAmountOut: number | bigint };
|
|
29
26
|
|
|
30
27
|
export function getLimitOrderFulfilledEncoder(): Encoder<LimitOrderFulfilledArgs> {
|
|
31
28
|
return getStructEncoder([
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { address, createSolanaRpc, type Base58EncodedBytes } from '@solana/kit';
|
|
2
|
+
import { getDefaultSolanaRPC } from './client.js';
|
|
3
|
+
import { logger } from '../../utils/logger.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Inspect Solana guards to find orders that are currently locked on-chain.
|
|
7
|
+
* @param userAddress - The user's Solana address
|
|
8
|
+
* @param config - The Solana RPC configuration
|
|
9
|
+
* @returns An object containing the Solana guard programs for cross-chain and single-chain orders
|
|
10
|
+
*/
|
|
11
|
+
export async function getSolanaOrdersWithLockedFunds(userAddress: string, config?: { rpcUrl?: string }) {
|
|
12
|
+
const rpc = config?.rpcUrl ? createSolanaRpc(config.rpcUrl) : getDefaultSolanaRPC();
|
|
13
|
+
|
|
14
|
+
// const singleChainGuardAddress = SINGLE_CHAIN_GUARD_ADDRESSES[ChainID.Solana];
|
|
15
|
+
|
|
16
|
+
const programAccountAddress = address('43cctGU9QJ4WEPzLoNEvo3TPiv6nMUG9puN2pXQSnB6V');
|
|
17
|
+
const programAccountsConfig = {
|
|
18
|
+
encoding: 'base64',
|
|
19
|
+
filters: [
|
|
20
|
+
{
|
|
21
|
+
memcmp: {
|
|
22
|
+
offset: 8n,
|
|
23
|
+
encoding: 'base58',
|
|
24
|
+
bytes: userAddress as Base58EncodedBytes,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
} as Readonly<unknown>;
|
|
29
|
+
|
|
30
|
+
logger.info(`Fetching cross-chain guard programs for user: ${userAddress}`);
|
|
31
|
+
const crossChainGuardPrograms = await rpc.getProgramAccounts(programAccountAddress, programAccountsConfig).send();
|
|
32
|
+
logger.info(`Found ${crossChainGuardPrograms.length} cross-chain guard programs`);
|
|
33
|
+
// const singleChainGuardPrograms = await rpc.getProgramAccounts(address(singleChainGuardAddress), programAccountsConfig).send();
|
|
34
|
+
|
|
35
|
+
// const crossChainCodec = getOrderCodec();
|
|
36
|
+
// const singleChainCodec = getLimitOrderCodec();
|
|
37
|
+
// const base64Encoder = getBase64Encoder();
|
|
38
|
+
|
|
39
|
+
const crossChainGuardProgramsWithOrders = crossChainGuardPrograms.map(({ pubkey, account }) => {
|
|
40
|
+
logger.info(`Account data: ${account} and pubkey: ${pubkey}`);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
pubkey,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
crossChainGuardPrograms: crossChainGuardProgramsWithOrders,
|
|
49
|
+
};
|
|
50
|
+
}
|
package/src/core/solana/sdk.ts
CHANGED
|
@@ -22,12 +22,19 @@ import { BaseSDK } from '../sdk.js';
|
|
|
22
22
|
import { createSolanaClient, type SolanaClient } from './client.js';
|
|
23
23
|
import { cancelCrossChainOrderInstructions, cancelSingleChainOrderInstructions } from './cancel-order.js';
|
|
24
24
|
import type { CrossChainOrder } from '../orders/cross-chain.js';
|
|
25
|
-
import type {
|
|
25
|
+
import type {
|
|
26
|
+
CrossChainOrderPrepared,
|
|
27
|
+
DcaSingleChainOrderPrepared,
|
|
28
|
+
SingleChainOrderPrepared,
|
|
29
|
+
} from '../../types/intent.js';
|
|
26
30
|
import { getSolanaCrossChainOrderInstructions, getSolanaSingleChainOrderInstructions } from './order-instructions.js';
|
|
27
31
|
import type { SingleChainOrder } from '../orders/single-chain.js';
|
|
28
32
|
import { fetchJWTToken, fetchSiweMessage } from '../../auth/siwe.js';
|
|
29
33
|
import { ChainID } from '../../chains.js';
|
|
30
34
|
import { bytesToHex } from 'viem';
|
|
35
|
+
import type { DcaSingleChainOrder } from '../orders/dca-single-chain.js';
|
|
36
|
+
import { getSolanaDcaSingleChainOrderInstructions } from './dca/create-order.js';
|
|
37
|
+
import { cancelDcaSingleChainOrderInstructions } from './dca/cancel-order.js';
|
|
31
38
|
|
|
32
39
|
/**
|
|
33
40
|
* Solana-specific SDK implementation
|
|
@@ -224,7 +231,7 @@ export class SolanaSDK extends BaseSDK {
|
|
|
224
231
|
};
|
|
225
232
|
}
|
|
226
233
|
|
|
227
|
-
protected async prepareSingleChainOrder(order: SingleChainOrder): Promise<SingleChainOrderPrepared> {
|
|
234
|
+
protected override async prepareSingleChainOrder(order: SingleChainOrder): Promise<SingleChainOrderPrepared> {
|
|
228
235
|
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
229
236
|
|
|
230
237
|
const { orderAddress, txBytes, secretNumber } = await getSolanaSingleChainOrderInstructions(order);
|
|
@@ -237,6 +244,62 @@ export class SolanaSDK extends BaseSDK {
|
|
|
237
244
|
|
|
238
245
|
const encodedTransaction = getBase64EncodedWireTransaction(signedTx);
|
|
239
246
|
|
|
247
|
+
await this.client.rpc
|
|
248
|
+
.sendTransaction(encodedTransaction, { preflightCommitment: this.config.commitment, encoding: 'base64' })
|
|
249
|
+
.send();
|
|
250
|
+
|
|
251
|
+
return {
|
|
252
|
+
order,
|
|
253
|
+
preparedData: {
|
|
254
|
+
orderPubkey: orderAddress,
|
|
255
|
+
secretNumber,
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
public async cancelDcaSingleChainOrder(orderId: string): Promise<string> {
|
|
260
|
+
const instructions = await cancelDcaSingleChainOrderInstructions(orderId, { rpcUrl: this.config.rpcProviderUrl });
|
|
261
|
+
const signer = await this.getUserSigner();
|
|
262
|
+
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
263
|
+
|
|
264
|
+
const noopSigner = createNoopSigner(signer.address);
|
|
265
|
+
|
|
266
|
+
const { value: latestBlockhash } = await this.client.rpc
|
|
267
|
+
.getLatestBlockhash({ commitment: this.config.commitment })
|
|
268
|
+
.send();
|
|
269
|
+
|
|
270
|
+
const transactionMessage = pipe(
|
|
271
|
+
createTransactionMessage({ version: 0 }),
|
|
272
|
+
(tx) => setTransactionMessageFeePayerSigner(noopSigner, tx),
|
|
273
|
+
(tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
|
|
274
|
+
(tx) => appendTransactionMessageInstructions(instructions, tx),
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
const myTx = compileTransaction(transactionMessage);
|
|
278
|
+
|
|
279
|
+
const signature = await signTransaction([signerKeyPair], myTx);
|
|
280
|
+
|
|
281
|
+
await this.client.sendAndConfirmTransaction(signature, {
|
|
282
|
+
commitment: this.config.commitment,
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
return orderId;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
protected override async prepareDcaSingleChainOrder(
|
|
289
|
+
order: DcaSingleChainOrder,
|
|
290
|
+
): Promise<DcaSingleChainOrderPrepared> {
|
|
291
|
+
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
292
|
+
|
|
293
|
+
const { orderAddress, txBytes, secretNumber } = await getSolanaDcaSingleChainOrderInstructions(order);
|
|
294
|
+
|
|
295
|
+
const transactionCodec = getTransactionCodec();
|
|
296
|
+
|
|
297
|
+
const tx = transactionCodec.decode(txBytes);
|
|
298
|
+
|
|
299
|
+
const signedTx = await partiallySignTransaction([signerKeyPair], tx);
|
|
300
|
+
|
|
301
|
+
const encodedTransaction = getBase64EncodedWireTransaction(signedTx);
|
|
302
|
+
|
|
240
303
|
await this.client.rpc
|
|
241
304
|
.sendTransaction(encodedTransaction, { preflightCommitment: this.config.commitment, encoding: 'base64' })
|
|
242
305
|
.send();
|
package/src/core/solana/utils.ts
CHANGED
|
@@ -2,8 +2,9 @@ import BN from 'bn.js';
|
|
|
2
2
|
import type { SingleChainOrder } from '../orders/single-chain.js';
|
|
3
3
|
import { PublicKey } from '@solana/web3.js';
|
|
4
4
|
import sha3 from 'js-sha3';
|
|
5
|
+
import type { DcaSingleChainOrder } from '../orders/dca-single-chain.js';
|
|
5
6
|
|
|
6
|
-
export function genSecretHashAndNumber(order: SingleChainOrder): {
|
|
7
|
+
export function genSecretHashAndNumber(order: SingleChainOrder | DcaSingleChainOrder): {
|
|
7
8
|
secretHash: number[];
|
|
8
9
|
secretNumber: string;
|
|
9
10
|
} {
|
package/src/core/sui/sdk.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { BaseSDK } from '../sdk.js';
|
|
|
5
5
|
import { createSuiClient } from './client.js';
|
|
6
6
|
import { getSuiOrderTransaction } from './order-transaction.js';
|
|
7
7
|
import { getSuiCancelCrossChainOrder } from './cancel.js';
|
|
8
|
-
import type { CrossChainOrderPrepared
|
|
8
|
+
import type { CrossChainOrderPrepared } from '../../types/intent.js';
|
|
9
9
|
import type { CrossChainOrder } from '../orders/cross-chain.js';
|
|
10
10
|
import { fetchJWTToken, fetchSiweMessage } from '../../auth/siwe.js';
|
|
11
11
|
import { ChainID } from '../../chains.js';
|
|
@@ -57,10 +57,6 @@ export class SuiSDK extends BaseSDK {
|
|
|
57
57
|
return Ed25519Keypair.fromSecretKey(this.config.privateKey);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
protected override prepareSingleChainOrder(): Promise<SingleChainOrderPrepared> {
|
|
61
|
-
throw new Error('Single-chain orders are not supported on Sui');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
60
|
public async authenticate(token?: string): Promise<string> {
|
|
65
61
|
const wallet = await this.getUserAddress();
|
|
66
62
|
|
|
@@ -103,7 +99,7 @@ export class SuiSDK extends BaseSDK {
|
|
|
103
99
|
* @returns Promise resolving to a prepared order with Sui-specific data
|
|
104
100
|
* @protected
|
|
105
101
|
*/
|
|
106
|
-
protected async prepareCrossChainOrder(order: CrossChainOrder): Promise<CrossChainOrderPrepared> {
|
|
102
|
+
protected override async prepareCrossChainOrder(order: CrossChainOrder): Promise<CrossChainOrderPrepared> {
|
|
107
103
|
const signer = this.getKeyPair();
|
|
108
104
|
|
|
109
105
|
const transaction = await getSuiOrderTransaction(order);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isValidSuiAddress, normalizeSuiAddress } from '@mysten/sui/utils';
|
|
2
2
|
import { MAX_UINT_64 } from '../../constants.js';
|
|
3
3
|
import { BaseValidator } from '../../utils/base-validator.js';
|
|
4
|
+
import { ValidationError } from '../../errors/index.js';
|
|
4
5
|
|
|
5
6
|
const SUI_TOKEN_ADDRESS_REGEX = /^0x[a-fA-F0-9]{64}::\w+::\w+$/;
|
|
6
7
|
|
|
@@ -33,4 +34,8 @@ export class SuiValidator extends BaseValidator {
|
|
|
33
34
|
override validateSingleChainOrderFeasability(): Promise<void> {
|
|
34
35
|
return Promise.resolve();
|
|
35
36
|
}
|
|
37
|
+
|
|
38
|
+
override validateDcaSingleChainOrderFeasability(): Promise<void> {
|
|
39
|
+
throw new ValidationError('DCA orders are not supported on Sui');
|
|
40
|
+
}
|
|
36
41
|
}
|