@shogun-sdk/intents-sdk 1.0.2 → 1.1.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/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 +94 -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/api/index.js +31 -0
- package/dist/esm/core/orders/api/index.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 +86 -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 +49 -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 +16 -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 +34 -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/api/index.d.ts +8 -0
- package/dist/types/core/orders/api/index.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 +13 -77
- 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 +8 -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 +6 -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 +20 -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 +147 -89
- package/src/core/evm/validator.ts +73 -11
- package/src/core/orders/api/fetch.ts +22 -0
- package/src/core/orders/api/index.ts +33 -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 +102 -136
- 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 +134 -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 +75 -30
- package/src/core/sui/validator.ts +5 -1
- package/src/errors/index.ts +1 -37
- package/src/index.ts +36 -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,6 +1,7 @@
|
|
|
1
1
|
import { ChainType, chainIdToChainTypeMap, type SupportedChain } from '../chains.js';
|
|
2
2
|
import { EvmValidator } from '../core/evm/validator.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CreateCrossChainOrderParams } from '../core/orders/cross-chain.js';
|
|
4
|
+
import type { CreateSingleChainOrderParams } from '../core/orders/single-chain.js';
|
|
4
5
|
import { SolanaValidator } from '../core/solana/validator.js';
|
|
5
6
|
import { SuiValidator } from '../core/sui/validator.js';
|
|
6
7
|
import { ValidationError } from '../errors/index.js';
|
|
@@ -21,19 +22,16 @@ export interface IDeadlineValidator {
|
|
|
21
22
|
isValidDeadline(deadline: number): boolean;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export interface ICrossChainValidator {
|
|
25
|
-
isValidCrossChain(sourceChainId: SupportedChain, destinationChainId: SupportedChain): boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
25
|
export interface IChainValidator extends IAddressValidator, ITokenValidator, IAmountValidator {
|
|
29
|
-
validateSourceChain(order:
|
|
30
|
-
validateDestinationChain(order:
|
|
26
|
+
validateSourceChain(order: CreateCrossChainOrderParams & { user: string }): Promise<void>;
|
|
27
|
+
validateDestinationChain(order: CreateCrossChainOrderParams): void;
|
|
28
|
+
validateSingleChainOrder(order: CreateSingleChainOrderParams & { user: string }): Promise<void>;
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
/**
|
|
34
32
|
* CommonValidator - Handles validations shared across chains
|
|
35
33
|
*/
|
|
36
|
-
export class CommonValidator implements IDeadlineValidator
|
|
34
|
+
export class CommonValidator implements IDeadlineValidator {
|
|
37
35
|
isValidDeadline(deadline: number): boolean {
|
|
38
36
|
return deadline > Math.floor(Date.now() / 1000);
|
|
39
37
|
}
|
|
@@ -43,16 +41,6 @@ export class CommonValidator implements IDeadlineValidator, ICrossChainValidator
|
|
|
43
41
|
throw new ValidationError('Deadline must be in the future');
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
isValidCrossChain(sourceChainId: SupportedChain, destinationChainId: SupportedChain): boolean {
|
|
48
|
-
return sourceChainId !== destinationChainId;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
validateCrossChain(sourceChainId: SupportedChain, destinationChainId: SupportedChain): void {
|
|
52
|
-
if (!this.isValidCrossChain(sourceChainId, destinationChainId)) {
|
|
53
|
-
throw new ValidationError('Source and destination chains cannot be the same');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
44
|
}
|
|
57
45
|
|
|
58
46
|
export class ValidatorFactory {
|
|
@@ -84,15 +72,13 @@ export class ValidatorFactory {
|
|
|
84
72
|
}
|
|
85
73
|
}
|
|
86
74
|
|
|
87
|
-
export class
|
|
75
|
+
export class CrossChainOrderValidator {
|
|
88
76
|
private readonly commonValidator = new CommonValidator();
|
|
89
77
|
|
|
90
|
-
async validateOrder(order:
|
|
78
|
+
async validateOrder(order: CreateCrossChainOrderParams & { user: string }): Promise<void> {
|
|
91
79
|
const sourceValidator = ValidatorFactory.getValidatorForChain(order.sourceChainId);
|
|
92
80
|
|
|
93
|
-
await sourceValidator.validateSourceChain(order);
|
|
94
|
-
|
|
95
|
-
// this.commonValidator.validateCrossChain(order.sourceChainId, order.destinationChainId);
|
|
81
|
+
await sourceValidator.validateSourceChain({ ...order, user: order.user });
|
|
96
82
|
|
|
97
83
|
const destinationValidator = ValidatorFactory.getValidatorForChain(order.destinationChainId);
|
|
98
84
|
|
|
@@ -101,3 +87,15 @@ export class OrderValidator {
|
|
|
101
87
|
this.commonValidator.validateDeadline(order.deadline);
|
|
102
88
|
}
|
|
103
89
|
}
|
|
90
|
+
|
|
91
|
+
export class SingleChainOrderValidator {
|
|
92
|
+
private readonly commonValidator = new CommonValidator();
|
|
93
|
+
|
|
94
|
+
async validateOrder(order: CreateSingleChainOrderParams & { user: string }): Promise<void> {
|
|
95
|
+
this.commonValidator.validateDeadline(order.deadline);
|
|
96
|
+
|
|
97
|
+
const chainValidator = ValidatorFactory.getValidatorForChain(order.chainId);
|
|
98
|
+
|
|
99
|
+
chainValidator.validateSingleChainOrder(order);
|
|
100
|
+
}
|
|
101
|
+
}
|
package/src/utils/parsers.ts
CHANGED
|
@@ -1,55 +1,30 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
2
|
import { formatUnits, parseUnits } from 'viem';
|
|
3
|
-
import { CalculateAmountError } from '../errors/index.js';
|
|
4
3
|
|
|
5
4
|
export namespace Parsers {
|
|
6
5
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
6
|
export function bigIntReplacer(_key: string, value: any): any {
|
|
8
|
-
|
|
7
|
+
if (typeof value === 'bigint') {
|
|
8
|
+
return value.toString();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (typeof value === 'string' && /^\d+n$/.test(value)) {
|
|
12
|
+
return value.slice(0, -1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return value;
|
|
9
16
|
}
|
|
10
17
|
|
|
11
|
-
/**
|
|
12
|
-
* Converts a bigint amount to a floating point USD value
|
|
13
|
-
* @param amount Amount in token's smallest unit
|
|
14
|
-
* @param decimals Number of decimal places for the token
|
|
15
|
-
* @returns USD value as number
|
|
16
|
-
*/
|
|
17
18
|
export function bigintToFloat(amount: bigint, decimals: number): number {
|
|
18
19
|
const formatted = formatUnits(amount, decimals);
|
|
19
20
|
const result = parseFloat(formatted);
|
|
20
21
|
|
|
21
|
-
if (!Number.isFinite(result)) {
|
|
22
|
-
throw new CalculateAmountError(`Conversion resulted in invalid number: ${formatted}`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
22
|
return result;
|
|
26
23
|
}
|
|
27
24
|
|
|
28
|
-
/**
|
|
29
|
-
* Converts a floating point USD value to bigint amount
|
|
30
|
-
* Uses viem's parseUnits for consistency and reliability
|
|
31
|
-
* @param usdValue USD value as number
|
|
32
|
-
* @param decimals Number of decimal places for the token
|
|
33
|
-
* @returns Amount in token's smallest unit
|
|
34
|
-
*/
|
|
35
25
|
export function floatToBigint(usdValue: number, decimals: number): bigint {
|
|
36
|
-
if (!Number.isFinite(usdValue) || usdValue < 0) {
|
|
37
|
-
throw new CalculateAmountError(`Invalid USD value: ${usdValue}`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (decimals < 0 || decimals > 77) {
|
|
41
|
-
throw new CalculateAmountError(`Invalid decimals: ${decimals}`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Convert to fixed-precision string to avoid floating point issues
|
|
45
26
|
const valueString = usdValue.toFixed(decimals);
|
|
46
27
|
|
|
47
|
-
|
|
48
|
-
return parseUnits(valueString, decimals);
|
|
49
|
-
} catch (error) {
|
|
50
|
-
throw new CalculateAmountError(
|
|
51
|
-
`Failed to convert ${usdValue} to bigint with ${decimals} decimals: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
52
|
-
);
|
|
53
|
-
}
|
|
28
|
+
return parseUnits(valueString, decimals);
|
|
54
29
|
}
|
|
55
30
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Aftermath } from 'aftermath-ts-sdk';
|
|
2
|
+
|
|
3
|
+
export type AfterMathQuoteParams = {
|
|
4
|
+
amountIn: bigint;
|
|
5
|
+
tokenIn: string;
|
|
6
|
+
tokenOut: string;
|
|
7
|
+
};
|
|
8
|
+
export class AftermathQuoteProvider {
|
|
9
|
+
public async getQuote(params: AfterMathQuoteParams) {
|
|
10
|
+
const afSdk = new Aftermath('MAINNET');
|
|
11
|
+
|
|
12
|
+
await afSdk.init();
|
|
13
|
+
|
|
14
|
+
const router = afSdk.Router();
|
|
15
|
+
|
|
16
|
+
const quote = await router.getCompleteTradeRouteGivenAmountIn({
|
|
17
|
+
coinInAmount: params.amountIn,
|
|
18
|
+
coinInType: params.tokenIn,
|
|
19
|
+
coinOutType: params.tokenOut,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return quote;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { ChainID, isEvmChain, type SupportedEvmChain } from '../../chains.js';
|
|
2
|
+
import { JupiterQuoteProvider } from './jupiter.js';
|
|
3
|
+
import { type QuoteResponse as JupiterQuoteResponse } from '@jup-ag/api';
|
|
4
|
+
import { ParaswapQuoteProvider, type SwapEstimateResult } from './paraswap.js';
|
|
5
|
+
import { CROSS_CHAIN_TOKENS } from './stablecoins-tokens.js';
|
|
6
|
+
import { AftermathQuoteProvider } from './aftermath.js';
|
|
7
|
+
import type { RouterCompleteTradeRoute } from 'aftermath-ts-sdk';
|
|
8
|
+
import { calculateAmounts } from '../defillama.js';
|
|
9
|
+
import { LiquidSwapQuoteProvider, type LiquidSwapQuoteResponse } from './liquidswap.js';
|
|
10
|
+
|
|
11
|
+
type SingleChainQuoteParams = {
|
|
12
|
+
chainId: ChainID;
|
|
13
|
+
amount: bigint;
|
|
14
|
+
tokenIn: string;
|
|
15
|
+
tokenOut: string;
|
|
16
|
+
slippageBps?: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type RouteProvider = 'paraswap' | 'jupiter' | 'aftermath' | 'liquidswap';
|
|
20
|
+
|
|
21
|
+
export type Quote = {
|
|
22
|
+
amountIn: bigint;
|
|
23
|
+
amountOut: bigint;
|
|
24
|
+
amountOutUsd: number;
|
|
25
|
+
amountInUsd: number;
|
|
26
|
+
slippage: number;
|
|
27
|
+
priceImpact: number;
|
|
28
|
+
provider: RouteProvider;
|
|
29
|
+
rawQuote: any;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type QuoteParams = {
|
|
33
|
+
sourceChainId: ChainID;
|
|
34
|
+
destChainId: ChainID;
|
|
35
|
+
amount: bigint;
|
|
36
|
+
tokenIn: string;
|
|
37
|
+
tokenOut: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type QuoteResponse = {
|
|
41
|
+
amountInUsd: number;
|
|
42
|
+
estimatedAmountInAsMinStablecoinAmount: bigint;
|
|
43
|
+
|
|
44
|
+
estimatedAmountOut: bigint;
|
|
45
|
+
estimatedAmountOutUsd: number;
|
|
46
|
+
|
|
47
|
+
estimatedAmountOutReduced: bigint;
|
|
48
|
+
estimatedAmountOutUsdReduced: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export class QuoteProvider {
|
|
52
|
+
private static readonly DEFAULT_BRIDGE_TOKEN = 'USDC';
|
|
53
|
+
private static readonly DEFAULT_BRIDGE_TOKEN_DECIMALS = 6;
|
|
54
|
+
|
|
55
|
+
public static async getQuoteFromDefillama(params: QuoteParams): Promise<QuoteResponse> {
|
|
56
|
+
const defillamaQuote = await calculateAmounts({
|
|
57
|
+
amountIn: params.amount,
|
|
58
|
+
tokenIn: params.tokenIn,
|
|
59
|
+
tokenOut: params.tokenOut,
|
|
60
|
+
destChainId: params.destChainId,
|
|
61
|
+
srcChainId: params.sourceChainId,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
amountInUsd: 0,
|
|
66
|
+
estimatedAmountOutUsd: 0,
|
|
67
|
+
estimatedAmountOutUsdReduced: 0,
|
|
68
|
+
|
|
69
|
+
estimatedAmountInAsMinStablecoinAmount: defillamaQuote.minStablecoinsAmount,
|
|
70
|
+
estimatedAmountOut: defillamaQuote.amountOut,
|
|
71
|
+
estimatedAmountOutReduced: defillamaQuote.amountOut,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public static async getQuoteWithDefillamaFallback(params: QuoteParams): Promise<QuoteResponse> {
|
|
76
|
+
try {
|
|
77
|
+
const quote = await this.getQuoteFromRouters(params);
|
|
78
|
+
return quote;
|
|
79
|
+
} catch (e) {
|
|
80
|
+
const quote = await this.getQuoteFromDefillama(params);
|
|
81
|
+
return quote;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public static async getQuote(params: QuoteParams): Promise<QuoteResponse> {
|
|
86
|
+
return this.getQuoteWithDefillamaFallback(params);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private static async getQuoteFromRouters(params: QuoteParams): Promise<QuoteResponse> {
|
|
90
|
+
const bridgeTokenSymbol = QuoteProvider.DEFAULT_BRIDGE_TOKEN;
|
|
91
|
+
|
|
92
|
+
const sourceBridgeToken = CROSS_CHAIN_TOKENS[bridgeTokenSymbol]?.[params.sourceChainId]!;
|
|
93
|
+
const destBridgeToken = CROSS_CHAIN_TOKENS[bridgeTokenSymbol]?.[params.destChainId]!;
|
|
94
|
+
|
|
95
|
+
const sourceSingleChainQuoteParams: SingleChainQuoteParams = {
|
|
96
|
+
chainId: params.sourceChainId,
|
|
97
|
+
amount: params.amount,
|
|
98
|
+
tokenIn: params.tokenIn,
|
|
99
|
+
tokenOut: sourceBridgeToken,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const sourceQuote = await this.getSingleChainQuote(sourceSingleChainQuoteParams);
|
|
103
|
+
|
|
104
|
+
const destSingleChainQuoteParams: SingleChainQuoteParams = {
|
|
105
|
+
chainId: params.destChainId,
|
|
106
|
+
amount: sourceQuote.amountOut,
|
|
107
|
+
tokenIn: destBridgeToken,
|
|
108
|
+
tokenOut: params.tokenOut,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const destQuote = await this.getSingleChainQuote(destSingleChainQuoteParams);
|
|
112
|
+
|
|
113
|
+
// Use weighted reduction instead of fixed percentage
|
|
114
|
+
const weightedReductionFactor = this.calculateWeightedReductionFactorForUsd(destQuote.amountOutUsd);
|
|
115
|
+
|
|
116
|
+
const estimatedAmountOutReduced = BigInt(Math.floor(Number(destQuote.amountOut) * weightedReductionFactor));
|
|
117
|
+
const estimatedAmountOutUsdReduced = destQuote.amountOutUsd * weightedReductionFactor;
|
|
118
|
+
|
|
119
|
+
const reducedAmountInUsd = this.calculateWeightedReductionFactorForUsd(sourceQuote.amountInUsd);
|
|
120
|
+
const estimatedAmountInAsMinStablecoinAmount = BigInt(
|
|
121
|
+
Math.floor(reducedAmountInUsd * 10 ** this.DEFAULT_BRIDGE_TOKEN_DECIMALS),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
estimatedAmountOut: destQuote.amountOut,
|
|
126
|
+
estimatedAmountOutUsd: destQuote.amountOutUsd,
|
|
127
|
+
amountInUsd: sourceQuote.amountInUsd,
|
|
128
|
+
estimatedAmountInAsMinStablecoinAmount,
|
|
129
|
+
estimatedAmountOutReduced,
|
|
130
|
+
estimatedAmountOutUsdReduced,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public static async getSingleChainQuote(params: SingleChainQuoteParams): Promise<Quote> {
|
|
135
|
+
if (params.tokenIn.toLowerCase() === params.tokenOut.toLowerCase()) {
|
|
136
|
+
let amountUsd = 0;
|
|
137
|
+
|
|
138
|
+
if (params.tokenIn.toLowerCase() === CROSS_CHAIN_TOKENS.USDC![params.chainId].toLowerCase()) {
|
|
139
|
+
amountUsd = Number(params.amount) / 10 ** this.DEFAULT_BRIDGE_TOKEN_DECIMALS;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
amountIn: params.amount,
|
|
144
|
+
amountOut: params.amount,
|
|
145
|
+
amountOutUsd: amountUsd,
|
|
146
|
+
amountInUsd: amountUsd,
|
|
147
|
+
slippage: 0,
|
|
148
|
+
priceImpact: 0,
|
|
149
|
+
provider: getProviderNameByChainId(params.chainId),
|
|
150
|
+
rawQuote: null,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (params.chainId === ChainID.Hyperliquid) {
|
|
155
|
+
const liquidSwapQuote = await QuoteProvider.getLiquidSwapQuote(params);
|
|
156
|
+
return QuoteProvider.transformLiquidSwapQuote(liquidSwapQuote);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (params.chainId === ChainID.Solana) {
|
|
160
|
+
const jupiterQuote = await QuoteProvider.getJupiterQuote(params);
|
|
161
|
+
return QuoteProvider.transformJupiterQuote(jupiterQuote);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (params.chainId === ChainID.Sui) {
|
|
165
|
+
const quote = await QuoteProvider.getAftermathQuote(params);
|
|
166
|
+
return QuoteProvider.transformAftermathQuote({ quote, request: params });
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (isEvmChain(params.chainId)) {
|
|
170
|
+
const paraswapQuote = await QuoteProvider.getParaswapQuote(params);
|
|
171
|
+
return QuoteProvider.transformParaswapQuote(paraswapQuote);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
throw new Error(`Unsupported chain for quote: ${params.chainId}`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
static transformLiquidSwapQuote(liquidSwapQuote: LiquidSwapQuoteResponse): Quote {
|
|
178
|
+
return {
|
|
179
|
+
amountIn: BigInt(liquidSwapQuote.amountIn),
|
|
180
|
+
amountOut: BigInt(liquidSwapQuote.amountOut),
|
|
181
|
+
amountOutUsd: 0,
|
|
182
|
+
amountInUsd: 0,
|
|
183
|
+
slippage: 0,
|
|
184
|
+
priceImpact: Number(liquidSwapQuote.averagePriceImpact),
|
|
185
|
+
provider: 'liquidswap',
|
|
186
|
+
rawQuote: liquidSwapQuote,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Calculates the weighted reduction factor for an amount in USD.
|
|
192
|
+
* For amounts <= $5, the reduction factor is 0.65.
|
|
193
|
+
*/
|
|
194
|
+
public static calculateWeightedReductionFactorForUsd(amountUsd: number): number {
|
|
195
|
+
if (amountUsd <= 5) {
|
|
196
|
+
return 0.5;
|
|
197
|
+
} else if (amountUsd <= 10) {
|
|
198
|
+
return 0.65;
|
|
199
|
+
} else if (amountUsd <= 20) {
|
|
200
|
+
return 0.77;
|
|
201
|
+
} else if (amountUsd <= 30) {
|
|
202
|
+
return 0.9;
|
|
203
|
+
} else {
|
|
204
|
+
return 0.95;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
protected static async getLiquidSwapQuote(params: SingleChainQuoteParams) {
|
|
209
|
+
const liquidSwapQuoter = new LiquidSwapQuoteProvider();
|
|
210
|
+
|
|
211
|
+
return liquidSwapQuoter.getQuote({
|
|
212
|
+
tokenIn: params.tokenIn,
|
|
213
|
+
tokenOut: params.tokenOut,
|
|
214
|
+
amountIn: params.amount.toString(),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
protected static async getJupiterQuote(params: SingleChainQuoteParams) {
|
|
219
|
+
const jupiterQuoter = new JupiterQuoteProvider();
|
|
220
|
+
|
|
221
|
+
return jupiterQuoter.getQuote({
|
|
222
|
+
amount: params.amount,
|
|
223
|
+
tokenIn: params.tokenIn,
|
|
224
|
+
tokenOut: params.tokenOut,
|
|
225
|
+
swapMode: 'ExactIn',
|
|
226
|
+
slippageBps: params.slippageBps,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
protected static async getParaswapQuote(params: SingleChainQuoteParams) {
|
|
231
|
+
const paraswapQuoter = new ParaswapQuoteProvider(params.chainId as SupportedEvmChain);
|
|
232
|
+
|
|
233
|
+
return paraswapQuoter.getSwapEstimation({
|
|
234
|
+
amount: BigInt(params.amount),
|
|
235
|
+
srcToken: params.tokenIn,
|
|
236
|
+
destToken: params.tokenOut,
|
|
237
|
+
side: 'SELL',
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
protected static async getAftermathQuote(params: SingleChainQuoteParams) {
|
|
242
|
+
const aftermathQuoter = new AftermathQuoteProvider();
|
|
243
|
+
|
|
244
|
+
return aftermathQuoter.getQuote({
|
|
245
|
+
amountIn: params.amount,
|
|
246
|
+
tokenIn: params.tokenIn,
|
|
247
|
+
tokenOut: params.tokenOut,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
private static transformAftermathQuote({
|
|
252
|
+
quote,
|
|
253
|
+
request,
|
|
254
|
+
}: {
|
|
255
|
+
quote: RouterCompleteTradeRoute;
|
|
256
|
+
request: SingleChainQuoteParams;
|
|
257
|
+
}): Quote {
|
|
258
|
+
let amountUsd = 0;
|
|
259
|
+
|
|
260
|
+
if (request.tokenIn === CROSS_CHAIN_TOKENS.USDC![request.chainId]) {
|
|
261
|
+
amountUsd = Number(quote.coinIn.amount) / 10 ** this.DEFAULT_BRIDGE_TOKEN_DECIMALS;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (request.tokenOut === CROSS_CHAIN_TOKENS.USDC![request.chainId]) {
|
|
265
|
+
amountUsd = Number(quote.coinOut.amount) / 10 ** this.DEFAULT_BRIDGE_TOKEN_DECIMALS;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
amountIn: quote.coinIn.amount,
|
|
270
|
+
amountOut: quote.coinOut.amount,
|
|
271
|
+
amountOutUsd: amountUsd,
|
|
272
|
+
amountInUsd: amountUsd,
|
|
273
|
+
slippage: quote.slippage ?? 0,
|
|
274
|
+
priceImpact: 0,
|
|
275
|
+
provider: 'aftermath',
|
|
276
|
+
rawQuote: quote,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
private static transformParaswapQuote(paraswapQuote: SwapEstimateResult): Quote {
|
|
281
|
+
return {
|
|
282
|
+
amountIn: BigInt(paraswapQuote.amountIn),
|
|
283
|
+
amountOut: BigInt(paraswapQuote.amountOut),
|
|
284
|
+
amountOutUsd: paraswapQuote.amountOutUsd,
|
|
285
|
+
amountInUsd: paraswapQuote.amountInUsd,
|
|
286
|
+
slippage: 0, // Calculate from paraswap data if available
|
|
287
|
+
priceImpact: paraswapQuote.quote.maxImpact ? Number(paraswapQuote.quote.maxImpact) * 100 : 0,
|
|
288
|
+
provider: 'paraswap',
|
|
289
|
+
rawQuote: paraswapQuote,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private static transformJupiterQuote({ quote }: { quote: JupiterQuoteResponse }): Quote {
|
|
294
|
+
const amountIn = Number(quote.inAmount);
|
|
295
|
+
const amountOut = Number(quote.outAmount);
|
|
296
|
+
let amountUsd = 0;
|
|
297
|
+
const priceImpact = quote.priceImpactPct ? Number(quote.priceImpactPct) * 100 : 0;
|
|
298
|
+
|
|
299
|
+
if (quote.outputMint === CROSS_CHAIN_TOKENS.USDC![ChainID.Solana]) {
|
|
300
|
+
amountUsd = amountOut / 10 ** this.DEFAULT_BRIDGE_TOKEN_DECIMALS;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (quote.inputMint === CROSS_CHAIN_TOKENS.USDC![ChainID.Solana]) {
|
|
304
|
+
amountUsd = amountIn / 10 ** this.DEFAULT_BRIDGE_TOKEN_DECIMALS;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return {
|
|
308
|
+
amountIn: BigInt(amountIn),
|
|
309
|
+
amountOut: BigInt(amountOut),
|
|
310
|
+
amountOutUsd: amountUsd,
|
|
311
|
+
amountInUsd: amountUsd,
|
|
312
|
+
slippage: quote.slippageBps ? quote.slippageBps / 100 : 0,
|
|
313
|
+
priceImpact,
|
|
314
|
+
provider: 'jupiter',
|
|
315
|
+
rawQuote: quote,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function getProviderNameByChainId(chainId: ChainID): RouteProvider {
|
|
321
|
+
switch (chainId) {
|
|
322
|
+
case ChainID.Sui:
|
|
323
|
+
return 'aftermath';
|
|
324
|
+
case ChainID.Solana:
|
|
325
|
+
return 'jupiter';
|
|
326
|
+
case ChainID.Hyperliquid:
|
|
327
|
+
return 'liquidswap';
|
|
328
|
+
default:
|
|
329
|
+
return 'paraswap';
|
|
330
|
+
}
|
|
331
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createJupiterApiClient, SwapApi, type QuoteResponse } from '@jup-ag/api';
|
|
2
|
+
|
|
3
|
+
export type JupiterQuoteParams = {
|
|
4
|
+
amount: bigint;
|
|
5
|
+
tokenIn: string;
|
|
6
|
+
tokenOut: string;
|
|
7
|
+
swapMode: 'ExactIn' | 'ExactOut';
|
|
8
|
+
slippageBps?: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const NATIVE_SOL = 'So11111111111111111111111111111111111111111';
|
|
12
|
+
const WRAPPED_SOL = 'So11111111111111111111111111111111111111112';
|
|
13
|
+
export class JupiterQuoteProvider {
|
|
14
|
+
public swapApi: SwapApi;
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
this.swapApi = createJupiterApiClient({ fetchApi: fetch });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async getQuote(params: JupiterQuoteParams): Promise<{ quote: QuoteResponse }> {
|
|
21
|
+
if (params.tokenIn === NATIVE_SOL) {
|
|
22
|
+
params.tokenIn = WRAPPED_SOL;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (params.tokenOut === NATIVE_SOL) {
|
|
26
|
+
params.tokenOut = WRAPPED_SOL;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const quote = await this.swapApi.quoteGet({
|
|
30
|
+
amount: Number(params.amount),
|
|
31
|
+
inputMint: params.tokenIn,
|
|
32
|
+
outputMint: params.tokenOut,
|
|
33
|
+
swapMode: params.swapMode,
|
|
34
|
+
slippageBps: params.slippageBps,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return { quote };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ChainID } from '../../chains.js';
|
|
2
|
+
import { isNativeEvmToken, WRAPPED_ETH_ADDRESSES } from '../../constants.js';
|
|
3
|
+
|
|
4
|
+
type LiquidSwapQuoteParams = {
|
|
5
|
+
tokenIn: string;
|
|
6
|
+
tokenOut: string;
|
|
7
|
+
amountIn: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type LiquidSwapQuoteResponse = {
|
|
11
|
+
success: boolean;
|
|
12
|
+
amountIn: string;
|
|
13
|
+
amountOut: string;
|
|
14
|
+
averagePriceImpact: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const LIQUID_SWAP_API_URL = 'https://api.liqd.ag';
|
|
18
|
+
|
|
19
|
+
export class LiquidSwapQuoteProvider {
|
|
20
|
+
public async getQuote(liquidSwapParams: LiquidSwapQuoteParams): Promise<LiquidSwapQuoteResponse> {
|
|
21
|
+
const params = {...liquidSwapParams};
|
|
22
|
+
|
|
23
|
+
if (isNativeEvmToken(params.tokenOut)) {
|
|
24
|
+
params.tokenOut = WRAPPED_ETH_ADDRESSES[ChainID.Hyperliquid];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (isNativeEvmToken(params.tokenIn)) {
|
|
28
|
+
params.tokenIn = WRAPPED_ETH_ADDRESSES[ChainID.Hyperliquid];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const url = `${LIQUID_SWAP_API_URL}/v2/route?tokenIn=${params.tokenIn}&tokenOut=${params.tokenOut}&amountIn=${params.amountIn}`;
|
|
32
|
+
const response = await fetch(url);
|
|
33
|
+
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw new Error('Failed to fetch quote from LiquidSwap API');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const data: LiquidSwapQuoteResponse = await response.json();
|
|
39
|
+
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { constructSimpleSDK, type OptimalRate } from '@paraswap/sdk';
|
|
2
|
+
import { ChainID, type SupportedEvmChain } from '../../chains.js';
|
|
3
|
+
import { ChainProvider } from '../../core/evm/chain-provider.js';
|
|
4
|
+
import { getContract, type Address } from 'viem';
|
|
5
|
+
import { ERC20ABI } from '../../core/evm/abi/erc20.js';
|
|
6
|
+
import { isNativeEvmToken, WRAPPED_ETH_ADDRESSES } from '../../constants.js';
|
|
7
|
+
|
|
8
|
+
const rpcProvidersUrl: Record<SupportedEvmChain, string> = {
|
|
9
|
+
[ChainID.Arbitrum]: 'https://arbitrum-one-rpc.publicnode.com',
|
|
10
|
+
[ChainID.Optimism]: 'https://optimism-rpc.publicnode.com',
|
|
11
|
+
[ChainID.Base]: 'https://base-rpc.publicnode.com',
|
|
12
|
+
[ChainID.Hyperliquid]: 'https://rpc.hyperliquid.xyz/evm',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type ParaswapQuoteRequestParams = {
|
|
16
|
+
srcToken: string;
|
|
17
|
+
destToken: string;
|
|
18
|
+
amount: bigint;
|
|
19
|
+
side: 'SELL' | 'BUY';
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type SwapEstimateResult = {
|
|
23
|
+
amountOut: bigint;
|
|
24
|
+
amountIn: bigint;
|
|
25
|
+
amountOutUsd: number;
|
|
26
|
+
amountInUsd: number;
|
|
27
|
+
quote: OptimalRate;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export class ParaswapQuoteProvider {
|
|
31
|
+
protected chainId: SupportedEvmChain;
|
|
32
|
+
|
|
33
|
+
constructor(chainId: SupportedEvmChain) {
|
|
34
|
+
this.chainId = chainId;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private async getTokenDecimals(tokenAddress: Address): Promise<number> {
|
|
38
|
+
const rpcUrl = rpcProvidersUrl[this.chainId];
|
|
39
|
+
const client = ChainProvider.getClient(this.chainId, rpcUrl);
|
|
40
|
+
const erc20Contract = getContract({
|
|
41
|
+
abi: ERC20ABI,
|
|
42
|
+
address: tokenAddress,
|
|
43
|
+
client,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return erc20Contract.read.decimals();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private async getQuote(paraswapParams: ParaswapQuoteRequestParams): Promise<OptimalRate> {
|
|
50
|
+
const params = { ...paraswapParams };
|
|
51
|
+
if (isNativeEvmToken(params.destToken)) {
|
|
52
|
+
params.destToken = WRAPPED_ETH_ADDRESSES[this.chainId];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const [srcTokenDecimals, destTokenDecimals] = await Promise.all([
|
|
56
|
+
this.getTokenDecimals(params.srcToken as Address),
|
|
57
|
+
this.getTokenDecimals(params.destToken as Address),
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
const sdk = constructSimpleSDK({ chainId: this.chainId, fetch: fetch });
|
|
61
|
+
return sdk.swap.getRate({
|
|
62
|
+
amount: params.amount.toString(),
|
|
63
|
+
destDecimals: destTokenDecimals,
|
|
64
|
+
destToken: params.destToken,
|
|
65
|
+
side: params.side,
|
|
66
|
+
srcDecimals: srcTokenDecimals,
|
|
67
|
+
srcToken: params.srcToken,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public async getSwapEstimation(params: ParaswapQuoteRequestParams): Promise<SwapEstimateResult> {
|
|
72
|
+
const optimalRate = await this.getQuote(params);
|
|
73
|
+
const amountOut = optimalRate.destAmount;
|
|
74
|
+
const amountIn = optimalRate.srcAmount;
|
|
75
|
+
|
|
76
|
+
const amountOutUsd = optimalRate.destUSD ?? 0;
|
|
77
|
+
const amountInUsd = optimalRate.srcUSD ?? 0;
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
amountIn: BigInt(amountIn),
|
|
81
|
+
amountOut: BigInt(amountOut),
|
|
82
|
+
amountOutUsd: Number(amountOutUsd),
|
|
83
|
+
amountInUsd: Number(amountInUsd),
|
|
84
|
+
quote: optimalRate,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ChainID } from '../../chains.js';
|
|
2
|
+
|
|
3
|
+
export type QuoteParams = {
|
|
4
|
+
sourceChainId: ChainID;
|
|
5
|
+
destChainId: ChainID;
|
|
6
|
+
amount: number;
|
|
7
|
+
tokenIn: string;
|
|
8
|
+
tokenOut: string;
|
|
9
|
+
slippageBps?: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const CROSS_CHAIN_TOKENS: Record<string, Record<ChainID, string>> = {
|
|
13
|
+
USDC: {
|
|
14
|
+
[ChainID.Solana]: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC on Solana
|
|
15
|
+
[ChainID.Base]: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC on Base
|
|
16
|
+
[ChainID.Arbitrum]: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // USDC on Arbitrum
|
|
17
|
+
[ChainID.Hyperliquid]: '0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb', // USDT on Hyperliquid (No USDC on Hyperliquid)
|
|
18
|
+
[ChainID.Sui]: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC', // USDC on Sui
|
|
19
|
+
[ChainID.Optimism]: '0x7F5c764cBc14f9669B88837ca1490cCa17c31607', // USDC on Optimism
|
|
20
|
+
},
|
|
21
|
+
// Add more tokens as needed
|
|
22
|
+
};
|