@shogun-sdk/intents-sdk 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/constants.js +24 -8
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/core/evm/intent-provider.js +55 -2
- package/dist/esm/core/evm/intent-provider.js.map +1 -1
- package/dist/esm/core/evm/order-signature.js +12 -1
- package/dist/esm/core/evm/order-signature.js.map +1 -1
- package/dist/esm/core/evm/permit2.js +24 -1
- package/dist/esm/core/evm/permit2.js.map +1 -1
- package/dist/esm/core/evm/sdk.js +9 -4
- package/dist/esm/core/evm/sdk.js.map +1 -1
- package/dist/esm/core/evm/validator.js +21 -0
- package/dist/esm/core/evm/validator.js.map +1 -1
- package/dist/esm/core/orders/cross-chain.js +4 -1
- package/dist/esm/core/orders/cross-chain.js.map +1 -1
- package/dist/esm/core/orders/dca-single-chain.js +169 -0
- package/dist/esm/core/orders/dca-single-chain.js.map +1 -0
- package/dist/esm/core/orders/single-chain.js +6 -1
- package/dist/esm/core/orders/single-chain.js.map +1 -1
- package/dist/esm/core/sdk.js +55 -81
- package/dist/esm/core/sdk.js.map +1 -1
- package/dist/esm/core/solana/dca/cancel-order.js +61 -0
- package/dist/esm/core/solana/dca/cancel-order.js.map +1 -0
- package/dist/esm/core/solana/dca/create-order.js +82 -0
- package/dist/esm/core/solana/dca/create-order.js.map +1 -0
- package/dist/esm/core/solana/generated/cross-chain/errors/sourceChainGuard.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/cancelOrder.js +5 -20
- package/dist/esm/core/solana/generated/cross-chain/instructions/cancelOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/claimTokens.js +4 -16
- package/dist/esm/core/solana/generated/cross-chain/instructions/claimTokens.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/collectProtocolFees.js +4 -16
- package/dist/esm/core/solana/generated/cross-chain/instructions/collectProtocolFees.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/createGuard.js +14 -56
- package/dist/esm/core/solana/generated/cross-chain/instructions/createGuard.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/createOrder.js +6 -24
- package/dist/esm/core/solana/generated/cross-chain/instructions/createOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/preStartOrderExecution.js +4 -16
- package/dist/esm/core/solana/generated/cross-chain/instructions/preStartOrderExecution.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/setAdmin.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/setAuctioneerPubKey.js +1 -4
- package/dist/esm/core/solana/generated/cross-chain/instructions/setAuctioneerPubKey.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/startOrderExecution.js +2 -8
- package/dist/esm/core/solana/generated/cross-chain/instructions/startOrderExecution.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/instructions/startOrderExecutionAfterSwap.js +3 -12
- package/dist/esm/core/solana/generated/cross-chain/instructions/startOrderExecutionAfterSwap.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/shared/index.js +2 -5
- package/dist/esm/core/solana/generated/cross-chain/shared/index.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/types/auctioneerPubkeyUpdated.js.map +1 -1
- package/dist/esm/core/solana/generated/cross-chain/types/tokenInSwapped.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/errors/singleChainGuard.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelDcaOrder.js +2 -8
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelDcaOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelLimitOrder.js +2 -8
- package/dist/esm/core/solana/generated/single-chain/instructions/cancelLimitOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/collectProtocolFees.js +6 -24
- package/dist/esm/core/solana/generated/single-chain/instructions/collectProtocolFees.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/createDcaOrder.js +6 -24
- package/dist/esm/core/solana/generated/single-chain/instructions/createDcaOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/createGuard.js +4 -16
- package/dist/esm/core/solana/generated/single-chain/instructions/createGuard.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/createLimitOrder.js +6 -24
- package/dist/esm/core/solana/generated/single-chain/instructions/createLimitOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.js +9 -36
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillLimitOrder.js +8 -32
- package/dist/esm/core/solana/generated/single-chain/instructions/fulfillLimitOrder.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/setAdmin.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.js +1 -4
- package/dist/esm/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/shared/index.js +2 -5
- package/dist/esm/core/solana/generated/single-chain/shared/index.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/types/auctioneerPubkeyUpdated.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/types/guardCreated.js.map +1 -1
- package/dist/esm/core/solana/generated/single-chain/types/limitOrderFulfilled.js.map +1 -1
- package/dist/esm/core/solana/inspect.js +43 -0
- package/dist/esm/core/solana/inspect.js.map +1 -0
- package/dist/esm/core/solana/sdk.js +36 -0
- package/dist/esm/core/solana/sdk.js.map +1 -1
- package/dist/esm/core/solana/utils.js.map +1 -1
- package/dist/esm/core/solana/validator.js +3 -0
- package/dist/esm/core/solana/validator.js.map +1 -1
- package/dist/esm/core/sui/sdk.js +0 -3
- package/dist/esm/core/sui/sdk.js.map +1 -1
- package/dist/esm/core/sui/validator.js +4 -0
- package/dist/esm/core/sui/validator.js.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/base-validator.js +28 -0
- package/dist/esm/utils/base-validator.js.map +1 -1
- package/dist/esm/utils/order-validator.js +31 -0
- package/dist/esm/utils/order-validator.js.map +1 -1
- package/dist/esm/utils/quote/aggregator.js +2 -2
- package/dist/esm/utils/quote/aggregator.js.map +1 -1
- package/dist/esm/utils/quote/liquidswap.js.map +1 -1
- package/dist/types/constants.d.ts +10 -7
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/core/evm/intent-provider.d.ts +5 -2
- package/dist/types/core/evm/intent-provider.d.ts.map +1 -1
- package/dist/types/core/evm/order-signature.d.ts +5 -0
- package/dist/types/core/evm/order-signature.d.ts.map +1 -1
- package/dist/types/core/evm/permit2.d.ts +90 -0
- package/dist/types/core/evm/permit2.d.ts.map +1 -1
- package/dist/types/core/evm/sdk.d.ts +3 -1
- package/dist/types/core/evm/sdk.d.ts.map +1 -1
- package/dist/types/core/evm/validator.d.ts +4 -0
- package/dist/types/core/evm/validator.d.ts.map +1 -1
- package/dist/types/core/orders/cross-chain.d.ts.map +1 -1
- package/dist/types/core/orders/dca-single-chain.d.ts +47 -0
- package/dist/types/core/orders/dca-single-chain.d.ts.map +1 -0
- package/dist/types/core/orders/single-chain.d.ts.map +1 -1
- package/dist/types/core/sdk.d.ts +15 -10
- package/dist/types/core/sdk.d.ts.map +1 -1
- package/dist/types/core/solana/dca/cancel-order.d.ts +5 -0
- package/dist/types/core/solana/dca/cancel-order.d.ts.map +1 -0
- package/dist/types/core/solana/dca/create-order.d.ts +8 -0
- package/dist/types/core/solana/dca/create-order.d.ts.map +1 -0
- package/dist/types/core/solana/generated/cross-chain/errors/sourceChainGuard.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/acceptAdmin.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/acceptAdmin.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/cancelOrder.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/cancelOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/claimTokens.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/claimTokens.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/collectProtocolFees.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/collectProtocolFees.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/createGuard.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/createOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/initialize.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/initialize.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/preStartOrderExecution.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/preStartOrderExecution.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/setAdmin.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/setAuctioneerPubKey.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/startOrderExecution.d.ts +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/startOrderExecution.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/instructions/startOrderExecutionAfterSwap.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/shared/index.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/types/auctioneerPubkeyUpdated.d.ts.map +1 -1
- package/dist/types/core/solana/generated/cross-chain/types/tokenInSwapped.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/errors/singleChainGuard.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/acceptAdmin.d.ts +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/acceptAdmin.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/cancelDcaOrder.d.ts +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/cancelDcaOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/cancelLimitOrder.d.ts +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/cancelLimitOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/collectProtocolFees.d.ts +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/collectProtocolFees.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/createDcaOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/createGuard.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/createLimitOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/fulfillLimitOrder.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/initialize.d.ts +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/initialize.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/setAdmin.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/shared/index.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/types/auctioneerPubkeyUpdated.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/types/guardCreated.d.ts.map +1 -1
- package/dist/types/core/solana/generated/single-chain/types/limitOrderFulfilled.d.ts.map +1 -1
- package/dist/types/core/solana/inspect.d.ts +14 -0
- package/dist/types/core/solana/inspect.d.ts.map +1 -0
- package/dist/types/core/solana/sdk.d.ts +4 -1
- package/dist/types/core/solana/sdk.d.ts.map +1 -1
- package/dist/types/core/solana/utils.d.ts +2 -1
- package/dist/types/core/solana/utils.d.ts.map +1 -1
- package/dist/types/core/solana/validator.d.ts +1 -0
- package/dist/types/core/solana/validator.d.ts.map +1 -1
- package/dist/types/core/sui/sdk.d.ts +1 -2
- package/dist/types/core/sui/sdk.d.ts.map +1 -1
- package/dist/types/core/sui/validator.d.ts +1 -0
- package/dist/types/core/sui/validator.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/intent.d.ts +22 -0
- package/dist/types/types/intent.d.ts.map +1 -1
- package/dist/types/utils/base-validator.d.ts +7 -0
- package/dist/types/utils/base-validator.d.ts.map +1 -1
- package/dist/types/utils/order-validator.d.ts +15 -0
- package/dist/types/utils/order-validator.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/auth/siwe.ts +1 -1
- package/src/constants.ts +72 -39
- package/src/core/evm/connectors/hyperevm.ts +1 -1
- package/src/core/evm/intent-provider.ts +88 -4
- package/src/core/evm/order-signature.ts +23 -1
- package/src/core/evm/permit2.ts +47 -1
- package/src/core/evm/sdk.ts +20 -7
- package/src/core/evm/validator.ts +32 -0
- package/src/core/orders/api/fetch.ts +0 -1
- package/src/core/orders/api/index.ts +4 -4
- package/src/core/orders/cross-chain.ts +5 -1
- package/src/core/orders/dca-single-chain.ts +143 -0
- package/src/core/orders/single-chain.ts +8 -1
- package/src/core/sdk.ts +72 -100
- package/src/core/solana/cancel-order.ts +1 -1
- package/src/core/solana/dca/cancel-order.ts +91 -0
- package/src/core/solana/dca/create-order.ts +142 -0
- package/src/core/solana/generated/cross-chain/errors/sourceChainGuard.ts +1 -3
- package/src/core/solana/generated/cross-chain/instructions/acceptAdmin.ts +1 -1
- package/src/core/solana/generated/cross-chain/instructions/cancelOrder.ts +6 -21
- package/src/core/solana/generated/cross-chain/instructions/claimTokens.ts +5 -17
- package/src/core/solana/generated/cross-chain/instructions/collectProtocolFees.ts +6 -20
- package/src/core/solana/generated/cross-chain/instructions/createGuard.ts +14 -56
- package/src/core/solana/generated/cross-chain/instructions/createOrder.ts +6 -24
- package/src/core/solana/generated/cross-chain/instructions/initialize.ts +1 -1
- package/src/core/solana/generated/cross-chain/instructions/preStartOrderExecution.ts +6 -20
- package/src/core/solana/generated/cross-chain/instructions/setAdmin.ts +1 -4
- package/src/core/solana/generated/cross-chain/instructions/setAuctioneerPubKey.ts +2 -7
- package/src/core/solana/generated/cross-chain/instructions/startOrderExecution.ts +4 -12
- package/src/core/solana/generated/cross-chain/instructions/startOrderExecutionAfterSwap.ts +3 -12
- package/src/core/solana/generated/cross-chain/shared/index.ts +2 -5
- package/src/core/solana/generated/cross-chain/types/auctioneerPubkeyUpdated.ts +1 -4
- package/src/core/solana/generated/cross-chain/types/tokenInSwapped.ts +1 -5
- package/src/core/solana/generated/single-chain/errors/singleChainGuard.ts +1 -3
- package/src/core/solana/generated/single-chain/instructions/acceptAdmin.ts +1 -1
- package/src/core/solana/generated/single-chain/instructions/cancelDcaOrder.ts +4 -12
- package/src/core/solana/generated/single-chain/instructions/cancelLimitOrder.ts +4 -12
- package/src/core/solana/generated/single-chain/instructions/collectProtocolFees.ts +8 -28
- package/src/core/solana/generated/single-chain/instructions/createDcaOrder.ts +6 -24
- package/src/core/solana/generated/single-chain/instructions/createGuard.ts +5 -20
- package/src/core/solana/generated/single-chain/instructions/createLimitOrder.ts +6 -24
- package/src/core/solana/generated/single-chain/instructions/fulfillDcaOrderInterval.ts +9 -36
- package/src/core/solana/generated/single-chain/instructions/fulfillLimitOrder.ts +8 -32
- package/src/core/solana/generated/single-chain/instructions/initialize.ts +1 -1
- package/src/core/solana/generated/single-chain/instructions/setAdmin.ts +1 -4
- package/src/core/solana/generated/single-chain/instructions/setAuctioneerPubKey.ts +2 -7
- package/src/core/solana/generated/single-chain/shared/index.ts +2 -5
- package/src/core/solana/generated/single-chain/types/auctioneerPubkeyUpdated.ts +1 -4
- package/src/core/solana/generated/single-chain/types/guardCreated.ts +1 -5
- package/src/core/solana/generated/single-chain/types/limitOrderFulfilled.ts +1 -4
- package/src/core/solana/inspect.ts +50 -0
- package/src/core/solana/order-instructions.ts +1 -1
- package/src/core/solana/sdk.ts +65 -2
- package/src/core/solana/utils.ts +2 -1
- package/src/core/solana/validator.ts +4 -0
- package/src/core/sui/sdk.ts +2 -6
- package/src/core/sui/validator.ts +5 -0
- package/src/index.ts +12 -1
- package/src/types/api.ts +1 -1
- package/src/types/intent.ts +27 -0
- package/src/utils/base-validator.ts +40 -0
- package/src/utils/order-validator.ts +38 -0
- package/src/utils/quote/aggregator.ts +2 -2
- package/src/utils/quote/liquidswap.ts +2 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -12,11 +12,13 @@ export { fetchUserOrders } from './core/orders/api/fetch.js';
|
|
|
12
12
|
export { AuctioneerAPI } from './core/orders/api/index.js';
|
|
13
13
|
export { type FetchJWTParams, type FetchSiweMessageParams, fetchJWTToken, fetchSiweMessage } from './auth/siwe.js';
|
|
14
14
|
export { ValidationError } from './errors/index.js';
|
|
15
|
-
export { type ApiCrossChainOrder, type ApiResponse, type ApiSingleChainOrder, type ApiUserOrders, type ChainOrderStatus, isErrorApiResponse, isSuccessApiResponse } from './types/api.js';
|
|
15
|
+
export { type ApiCrossChainOrder, type ApiResponse, type ApiSingleChainOrder, type ApiUserOrders, type ChainOrderStatus, isErrorApiResponse, isSuccessApiResponse, } from './types/api.js';
|
|
16
16
|
export { calculateAmounts, getCoinFromResponse, getTokensData } from './utils/defillama.js';
|
|
17
17
|
export type { DefiLlamaCoinData, DefiLlamaTokensResponse } from './utils/defillama.js';
|
|
18
18
|
export { getCancelCrossChainOrderRawData, getCancelSingleChainOrderRawData, type CancelSingleChainOrderParams, type CancelCrossChainOrderParams, getInvalidateNoncesRawData, } from './core/evm/cancel-order.js';
|
|
19
|
+
export { cancelDcaSingleChainOrderInstructions } from './core/solana/dca/cancel-order.js';
|
|
19
20
|
export { getEVMCrossChainOrderTypedData, getEVMSingleChainOrderTypedData } from './core/evm/order-signature.js';
|
|
21
|
+
export { getSolanaOrdersWithLockedFunds } from './core/solana/inspect.js';
|
|
20
22
|
export { getSolanaCrossChainOrderInstructions, getSolanaSingleChainOrderInstructions, } from './core/solana/order-instructions.js';
|
|
21
23
|
export { cancelCrossChainOrderInstructionsAsBytes, cancelSingleChainOrderInstructionsAsBytes, } from './core/solana/cancel-order.js';
|
|
22
24
|
export { getSuiOrderTransaction } from './core/sui/order-transaction.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACvH,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAErE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,YAAY,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,YAAY,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAElF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,sBAAsB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACnH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,
|
|
1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M,sBAAsB,CAAC;AACvF,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qCAAqC,EAAE,MAAM,mCAAmC,CAAC;AAC1F,OAAO,EAAE,8BAA8B,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAEhH,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAE1E,OAAO,EACL,oCAAoC,EACpC,qCAAqC,GACtC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,wCAAwC,EACxC,yCAAyC,GAC1C,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -2,6 +2,7 @@ import type { SupportedChain } from '../chains.js';
|
|
|
2
2
|
import type { CrossChainOrder } from '../core/orders/cross-chain.js';
|
|
3
3
|
import type { ExtraTransfer } from '../core/orders/common.js';
|
|
4
4
|
import type { SingleChainOrder } from '../core/orders/single-chain.js';
|
|
5
|
+
import type { DcaSingleChainOrder } from '../core/orders/dca-single-chain.js';
|
|
5
6
|
/**
|
|
6
7
|
* Details required to execute the order on the destination chain
|
|
7
8
|
* Contains all information needed for the cross-chain fulfillment
|
|
@@ -102,4 +103,25 @@ export type SingleChainOrderPrepared = {
|
|
|
102
103
|
order: SingleChainOrder;
|
|
103
104
|
preparedData: SingleChainPreparedData;
|
|
104
105
|
};
|
|
106
|
+
export type DcaSingleChainUserIntentRequest = {
|
|
107
|
+
genericData: DcaSingleChainOrder;
|
|
108
|
+
chainSpecificData: {
|
|
109
|
+
EVM?: DcaSingleChainEVMPreparedData;
|
|
110
|
+
Solana?: DcaSingleChainSolanaPreparedData;
|
|
111
|
+
Sui?: never;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
export type DcaSingleChainEVMPreparedData = {
|
|
115
|
+
nonce: string;
|
|
116
|
+
signature: string | Hash;
|
|
117
|
+
};
|
|
118
|
+
export type DcaSingleChainSolanaPreparedData = {
|
|
119
|
+
secretNumber: string;
|
|
120
|
+
orderPubkey: string;
|
|
121
|
+
};
|
|
122
|
+
export type DcaSingleChainPreparedData = DcaSingleChainEVMPreparedData | DcaSingleChainSolanaPreparedData;
|
|
123
|
+
export type DcaSingleChainOrderPrepared = {
|
|
124
|
+
order: DcaSingleChainOrder;
|
|
125
|
+
preparedData: DcaSingleChainPreparedData;
|
|
126
|
+
};
|
|
105
127
|
//# sourceMappingURL=intent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../../../src/types/intent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../../../src/types/intent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAg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;IACrC,KAAK,EAAE,gBAAgB,CAAC;IACxB,YAAY,EAAE,uBAAuB,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,WAAW,EAAE,mBAAmB,CAAC;IACjC,iBAAiB,EAAE;QACjB,GAAG,CAAC,EAAE,6BAA6B,CAAC;QACpC,MAAM,CAAC,EAAE,gCAAgC,CAAC;QAC1C,GAAG,CAAC,EAAE,KAAK,CAAC;KACb,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,6BAA6B,GAAG,gCAAgC,CAAC;AAE1G,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,YAAY,EAAE,0BAA0B,CAAC;CAC1C,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CreateCrossChainOrderParams } from '../core/orders/cross-chain.js';
|
|
2
|
+
import type { CreateDcaSingleChainOrderParams } from '../core/orders/dca-single-chain.js';
|
|
2
3
|
import type { CreateSingleChainOrderParams } from '../core/orders/single-chain.js';
|
|
3
4
|
import type { IChainValidator } from './order-validator.js';
|
|
4
5
|
/**
|
|
@@ -29,6 +30,12 @@ export declare abstract class BaseValidator implements IChainValidator {
|
|
|
29
30
|
* Validate destination chain specific parameters of the order
|
|
30
31
|
*/
|
|
31
32
|
validateDestinationChain(order: CreateCrossChainOrderParams): void;
|
|
33
|
+
abstract validateDcaSingleChainOrderFeasability(order: CreateDcaSingleChainOrderParams & {
|
|
34
|
+
user: string;
|
|
35
|
+
}): Promise<void>;
|
|
36
|
+
validateDcaSingleChainOrder(order: CreateDcaSingleChainOrderParams & {
|
|
37
|
+
user: string;
|
|
38
|
+
}): Promise<void>;
|
|
32
39
|
/**
|
|
33
40
|
* Helper methods that throw specific validation errors
|
|
34
41
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-validator.d.ts","sourceRoot":"","sources":["../../../src/utils/base-validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAEnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;;GAGG;AACH,8BAAsB,aAAc,YAAW,eAAe;IAC5D,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IACjD,QAAQ,CAAC,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAC3D,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAC/C,SAAS,CAAC,QAAQ,CAAC,YAAY,IAAI,MAAM;IACzC,QAAQ,CAAC,kCAAkC,CAAC,KAAK,EAAE,2BAA2B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IACjH,QAAQ,CAAC,mCAAmC,CAAC,KAAK,EAAE,4BAA4B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAEnH;;OAEG;IACG,mBAAmB,CAAC,KAAK,EAAE,2BAA2B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzF,wBAAwB,CAAC,KAAK,EAAE,4BAA4B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBrG;;OAEG;IACH,wBAAwB,CAAC,KAAK,EAAE,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AC,KAAK,EAAE,4BAA4B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBrG;;OAEG;IACH,wBAAwB,CAAC,KAAK,EAAE,2BAA2B,GAAG,IAAI;IAclE,QAAQ,CAAC,sCAAsC,CAC7C,KAAK,EAAE,+BAA+B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GACxD,OAAO,CAAC,IAAI,CAAC;IAEV,2BAA2B,CAAC,KAAK,EAAE,+BAA+B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmC3G;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMhD,SAAS,CAAC,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAM1D,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAK/C"}
|
|
@@ -21,6 +21,9 @@ export interface IChainValidator extends IAddressValidator, ITokenValidator, IAm
|
|
|
21
21
|
validateSingleChainOrder(order: CreateSingleChainOrderParams & {
|
|
22
22
|
user: string;
|
|
23
23
|
}): Promise<void>;
|
|
24
|
+
validateDcaSingleChainOrder(order: CreateDcaSingleChainOrderParams & {
|
|
25
|
+
user: string;
|
|
26
|
+
}): Promise<void>;
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* CommonValidator - Handles validations shared across chains
|
|
@@ -46,4 +49,16 @@ export declare class SingleChainOrderValidator {
|
|
|
46
49
|
user: string;
|
|
47
50
|
}): Promise<void>;
|
|
48
51
|
}
|
|
52
|
+
import type { CreateDcaSingleChainOrderParams } from '../core/orders/dca-single-chain.js';
|
|
53
|
+
export interface IDcaValidator {
|
|
54
|
+
validateDcaSingleChainOrder(order: CreateDcaSingleChainOrderParams & {
|
|
55
|
+
user: string;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
export declare class DcaSingleChainOrderValidator {
|
|
59
|
+
private readonly commonValidator;
|
|
60
|
+
validateOrder(order: CreateDcaSingleChainOrderParams & {
|
|
61
|
+
user: string;
|
|
62
|
+
}): Promise<void>;
|
|
63
|
+
}
|
|
49
64
|
//# sourceMappingURL=order-validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-validator.d.ts","sourceRoot":"","sources":["../../../src/utils/order-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAErF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAKnF,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1C;AAED,MAAM,WAAW,eAAe;IAC9B,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;CACpD;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CACxC;AAED,MAAM,WAAW,kBAAkB;IACjC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5C;AAED,MAAM,WAAW,eAAgB,SAAQ,iBAAiB,EAAE,eAAe,EAAE,gBAAgB;IAC3F,mBAAmB,CAAC,KAAK,EAAE,2BAA2B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1F,wBAAwB,CAAC,KAAK,EAAE,2BAA2B,GAAG,IAAI,CAAC;IACnE,wBAAwB,CAAC,KAAK,EAAE,4BAA4B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"order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I;CAKzC;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,UAAU,CAA8C;IAEvE,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,eAAe;IAoB1D,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,eAAe;CAItE;AAED,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IAEnD,aAAa,CAAC,KAAK,EAAE,2BAA2B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAW1F;AAED,qBAAa,yBAAyB;IACpC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IAEnD,aAAa,CAAC,KAAK,EAAE,4BAA4B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAO3F;AAED,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,oCAAoC,CAAC;AAE1F,MAAM,WAAW,aAAa;IAC5B,2BAA2B,CAAC,KAAK,EAAE,+BAA+B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvG;AAED,qBAAa,4BAA4B;IACvC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IAEnD,aAAa,CAAC,KAAK,EAAE,+BAA+B,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CA0B9F"}
|
package/package.json
CHANGED
package/src/auth/siwe.ts
CHANGED
package/src/constants.ts
CHANGED
|
@@ -1,69 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Address
|
|
1
|
+
import { type Address as SolanaAddress } from '@solana/kit';
|
|
2
|
+
import type { Address as EvmAddress } from 'viem';
|
|
3
3
|
import type { SupportedChain, SupportedEvmChain, SupportedSuiChain } from './chains.js';
|
|
4
4
|
import { ChainID } from './chains.js';
|
|
5
5
|
|
|
6
|
-
const useProdConfig =
|
|
6
|
+
const useProdConfig = false;
|
|
7
7
|
|
|
8
8
|
export enum OrderType {
|
|
9
9
|
CROSS_CHAIN_LIMIT = 'CROSS_CHAIN_LIMIT',
|
|
10
10
|
SINGLE_CHAIN_LIMIT = 'SINGLE_CHAIN_LIMIT',
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const PERMIT2_ADDRESS: Record<SupportedEvmChain,
|
|
14
|
-
[ChainID.Arbitrum]: '0x000000000022d473030f116ddee9f6b43ac78ba3' as
|
|
15
|
-
[ChainID.Optimism]: '0x000000000022d473030f116ddee9f6b43ac78ba3' as
|
|
16
|
-
[ChainID.Base]: '0x000000000022d473030f116ddee9f6b43ac78ba3' as
|
|
17
|
-
[ChainID.Hyperliquid]: '0x000000000022d473030f116ddee9f6b43ac78ba3' as
|
|
13
|
+
export const PERMIT2_ADDRESS: Record<SupportedEvmChain, EvmAddress> = {
|
|
14
|
+
[ChainID.Arbitrum]: '0x000000000022d473030f116ddee9f6b43ac78ba3' as EvmAddress,
|
|
15
|
+
[ChainID.Optimism]: '0x000000000022d473030f116ddee9f6b43ac78ba3' as EvmAddress,
|
|
16
|
+
[ChainID.Base]: '0x000000000022d473030f116ddee9f6b43ac78ba3' as EvmAddress,
|
|
17
|
+
[ChainID.Hyperliquid]: '0x000000000022d473030f116ddee9f6b43ac78ba3' as EvmAddress,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
// Production guard addresses
|
|
21
|
-
export const PROD_CROSS_CHAIN_GUARD_ADDRESSES: Record<SupportedChain, SolanaAddress |
|
|
22
|
-
[ChainID.Arbitrum]: '0x921ab91ee3dc38fd47aefd6218fd6b0bd9d64c18' as
|
|
23
|
-
[ChainID.Optimism]: '0xa89b2aae94769bf4a5dc9982eabe2c513564d1ea' as
|
|
24
|
-
[ChainID.Base]: '0x5173e9f12e2485f990ce4dac877d8545fb4ec81a' as
|
|
25
|
-
[ChainID.Hyperliquid]: '0x6595bcc70e0c34ecf9174bb72881eea89b075021' as
|
|
26
|
-
[ChainID.Solana]:
|
|
21
|
+
export const PROD_CROSS_CHAIN_GUARD_ADDRESSES: Record<SupportedChain, SolanaAddress | EvmAddress> = {
|
|
22
|
+
[ChainID.Arbitrum]: '0x921ab91ee3dc38fd47aefd6218fd6b0bd9d64c18' as EvmAddress,
|
|
23
|
+
[ChainID.Optimism]: '0xa89b2aae94769bf4a5dc9982eabe2c513564d1ea' as EvmAddress,
|
|
24
|
+
[ChainID.Base]: '0x5173e9f12e2485f990ce4dac877d8545fb4ec81a' as EvmAddress,
|
|
25
|
+
[ChainID.Hyperliquid]: '0x6595bcc70e0c34ecf9174bb72881eea89b075021' as EvmAddress,
|
|
26
|
+
[ChainID.Solana]:
|
|
27
|
+
'4kD6otCKkKZQej8YNQkWdzG9xMo5XYN8T1BbUrJUE63E' as SolanaAddress<'4kD6otCKkKZQej8YNQkWdzG9xMo5XYN8T1BbUrJUE63E'>,
|
|
27
28
|
[ChainID.Sui]: '0x88a47715f41c5e47ff6d6dcfc0285f3802ae1587a9f411d0daff20269245a1b0',
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
// Test guard addresses
|
|
31
|
-
export const TEST_CROSS_CHAIN_GUARD_ADDRESSES: Record<SupportedChain, SolanaAddress |
|
|
32
|
-
[ChainID.Arbitrum]: '0x8cfacbe4e236c0ca0a7b4b9fc5b696aa9f07cc41' as
|
|
33
|
-
[ChainID.Optimism]: '0x66fbcccbd3ffe2d347bc2776ef8a6561ff29998e' as
|
|
34
|
-
[ChainID.Base]: '0xa895a53634854756ae8e902065e3be26ee36381d' as
|
|
35
|
-
[ChainID.Hyperliquid]: '0xB8ec423b5f03b138Ad47c85Ea5F7AAEBB116D65e' as
|
|
36
|
-
[ChainID.Solana]:
|
|
32
|
+
export const TEST_CROSS_CHAIN_GUARD_ADDRESSES: Record<SupportedChain, SolanaAddress | EvmAddress> = {
|
|
33
|
+
[ChainID.Arbitrum]: '0x8cfacbe4e236c0ca0a7b4b9fc5b696aa9f07cc41' as EvmAddress,
|
|
34
|
+
[ChainID.Optimism]: '0x66fbcccbd3ffe2d347bc2776ef8a6561ff29998e' as EvmAddress,
|
|
35
|
+
[ChainID.Base]: '0xa895a53634854756ae8e902065e3be26ee36381d' as EvmAddress,
|
|
36
|
+
[ChainID.Hyperliquid]: '0xB8ec423b5f03b138Ad47c85Ea5F7AAEBB116D65e' as EvmAddress,
|
|
37
|
+
[ChainID.Solana]:
|
|
38
|
+
'FAKnXTY7cNz9wMTpH1wwsU9a1xzBAiMwAn2NXmGMLynP' as SolanaAddress<'FAKnXTY7cNz9wMTpH1wwsU9a1xzBAiMwAn2NXmGMLynP'>,
|
|
37
39
|
[ChainID.Sui]: '0xd5057237ba5fe3d9aa00bb2a1555c3d3de77fd5653e72ce70f4aa0561fa9f04d',
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
// Prod guard addresses
|
|
41
|
-
export const PROD_SINGLE_CHAIN_GUARD_ADDRESSES: Record<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
[ChainID.
|
|
46
|
-
[ChainID.
|
|
43
|
+
export const PROD_SINGLE_CHAIN_GUARD_ADDRESSES: Record<
|
|
44
|
+
Exclude<ChainID, SupportedSuiChain>,
|
|
45
|
+
SolanaAddress | EvmAddress
|
|
46
|
+
> = {
|
|
47
|
+
[ChainID.Arbitrum]: '0x0' as EvmAddress,
|
|
48
|
+
[ChainID.Optimism]: '0x0' as EvmAddress,
|
|
49
|
+
[ChainID.Base]: '0x449808a27f42518c57791d4c2c6626f0069a0ed9' as EvmAddress,
|
|
50
|
+
[ChainID.Hyperliquid]: '0x618ee9b6829261108d811b91581e00da192b0b75' as EvmAddress,
|
|
51
|
+
[ChainID.Solana]:
|
|
52
|
+
'CwWkajHjBCWMKZdwR5D1P5M6Fgf9dAyxqZ1qDZgZGo1e' as SolanaAddress<'CwWkajHjBCWMKZdwR5D1P5M6Fgf9dAyxqZ1qDZgZGo1e'>,
|
|
47
53
|
};
|
|
48
54
|
|
|
49
55
|
// Test guard addresses
|
|
50
|
-
export const TEST_SINGLE_CHAIN_GUARD_ADDRESSES: Record<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
[ChainID.
|
|
55
|
-
[ChainID.
|
|
56
|
+
export const TEST_SINGLE_CHAIN_GUARD_ADDRESSES: Record<
|
|
57
|
+
Exclude<ChainID, SupportedSuiChain>,
|
|
58
|
+
SolanaAddress | EvmAddress
|
|
59
|
+
> = {
|
|
60
|
+
[ChainID.Arbitrum]: '0x0' as EvmAddress,
|
|
61
|
+
[ChainID.Optimism]: '0x0' as EvmAddress,
|
|
62
|
+
[ChainID.Base]: '0x5602cedc725564694162a320c5bb91b5b4b25fca' as EvmAddress,
|
|
63
|
+
[ChainID.Hyperliquid]: '0x6a2f41f905035fa89b7329c0661061b580b1eb92' as EvmAddress,
|
|
64
|
+
[ChainID.Solana]:
|
|
65
|
+
'4wi5wsgSs9q9WV55s9AvKWTdeMNPcDXhzcbx5SoRRFcg' as SolanaAddress<'4wi5wsgSs9q9WV55s9AvKWTdeMNPcDXhzcbx5SoRRFcg'>,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const PROD_DCA_SINGLE_CHAIN_GUARD_ADDRESSES: Record<SupportedEvmChain, EvmAddress> = {
|
|
69
|
+
[ChainID.Arbitrum]: '0x0000000000000000000000000000000000000000' as EvmAddress,
|
|
70
|
+
[ChainID.Optimism]: '0x0000000000000000000000000000000000000000' as EvmAddress,
|
|
71
|
+
[ChainID.Base]: '0x1ab119e95a87ff59a57eba6dec6599aff8b2d7e4' as EvmAddress,
|
|
72
|
+
[ChainID.Hyperliquid]: '0x490911e5236f68ba921cbecc4b82b5e01b745731' as EvmAddress,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Test guard addresses
|
|
76
|
+
export const TEST_DCA_SINGLE_CHAIN_GUARD_ADDRESSES: Record<SupportedEvmChain, EvmAddress> = {
|
|
77
|
+
[ChainID.Arbitrum]: '0x0000000000000000000000000000000000000000' as EvmAddress,
|
|
78
|
+
[ChainID.Optimism]: '0x0000000000000000000000000000000000000000' as EvmAddress,
|
|
79
|
+
[ChainID.Base]: '0x79fd6a458066396c8938823049b6e614ce6b71f2' as EvmAddress,
|
|
80
|
+
[ChainID.Hyperliquid]: '0x5156e6c7b7a1c60ed4d6b2175f88f1f6875c78d8' as EvmAddress,
|
|
56
81
|
};
|
|
57
82
|
|
|
58
83
|
export const CROSS_CHAIN_GUARD_ADDRESSES = useProdConfig
|
|
59
84
|
? PROD_CROSS_CHAIN_GUARD_ADDRESSES
|
|
60
85
|
: TEST_CROSS_CHAIN_GUARD_ADDRESSES;
|
|
86
|
+
|
|
61
87
|
export const SINGLE_CHAIN_GUARD_ADDRESSES = useProdConfig
|
|
62
88
|
? PROD_SINGLE_CHAIN_GUARD_ADDRESSES
|
|
63
89
|
: TEST_SINGLE_CHAIN_GUARD_ADDRESSES;
|
|
64
90
|
|
|
65
|
-
export const
|
|
66
|
-
|
|
91
|
+
export const DCA_SINGLE_CHAIN_GUARD_ADDRESSES = useProdConfig
|
|
92
|
+
? PROD_DCA_SINGLE_CHAIN_GUARD_ADDRESSES
|
|
93
|
+
: TEST_DCA_SINGLE_CHAIN_GUARD_ADDRESSES;
|
|
94
|
+
|
|
95
|
+
export const NATIVE_SOLANA_TOKEN_ADDRESS =
|
|
96
|
+
'So11111111111111111111111111111111111111111' as SolanaAddress<'So11111111111111111111111111111111111111111'>;
|
|
97
|
+
export const WRAPPED_SOL_MINT_ADDRESS =
|
|
98
|
+
'So11111111111111111111111111111111111111112' as SolanaAddress<'So11111111111111111111111111111111111111112'>;
|
|
67
99
|
|
|
68
100
|
type SolanaMint = {
|
|
69
101
|
name: string;
|
|
@@ -109,14 +141,15 @@ export const NATIVE_EVM_ETH_ADDRESSES = [
|
|
|
109
141
|
'0x0000000000000000000000000000000000000000',
|
|
110
142
|
];
|
|
111
143
|
|
|
112
|
-
export const WRAPPED_ETH_ADDRESSES: Record<SupportedEvmChain,
|
|
113
|
-
[ChainID.Arbitrum]: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1' as
|
|
114
|
-
[ChainID.Optimism]: '0x4200000000000000000000000000000000000006' as
|
|
115
|
-
[ChainID.Base]: '0x4200000000000000000000000000000000000006' as
|
|
116
|
-
[ChainID.Hyperliquid]: '0x5555555555555555555555555555555555555555' as
|
|
144
|
+
export const WRAPPED_ETH_ADDRESSES: Record<SupportedEvmChain, EvmAddress> = {
|
|
145
|
+
[ChainID.Arbitrum]: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1' as EvmAddress,
|
|
146
|
+
[ChainID.Optimism]: '0x4200000000000000000000000000000000000006' as EvmAddress,
|
|
147
|
+
[ChainID.Base]: '0x4200000000000000000000000000000000000006' as EvmAddress,
|
|
148
|
+
[ChainID.Hyperliquid]: '0x5555555555555555555555555555555555555555' as EvmAddress,
|
|
117
149
|
};
|
|
118
150
|
|
|
119
151
|
export const NATIVE_SUI_TOKEN_ADDRESS = '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI';
|
|
152
|
+
|
|
120
153
|
export function isNativeEvmToken(tokenAddress: string): boolean {
|
|
121
154
|
const normalizedAddress = tokenAddress.toLowerCase();
|
|
122
155
|
|
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
import { type Address } from 'viem';
|
|
2
2
|
import { type SupportedEvmChain } from '../../chains.js';
|
|
3
3
|
import type { EVMConfig } from '../../config.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
SINGLE_CHAIN_GUARD_ADDRESSES,
|
|
6
|
+
CROSS_CHAIN_GUARD_ADDRESSES,
|
|
7
|
+
MAX_UINT_32,
|
|
8
|
+
DCA_SINGLE_CHAIN_GUARD_ADDRESSES,
|
|
9
|
+
} from '../../constants.js';
|
|
10
|
+
import {
|
|
11
|
+
getEVMCrossChainOrderTypedData,
|
|
12
|
+
getEVMDcaSingleChainOrderTypedData,
|
|
13
|
+
getEVMSingleChainOrderTypedData,
|
|
14
|
+
} from './order-signature.js';
|
|
15
|
+
import {
|
|
16
|
+
type CrossChainPermitTransferFrom,
|
|
17
|
+
type DcaSingleChainPermitTransferFrom,
|
|
18
|
+
type SingleChainPermitTransferFrom,
|
|
19
|
+
type TransferData,
|
|
20
|
+
} from './permit2.js';
|
|
7
21
|
import { ChainProvider } from './chain-provider.js';
|
|
8
22
|
import type { CrossChainOrder } from '../orders/cross-chain.js';
|
|
9
23
|
import type { SingleChainOrder } from '../orders/single-chain.js';
|
|
10
|
-
import type {
|
|
24
|
+
import type {
|
|
25
|
+
CrossChainOrderPrepared,
|
|
26
|
+
DcaSingleChainOrderPrepared,
|
|
27
|
+
SingleChainOrderPrepared,
|
|
28
|
+
} from '../../types/intent.js';
|
|
29
|
+
import type { DcaSingleChainOrder } from '../orders/dca-single-chain.js';
|
|
11
30
|
|
|
12
31
|
export class EVMIntentProvider {
|
|
13
32
|
provider: ChainProvider;
|
|
@@ -119,4 +138,69 @@ export class EVMIntentProvider {
|
|
|
119
138
|
static getRandomNonce(): bigint {
|
|
120
139
|
return BigInt(Math.floor(Math.random() * Number(MAX_UINT_32)));
|
|
121
140
|
}
|
|
141
|
+
|
|
142
|
+
async prepareDcaSingleChainOrder(order: DcaSingleChainOrder): Promise<DcaSingleChainOrderPrepared> {
|
|
143
|
+
const { orderTypedData: dataToSign, nonce } = await getEVMDcaSingleChainOrderTypedData(order);
|
|
144
|
+
|
|
145
|
+
const signature = await this.provider.walletClient.signTypedData({
|
|
146
|
+
message: dataToSign.message,
|
|
147
|
+
primaryType: dataToSign.primaryType,
|
|
148
|
+
types: dataToSign.types,
|
|
149
|
+
domain: dataToSign.domain,
|
|
150
|
+
account: this.provider.getAccount(),
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
order,
|
|
155
|
+
preparedData: {
|
|
156
|
+
nonce: nonce.toString(),
|
|
157
|
+
signature: signature.slice(2),
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static getDcaSingleChainPermissionMessage(
|
|
163
|
+
order: DcaSingleChainOrder,
|
|
164
|
+
nonce: bigint,
|
|
165
|
+
): DcaSingleChainPermitTransferFrom {
|
|
166
|
+
const spender = DCA_SINGLE_CHAIN_GUARD_ADDRESSES[order.chainId as SupportedEvmChain] as Address;
|
|
167
|
+
|
|
168
|
+
const requestedOutput: TransferData = {
|
|
169
|
+
token: order.tokenOut as Address,
|
|
170
|
+
receiver: order.destinationAddress as Address,
|
|
171
|
+
amount: BigInt(order.amountOutMin),
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const extraTransfers: TransferData[] =
|
|
175
|
+
order.extraTransfers?.map((transfer) => ({
|
|
176
|
+
token: transfer.token as Address,
|
|
177
|
+
receiver: transfer.receiver as Address,
|
|
178
|
+
amount: transfer.amount,
|
|
179
|
+
})) || [];
|
|
180
|
+
|
|
181
|
+
const totalAmountIn = BigInt(order.amountInPerInterval) * BigInt(order.totalIntervals);
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
permitted: {
|
|
185
|
+
token: order.tokenIn as Address,
|
|
186
|
+
amount: totalAmountIn,
|
|
187
|
+
},
|
|
188
|
+
spender,
|
|
189
|
+
nonce,
|
|
190
|
+
deadline: BigInt(order.deadline),
|
|
191
|
+
witness: {
|
|
192
|
+
user: order.user as Address,
|
|
193
|
+
tokenIn: order.tokenIn as Address,
|
|
194
|
+
startTime: order.startTime,
|
|
195
|
+
amountInPerInterval: BigInt(order.amountInPerInterval),
|
|
196
|
+
totalIntervals: order.totalIntervals,
|
|
197
|
+
intervalDuration: order.intervalDuration,
|
|
198
|
+
requestedOutput,
|
|
199
|
+
encodedExternalCallData: '0x', // TODO: Update when external call data is supported
|
|
200
|
+
extraTransfers,
|
|
201
|
+
deadline: order.deadline,
|
|
202
|
+
nonce,
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
}
|
|
122
206
|
}
|
|
@@ -2,7 +2,13 @@ import type { TypedDataDefinition } from 'viem';
|
|
|
2
2
|
import type { SupportedEvmChain } from '../../chains.js';
|
|
3
3
|
import type { CrossChainOrder } from '../orders/cross-chain.js';
|
|
4
4
|
import { EVMIntentProvider } from './intent-provider.js';
|
|
5
|
-
import {
|
|
5
|
+
import type { DcaSingleChainOrder } from '../orders/dca-single-chain.js';
|
|
6
|
+
import {
|
|
7
|
+
CROSS_CHAIN_PERMIT2_TYPES,
|
|
8
|
+
DCA_SINGLE_CHAIN_PERMIT2_TYPES,
|
|
9
|
+
PERMIT2_DOMAIN,
|
|
10
|
+
SINGLE_CHAIN_LIMIT_PERMIT2_TYPES,
|
|
11
|
+
} from './permit2.js';
|
|
6
12
|
import type { SingleChainOrder } from '../orders/single-chain.js';
|
|
7
13
|
|
|
8
14
|
export async function getEVMSingleChainOrderTypedData(
|
|
@@ -41,3 +47,19 @@ export async function getEVMCrossChainOrderTypedData(
|
|
|
41
47
|
|
|
42
48
|
return { orderTypedData, nonce: randomNonce };
|
|
43
49
|
}
|
|
50
|
+
|
|
51
|
+
export async function getEVMDcaSingleChainOrderTypedData(
|
|
52
|
+
order: DcaSingleChainOrder,
|
|
53
|
+
): Promise<{ orderTypedData: TypedDataDefinition; nonce: bigint }> {
|
|
54
|
+
const randomNonce = EVMIntentProvider.getRandomNonce();
|
|
55
|
+
const permissionMessage = EVMIntentProvider.getDcaSingleChainPermissionMessage(order, randomNonce);
|
|
56
|
+
|
|
57
|
+
const orderTypedData = {
|
|
58
|
+
domain: PERMIT2_DOMAIN(order.chainId as SupportedEvmChain),
|
|
59
|
+
types: DCA_SINGLE_CHAIN_PERMIT2_TYPES,
|
|
60
|
+
primaryType: 'PermitWitnessTransferFrom',
|
|
61
|
+
message: permissionMessage,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return { orderTypedData, nonce: randomNonce };
|
|
65
|
+
}
|
package/src/core/evm/permit2.ts
CHANGED
|
@@ -100,7 +100,6 @@ export const CROSS_CHAIN_PERMIT2_TYPES = {
|
|
|
100
100
|
],
|
|
101
101
|
} as const;
|
|
102
102
|
|
|
103
|
-
// Single-chain limit order types
|
|
104
103
|
export const SINGLE_CHAIN_LIMIT_PERMIT2_TYPES = {
|
|
105
104
|
TokenPermissions: TOKEN_PERMISSIONS_TYPE,
|
|
106
105
|
TransferData: TRANSFER_DATA_TYPE,
|
|
@@ -128,3 +127,50 @@ export const PERMIT2_DOMAIN = (chainId: SupportedEvmChain): TypedDataDomain => (
|
|
|
128
127
|
chainId,
|
|
129
128
|
verifyingContract: PERMIT2_ADDRESS[chainId],
|
|
130
129
|
});
|
|
130
|
+
|
|
131
|
+
type DcaSingleChainOrderWitness = {
|
|
132
|
+
user: Address;
|
|
133
|
+
tokenIn: Address;
|
|
134
|
+
startTime: number;
|
|
135
|
+
amountInPerInterval: bigint;
|
|
136
|
+
totalIntervals: number;
|
|
137
|
+
intervalDuration: number;
|
|
138
|
+
requestedOutput: TransferData;
|
|
139
|
+
extraTransfers: TransferData[];
|
|
140
|
+
encodedExternalCallData: Hex;
|
|
141
|
+
deadline: number;
|
|
142
|
+
nonce: bigint;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export type DcaSingleChainPermitTransferFrom = {
|
|
146
|
+
permitted: TokenPermissions;
|
|
147
|
+
spender: Address;
|
|
148
|
+
nonce: bigint;
|
|
149
|
+
deadline: bigint;
|
|
150
|
+
witness: DcaSingleChainOrderWitness;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const DCA_SINGLE_CHAIN_PERMIT2_TYPES = {
|
|
154
|
+
TokenPermissions: TOKEN_PERMISSIONS_TYPE,
|
|
155
|
+
TransferData: TRANSFER_DATA_TYPE,
|
|
156
|
+
SingleChainDcaOrder: [
|
|
157
|
+
{ type: 'address', name: 'user' },
|
|
158
|
+
{ type: 'address', name: 'tokenIn' },
|
|
159
|
+
{ type: 'uint32', name: 'startTime' },
|
|
160
|
+
{ type: 'uint256', name: 'amountInPerInterval' },
|
|
161
|
+
{ type: 'uint24', name: 'totalIntervals' },
|
|
162
|
+
{ type: 'uint32', name: 'intervalDuration' },
|
|
163
|
+
{ type: 'TransferData', name: 'requestedOutput' },
|
|
164
|
+
{ type: 'TransferData[]', name: 'extraTransfers' },
|
|
165
|
+
{ type: 'bytes', name: 'encodedExternalCallData' },
|
|
166
|
+
{ type: 'uint32', name: 'deadline' },
|
|
167
|
+
{ type: 'uint256', name: 'nonce' },
|
|
168
|
+
],
|
|
169
|
+
PermitWitnessTransferFrom: [
|
|
170
|
+
{ name: 'permitted', type: 'TokenPermissions' },
|
|
171
|
+
{ name: 'spender', type: 'address' },
|
|
172
|
+
{ name: 'nonce', type: 'uint256' },
|
|
173
|
+
{ name: 'deadline', type: 'uint256' },
|
|
174
|
+
{ name: 'witness', type: 'SingleChainDcaOrder' },
|
|
175
|
+
],
|
|
176
|
+
} as const;
|
package/src/core/evm/sdk.ts
CHANGED
|
@@ -12,8 +12,13 @@ import {
|
|
|
12
12
|
import type { ExtraTransfer } from '../orders/common.js';
|
|
13
13
|
import type { CrossChainOrder } from '../orders/cross-chain.js';
|
|
14
14
|
import type { SingleChainOrder } from '../orders/single-chain.js';
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
CrossChainOrderPrepared,
|
|
17
|
+
DcaSingleChainOrderPrepared,
|
|
18
|
+
SingleChainOrderPrepared,
|
|
19
|
+
} from '../../types/intent.js';
|
|
16
20
|
import { fetchJWTToken, fetchSiweMessage } from '../../auth/siwe.js';
|
|
21
|
+
import type { DcaSingleChainOrder } from '../orders/dca-single-chain.js';
|
|
17
22
|
|
|
18
23
|
type CancelSingleChainOrderParams = {
|
|
19
24
|
orderId: string;
|
|
@@ -51,7 +56,7 @@ export class EVMSDK extends BaseSDK {
|
|
|
51
56
|
this.config = config;
|
|
52
57
|
this.evmIntentProvider = new EVMIntentProvider(config);
|
|
53
58
|
}
|
|
54
|
-
|
|
59
|
+
|
|
55
60
|
public async cancelCrossChainOrder(params: CancelCrossChainOrderParams): Promise<string> {
|
|
56
61
|
const chainId = this.config.chainId;
|
|
57
62
|
const auctioneerAddress = CROSS_CHAIN_GUARD_ADDRESSES[chainId] as Hex;
|
|
@@ -61,7 +66,7 @@ export class EVMSDK extends BaseSDK {
|
|
|
61
66
|
const permit2Contract = this.evmIntentProvider.provider.getPermit2Contract(PERMIT2_ADDRESS[chainId]);
|
|
62
67
|
|
|
63
68
|
const orderIdHex = params.orderId as Hex;
|
|
64
|
-
|
|
69
|
+
const [initialized, deactivated] = await auctioneerContract.read.orderData([orderIdHex]);
|
|
65
70
|
let txHash: Hex;
|
|
66
71
|
|
|
67
72
|
if (initialized) {
|
|
@@ -84,9 +89,9 @@ export class EVMSDK extends BaseSDK {
|
|
|
84
89
|
txHash = tx;
|
|
85
90
|
} else {
|
|
86
91
|
const nonce = BigInt(params.nonce);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
const nonceWordPos = nonce >> 8n;
|
|
93
|
+
const nonceBitPos = nonce - nonceWordPos * 256n;
|
|
94
|
+
const mask = 1n << nonceBitPos;
|
|
90
95
|
|
|
91
96
|
const currentNonceBitmap = await permit2Contract.read.nonceBitmap([userAddress, nonceWordPos]);
|
|
92
97
|
if ((currentNonceBitmap & (1n << nonceBitPos)) !== 0n) {
|
|
@@ -221,8 +226,16 @@ export class EVMSDK extends BaseSDK {
|
|
|
221
226
|
return this.evmIntentProvider.prepareCrossChainOrder(order);
|
|
222
227
|
}
|
|
223
228
|
|
|
224
|
-
protected async prepareSingleChainOrder(order: SingleChainOrder): Promise<SingleChainOrderPrepared> {
|
|
229
|
+
protected override async prepareSingleChainOrder(order: SingleChainOrder): Promise<SingleChainOrderPrepared> {
|
|
225
230
|
await this.approveAllowanceIfNeeded(order.tokenIn as Address, order.amountIn);
|
|
226
231
|
return this.evmIntentProvider.prepareSingleChainOrder(order);
|
|
227
232
|
}
|
|
233
|
+
|
|
234
|
+
protected override async prepareDcaSingleChainOrder(
|
|
235
|
+
order: DcaSingleChainOrder,
|
|
236
|
+
): Promise<DcaSingleChainOrderPrepared> {
|
|
237
|
+
const totalAmountIn = order.getTotalAmountIn();
|
|
238
|
+
await this.approveAllowanceIfNeeded(order.tokenIn as Address, totalAmountIn);
|
|
239
|
+
return this.evmIntentProvider.prepareDcaSingleChainOrder(order);
|
|
240
|
+
}
|
|
228
241
|
}
|
|
@@ -7,6 +7,7 @@ import type { CreateCrossChainOrderParams } from '../orders/cross-chain.js';
|
|
|
7
7
|
import { ERC20ABI } from './abi/erc20.js';
|
|
8
8
|
import { ChainProvider } from './chain-provider.js';
|
|
9
9
|
import type { CreateSingleChainOrderParams } from '../orders/single-chain.js';
|
|
10
|
+
import type { CreateDcaSingleChainOrderParams } from '../orders/dca-single-chain.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Chain-specific validator implementations
|
|
@@ -119,4 +120,35 @@ export class EvmValidator extends BaseValidator {
|
|
|
119
120
|
// );
|
|
120
121
|
// }
|
|
121
122
|
}
|
|
123
|
+
|
|
124
|
+
override async validateDcaSingleChainOrderFeasability(
|
|
125
|
+
order: CreateDcaSingleChainOrderParams & { user: string },
|
|
126
|
+
): Promise<void> {
|
|
127
|
+
const chain = order.chainId as SupportedEvmChain;
|
|
128
|
+
|
|
129
|
+
const client = ChainProvider.getClient(chain);
|
|
130
|
+
const user = order.user as Address;
|
|
131
|
+
|
|
132
|
+
if (isNativeEvmToken(order.tokenIn)) {
|
|
133
|
+
throw new ValidationError('Native token is not supported for DCA orders.');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const ERC20Contract = getContract({
|
|
137
|
+
address: order.tokenIn as Address,
|
|
138
|
+
abi: ERC20ABI,
|
|
139
|
+
client: {
|
|
140
|
+
public: client,
|
|
141
|
+
chain,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const totalAmountIn = order.amountInPerInterval * BigInt(order.totalIntervals);
|
|
146
|
+
const balance = await ERC20Contract.read.balanceOf([user]);
|
|
147
|
+
|
|
148
|
+
if (balance < totalAmountIn) {
|
|
149
|
+
throw new InsufficientBalanceError(
|
|
150
|
+
`Insufficient balance for DCA order. Token: ${order.tokenIn}. Current balance: ${balance}. Required total: ${totalAmountIn}`,
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
122
154
|
}
|