@shogun-sdk/intents-sdk 1.0.2 → 1.1.0
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/README.md +0 -1
- package/dist/esm/auth/siwe.js +26 -0
- package/dist/esm/auth/siwe.js.map +1 -0
- package/dist/esm/chains.js +21 -8
- package/dist/esm/chains.js.map +1 -1
- package/dist/esm/constants.js +73 -35
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/core/evm/abi/single-chain-guard-limit.js +768 -0
- package/dist/esm/core/evm/abi/single-chain-guard-limit.js.map +1 -0
- package/dist/esm/core/evm/cancel-order.js +130 -0
- package/dist/esm/core/evm/cancel-order.js.map +1 -0
- package/dist/esm/core/evm/{viem-provider.js → chain-provider.js} +18 -3
- package/dist/esm/core/evm/chain-provider.js.map +1 -0
- package/dist/esm/core/evm/connectors/hyperevm.js +23 -0
- package/dist/esm/core/evm/connectors/hyperevm.js.map +1 -0
- package/dist/esm/core/evm/intent-provider.js +58 -8
- package/dist/esm/core/evm/intent-provider.js.map +1 -1
- package/dist/esm/core/evm/order-signature.js +15 -15
- package/dist/esm/core/evm/order-signature.js.map +1 -1
- package/dist/esm/core/evm/permit2.js +31 -3
- package/dist/esm/core/evm/permit2.js.map +1 -1
- package/dist/esm/core/evm/sdk.js +112 -78
- package/dist/esm/core/evm/sdk.js.map +1 -1
- package/dist/esm/core/evm/validator.js +52 -8
- package/dist/esm/core/evm/validator.js.map +1 -1
- package/dist/esm/core/orders/api/fetch.js +17 -0
- package/dist/esm/core/orders/api/fetch.js.map +1 -0
- package/dist/esm/core/orders/common.js +8 -0
- package/dist/esm/core/orders/common.js.map +1 -0
- package/dist/esm/core/orders/cross-chain.js +316 -0
- package/dist/esm/core/orders/cross-chain.js.map +1 -0
- package/dist/esm/core/orders/single-chain.js +185 -0
- package/dist/esm/core/orders/single-chain.js.map +1 -0
- package/dist/esm/core/sdk.js +77 -109
- package/dist/esm/core/sdk.js.map +1 -1
- package/dist/esm/core/solana/cancel-order.js +176 -0
- package/dist/esm/core/solana/cancel-order.js.map +1 -0
- package/dist/esm/core/solana/generated/{accounts → cross-chain/accounts}/adminSingleton.js +3 -1
- package/dist/esm/core/solana/generated/cross-chain/accounts/adminSingleton.js.map +1 -0
- package/dist/esm/core/solana/generated/{accounts → cross-chain/accounts}/guard.js +1 -1
- package/dist/esm/core/solana/generated/cross-chain/accounts/guard.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/accounts/index.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/accounts/order.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/errors/index.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/errors/sourceChainGuard.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/index.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/acceptAdmin.js +91 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/acceptAdmin.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/cancelOrder.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/claimTokens.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/collectProtocolFees.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/createGuard.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/createOrder.js.map +1 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/index.js +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/index.js.map +1 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/initialize.js +19 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/initialize.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/preStartOrderExecution.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/setAdmin.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/setAuctioneerPubKey.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/startOrderExecution.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/instructions/startOrderExecutionAfterSwap.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/programs/index.js.map +1 -0
- package/dist/esm/core/solana/generated/{programs → cross-chain/programs}/sourceChainGuard.js +16 -12
- package/dist/esm/core/solana/generated/cross-chain/programs/sourceChainGuard.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/shared/index.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/types/adminUpdateStarted.js +18 -0
- package/dist/esm/core/solana/generated/cross-chain/types/adminUpdateStarted.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/types/adminUpdated.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/types/auctioneerPubkeyUpdated.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/types/executionStarted.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/types/guardCreated.js.map +1 -0
- package/dist/esm/core/solana/generated/{types → cross-chain/types}/index.js +1 -0
- package/dist/esm/core/solana/generated/cross-chain/types/index.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/types/orderCancelled.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/types/orderCreated.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/types/orderFulfilled.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/types/tokenInSwapped.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/accounts/adminSingleton.js +58 -0
- package/dist/esm/core/solana/generated/single-chain/accounts/adminSingleton.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/accounts/dcaOrder.js +75 -0
- package/dist/esm/core/solana/generated/single-chain/accounts/dcaOrder.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/accounts/guard.js +62 -0
- package/dist/esm/core/solana/generated/single-chain/accounts/guard.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/accounts/index.js +12 -0
- package/dist/esm/core/solana/generated/single-chain/accounts/index.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/accounts/limitOrder.js +65 -0
- package/dist/esm/core/solana/generated/single-chain/accounts/limitOrder.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/errors/index.js +9 -0
- package/dist/esm/core/solana/generated/single-chain/errors/index.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/errors/singleChainGuard.js +101 -0
- package/dist/esm/core/solana/generated/single-chain/errors/singleChainGuard.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/index.js +13 -0
- package/dist/esm/core/solana/generated/single-chain/index.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/acceptAdmin.js +91 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/acceptAdmin.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelDcaOrder.js +91 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelDcaOrder.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelLimitOrder.js +91 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelLimitOrder.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/collectProtocolFees.js +140 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/collectProtocolFees.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/createDcaOrder.js +188 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/createDcaOrder.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/createGuard.js +173 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/createGuard.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/createLimitOrder.js +184 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/createLimitOrder.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.js +170 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillLimitOrder.js +167 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillLimitOrder.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/index.js +20 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/index.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/initialize.js +127 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/initialize.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/setAdmin.js +98 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/setAdmin.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.js +104 -0
- package/dist/esm/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/programs/index.js +9 -0
- package/dist/esm/core/solana/generated/single-chain/programs/index.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/programs/singleChainGuard.js +90 -0
- package/dist/esm/core/solana/generated/single-chain/programs/singleChainGuard.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/shared/index.js +82 -0
- package/dist/esm/core/solana/generated/single-chain/shared/index.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/types/adminUpdateStarted.js +18 -0
- package/dist/esm/core/solana/generated/single-chain/types/adminUpdateStarted.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/types/adminUpdated.js +18 -0
- package/dist/esm/core/solana/generated/single-chain/types/adminUpdated.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/types/auctioneerPubkeyUpdated.js +24 -0
- package/dist/esm/core/solana/generated/single-chain/types/auctioneerPubkeyUpdated.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/types/dcaOrderCreated.js +42 -0
- package/dist/esm/core/solana/generated/single-chain/types/dcaOrderCreated.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/types/dcaOrderFulfilled.js +18 -0
- package/dist/esm/core/solana/generated/single-chain/types/dcaOrderFulfilled.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/types/dcaOrderIntervalFulfilled.js +30 -0
- package/dist/esm/core/solana/generated/single-chain/types/dcaOrderIntervalFulfilled.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/types/guardCreated.js +26 -0
- package/dist/esm/core/solana/generated/single-chain/types/guardCreated.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/types/index.js +18 -0
- package/dist/esm/core/solana/generated/single-chain/types/index.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/types/limitOrderCreated.js +36 -0
- package/dist/esm/core/solana/generated/single-chain/types/limitOrderCreated.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/types/limitOrderFulfilled.js +24 -0
- package/dist/esm/core/solana/generated/single-chain/types/limitOrderFulfilled.js.map +1 -0
- package/dist/esm/core/solana/generated/single-chain/types/orderCancelled.js +18 -0
- package/dist/esm/core/solana/generated/single-chain/types/orderCancelled.js.map +1 -0
- package/dist/esm/core/solana/order-instructions.js +89 -28
- package/dist/esm/core/solana/order-instructions.js.map +1 -1
- package/dist/esm/core/solana/sdk.js +104 -26
- package/dist/esm/core/solana/sdk.js.map +1 -1
- package/dist/esm/core/solana/utils.js +19 -0
- package/dist/esm/core/solana/utils.js.map +1 -0
- package/dist/esm/core/solana/validator.js +4 -1
- package/dist/esm/core/solana/validator.js.map +1 -1
- package/dist/esm/core/sui/cancel.js +36 -0
- package/dist/esm/core/sui/cancel.js.map +1 -0
- package/dist/esm/core/sui/order-transaction.js +10 -19
- package/dist/esm/core/sui/order-transaction.js.map +1 -1
- package/dist/esm/core/sui/sdk.js +67 -24
- package/dist/esm/core/sui/sdk.js.map +1 -1
- package/dist/esm/core/sui/validator.js +4 -1
- package/dist/esm/core/sui/validator.js.map +1 -1
- package/dist/esm/errors/index.js +0 -32
- package/dist/esm/errors/index.js.map +1 -1
- package/dist/esm/index.js +15 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/api.js +6 -1
- package/dist/esm/types/api.js.map +1 -1
- package/dist/esm/utils/base-validator.js +16 -4
- package/dist/esm/utils/base-validator.js.map +1 -1
- package/dist/esm/utils/defillama.js +12 -23
- package/dist/esm/utils/defillama.js.map +1 -1
- package/dist/esm/utils/order-validator.js +17 -11
- package/dist/esm/utils/order-validator.js.map +1 -1
- package/dist/esm/utils/parsers.js +8 -31
- package/dist/esm/utils/parsers.js.map +1 -1
- package/dist/esm/utils/quote/aftermath.js +15 -0
- package/dist/esm/utils/quote/aftermath.js.map +1 -0
- package/dist/esm/utils/quote/aggregator.js +254 -0
- package/dist/esm/utils/quote/aggregator.js.map +1 -0
- package/dist/esm/utils/quote/jupiter.js +31 -0
- package/dist/esm/utils/quote/jupiter.js.map +1 -0
- package/dist/esm/utils/quote/liquidswap.js +22 -0
- package/dist/esm/utils/quote/liquidswap.js.map +1 -0
- package/dist/esm/utils/quote/paraswap.js +67 -0
- package/dist/esm/utils/quote/paraswap.js.map +1 -0
- package/dist/esm/utils/quote/stablecoins-tokens.js +13 -0
- package/dist/esm/utils/quote/stablecoins-tokens.js.map +1 -0
- package/dist/types/auth/siwe.d.ts +13 -0
- package/dist/types/auth/siwe.d.ts.map +1 -0
- package/dist/types/chains.d.ts +11 -9
- package/dist/types/chains.d.ts.map +1 -1
- package/dist/types/constants.d.ts +29 -11
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/core/evm/abi/single-chain-guard-limit.d.ts +596 -0
- package/dist/types/core/evm/abi/single-chain-guard-limit.d.ts.map +1 -0
- package/dist/types/core/evm/cancel-order.d.ts +28 -0
- package/dist/types/core/evm/cancel-order.d.ts.map +1 -0
- package/dist/types/core/evm/chain-provider.d.ts +62338 -0
- package/dist/types/core/evm/chain-provider.d.ts.map +1 -0
- package/dist/types/core/evm/connectors/hyperevm.d.ts +38 -0
- package/dist/types/core/evm/connectors/hyperevm.d.ts.map +1 -0
- package/dist/types/core/evm/intent-provider.d.ts +9 -6
- package/dist/types/core/evm/intent-provider.d.ts.map +1 -1
- package/dist/types/core/evm/order-signature.d.ts +9 -17
- package/dist/types/core/evm/order-signature.d.ts.map +1 -1
- package/dist/types/core/evm/permit2.d.ts +100 -4
- package/dist/types/core/evm/permit2.d.ts.map +1 -1
- package/dist/types/core/evm/sdk.d.ts +38 -27
- package/dist/types/core/evm/sdk.d.ts.map +1 -1
- package/dist/types/core/evm/validator.d.ts +8 -2
- package/dist/types/core/evm/validator.d.ts.map +1 -1
- package/dist/types/core/orders/api/fetch.d.ts +3 -0
- package/dist/types/core/orders/api/fetch.d.ts.map +1 -0
- package/dist/types/core/orders/common.d.ts +12 -0
- package/dist/types/core/orders/common.d.ts.map +1 -0
- package/dist/types/core/{order.d.ts → orders/cross-chain.d.ts} +36 -33
- package/dist/types/core/orders/cross-chain.d.ts.map +1 -0
- package/dist/types/core/orders/single-chain.d.ts +46 -0
- package/dist/types/core/orders/single-chain.d.ts.map +1 -0
- package/dist/types/core/sdk.d.ts +15 -78
- package/dist/types/core/sdk.d.ts.map +1 -1
- package/dist/types/core/solana/cancel-order.d.ts +18 -0
- package/dist/types/core/solana/cancel-order.d.ts.map +1 -0
- package/dist/types/core/solana/generated/{accounts → cross-chain/accounts}/adminSingleton.d.ts +5 -1
- package/dist/types/core/solana/generated/cross-chain/accounts/adminSingleton.d.ts.map +1 -0
- package/dist/types/core/solana/generated/{accounts → cross-chain/accounts}/guard.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/accounts/guard.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/accounts/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/{accounts → cross-chain/accounts}/order.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/accounts/order.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/errors/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/errors/sourceChainGuard.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/instructions/acceptAdmin.d.ts +56 -0
- package/dist/types/core/solana/generated/cross-chain/instructions/acceptAdmin.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/instructions/cancelOrder.d.ts.map +1 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/claimTokens.d.ts +6 -6
- package/dist/types/core/solana/generated/cross-chain/instructions/claimTokens.d.ts.map +1 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/collectProtocolFees.d.ts +3 -3
- package/dist/types/core/solana/generated/cross-chain/instructions/collectProtocolFees.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/instructions/createGuard.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/instructions/createOrder.d.ts.map +1 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/index.d.ts +1 -0
- package/dist/types/core/solana/generated/cross-chain/instructions/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/initialize.d.ts +30 -7
- package/dist/types/core/solana/generated/cross-chain/instructions/initialize.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/instructions/preStartOrderExecution.d.ts.map +1 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/setAdmin.d.ts +3 -3
- package/dist/types/core/solana/generated/cross-chain/instructions/setAdmin.d.ts.map +1 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/setAuctioneerPubKey.d.ts +3 -3
- package/dist/types/core/solana/generated/cross-chain/instructions/setAuctioneerPubKey.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/instructions/startOrderExecution.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/instructions/startOrderExecutionAfterSwap.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/programs/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/{programs → cross-chain/programs}/sourceChainGuard.d.ts +17 -14
- package/dist/types/core/solana/generated/cross-chain/programs/sourceChainGuard.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/shared/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/types/adminUpdateStarted.d.ts +16 -0
- package/dist/types/core/solana/generated/cross-chain/types/adminUpdateStarted.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/types/adminUpdated.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/types/auctioneerPubkeyUpdated.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/types/executionStarted.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/types/guardCreated.d.ts.map +1 -0
- package/dist/types/core/solana/generated/{types → cross-chain/types}/index.d.ts +1 -0
- package/dist/types/core/solana/generated/cross-chain/types/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/types/orderCancelled.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/types/orderCreated.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/types/orderFulfilled.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/types/tokenInSwapped.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/accounts/adminSingleton.d.ts +40 -0
- package/dist/types/core/solana/generated/single-chain/accounts/adminSingleton.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/accounts/dcaOrder.d.ts +99 -0
- package/dist/types/core/solana/generated/single-chain/accounts/dcaOrder.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/accounts/guard.d.ts +48 -0
- package/dist/types/core/solana/generated/single-chain/accounts/guard.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/accounts/index.d.ts +12 -0
- package/dist/types/core/solana/generated/single-chain/accounts/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/accounts/limitOrder.d.ts +79 -0
- package/dist/types/core/solana/generated/single-chain/accounts/limitOrder.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/errors/index.d.ts +9 -0
- package/dist/types/core/solana/generated/single-chain/errors/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/errors/singleChainGuard.d.ts +71 -0
- package/dist/types/core/solana/generated/single-chain/errors/singleChainGuard.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/index.d.ts +13 -0
- package/dist/types/core/solana/generated/single-chain/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/acceptAdmin.d.ts +56 -0
- package/dist/types/core/solana/generated/single-chain/instructions/acceptAdmin.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/cancelDcaOrder.d.ts +72 -0
- package/dist/types/core/solana/generated/single-chain/instructions/cancelDcaOrder.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/cancelLimitOrder.d.ts +72 -0
- package/dist/types/core/solana/generated/single-chain/instructions/cancelLimitOrder.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/collectProtocolFees.d.ts +91 -0
- package/dist/types/core/solana/generated/single-chain/instructions/collectProtocolFees.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/createDcaOrder.d.ts +134 -0
- package/dist/types/core/solana/generated/single-chain/instructions/createDcaOrder.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/createGuard.d.ts +107 -0
- package/dist/types/core/solana/generated/single-chain/instructions/createGuard.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/createLimitOrder.d.ts +126 -0
- package/dist/types/core/solana/generated/single-chain/instructions/createLimitOrder.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.d.ts +179 -0
- package/dist/types/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/fulfillLimitOrder.d.ts +179 -0
- package/dist/types/core/solana/generated/single-chain/instructions/fulfillLimitOrder.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/index.d.ts +20 -0
- package/dist/types/core/solana/generated/single-chain/instructions/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/initialize.d.ts +86 -0
- package/dist/types/core/solana/generated/single-chain/instructions/initialize.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/setAdmin.d.ts +61 -0
- package/dist/types/core/solana/generated/single-chain/instructions/setAdmin.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.d.ts +68 -0
- package/dist/types/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/programs/index.d.ts +9 -0
- package/dist/types/core/solana/generated/single-chain/programs/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/programs/singleChainGuard.d.ts +63 -0
- package/dist/types/core/solana/generated/single-chain/programs/singleChainGuard.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/shared/index.d.ts +52 -0
- package/dist/types/core/solana/generated/single-chain/shared/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/types/adminUpdateStarted.d.ts +16 -0
- package/dist/types/core/solana/generated/single-chain/types/adminUpdateStarted.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/types/adminUpdated.d.ts +16 -0
- package/dist/types/core/solana/generated/single-chain/types/adminUpdated.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/types/auctioneerPubkeyUpdated.d.ts +17 -0
- package/dist/types/core/solana/generated/single-chain/types/auctioneerPubkeyUpdated.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/types/dcaOrderCreated.d.ts +38 -0
- package/dist/types/core/solana/generated/single-chain/types/dcaOrderCreated.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/types/dcaOrderFulfilled.d.ts +16 -0
- package/dist/types/core/solana/generated/single-chain/types/dcaOrderFulfilled.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/types/dcaOrderIntervalFulfilled.d.ts +26 -0
- package/dist/types/core/solana/generated/single-chain/types/dcaOrderIntervalFulfilled.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/types/guardCreated.d.ts +18 -0
- package/dist/types/core/solana/generated/single-chain/types/guardCreated.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/types/index.d.ts +18 -0
- package/dist/types/core/solana/generated/single-chain/types/index.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/types/limitOrderCreated.d.ts +32 -0
- package/dist/types/core/solana/generated/single-chain/types/limitOrderCreated.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/types/limitOrderFulfilled.d.ts +20 -0
- package/dist/types/core/solana/generated/single-chain/types/limitOrderFulfilled.d.ts.map +1 -0
- package/dist/types/core/solana/generated/single-chain/types/orderCancelled.d.ts +16 -0
- package/dist/types/core/solana/generated/single-chain/types/orderCancelled.d.ts.map +1 -0
- package/dist/types/core/solana/order-instructions.d.ts +14 -15
- package/dist/types/core/solana/order-instructions.d.ts.map +1 -1
- package/dist/types/core/solana/sdk.d.ts +12 -4
- package/dist/types/core/solana/sdk.d.ts.map +1 -1
- package/dist/types/core/solana/utils.d.ts +6 -0
- package/dist/types/core/solana/utils.d.ts.map +1 -0
- package/dist/types/core/solana/validator.d.ts +2 -1
- package/dist/types/core/solana/validator.d.ts.map +1 -1
- package/dist/types/core/sui/cancel.d.ts +3 -0
- package/dist/types/core/sui/cancel.d.ts.map +1 -0
- package/dist/types/core/sui/order-transaction.d.ts +2 -7
- package/dist/types/core/sui/order-transaction.d.ts.map +1 -1
- package/dist/types/core/sui/sdk.d.ts +10 -4
- package/dist/types/core/sui/sdk.d.ts.map +1 -1
- package/dist/types/core/sui/validator.d.ts +2 -1
- package/dist/types/core/sui/validator.d.ts.map +1 -1
- package/dist/types/errors/index.d.ts +0 -15
- package/dist/types/errors/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +19 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/api.d.ts +59 -2
- package/dist/types/types/api.d.ts.map +1 -1
- package/dist/types/types/intent.d.ts +33 -57
- package/dist/types/types/intent.d.ts.map +1 -1
- package/dist/types/utils/base-validator.d.ts +15 -4
- package/dist/types/utils/base-validator.d.ts.map +1 -1
- package/dist/types/utils/defillama.d.ts +1 -1
- package/dist/types/utils/defillama.d.ts.map +1 -1
- package/dist/types/utils/order-validator.d.ts +20 -11
- package/dist/types/utils/order-validator.d.ts.map +1 -1
- package/dist/types/utils/parsers.d.ts +0 -13
- package/dist/types/utils/parsers.d.ts.map +1 -1
- package/dist/types/utils/quote/aftermath.d.ts +9 -0
- package/dist/types/utils/quote/aftermath.d.ts.map +1 -0
- package/dist/types/utils/quote/aggregator.d.ts +64 -0
- package/dist/types/utils/quote/aggregator.d.ts.map +1 -0
- package/dist/types/utils/quote/jupiter.d.ts +16 -0
- package/dist/types/utils/quote/jupiter.d.ts.map +1 -0
- package/dist/types/utils/quote/liquidswap.d.ts +16 -0
- package/dist/types/utils/quote/liquidswap.d.ts.map +1 -0
- package/dist/types/utils/quote/paraswap.d.ts +23 -0
- package/dist/types/utils/quote/paraswap.d.ts.map +1 -0
- package/dist/types/utils/quote/stablecoins-tokens.d.ts +11 -0
- package/dist/types/utils/quote/stablecoins-tokens.d.ts.map +1 -0
- package/package.json +14 -2
- package/src/auth/siwe.ts +41 -0
- package/src/chains.ts +21 -10
- package/src/constants.ts +86 -38
- package/src/core/evm/abi/single-chain-guard-limit.ts +767 -0
- package/src/core/evm/cancel-order.ts +163 -0
- package/src/core/evm/{viem-provider.ts → chain-provider.ts} +18 -2
- package/src/core/evm/connectors/hyperevm.ts +23 -0
- package/src/core/evm/intent-provider.ts +71 -12
- package/src/core/evm/order-signature.ts +25 -38
- package/src/core/evm/permit2.ts +82 -12
- package/src/core/evm/sdk.ts +165 -88
- package/src/core/evm/validator.ts +73 -11
- package/src/core/orders/api/fetch.ts +21 -0
- package/src/core/orders/common.ts +19 -0
- package/src/core/orders/cross-chain.ts +323 -0
- package/src/core/orders/single-chain.ts +174 -0
- package/src/core/sdk.ts +104 -137
- package/src/core/solana/cancel-order.ts +264 -0
- package/src/core/solana/generated/{accounts → cross-chain/accounts}/adminSingleton.ts +15 -9
- package/src/core/solana/generated/{accounts → cross-chain/accounts}/guard.ts +10 -10
- package/src/core/solana/generated/{accounts → cross-chain/accounts}/order.ts +8 -8
- package/src/core/solana/generated/cross-chain/instructions/acceptAdmin.ts +200 -0
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/claimTokens.ts +10 -10
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/collectProtocolFees.ts +8 -8
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/createGuard.ts +5 -5
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/createOrder.ts +5 -5
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/index.ts +1 -0
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/initialize.ts +104 -12
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/setAdmin.ts +8 -8
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/setAuctioneerPubKey.ts +8 -8
- package/src/core/solana/generated/{programs → cross-chain/programs}/sourceChainGuard.ts +16 -2
- package/src/core/solana/generated/{shared → cross-chain/shared}/index.ts +2 -2
- package/src/core/solana/generated/cross-chain/types/adminUpdateStarted.ts +35 -0
- package/src/core/solana/generated/{types → cross-chain/types}/index.ts +1 -0
- package/src/core/solana/generated/single-chain/accounts/adminSingleton.ts +142 -0
- package/src/core/solana/generated/single-chain/accounts/dcaOrder.ts +222 -0
- package/src/core/solana/generated/single-chain/accounts/guard.ts +156 -0
- package/src/core/solana/generated/single-chain/accounts/index.ts +12 -0
- package/src/core/solana/generated/single-chain/accounts/limitOrder.ts +192 -0
- package/src/core/solana/generated/single-chain/errors/index.ts +9 -0
- package/src/core/solana/generated/single-chain/errors/singleChainGuard.ts +140 -0
- package/src/core/solana/generated/single-chain/index.ts +13 -0
- package/src/core/solana/generated/single-chain/instructions/acceptAdmin.ts +200 -0
- package/src/core/solana/generated/single-chain/instructions/cancelDcaOrder.ts +251 -0
- package/src/core/solana/generated/single-chain/instructions/cancelLimitOrder.ts +254 -0
- package/src/core/solana/generated/single-chain/instructions/collectProtocolFees.ts +373 -0
- package/src/core/solana/generated/single-chain/instructions/createDcaOrder.ts +500 -0
- package/src/core/solana/generated/single-chain/instructions/createGuard.ts +437 -0
- package/src/core/solana/generated/single-chain/instructions/createLimitOrder.ts +491 -0
- package/src/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.ts +538 -0
- package/src/core/solana/generated/single-chain/instructions/fulfillLimitOrder.ts +532 -0
- package/src/core/solana/generated/single-chain/instructions/index.ts +20 -0
- package/src/core/solana/generated/single-chain/instructions/initialize.ts +323 -0
- package/src/core/solana/generated/single-chain/instructions/setAdmin.ts +211 -0
- package/src/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.ts +241 -0
- package/src/core/solana/generated/single-chain/programs/index.ts +9 -0
- package/src/core/solana/generated/single-chain/programs/singleChainGuard.ts +247 -0
- package/src/core/solana/generated/single-chain/shared/index.ts +124 -0
- package/src/core/solana/generated/single-chain/types/adminUpdateStarted.ts +35 -0
- package/src/core/solana/generated/single-chain/types/adminUpdated.ts +35 -0
- package/src/core/solana/generated/single-chain/types/auctioneerPubkeyUpdated.ts +44 -0
- package/src/core/solana/generated/single-chain/types/dcaOrderCreated.ts +89 -0
- package/src/core/solana/generated/single-chain/types/dcaOrderFulfilled.ts +35 -0
- package/src/core/solana/generated/single-chain/types/dcaOrderIntervalFulfilled.ts +63 -0
- package/src/core/solana/generated/single-chain/types/guardCreated.ts +47 -0
- package/src/core/solana/generated/single-chain/types/index.ts +18 -0
- package/src/core/solana/generated/single-chain/types/limitOrderCreated.ts +77 -0
- package/src/core/solana/generated/single-chain/types/limitOrderFulfilled.ts +46 -0
- package/src/core/solana/generated/single-chain/types/orderCancelled.ts +35 -0
- package/src/core/solana/order-instructions.ts +166 -52
- package/src/core/solana/sdk.ts +153 -31
- package/src/core/solana/utils.ts +31 -0
- package/src/core/solana/validator.ts +5 -1
- package/src/core/sui/cancel.ts +44 -0
- package/src/core/sui/order-transaction.ts +14 -31
- package/src/core/sui/sdk.ts +93 -30
- package/src/core/sui/validator.ts +5 -1
- package/src/errors/index.ts +1 -37
- package/src/index.ts +35 -14
- package/src/types/api.ts +73 -4
- package/src/types/intent.ts +42 -63
- package/src/utils/base-validator.ts +26 -8
- package/src/utils/defillama.ts +15 -30
- package/src/utils/order-validator.ts +21 -23
- package/src/utils/parsers.ts +10 -35
- package/src/utils/quote/aftermath.ts +24 -0
- package/src/utils/quote/aggregator.ts +331 -0
- package/src/utils/quote/jupiter.ts +39 -0
- package/src/utils/quote/liquidswap.ts +42 -0
- package/src/utils/quote/paraswap.ts +87 -0
- package/src/utils/quote/stablecoins-tokens.ts +22 -0
- package/dist/esm/core/evm/viem-provider.js.map +0 -1
- package/dist/esm/core/order.js +0 -190
- package/dist/esm/core/order.js.map +0 -1
- package/dist/esm/core/solana/generated/accounts/adminSingleton.js.map +0 -1
- package/dist/esm/core/solana/generated/accounts/guard.js.map +0 -1
- package/dist/esm/core/solana/generated/accounts/index.js.map +0 -1
- package/dist/esm/core/solana/generated/accounts/order.js.map +0 -1
- package/dist/esm/core/solana/generated/errors/index.js.map +0 -1
- package/dist/esm/core/solana/generated/errors/sourceChainGuard.js.map +0 -1
- package/dist/esm/core/solana/generated/index.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/cancelOrder.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/claimTokens.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/collectProtocolFees.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/createGuard.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/createOrder.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/index.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/initialize.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/preStartOrderExecution.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/setAdmin.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/setAuctioneerPubKey.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/startOrderExecution.js.map +0 -1
- package/dist/esm/core/solana/generated/instructions/startOrderExecutionAfterSwap.js.map +0 -1
- package/dist/esm/core/solana/generated/programs/index.js.map +0 -1
- package/dist/esm/core/solana/generated/programs/sourceChainGuard.js.map +0 -1
- package/dist/esm/core/solana/generated/shared/index.js.map +0 -1
- package/dist/esm/core/solana/generated/types/adminUpdated.js.map +0 -1
- package/dist/esm/core/solana/generated/types/auctioneerPubkeyUpdated.js.map +0 -1
- package/dist/esm/core/solana/generated/types/executionStarted.js.map +0 -1
- package/dist/esm/core/solana/generated/types/guardCreated.js.map +0 -1
- package/dist/esm/core/solana/generated/types/index.js.map +0 -1
- package/dist/esm/core/solana/generated/types/orderCancelled.js.map +0 -1
- package/dist/esm/core/solana/generated/types/orderCreated.js.map +0 -1
- package/dist/esm/core/solana/generated/types/orderFulfilled.js.map +0 -1
- package/dist/esm/core/solana/generated/types/tokenInSwapped.js.map +0 -1
- package/dist/esm/types/user-order.js +0 -16
- package/dist/esm/types/user-order.js.map +0 -1
- package/dist/types/core/evm/viem-provider.d.ts +0 -19304
- package/dist/types/core/evm/viem-provider.d.ts.map +0 -1
- package/dist/types/core/order.d.ts.map +0 -1
- package/dist/types/core/solana/generated/accounts/adminSingleton.d.ts.map +0 -1
- package/dist/types/core/solana/generated/accounts/guard.d.ts.map +0 -1
- package/dist/types/core/solana/generated/accounts/index.d.ts.map +0 -1
- package/dist/types/core/solana/generated/accounts/order.d.ts.map +0 -1
- package/dist/types/core/solana/generated/errors/index.d.ts.map +0 -1
- package/dist/types/core/solana/generated/errors/sourceChainGuard.d.ts.map +0 -1
- package/dist/types/core/solana/generated/index.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/cancelOrder.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/claimTokens.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/collectProtocolFees.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/createGuard.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/createOrder.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/index.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/initialize.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/preStartOrderExecution.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/setAdmin.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/setAuctioneerPubKey.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/startOrderExecution.d.ts.map +0 -1
- package/dist/types/core/solana/generated/instructions/startOrderExecutionAfterSwap.d.ts.map +0 -1
- package/dist/types/core/solana/generated/programs/index.d.ts.map +0 -1
- package/dist/types/core/solana/generated/programs/sourceChainGuard.d.ts.map +0 -1
- package/dist/types/core/solana/generated/shared/index.d.ts.map +0 -1
- package/dist/types/core/solana/generated/types/adminUpdated.d.ts.map +0 -1
- package/dist/types/core/solana/generated/types/auctioneerPubkeyUpdated.d.ts.map +0 -1
- package/dist/types/core/solana/generated/types/executionStarted.d.ts.map +0 -1
- package/dist/types/core/solana/generated/types/guardCreated.d.ts.map +0 -1
- package/dist/types/core/solana/generated/types/index.d.ts.map +0 -1
- package/dist/types/core/solana/generated/types/orderCancelled.d.ts.map +0 -1
- package/dist/types/core/solana/generated/types/orderCreated.d.ts.map +0 -1
- package/dist/types/core/solana/generated/types/orderFulfilled.d.ts.map +0 -1
- package/dist/types/core/solana/generated/types/tokenInSwapped.d.ts.map +0 -1
- package/dist/types/types/user-order.d.ts +0 -37
- package/dist/types/types/user-order.d.ts.map +0 -1
- package/src/core/order.ts +0 -186
- package/src/types/user-order.ts +0 -74
- package/dist/esm/core/solana/generated/{accounts → cross-chain/accounts}/index.js +0 -0
- package/dist/esm/core/solana/generated/{accounts → cross-chain/accounts}/order.js +0 -0
- package/dist/esm/core/solana/generated/{errors → cross-chain/errors}/index.js +0 -0
- package/dist/esm/core/solana/generated/{errors → cross-chain/errors}/sourceChainGuard.js +0 -0
- package/dist/esm/core/solana/generated/{index.js → cross-chain/index.js} +0 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/cancelOrder.js +0 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/claimTokens.js +0 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/collectProtocolFees.js +0 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/createGuard.js +0 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/createOrder.js +0 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/preStartOrderExecution.js +0 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/setAdmin.js +0 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/setAuctioneerPubKey.js +0 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/startOrderExecution.js +0 -0
- package/dist/esm/core/solana/generated/{instructions → cross-chain/instructions}/startOrderExecutionAfterSwap.js +0 -0
- package/dist/esm/core/solana/generated/{programs → cross-chain/programs}/index.js +0 -0
- package/dist/esm/core/solana/generated/{shared → cross-chain/shared}/index.js +0 -0
- package/dist/esm/core/solana/generated/{types → cross-chain/types}/adminUpdated.js +0 -0
- package/dist/esm/core/solana/generated/{types → cross-chain/types}/auctioneerPubkeyUpdated.js +0 -0
- package/dist/esm/core/solana/generated/{types → cross-chain/types}/executionStarted.js +0 -0
- package/dist/esm/core/solana/generated/{types → cross-chain/types}/guardCreated.js +0 -0
- package/dist/esm/core/solana/generated/{types → cross-chain/types}/orderCancelled.js +0 -0
- package/dist/esm/core/solana/generated/{types → cross-chain/types}/orderCreated.js +0 -0
- package/dist/esm/core/solana/generated/{types → cross-chain/types}/orderFulfilled.js +0 -0
- package/dist/esm/core/solana/generated/{types → cross-chain/types}/tokenInSwapped.js +0 -0
- package/dist/types/core/solana/generated/{accounts → cross-chain/accounts}/index.d.ts +0 -0
- package/dist/types/core/solana/generated/{errors → cross-chain/errors}/index.d.ts +0 -0
- package/dist/types/core/solana/generated/{errors → cross-chain/errors}/sourceChainGuard.d.ts +0 -0
- package/dist/types/core/solana/generated/{index.d.ts → cross-chain/index.d.ts} +0 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/cancelOrder.d.ts +0 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/createGuard.d.ts +0 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/createOrder.d.ts +0 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/preStartOrderExecution.d.ts +0 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/startOrderExecution.d.ts +0 -0
- package/dist/types/core/solana/generated/{instructions → cross-chain/instructions}/startOrderExecutionAfterSwap.d.ts +0 -0
- package/dist/types/core/solana/generated/{programs → cross-chain/programs}/index.d.ts +0 -0
- package/dist/types/core/solana/generated/{shared → cross-chain/shared}/index.d.ts +0 -0
- package/dist/types/core/solana/generated/{types → cross-chain/types}/adminUpdated.d.ts +0 -0
- package/dist/types/core/solana/generated/{types → cross-chain/types}/auctioneerPubkeyUpdated.d.ts +0 -0
- package/dist/types/core/solana/generated/{types → cross-chain/types}/executionStarted.d.ts +0 -0
- package/dist/types/core/solana/generated/{types → cross-chain/types}/guardCreated.d.ts +0 -0
- package/dist/types/core/solana/generated/{types → cross-chain/types}/orderCancelled.d.ts +0 -0
- package/dist/types/core/solana/generated/{types → cross-chain/types}/orderCreated.d.ts +0 -0
- package/dist/types/core/solana/generated/{types → cross-chain/types}/orderFulfilled.d.ts +0 -0
- package/dist/types/core/solana/generated/{types → cross-chain/types}/tokenInSwapped.d.ts +0 -0
- package/src/core/solana/generated/{accounts → cross-chain/accounts}/index.ts +0 -0
- package/src/core/solana/generated/{errors → cross-chain/errors}/index.ts +0 -0
- package/src/core/solana/generated/{errors → cross-chain/errors}/sourceChainGuard.ts +0 -0
- package/src/core/solana/generated/{index.ts → cross-chain/index.ts} +0 -0
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/cancelOrder.ts +4 -4
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/preStartOrderExecution.ts +4 -4
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/startOrderExecution.ts +4 -4
- package/src/core/solana/generated/{instructions → cross-chain/instructions}/startOrderExecutionAfterSwap.ts +4 -4
- package/src/core/solana/generated/{programs → cross-chain/programs}/index.ts +0 -0
- package/src/core/solana/generated/{types → cross-chain/types}/adminUpdated.ts +4 -4
- package/src/core/solana/generated/{types → cross-chain/types}/auctioneerPubkeyUpdated.ts +4 -4
- package/src/core/solana/generated/{types → cross-chain/types}/executionStarted.ts +4 -4
- package/src/core/solana/generated/{types → cross-chain/types}/guardCreated.ts +4 -4
- package/src/core/solana/generated/{types → cross-chain/types}/orderCancelled.ts +4 -4
- package/src/core/solana/generated/{types → cross-chain/types}/orderCreated.ts +4 -4
- package/src/core/solana/generated/{types → cross-chain/types}/orderFulfilled.ts +4 -4
- package/src/core/solana/generated/{types → cross-chain/types}/tokenInSwapped.ts +4 -4
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
-
import { normalizeSuiObjectId
|
|
2
|
+
import { normalizeSuiObjectId } from '@mysten/sui/utils';
|
|
3
3
|
|
|
4
4
|
import { ChainID } from '../../chains.js';
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
CROSS_CHAIN_GUARD_ADDRESSES,
|
|
7
|
+
NATIVE_SUI_TOKEN_ADDRESS,
|
|
7
8
|
SUI_GUARD_COLLATERAL_TYPE,
|
|
8
9
|
SUI_GUARD_STABLECOIN_TYPE,
|
|
9
10
|
SUI_PACKAGE_ID,
|
|
10
11
|
} from '../../constants.js';
|
|
11
12
|
import { ValidationError } from '../../errors/index.js';
|
|
12
|
-
import type { Order } from '../order.js';
|
|
13
13
|
import { createSuiClient } from './client.js';
|
|
14
|
-
import {
|
|
15
|
-
import type { ApiResponse } from '../../types/api.js';
|
|
16
|
-
import type { PreparedOrder } from '../../types/intent.js';
|
|
14
|
+
import type { CrossChainOrder } from '../orders/cross-chain.js';
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* Generates Sui order transaction for creating an order
|
|
20
18
|
* @param order The order to generate transaction for
|
|
21
19
|
* @returns Object containing the transaction
|
|
22
20
|
*/
|
|
23
|
-
export async function getSuiOrderTransaction(order:
|
|
21
|
+
export async function getSuiOrderTransaction(order: CrossChainOrder): Promise<Transaction> {
|
|
24
22
|
const userAddress = order.user;
|
|
25
23
|
const client = createSuiClient();
|
|
26
24
|
const coins = await client.getCoins({
|
|
@@ -28,7 +26,7 @@ export async function getSuiOrderTransaction(order: Order): Promise<Transaction>
|
|
|
28
26
|
coinType: order.sourceTokenAddress,
|
|
29
27
|
});
|
|
30
28
|
|
|
31
|
-
const guardAddress =
|
|
29
|
+
const guardAddress = CROSS_CHAIN_GUARD_ADDRESSES[ChainID.Sui];
|
|
32
30
|
|
|
33
31
|
const sourceTokenInCoins = coins.data.sort((a, b) => Number(b.balance) - Number(a.balance));
|
|
34
32
|
|
|
@@ -44,7 +42,8 @@ export async function getSuiOrderTransaction(order: Order): Promise<Transaction>
|
|
|
44
42
|
);
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
const spendingGasCoin =
|
|
45
|
+
const spendingGasCoin =
|
|
46
|
+
normalizeSuiObjectId(order.sourceTokenAddress) === normalizeSuiObjectId(NATIVE_SUI_TOKEN_ADDRESS);
|
|
48
47
|
|
|
49
48
|
const tx = new Transaction();
|
|
50
49
|
const coinInArg = spendingGasCoin ? tx.gas : sourceTokenInCoins[0]!.coinObjectId;
|
|
@@ -66,11 +65,12 @@ export async function getSuiOrderTransaction(order: Order): Promise<Transaction>
|
|
|
66
65
|
module: 'source_chain_guard',
|
|
67
66
|
function: 'create_order',
|
|
68
67
|
arguments: [
|
|
69
|
-
tx.object(guardAddress),
|
|
70
|
-
coinIn,
|
|
71
|
-
tx.pure.u64(order.minStablecoinAmount),
|
|
72
|
-
tx.pure.u64(order.deadline * 1000), //
|
|
73
|
-
tx.pure.vector('u8', order.executionDetailsHashToBytes()),
|
|
68
|
+
tx.object(guardAddress), // arg0: &Guard<T0, T2>
|
|
69
|
+
coinIn, // arg1: Coin<T1>
|
|
70
|
+
tx.pure.u64(order.minStablecoinAmount), // arg2: min_stablecoins_amount
|
|
71
|
+
tx.pure.u64(order.deadline * 1000), // arg3: deadline (converted to milliseconds)
|
|
72
|
+
tx.pure.vector('u8', order.executionDetailsHashToBytes()), // arg4: execution_details_hash
|
|
73
|
+
tx.object.clock(), // arg5: &Clock
|
|
74
74
|
],
|
|
75
75
|
typeArguments: [SUI_GUARD_COLLATERAL_TYPE, order.sourceTokenAddress, SUI_GUARD_STABLECOIN_TYPE],
|
|
76
76
|
});
|
|
@@ -79,20 +79,3 @@ export async function getSuiOrderTransaction(order: Order): Promise<Transaction>
|
|
|
79
79
|
|
|
80
80
|
return tx;
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
export async function sendSuiRequest({
|
|
84
|
-
order,
|
|
85
|
-
transactionDigest,
|
|
86
|
-
}: {
|
|
87
|
-
order: Order;
|
|
88
|
-
transactionDigest: string;
|
|
89
|
-
}): Promise<ApiResponse> {
|
|
90
|
-
const preparedOrder: PreparedOrder = {
|
|
91
|
-
order,
|
|
92
|
-
preparedData: {
|
|
93
|
-
transactionHash: transactionDigest,
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
return BaseSDK.sendOrder(preparedOrder);
|
|
98
|
-
}
|
package/src/core/sui/sdk.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { SuiClient } from '@mysten/sui/client';
|
|
2
2
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
3
|
-
|
|
4
3
|
import type { SuiConfig } from '../../config.js';
|
|
5
|
-
import { OrderCreationError } from '../../errors/index.js';
|
|
6
|
-
import type { PreparedOrder } from '../../types/intent.js';
|
|
7
|
-
import { Order } from '../order.js';
|
|
8
4
|
import { BaseSDK } from '../sdk.js';
|
|
9
5
|
import { createSuiClient } from './client.js';
|
|
10
6
|
import { getSuiOrderTransaction } from './order-transaction.js';
|
|
7
|
+
import { getSuiCancelCrossChainOrder } from './cancel.js';
|
|
8
|
+
import type { CrossChainOrderPrepared, SingleChainOrderPrepared } from '../../types/intent.js';
|
|
9
|
+
import type { CrossChainOrder } from '../orders/cross-chain.js';
|
|
10
|
+
import type { ApiUserOrders } from '../../types/api.js';
|
|
11
|
+
import { fetchJWTToken, fetchSiweMessage } from '../../auth/siwe.js';
|
|
12
|
+
import { fetchUserOrders } from '../orders/api/fetch.js';
|
|
13
|
+
import { ChainID } from '../../chains.js';
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Sui-specific SDK implementation
|
|
@@ -17,14 +20,11 @@ import { getSuiOrderTransaction } from './order-transaction.js';
|
|
|
17
20
|
* Supports cross-chain swaps from Sui to other supported chains.
|
|
18
21
|
*/
|
|
19
22
|
export class SuiSDK extends BaseSDK {
|
|
20
|
-
protected override cancelOrderInternal(): Promise<string> {
|
|
21
|
-
throw new Error('Method not implemented.');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
23
|
/** Configuration for Sui connection and authentication */
|
|
25
24
|
private readonly config: SuiConfig;
|
|
26
25
|
/** Client for Sui RPC interactions and transaction handling */
|
|
27
26
|
private client: SuiClient;
|
|
27
|
+
private token?: string;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Creates a new instance of the Sui SDK
|
|
@@ -60,6 +60,54 @@ export class SuiSDK extends BaseSDK {
|
|
|
60
60
|
return Ed25519Keypair.fromSecretKey(this.config.privateKey);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
protected override prepareSingleChainOrder(): Promise<SingleChainOrderPrepared> {
|
|
64
|
+
throw new Error('Single-chain orders are not supported on Sui');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public async authenticate(token?: string): Promise<string> {
|
|
68
|
+
const wallet = await this.getUserAddress();
|
|
69
|
+
|
|
70
|
+
const response = await fetchSiweMessage({
|
|
71
|
+
chainId: ChainID.Sui,
|
|
72
|
+
wallet,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const message = response.data!;
|
|
76
|
+
|
|
77
|
+
const keypair = this.getKeyPair();
|
|
78
|
+
|
|
79
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
80
|
+
|
|
81
|
+
const { signature } = await keypair.signPersonalMessage(messageBytes);
|
|
82
|
+
|
|
83
|
+
const jwt = await fetchJWTToken(
|
|
84
|
+
{
|
|
85
|
+
message,
|
|
86
|
+
signature,
|
|
87
|
+
},
|
|
88
|
+
token,
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const newToken = jwt.data!;
|
|
92
|
+
|
|
93
|
+
return newToken;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public setToken(token: string) {
|
|
97
|
+
this.token = token;
|
|
98
|
+
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public override async getOrders(): Promise<ApiUserOrders> {
|
|
103
|
+
if (!this.token) {
|
|
104
|
+
throw new Error('No token provided');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const orders = await fetchUserOrders(this.token);
|
|
108
|
+
|
|
109
|
+
return orders;
|
|
110
|
+
}
|
|
63
111
|
/**
|
|
64
112
|
* Prepares a Sui order for submission
|
|
65
113
|
*
|
|
@@ -73,27 +121,42 @@ export class SuiSDK extends BaseSDK {
|
|
|
73
121
|
* @returns Promise resolving to a prepared order with Sui-specific data
|
|
74
122
|
* @protected
|
|
75
123
|
*/
|
|
76
|
-
protected async
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
124
|
+
protected async prepareCrossChainOrder(order: CrossChainOrder): Promise<CrossChainOrderPrepared> {
|
|
125
|
+
const signer = this.getKeyPair();
|
|
126
|
+
|
|
127
|
+
const transaction = await getSuiOrderTransaction(order);
|
|
128
|
+
|
|
129
|
+
const tx = await this.client.signAndExecuteTransaction({
|
|
130
|
+
signer,
|
|
131
|
+
transaction,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
await this.client.waitForTransaction({ digest: tx.digest });
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
order,
|
|
138
|
+
preparedData: {
|
|
139
|
+
transactionHash: tx.digest,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public async cancelCrossChainOrder(orderId: string): Promise<string> {
|
|
145
|
+
const signer = this.getKeyPair();
|
|
146
|
+
|
|
147
|
+
const transaction = await getSuiCancelCrossChainOrder(orderId);
|
|
148
|
+
|
|
149
|
+
const sender = await this.getUserAddress();
|
|
150
|
+
|
|
151
|
+
transaction.setSender(sender);
|
|
152
|
+
|
|
153
|
+
const tx = await this.client.signAndExecuteTransaction({
|
|
154
|
+
signer,
|
|
155
|
+
transaction,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
await this.client.waitForTransaction({ digest: tx.digest });
|
|
159
|
+
|
|
160
|
+
return tx.digest;
|
|
98
161
|
}
|
|
99
162
|
}
|
|
@@ -25,8 +25,12 @@ export class SuiValidator extends BaseValidator {
|
|
|
25
25
|
return 'Sui';
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
public async
|
|
28
|
+
public async validateCrossChainOrderFeasability(): Promise<void> {
|
|
29
29
|
// No chain-specific validation implemented for now for Sui
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
override validateSingleChainOrderFeasability(): Promise<void> {
|
|
34
|
+
return Promise.resolve();
|
|
35
|
+
}
|
|
32
36
|
}
|
package/src/errors/index.ts
CHANGED
|
@@ -32,29 +32,6 @@ export class BaseError extends Error {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
// Chain-specific error classes
|
|
36
|
-
export class EVMError extends BaseError {
|
|
37
|
-
constructor(message: string, cause?: unknown) {
|
|
38
|
-
super(message, cause);
|
|
39
|
-
Object.setPrototypeOf(this, EVMError.prototype);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export class SolanaError extends BaseError {
|
|
44
|
-
constructor(message: string, cause?: unknown) {
|
|
45
|
-
super(message, cause);
|
|
46
|
-
Object.setPrototypeOf(this, SolanaError.prototype);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export class SuiError extends BaseError {
|
|
51
|
-
constructor(message: string, cause?: unknown) {
|
|
52
|
-
super(message, cause);
|
|
53
|
-
Object.setPrototypeOf(this, SuiError.prototype);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Specific error types
|
|
58
35
|
export class ValidationError extends BaseError {
|
|
59
36
|
constructor(message: string, cause?: unknown) {
|
|
60
37
|
super(message, cause);
|
|
@@ -62,13 +39,6 @@ export class ValidationError extends BaseError {
|
|
|
62
39
|
}
|
|
63
40
|
}
|
|
64
41
|
|
|
65
|
-
export class OrderCreationError extends BaseError {
|
|
66
|
-
constructor(message: string, cause?: unknown) {
|
|
67
|
-
super(message, cause);
|
|
68
|
-
Object.setPrototypeOf(this, OrderCreationError.prototype);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
42
|
export class NetworkError extends BaseError {
|
|
73
43
|
constructor(message: string, cause?: unknown) {
|
|
74
44
|
super(message, cause);
|
|
@@ -83,19 +53,13 @@ export class InsufficientBalanceError extends BaseError {
|
|
|
83
53
|
}
|
|
84
54
|
}
|
|
85
55
|
|
|
86
|
-
export class CalculateAmountError extends BaseError {
|
|
87
|
-
constructor(message: string, cause?: unknown) {
|
|
88
|
-
super(message, cause);
|
|
89
|
-
Object.setPrototypeOf(this, CalculateAmountError.prototype);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
56
|
export class InsufficientAllowanceError extends BaseError {
|
|
94
57
|
constructor(message: string, cause?: unknown) {
|
|
95
58
|
super(message, cause);
|
|
96
59
|
Object.setPrototypeOf(this, InsufficientAllowanceError.prototype);
|
|
97
60
|
}
|
|
98
61
|
}
|
|
62
|
+
|
|
99
63
|
export function handleError(error: unknown): BaseError {
|
|
100
64
|
if (error instanceof BaseError) {
|
|
101
65
|
return error;
|
package/src/index.ts
CHANGED
|
@@ -1,21 +1,42 @@
|
|
|
1
|
-
export { ChainID, ChainType, SupportedChains } from './chains.js';
|
|
2
|
-
export type { SupportedEvmChain } from './chains.js';
|
|
1
|
+
export { ChainID, ChainType, SupportedChains, isSupportedChain, chainIdToChainTypeMap, isEvmChain } from './chains.js';
|
|
2
|
+
export type { SupportedEvmChain, SupportedChain } from './chains.js';
|
|
3
3
|
|
|
4
4
|
export type { EVMConfig, SolanaConfig, SuiConfig } from './config.js';
|
|
5
5
|
export { EVMSDK } from './core/evm/sdk.js';
|
|
6
|
-
export { Order } from './core/order.js';
|
|
7
6
|
export { SolanaSDK } from './core/solana/sdk.js';
|
|
8
7
|
export { SuiSDK } from './core/sui/sdk.js';
|
|
8
|
+
export { CrossChainOrder } from './core/orders/cross-chain.js';
|
|
9
|
+
export type { CreateCrossChainOrderParams } from './core/orders/cross-chain.js';
|
|
10
|
+
export { SingleChainOrder } from './core/orders/single-chain.js';
|
|
11
|
+
export type { CreateSingleChainOrderParams } from './core/orders/single-chain.js';
|
|
12
|
+
|
|
13
|
+
export { fetchUserOrders } from './core/orders/api/fetch.js';
|
|
14
|
+
export { type FetchJWTParams, type FetchSiweMessageParams, fetchJWTToken, fetchSiweMessage } from './auth/siwe.js';
|
|
9
15
|
export { ValidationError } from './errors/index.js';
|
|
10
|
-
export {
|
|
11
|
-
|
|
12
|
-
chainIdToDefiLlamaChainMap,
|
|
13
|
-
createDefiLlamaCoinKey,
|
|
14
|
-
getCoinFromResponse,
|
|
15
|
-
getTokensData,
|
|
16
|
-
} from './utils/defillama.js';
|
|
16
|
+
export { type ApiCrossChainOrder, type ApiResponse, type ApiSingleChainOrder, type ApiUserOrders, type ChainOrderStatus, isErrorApiResponse, isSuccessApiResponse } from './types/api.js';
|
|
17
|
+
export { calculateAmounts, getCoinFromResponse, getTokensData } from './utils/defillama.js';
|
|
17
18
|
export type { DefiLlamaCoinData, DefiLlamaTokensResponse } from './utils/defillama.js';
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
export {
|
|
20
|
+
getCancelCrossChainOrderRawData,
|
|
21
|
+
getCancelSingleChainOrderRawData,
|
|
22
|
+
type CancelSingleChainOrderParams,
|
|
23
|
+
type CancelCrossChainOrderParams,
|
|
24
|
+
getInvalidateNoncesRawData,
|
|
25
|
+
} from './core/evm/cancel-order.js';
|
|
26
|
+
export { getEVMCrossChainOrderTypedData, getEVMSingleChainOrderTypedData } from './core/evm/order-signature.js';
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
getSolanaCrossChainOrderInstructions,
|
|
30
|
+
getSolanaSingleChainOrderInstructions,
|
|
31
|
+
} from './core/solana/order-instructions.js';
|
|
32
|
+
export {
|
|
33
|
+
cancelCrossChainOrderInstructionsAsBytes,
|
|
34
|
+
cancelSingleChainOrderInstructionsAsBytes,
|
|
35
|
+
} from './core/solana/cancel-order.js';
|
|
36
|
+
export { getSuiOrderTransaction } from './core/sui/order-transaction.js';
|
|
37
|
+
export { getSuiCancelCrossChainOrder } from './core/sui/cancel.js';
|
|
38
|
+
|
|
39
|
+
export { QuoteProvider } from './utils/quote/aggregator.js';
|
|
40
|
+
export type { QuoteResponse } from './utils/quote/aggregator.js';
|
|
41
|
+
|
|
42
|
+
export { CROSS_CHAIN_GUARD_ADDRESSES, SINGLE_CHAIN_GUARD_ADDRESSES, PERMIT2_ADDRESS } from './constants.js';
|
package/src/types/api.ts
CHANGED
|
@@ -1,9 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
success: boolean;
|
|
3
|
-
code: number;
|
|
1
|
+
import type { ExtraTransfer } from '../core/orders/common.js';
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
export type ChainOrderStatus = 'Auction' | 'NoBids' | 'Executing' | 'Fulfilled' | 'Cancelled' | 'Outdated';
|
|
4
|
+
|
|
5
|
+
export type ApiCrossChainOrder = {
|
|
6
|
+
orderId: string;
|
|
7
|
+
// Flattened fields from the API response
|
|
8
|
+
user: string;
|
|
9
|
+
srcChainId: number;
|
|
10
|
+
tokenIn: string;
|
|
11
|
+
minStablecoinsAmount: string;
|
|
12
|
+
destChainId: number;
|
|
13
|
+
tokenOut: string;
|
|
14
|
+
amountOutMin: string;
|
|
15
|
+
destinationAddress: string;
|
|
16
|
+
extraTransfers?: ExtraTransfer[];
|
|
17
|
+
deadline: number;
|
|
18
|
+
executionDetailsHash: string;
|
|
19
|
+
amountIn: string;
|
|
20
|
+
// Cross-chain specific fields
|
|
21
|
+
executionDetails: string;
|
|
22
|
+
orderCreationTime: number;
|
|
23
|
+
orderStatus: ChainOrderStatus;
|
|
24
|
+
tokensInWereSwappedToStablecoins: boolean;
|
|
25
|
+
lockedStablecoins: string;
|
|
26
|
+
nonce?: string;
|
|
27
|
+
orderFulfillmentTimestamp?: number;
|
|
28
|
+
transactionHash?: string;
|
|
29
|
+
amountOut?: string;
|
|
30
|
+
};
|
|
6
31
|
|
|
32
|
+
export type ApiSingleChainOrder = {
|
|
33
|
+
orderId: string;
|
|
34
|
+
// Flattened fields from the API response
|
|
35
|
+
user: string;
|
|
36
|
+
chainId: number;
|
|
37
|
+
tokenIn: string;
|
|
38
|
+
tokenOut: string;
|
|
39
|
+
amountOutMin: string;
|
|
40
|
+
destinationAddress: string;
|
|
41
|
+
extraTransfers?: ExtraTransfer[];
|
|
42
|
+
deadline: number;
|
|
43
|
+
amountIn: string;
|
|
44
|
+
// Single-chain specific fields
|
|
45
|
+
orderCreationTime: number;
|
|
46
|
+
orderStatus: ChainOrderStatus;
|
|
47
|
+
nonce?: string;
|
|
48
|
+
orderFulfillmentTimestamp?: number;
|
|
49
|
+
transactionHash?: string;
|
|
50
|
+
amountOut?: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type ApiUserOrders = {
|
|
54
|
+
singleChainLimitOrders: ApiSingleChainOrder[];
|
|
55
|
+
crossChainLimitOrders: ApiCrossChainOrder[];
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type ValidResponseData = ApiUserOrders | string | null;
|
|
59
|
+
|
|
60
|
+
export type ApiResponse<T extends ValidResponseData = ValidResponseData> = {
|
|
61
|
+
success: boolean;
|
|
62
|
+
code: number;
|
|
63
|
+
data?: T;
|
|
7
64
|
error?: unknown;
|
|
8
65
|
extra_error_data?: unknown;
|
|
9
66
|
};
|
|
67
|
+
|
|
68
|
+
export function isSuccessApiResponse<T extends ValidResponseData>(
|
|
69
|
+
response: ApiResponse<T>,
|
|
70
|
+
): response is ApiResponse<T> & { success: true; data: T } {
|
|
71
|
+
return response.success;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function isErrorApiResponse<T extends ValidResponseData>(
|
|
75
|
+
response: ApiResponse<T>,
|
|
76
|
+
): response is ApiResponse<T> & { success: false; error: unknown } {
|
|
77
|
+
return !response.success;
|
|
78
|
+
}
|
package/src/types/intent.ts
CHANGED
|
@@ -1,35 +1,7 @@
|
|
|
1
1
|
import type { SupportedChain } from '../chains.js';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Parameters for creating a cross-chain order
|
|
6
|
-
* Used as input for the createOrder and createAndSendOrder methods
|
|
7
|
-
*/
|
|
8
|
-
export type CreateOrderParams = {
|
|
9
|
-
/** Chain ID where tokens will be sent from */
|
|
10
|
-
sourceChainId: SupportedChain;
|
|
11
|
-
/** Token address on the source chain to be swapped */
|
|
12
|
-
sourceTokenAddress: string;
|
|
13
|
-
/** Amount of source tokens to swap, in smallest units (e.g., Wei for ETH) */
|
|
14
|
-
sourceTokenAmount: bigint;
|
|
15
|
-
|
|
16
|
-
/** Chain ID where tokens will be received */
|
|
17
|
-
destinationChainId: SupportedChain;
|
|
18
|
-
/** Token address on the destination chain to receive */
|
|
19
|
-
destinationTokenAddress: string;
|
|
20
|
-
/** Minimum amount of destination tokens to receive, in smallest units */
|
|
21
|
-
destinationTokenMinAmount?: bigint;
|
|
22
|
-
/** Recipient wallet address on the destination chain */
|
|
23
|
-
destinationAddress: string;
|
|
24
|
-
|
|
25
|
-
/** Minimum amount of stablecoins in the intermediate swap, in smallest units */
|
|
26
|
-
minStablecoinAmount?: bigint;
|
|
27
|
-
/** Timestamp (in seconds) after which the order expires */
|
|
28
|
-
deadline: number;
|
|
29
|
-
|
|
30
|
-
/** Extra Transfers */
|
|
31
|
-
extraTransfers?: ExtraTransfer[];
|
|
32
|
-
};
|
|
2
|
+
import type { CrossChainOrder } from '../core/orders/cross-chain.js';
|
|
3
|
+
import type { ExtraTransfer } from '../core/orders/common.js';
|
|
4
|
+
import type { SingleChainOrder } from '../core/orders/single-chain.js';
|
|
33
5
|
|
|
34
6
|
/**
|
|
35
7
|
* Details required to execute the order on the destination chain
|
|
@@ -48,15 +20,10 @@ export type ExecutionDetails = {
|
|
|
48
20
|
extraTransfers?: ExtraTransfer[];
|
|
49
21
|
};
|
|
50
22
|
|
|
51
|
-
/** Hex string with 0x prefix, used for various hashes */
|
|
52
23
|
export type Hash = `0x${string}`;
|
|
53
24
|
/** Hash of execution details, used to verify order integrity across chains */
|
|
54
25
|
export type ExecutionDetailsHash = Hash;
|
|
55
26
|
|
|
56
|
-
/**
|
|
57
|
-
* EVM-specific data required for prepared orders
|
|
58
|
-
* Contains the signature and nonce for Permit2 allowance
|
|
59
|
-
*/
|
|
60
27
|
export type EvmPreparedData = {
|
|
61
28
|
/** Random nonce for Permit2 signature, prevents replay attacks */
|
|
62
29
|
nonce: string;
|
|
@@ -64,19 +31,11 @@ export type EvmPreparedData = {
|
|
|
64
31
|
signature: string | Hash;
|
|
65
32
|
};
|
|
66
33
|
|
|
67
|
-
/**
|
|
68
|
-
* Sui-specific data required for prepared orders
|
|
69
|
-
* Contains the transaction hash of the order creation transaction
|
|
70
|
-
*/
|
|
71
34
|
export type SuiPreparedData = {
|
|
72
35
|
/** Transaction hash of the successful order creation transaction */
|
|
73
36
|
transactionHash: string;
|
|
74
37
|
};
|
|
75
38
|
|
|
76
|
-
/**
|
|
77
|
-
* Solana-specific data required for prepared orders
|
|
78
|
-
* Contains the public key of the created order account
|
|
79
|
-
*/
|
|
80
39
|
export type SolanaPreparedData = {
|
|
81
40
|
/** Public key of the created order account on Solana */
|
|
82
41
|
orderPubkey: string;
|
|
@@ -101,13 +60,12 @@ export type SourceChainData = {
|
|
|
101
60
|
deadline: number;
|
|
102
61
|
/** Hash of execution details for cross-chain verification */
|
|
103
62
|
executionDetailsHash: ExecutionDetailsHash;
|
|
63
|
+
stopLossMaxOut?: bigint;
|
|
64
|
+
takeProfitMinOut?: bigint;
|
|
65
|
+
extraTransfers?: ExtraTransfer[];
|
|
104
66
|
};
|
|
105
67
|
|
|
106
|
-
|
|
107
|
-
* Complete user intent request sent to the auctioneer service
|
|
108
|
-
* Contains all the information needed to execute the cross-chain swap
|
|
109
|
-
*/
|
|
110
|
-
export type UserIntentRequest = {
|
|
68
|
+
export type CrossChainUserIntentRequest = {
|
|
111
69
|
/** Generic data common to all chains */
|
|
112
70
|
genericData: SourceChainData;
|
|
113
71
|
/** JSON-stringified execution details for the destination chain */
|
|
@@ -123,21 +81,42 @@ export type UserIntentRequest = {
|
|
|
123
81
|
};
|
|
124
82
|
};
|
|
125
83
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
84
|
+
export type SingleChainUserIntentRequest = {
|
|
85
|
+
genericData: SingleChainOrder;
|
|
86
|
+
chainSpecificData: {
|
|
87
|
+
EVM?: EvmPreparedData;
|
|
88
|
+
Solana?: SolanaPreparedData;
|
|
89
|
+
Sui?: SolanaPreparedData;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
130
93
|
export type ChainPreparedData = EvmPreparedData | SuiPreparedData | SolanaPreparedData;
|
|
131
94
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
* Contains both the order details and chain-specific prepared data
|
|
135
|
-
*/
|
|
136
|
-
export type PreparedOrder = {
|
|
137
|
-
/** The original order with all cross-chain details */
|
|
138
|
-
order: Order;
|
|
139
|
-
/** Chain-specific data needed for order execution */
|
|
95
|
+
export type CrossChainOrderPrepared = {
|
|
96
|
+
order: CrossChainOrder;
|
|
140
97
|
preparedData: ChainPreparedData;
|
|
141
|
-
|
|
142
|
-
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type SingleChainEVMPreparedData = {
|
|
101
|
+
nonce: string;
|
|
102
|
+
signature: string | Hash;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export type SingleChainSolanaPreparedData = {
|
|
106
|
+
secretNumber: string;
|
|
107
|
+
orderPubkey: string;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type SingleChainSuiPreparedData = {
|
|
111
|
+
transactionHash: string;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export type SingleChainPreparedData =
|
|
115
|
+
| SingleChainEVMPreparedData
|
|
116
|
+
| SingleChainSolanaPreparedData
|
|
117
|
+
| SingleChainSuiPreparedData;
|
|
118
|
+
|
|
119
|
+
export type SingleChainOrderPrepared = {
|
|
120
|
+
order: SingleChainOrder;
|
|
121
|
+
preparedData: SingleChainPreparedData;
|
|
143
122
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CreateCrossChainOrderParams } from '../core/orders/cross-chain.js';
|
|
2
|
+
import type { CreateSingleChainOrderParams } from '../core/orders/single-chain.js';
|
|
2
3
|
import { ValidationError } from '../errors/index.js';
|
|
3
4
|
import type { IChainValidator } from './order-validator.js';
|
|
4
5
|
|
|
@@ -11,26 +12,43 @@ export abstract class BaseValidator implements IChainValidator {
|
|
|
11
12
|
abstract isValidTokenAddress(tokenAddress: string): boolean;
|
|
12
13
|
abstract isValidAmount(amount: bigint): boolean;
|
|
13
14
|
protected abstract getChainName(): string;
|
|
14
|
-
abstract
|
|
15
|
+
abstract validateCrossChainOrderFeasability(order: CreateCrossChainOrderParams & { user: string }): Promise<void>;
|
|
16
|
+
abstract validateSingleChainOrderFeasability(order: CreateSingleChainOrderParams & { user: string }): Promise<void>;
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Validate source chain specific parameters of the order
|
|
18
20
|
*/
|
|
19
|
-
async validateSourceChain(order:
|
|
20
|
-
this.validateAddress(order.user);
|
|
21
|
+
async validateSourceChain(order: CreateCrossChainOrderParams & { user: string }): Promise<void> {
|
|
21
22
|
this.validateTokenAddress(order.sourceTokenAddress);
|
|
22
23
|
this.validateAmount(order.sourceTokenAmount);
|
|
23
|
-
this.validateAmount(order.minStablecoinAmount);
|
|
24
|
-
await this.
|
|
24
|
+
this.validateAmount(order.minStablecoinAmount ?? 1n);
|
|
25
|
+
await this.validateCrossChainOrderFeasability({ ...order, user: order.user });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async validateSingleChainOrder(order: CreateSingleChainOrderParams & { user: string }): Promise<void> {
|
|
29
|
+
this.validateTokenAddress(order.tokenIn);
|
|
30
|
+
this.validateTokenAddress(order.tokenOut);
|
|
31
|
+
this.validateAmount(order.amountIn);
|
|
32
|
+
this.validateAmount(order.amountOutMin ?? 1n);
|
|
33
|
+
|
|
34
|
+
if (order.stopLossMaxOut) {
|
|
35
|
+
this.validateAmount(order.stopLossMaxOut);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (order.takeProfitMinOut) {
|
|
39
|
+
this.validateAmount(order.takeProfitMinOut);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
await this.validateSingleChainOrderFeasability(order);
|
|
25
43
|
}
|
|
26
44
|
|
|
27
45
|
/**
|
|
28
46
|
* Validate destination chain specific parameters of the order
|
|
29
47
|
*/
|
|
30
|
-
validateDestinationChain(order:
|
|
48
|
+
validateDestinationChain(order: CreateCrossChainOrderParams): void {
|
|
31
49
|
this.validateAddress(order.destinationAddress);
|
|
32
50
|
this.validateTokenAddress(order.destinationTokenAddress);
|
|
33
|
-
this.validateAmount(order.destinationTokenMinAmount);
|
|
51
|
+
this.validateAmount(order.destinationTokenMinAmount ?? 1n);
|
|
34
52
|
|
|
35
53
|
if (order.extraTransfers) {
|
|
36
54
|
for (const extraTransfer of order.extraTransfers) {
|