@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/src/index.ts
CHANGED
|
@@ -14,7 +14,15 @@ export { fetchUserOrders } from './core/orders/api/fetch.js';
|
|
|
14
14
|
export { AuctioneerAPI } from './core/orders/api/index.js';
|
|
15
15
|
export { type FetchJWTParams, type FetchSiweMessageParams, fetchJWTToken, fetchSiweMessage } from './auth/siwe.js';
|
|
16
16
|
export { ValidationError } from './errors/index.js';
|
|
17
|
-
export {
|
|
17
|
+
export {
|
|
18
|
+
type ApiCrossChainOrder,
|
|
19
|
+
type ApiResponse,
|
|
20
|
+
type ApiSingleChainOrder,
|
|
21
|
+
type ApiUserOrders,
|
|
22
|
+
type ChainOrderStatus,
|
|
23
|
+
isErrorApiResponse,
|
|
24
|
+
isSuccessApiResponse,
|
|
25
|
+
} from './types/api.js';
|
|
18
26
|
export { calculateAmounts, getCoinFromResponse, getTokensData } from './utils/defillama.js';
|
|
19
27
|
export type { DefiLlamaCoinData, DefiLlamaTokensResponse } from './utils/defillama.js';
|
|
20
28
|
export {
|
|
@@ -24,8 +32,11 @@ export {
|
|
|
24
32
|
type CancelCrossChainOrderParams,
|
|
25
33
|
getInvalidateNoncesRawData,
|
|
26
34
|
} from './core/evm/cancel-order.js';
|
|
35
|
+
export { cancelDcaSingleChainOrderInstructions } from './core/solana/dca/cancel-order.js';
|
|
27
36
|
export { getEVMCrossChainOrderTypedData, getEVMSingleChainOrderTypedData } from './core/evm/order-signature.js';
|
|
28
37
|
|
|
38
|
+
export { getSolanaOrdersWithLockedFunds } from './core/solana/inspect.js';
|
|
39
|
+
|
|
29
40
|
export {
|
|
30
41
|
getSolanaCrossChainOrderInstructions,
|
|
31
42
|
getSolanaSingleChainOrderInstructions,
|
package/src/types/api.ts
CHANGED
package/src/types/intent.ts
CHANGED
|
@@ -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
|
/**
|
|
7
8
|
* Details required to execute the order on the destination chain
|
|
@@ -120,3 +121,29 @@ export type SingleChainOrderPrepared = {
|
|
|
120
121
|
order: SingleChainOrder;
|
|
121
122
|
preparedData: SingleChainPreparedData;
|
|
122
123
|
};
|
|
124
|
+
|
|
125
|
+
export type DcaSingleChainUserIntentRequest = {
|
|
126
|
+
genericData: DcaSingleChainOrder;
|
|
127
|
+
chainSpecificData: {
|
|
128
|
+
EVM?: DcaSingleChainEVMPreparedData;
|
|
129
|
+
Solana?: DcaSingleChainSolanaPreparedData;
|
|
130
|
+
Sui?: never; // DCA not supported on Sui
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type DcaSingleChainEVMPreparedData = {
|
|
135
|
+
nonce: string;
|
|
136
|
+
signature: string | Hash;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export type DcaSingleChainSolanaPreparedData = {
|
|
140
|
+
secretNumber: string;
|
|
141
|
+
orderPubkey: string;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type DcaSingleChainPreparedData = DcaSingleChainEVMPreparedData | DcaSingleChainSolanaPreparedData;
|
|
145
|
+
|
|
146
|
+
export type DcaSingleChainOrderPrepared = {
|
|
147
|
+
order: DcaSingleChainOrder;
|
|
148
|
+
preparedData: DcaSingleChainPreparedData;
|
|
149
|
+
};
|
|
@@ -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 { ValidationError } from '../errors/index.js';
|
|
4
5
|
import type { IChainValidator } from './order-validator.js';
|
|
@@ -59,6 +60,45 @@ export abstract class BaseValidator implements IChainValidator {
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
abstract validateDcaSingleChainOrderFeasability(
|
|
64
|
+
order: CreateDcaSingleChainOrderParams & { user: string },
|
|
65
|
+
): Promise<void>;
|
|
66
|
+
|
|
67
|
+
async validateDcaSingleChainOrder(order: CreateDcaSingleChainOrderParams & { user: string }): Promise<void> {
|
|
68
|
+
this.validateTokenAddress(order.tokenIn);
|
|
69
|
+
this.validateTokenAddress(order.tokenOut);
|
|
70
|
+
this.validateAmount(order.amountInPerInterval);
|
|
71
|
+
this.validateAmount(order.amountOutMin ?? 1n);
|
|
72
|
+
this.validateAddress(order.destinationAddress);
|
|
73
|
+
|
|
74
|
+
// Validate DCA-specific parameters
|
|
75
|
+
if (order.totalIntervals <= 0) {
|
|
76
|
+
throw new ValidationError('Total intervals must be greater than 0');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (order.intervalDuration <= 0) {
|
|
80
|
+
throw new ValidationError('Interval duration must be greater than 0');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (order.startTime < 0) {
|
|
84
|
+
throw new ValidationError('Start time must be non-negative');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Validate total amount doesn't overflow
|
|
88
|
+
const totalAmount = order.amountInPerInterval * BigInt(order.totalIntervals);
|
|
89
|
+
this.validateAmount(totalAmount);
|
|
90
|
+
|
|
91
|
+
if (order.extraTransfers) {
|
|
92
|
+
for (const extraTransfer of order.extraTransfers) {
|
|
93
|
+
this.validateAddress(extraTransfer.receiver);
|
|
94
|
+
this.validateTokenAddress(extraTransfer.token);
|
|
95
|
+
this.validateAmount(extraTransfer.amount);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
await this.validateDcaSingleChainOrderFeasability(order);
|
|
100
|
+
}
|
|
101
|
+
|
|
62
102
|
/**
|
|
63
103
|
* Helper methods that throw specific validation errors
|
|
64
104
|
*/
|
|
@@ -26,6 +26,7 @@ export interface IChainValidator extends IAddressValidator, ITokenValidator, IAm
|
|
|
26
26
|
validateSourceChain(order: CreateCrossChainOrderParams & { user: string }): Promise<void>;
|
|
27
27
|
validateDestinationChain(order: CreateCrossChainOrderParams): void;
|
|
28
28
|
validateSingleChainOrder(order: CreateSingleChainOrderParams & { user: string }): Promise<void>;
|
|
29
|
+
validateDcaSingleChainOrder(order: CreateDcaSingleChainOrderParams & { user: string }): Promise<void>;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
@@ -99,3 +100,40 @@ export class SingleChainOrderValidator {
|
|
|
99
100
|
chainValidator.validateSingleChainOrder(order);
|
|
100
101
|
}
|
|
101
102
|
}
|
|
103
|
+
|
|
104
|
+
import type { CreateDcaSingleChainOrderParams } from '../core/orders/dca-single-chain.js';
|
|
105
|
+
|
|
106
|
+
export interface IDcaValidator {
|
|
107
|
+
validateDcaSingleChainOrder(order: CreateDcaSingleChainOrderParams & { user: string }): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class DcaSingleChainOrderValidator {
|
|
111
|
+
private readonly commonValidator = new CommonValidator();
|
|
112
|
+
|
|
113
|
+
async validateOrder(order: CreateDcaSingleChainOrderParams & { user: string }): Promise<void> {
|
|
114
|
+
this.commonValidator.validateDeadline(order.deadline);
|
|
115
|
+
|
|
116
|
+
// Validate start time is in the future or current time
|
|
117
|
+
if (order.startTime < Math.floor(Date.now() / 1000)) {
|
|
118
|
+
throw new ValidationError('Start time must be in the future or current time');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Validate intervals
|
|
122
|
+
if (order.totalIntervals <= 0) {
|
|
123
|
+
throw new ValidationError('Total intervals must be greater than 0');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (order.intervalDuration <= 0) {
|
|
127
|
+
throw new ValidationError('Interval duration must be greater than 0');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Validate that the order will complete before deadline
|
|
131
|
+
const estimatedCompletionTime = order.startTime + order.totalIntervals * order.intervalDuration;
|
|
132
|
+
if (estimatedCompletionTime > order.deadline) {
|
|
133
|
+
throw new ValidationError('Order would complete after deadline');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const chainValidator = ValidatorFactory.getValidatorForChain(order.chainId);
|
|
137
|
+
await chainValidator.validateDcaSingleChainOrder(order);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -89,8 +89,8 @@ export class QuoteProvider {
|
|
|
89
89
|
private static async getQuoteFromRouters(params: QuoteParams): Promise<QuoteResponse> {
|
|
90
90
|
const bridgeTokenSymbol = QuoteProvider.DEFAULT_BRIDGE_TOKEN;
|
|
91
91
|
|
|
92
|
-
const sourceBridgeToken = CROSS_CHAIN_TOKENS[bridgeTokenSymbol]?.[params.sourceChainId]
|
|
93
|
-
const destBridgeToken = CROSS_CHAIN_TOKENS[bridgeTokenSymbol]?.[params.destChainId]
|
|
92
|
+
const sourceBridgeToken = CROSS_CHAIN_TOKENS[bridgeTokenSymbol]?.[params.sourceChainId] || '';
|
|
93
|
+
const destBridgeToken = CROSS_CHAIN_TOKENS[bridgeTokenSymbol]?.[params.destChainId] || '';
|
|
94
94
|
|
|
95
95
|
const sourceSingleChainQuoteParams: SingleChainQuoteParams = {
|
|
96
96
|
chainId: params.sourceChainId,
|
|
@@ -18,8 +18,8 @@ const LIQUID_SWAP_API_URL = 'https://api.liqd.ag';
|
|
|
18
18
|
|
|
19
19
|
export class LiquidSwapQuoteProvider {
|
|
20
20
|
public async getQuote(liquidSwapParams: LiquidSwapQuoteParams): Promise<LiquidSwapQuoteResponse> {
|
|
21
|
-
const params = {...liquidSwapParams};
|
|
22
|
-
|
|
21
|
+
const params = { ...liquidSwapParams };
|
|
22
|
+
|
|
23
23
|
if (isNativeEvmToken(params.tokenOut)) {
|
|
24
24
|
params.tokenOut = WRAPPED_ETH_ADDRESSES[ChainID.Hyperliquid];
|
|
25
25
|
}
|