@shogun-sdk/intents-sdk 1.2.31 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -3
- package/dist/esm/constants.js +5 -4
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/core/evm/intent-helpers.js +11 -6
- package/dist/esm/core/evm/intent-helpers.js.map +1 -1
- package/dist/esm/core/orders/cross-chain.js +0 -8
- package/dist/esm/core/orders/cross-chain.js.map +1 -1
- package/dist/esm/core/solana/intent-helpers.js +11 -8
- package/dist/esm/core/solana/intent-helpers.js.map +1 -1
- package/dist/esm/core/sui/cross-chain-limit-order.js +0 -17
- package/dist/esm/core/sui/cross-chain-limit-order.js.map +1 -1
- package/dist/esm/core/sui/intent-helpers.js +12 -8
- package/dist/esm/core/sui/intent-helpers.js.map +1 -1
- package/dist/esm/index.js +6 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/token-list.js +2 -0
- package/dist/esm/types/token-list.js.map +1 -0
- package/dist/esm/utils/generate-execution-details-hash.js +15 -0
- package/dist/esm/utils/generate-execution-details-hash.js.map +1 -0
- package/dist/esm/utils/quote/aggregator.js +85 -10
- package/dist/esm/utils/quote/aggregator.js.map +1 -1
- package/dist/esm/utils/quote/raydium.js +82 -0
- package/dist/esm/utils/quote/raydium.js.map +1 -0
- package/dist/esm/utils/tokens/index.js +37 -0
- package/dist/esm/utils/tokens/index.js.map +1 -0
- package/dist/types/constants.d.ts +4 -3
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/core/evm/intent-helpers.d.ts.map +1 -1
- package/dist/types/core/orders/cross-chain.d.ts +0 -2
- package/dist/types/core/orders/cross-chain.d.ts.map +1 -1
- package/dist/types/core/solana/intent-helpers.d.ts.map +1 -1
- package/dist/types/core/sui/cross-chain-limit-order.d.ts +0 -9
- package/dist/types/core/sui/cross-chain-limit-order.d.ts.map +1 -1
- package/dist/types/core/sui/intent-helpers.d.ts +1 -0
- package/dist/types/core/sui/intent-helpers.d.ts.map +1 -1
- package/dist/types/index.d.ts +6 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/intent.d.ts +2 -2
- package/dist/types/types/intent.d.ts.map +1 -1
- package/dist/types/types/token-list.d.ts +30 -0
- package/dist/types/types/token-list.d.ts.map +1 -0
- package/dist/types/utils/generate-execution-details-hash.d.ts +11 -0
- package/dist/types/utils/generate-execution-details-hash.d.ts.map +1 -0
- package/dist/types/utils/quote/aggregator.d.ts +21 -5
- package/dist/types/utils/quote/aggregator.d.ts.map +1 -1
- package/dist/types/utils/quote/raydium.d.ts +79 -0
- package/dist/types/utils/quote/raydium.d.ts.map +1 -0
- package/dist/types/utils/tokens/index.d.ts +20 -0
- package/dist/types/utils/tokens/index.d.ts.map +1 -0
- package/package.json +19 -18
- package/src/constants.ts +6 -4
- package/src/core/evm/intent-helpers.ts +13 -6
- package/src/core/orders/cross-chain.ts +0 -10
- package/src/core/solana/intent-helpers.ts +11 -8
- package/src/core/sui/cross-chain-limit-order.ts +0 -25
- package/src/core/sui/intent-helpers.ts +14 -13
- package/src/index.ts +14 -7
- package/src/types/intent.ts +3 -2
- package/src/types/token-list.ts +35 -0
- package/src/utils/generate-execution-details-hash.ts +34 -0
- package/src/utils/quote/aggregator.ts +106 -16
- package/src/utils/quote/raydium.ts +165 -0
- package/src/utils/tokens/index.ts +38 -0
- package/dist/esm/core/solana/cross-chain-limit-order.js +0 -18
- package/dist/esm/core/solana/cross-chain-limit-order.js.map +0 -1
- package/dist/types/core/solana/cross-chain-limit-order.d.ts +0 -9
- package/dist/types/core/solana/cross-chain-limit-order.d.ts.map +0 -1
- package/src/core/solana/cross-chain-limit-order.ts +0 -24
|
@@ -3,14 +3,16 @@ import { type QuoteResponse as JupiterQuoteResponse } from '@jup-ag/api';
|
|
|
3
3
|
import { type SwapEstimateResult } from './paraswap.js';
|
|
4
4
|
import type { RouterCompleteTradeRoute } from 'aftermath-ts-sdk';
|
|
5
5
|
import { type LiquidSwapQuoteResponse } from './liquidswap.js';
|
|
6
|
+
import { type RaydiumQuoteResponse } from './raydium.js';
|
|
6
7
|
type SingleChainQuoteParams = {
|
|
7
8
|
chainId: ChainID;
|
|
8
9
|
amount: bigint;
|
|
9
10
|
tokenIn: string;
|
|
10
11
|
tokenOut: string;
|
|
11
12
|
slippageBps?: number;
|
|
13
|
+
provider?: RouteProvider;
|
|
12
14
|
};
|
|
13
|
-
export type RouteProvider = 'paraswap' | 'jupiter' | 'aftermath' | 'liquidswap';
|
|
15
|
+
export type RouteProvider = 'paraswap' | 'jupiter' | 'aftermath' | 'liquidswap' | 'raydium';
|
|
14
16
|
export type Quote = {
|
|
15
17
|
amountIn: bigint;
|
|
16
18
|
amountOut: bigint;
|
|
@@ -21,7 +23,7 @@ export type Quote = {
|
|
|
21
23
|
provider: RouteProvider;
|
|
22
24
|
rawQuote: any;
|
|
23
25
|
};
|
|
24
|
-
export type
|
|
26
|
+
export type IntentsQuoteParams = {
|
|
25
27
|
sourceChainId: ChainID;
|
|
26
28
|
destChainId: ChainID;
|
|
27
29
|
amount: bigint;
|
|
@@ -39,9 +41,21 @@ export type QuoteResponse = {
|
|
|
39
41
|
export declare class QuoteProvider {
|
|
40
42
|
private static readonly DEFAULT_BRIDGE_TOKEN;
|
|
41
43
|
private static readonly DEFAULT_BRIDGE_TOKEN_DECIMALS;
|
|
42
|
-
static getQuoteFromDefillama(params:
|
|
43
|
-
static getQuoteWithDefillamaFallback(params:
|
|
44
|
-
static getQuote(params:
|
|
44
|
+
static getQuoteFromDefillama(params: IntentsQuoteParams): Promise<QuoteResponse>;
|
|
45
|
+
static getQuoteWithDefillamaFallback(params: IntentsQuoteParams): Promise<QuoteResponse>;
|
|
46
|
+
static getQuote(params: IntentsQuoteParams): Promise<QuoteResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Get a quote for Solana with explicit provider selection
|
|
49
|
+
* @param params - Quote parameters including provider preference
|
|
50
|
+
* @returns Quote response
|
|
51
|
+
*/
|
|
52
|
+
static getSolanaQuote(params: {
|
|
53
|
+
amount: bigint;
|
|
54
|
+
tokenIn: string;
|
|
55
|
+
tokenOut: string;
|
|
56
|
+
slippageBps?: number;
|
|
57
|
+
provider?: 'jupiter' | 'raydium';
|
|
58
|
+
}): Promise<Quote>;
|
|
45
59
|
private static getQuoteFromRouters;
|
|
46
60
|
static getSingleChainQuote(params: SingleChainQuoteParams): Promise<Quote>;
|
|
47
61
|
static transformLiquidSwapQuote(liquidSwapQuote: LiquidSwapQuoteResponse): Quote;
|
|
@@ -56,9 +70,11 @@ export declare class QuoteProvider {
|
|
|
56
70
|
}>;
|
|
57
71
|
protected static getParaswapQuote(params: SingleChainQuoteParams): Promise<SwapEstimateResult>;
|
|
58
72
|
protected static getAftermathQuote(params: SingleChainQuoteParams): Promise<RouterCompleteTradeRoute>;
|
|
73
|
+
protected static getRaydiumQuote(params: SingleChainQuoteParams): Promise<RaydiumQuoteResponse>;
|
|
59
74
|
private static transformAftermathQuote;
|
|
60
75
|
private static transformParaswapQuote;
|
|
61
76
|
private static transformJupiterQuote;
|
|
77
|
+
private static transformRaydiumQuote;
|
|
62
78
|
}
|
|
63
79
|
export {};
|
|
64
80
|
//# sourceMappingURL=aggregator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../../../src/utils/quote/aggregator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsC,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAAE,KAAK,aAAa,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG/E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAA2B,KAAK,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"aggregator.d.ts","sourceRoot":"","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AAe,CAAC,MAAM,EAAE,sBAAsB;IAWrE,OAAO,CAAC,MAAM,CAAC,uBAAuB;IA6BtC,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAarC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IA2BpC,OAAO,CAAC,MAAM,CAAC,qBAAqB;CAyBrC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
type RaydiumQuoteParams = {
|
|
2
|
+
inputMint: string;
|
|
3
|
+
outputMint: string;
|
|
4
|
+
amount: string;
|
|
5
|
+
slippageBps: number;
|
|
6
|
+
};
|
|
7
|
+
export type RaydiumQuoteResponse = {
|
|
8
|
+
success: boolean;
|
|
9
|
+
data: {
|
|
10
|
+
inputMint: string;
|
|
11
|
+
outputMint: string;
|
|
12
|
+
inAmount: string;
|
|
13
|
+
outAmount: string;
|
|
14
|
+
otherAmountThreshold: string;
|
|
15
|
+
swapMode: string;
|
|
16
|
+
slippageBps: number;
|
|
17
|
+
platformFee: null;
|
|
18
|
+
priceImpactPct: string;
|
|
19
|
+
routePlan: Array<{
|
|
20
|
+
swapInfo: {
|
|
21
|
+
ammKey: string;
|
|
22
|
+
label: string;
|
|
23
|
+
inputMint: string;
|
|
24
|
+
outputMint: string;
|
|
25
|
+
notEnoughLiquidity: boolean;
|
|
26
|
+
minInAmount: string;
|
|
27
|
+
minOutAmount: string;
|
|
28
|
+
priceImpactPct: string;
|
|
29
|
+
lpFee: {
|
|
30
|
+
amount: string;
|
|
31
|
+
mint: string;
|
|
32
|
+
pct: number;
|
|
33
|
+
};
|
|
34
|
+
platformFee: {
|
|
35
|
+
amount: string;
|
|
36
|
+
mint: string;
|
|
37
|
+
pct: number;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
percent: number;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare class RaydiumQuoteProvider {
|
|
45
|
+
/**
|
|
46
|
+
* Get priority fee recommendations from Raydium API
|
|
47
|
+
* @returns Priority fee data with different tiers (vh, h, m)
|
|
48
|
+
*/
|
|
49
|
+
getPriorityFee(): Promise<{
|
|
50
|
+
vh: number;
|
|
51
|
+
h: number;
|
|
52
|
+
m: number;
|
|
53
|
+
}>;
|
|
54
|
+
getQuote(raydiumParams: RaydiumQuoteParams): Promise<RaydiumQuoteResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Get transaction data for executing a swap
|
|
57
|
+
* @param params - Transaction parameters
|
|
58
|
+
* @returns Serialized transaction data
|
|
59
|
+
*/
|
|
60
|
+
getSwapTransaction(params: {
|
|
61
|
+
swapResponse: RaydiumQuoteResponse;
|
|
62
|
+
wallet: string;
|
|
63
|
+
txVersion: 'V0' | 'LEGACY';
|
|
64
|
+
wrapSol?: boolean;
|
|
65
|
+
unwrapSol?: boolean;
|
|
66
|
+
inputAccount?: string;
|
|
67
|
+
outputAccount?: string;
|
|
68
|
+
computeUnitPriceMicroLamports?: string;
|
|
69
|
+
}): Promise<{
|
|
70
|
+
id: string;
|
|
71
|
+
version: string;
|
|
72
|
+
success: boolean;
|
|
73
|
+
data: {
|
|
74
|
+
transaction: string;
|
|
75
|
+
}[];
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=raydium.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raydium.d.ts","sourceRoot":"","sources":["../../../../src/utils/quote/raydium.ts"],"names":[],"mappings":"AAQA,KAAK,kBAAkB,GAAG;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,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AO,CAAC;QAClB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,6BAA6B,CAAC,EAAE,MAAM,CAAC;KACxC,GAAG,OAAO,CAAC;QACV,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE;YAAE,WAAW,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KACjC,CAAC;CA+BH"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TokenSearchParams, TokenSearchResponse } from '../../types/token-list.js';
|
|
2
|
+
/**
|
|
3
|
+
* getTokenList
|
|
4
|
+
*
|
|
5
|
+
* High-level SDK function for token discovery.
|
|
6
|
+
* Supports cancellation via AbortController.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { getTokenList } from "@shogun/sdk";
|
|
11
|
+
*
|
|
12
|
+
* const controller = new AbortController();
|
|
13
|
+
* const res = await getTokenList({ q: "usdc", networkId: 8453, signal: controller.signal });
|
|
14
|
+
*
|
|
15
|
+
* To cancel:
|
|
16
|
+
* controller.abort();
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function getTokenList(params: TokenSearchParams): Promise<TokenSearchResponse>;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/tokens/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAExF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAiB1F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shogun-sdk/intents-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shogun Network Intent-based cross-chain swaps SDK",
|
|
6
6
|
"author": "Shogun network",
|
|
@@ -48,26 +48,27 @@
|
|
|
48
48
|
"typescript": "5.8.2"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@coral-xyz/anchor": "
|
|
52
|
-
"@jup-ag/api": "
|
|
53
|
-
"@mysten/bcs": "
|
|
54
|
-
"@mysten/sui": "
|
|
55
|
-
"@paraswap/sdk": "
|
|
56
|
-
"@
|
|
57
|
-
"@solana/
|
|
58
|
-
"@solana/
|
|
59
|
-
"@solana/
|
|
60
|
-
"@solana/
|
|
61
|
-
"@solana/
|
|
62
|
-
"@solana/
|
|
51
|
+
"@coral-xyz/anchor": "0.31.1",
|
|
52
|
+
"@jup-ag/api": "6.0.44",
|
|
53
|
+
"@mysten/bcs": "1.8.0",
|
|
54
|
+
"@mysten/sui": "1.29.1",
|
|
55
|
+
"@paraswap/sdk": "7.3.1",
|
|
56
|
+
"@raydium-io/raydium-sdk-v2": "0.2.29-alpha",
|
|
57
|
+
"@solana/accounts": "3.0.3",
|
|
58
|
+
"@solana/addresses": "3.0.3",
|
|
59
|
+
"@solana/codecs": "3.0.3",
|
|
60
|
+
"@solana/errors": "3.0.3",
|
|
61
|
+
"@solana/instructions": "3.0.3",
|
|
62
|
+
"@solana/programs": "3.0.3",
|
|
63
|
+
"@solana/signers": "3.0.3",
|
|
63
64
|
"@solana/web3.js": "1.98.2",
|
|
64
|
-
"@uniswap/permit2-sdk": "
|
|
65
|
-
"aftermath-ts-sdk": "
|
|
66
|
-
"bn.js": "
|
|
65
|
+
"@uniswap/permit2-sdk": "1.4.0",
|
|
66
|
+
"aftermath-ts-sdk": "1.3.14",
|
|
67
|
+
"bn.js": "5.2.2",
|
|
67
68
|
"dayjs": "1.11.13",
|
|
68
69
|
"ethers": "6.13.5",
|
|
69
|
-
"js-sha3": "
|
|
70
|
-
"solana": "
|
|
70
|
+
"js-sha3": "0.9.3",
|
|
71
|
+
"solana": "3.0.0",
|
|
71
72
|
"viem": "2.31.0"
|
|
72
73
|
},
|
|
73
74
|
"scripts": {
|
package/src/constants.ts
CHANGED
|
@@ -25,7 +25,7 @@ export const PROD_CROSS_CHAIN_GUARD_ADDRESSES: Record<SupportedChain, SolanaAddr
|
|
|
25
25
|
[ChainID.Hyperliquid]: '0xd493dc28466b42b408aed664c2af8bf81c32a7a8' as EvmAddress,
|
|
26
26
|
[ChainID.Solana]:
|
|
27
27
|
'AiTqNSZe6Nxs2myiUX1cP6YfiER3v2pWuMYMSLYcrpyo' as SolanaAddress<'AiTqNSZe6Nxs2myiUX1cP6YfiER3v2pWuMYMSLYcrpyo'>,
|
|
28
|
-
[ChainID.Sui]: '
|
|
28
|
+
[ChainID.Sui]: '0x70d005df81d0fd7f7a7aaf87fa8676bff427f7202897b373bbf3d5bf0a8792de',
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// Test guard addresses
|
|
@@ -36,7 +36,7 @@ export const TEST_CROSS_CHAIN_GUARD_ADDRESSES: Record<SupportedChain, SolanaAddr
|
|
|
36
36
|
[ChainID.Hyperliquid]: '0x8eb7cee346aa7509804cec5c6dc34c94de586bba' as EvmAddress,
|
|
37
37
|
[ChainID.Solana]:
|
|
38
38
|
'97XuksD34dyU3qyPDNwQ8qfPw1zHoUa7xVxBVdojSJ7E' as SolanaAddress<'97XuksD34dyU3qyPDNwQ8qfPw1zHoUa7xVxBVdojSJ7E'>,
|
|
39
|
-
[ChainID.Sui]: '
|
|
39
|
+
[ChainID.Sui]: '0x47f2934f621483bc485feeb78972dd2fb25840074e296fffb9e64f9bde6d2ff1',
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
// Prod guard addresses
|
|
@@ -111,8 +111,8 @@ export const SOLANA_USDC_MINT = {
|
|
|
111
111
|
|
|
112
112
|
export const SOLANA_MINT_TOKEN = SOLANA_USDC_MINT;
|
|
113
113
|
|
|
114
|
-
export const PROD_SUI_PACKAGE_ID = '
|
|
115
|
-
export const TEST_SUI_PACKAGE_ID = '
|
|
114
|
+
export const PROD_SUI_PACKAGE_ID = '0x2c9b6a7a018f2f02663a1b2247e7e53d0bf832b30ab9534c49699a78a2f659f2'// '0x9c0c9b7f5ddf7efbde76571783ef4a8a26b36ae5c2ef2eeba8fbc604a29cb195';
|
|
115
|
+
export const TEST_SUI_PACKAGE_ID = '0x2c9b6a7a018f2f02663a1b2247e7e53d0bf832b30ab9534c49699a78a2f659f2';
|
|
116
116
|
export const SUI_PACKAGE_ID = useProdConfig ? PROD_SUI_PACKAGE_ID : TEST_SUI_PACKAGE_ID;
|
|
117
117
|
|
|
118
118
|
export const SUI_GUARD_COLLATERAL_TYPE =
|
|
@@ -149,3 +149,5 @@ export function isNativeEvmToken(tokenAddress: string): boolean {
|
|
|
149
149
|
|
|
150
150
|
return NATIVE_EVM_ETH_ADDRESSES.some((addr) => addr.toLowerCase() === normalizedAddress);
|
|
151
151
|
}
|
|
152
|
+
|
|
153
|
+
export const TOKEN_SEARCH_API_BASE_URL = 'https://token-search-api.vercel.app';
|
|
@@ -5,6 +5,8 @@ import type { CrossChainOrder } from '../orders/cross-chain.js';
|
|
|
5
5
|
import type { DcaSingleChainOrder } from '../orders/dca-single-chain.js';
|
|
6
6
|
import type { ExtraTransfer } from '../orders/common.js';
|
|
7
7
|
import { getEVMCrossChainOrderTypedData, getEVMSingleChainOrderTypedData, getEVMDcaSingleChainOrderTypedData } from './order-signature.js';
|
|
8
|
+
import { generateExecutionDetailsHash } from '../../utils/generate-execution-details-hash.js';
|
|
9
|
+
import { Parsers } from '../../utils/parsers.js';
|
|
8
10
|
|
|
9
11
|
export type CreateEvmSingleChainLimitOrderIntentParams = {
|
|
10
12
|
user: `0x${string}`;
|
|
@@ -132,16 +134,21 @@ export function createEvmSingleChainDcaOrderIntentRequest(
|
|
|
132
134
|
export function createEvmCrossChainOrderIntentRequest(
|
|
133
135
|
params: CreateEvmCrossChainOrderIntentParams
|
|
134
136
|
): CrossChainUserIntentRequest {
|
|
135
|
-
const executionDetails =
|
|
137
|
+
const executionDetails = {
|
|
136
138
|
destChainId: params.destinationChainId,
|
|
137
139
|
tokenOut: params.destinationTokenAddress,
|
|
138
|
-
amountOutMin: params.destinationTokenMinAmount ||
|
|
140
|
+
amountOutMin: params.destinationTokenMinAmount?.toString() || '1',
|
|
139
141
|
destinationAddress: params.destinationAddress,
|
|
140
142
|
extraTransfers: params.extraTransfers,
|
|
141
|
-
|
|
143
|
+
stopLossMaxOut: params.stopLossMaxOut?.toString(),
|
|
144
|
+
takeProfitMinOut: params.takeProfitMinOut?.toString(),
|
|
145
|
+
};
|
|
146
|
+
const executionDetailsString = JSON.stringify(executionDetails, Parsers.bigIntReplacer);
|
|
142
147
|
|
|
143
148
|
// Calculate execution details hash
|
|
144
|
-
const executionDetailsHash =
|
|
149
|
+
const executionDetailsHash = generateExecutionDetailsHash(
|
|
150
|
+
executionDetails
|
|
151
|
+
);
|
|
145
152
|
|
|
146
153
|
const genericData = {
|
|
147
154
|
user: params.user,
|
|
@@ -150,7 +157,7 @@ export function createEvmCrossChainOrderIntentRequest(
|
|
|
150
157
|
amountIn: params.sourceTokenAmount,
|
|
151
158
|
minStablecoinsAmount: params.minStablecoinAmount || 1n,
|
|
152
159
|
deadline: params.deadline,
|
|
153
|
-
executionDetailsHash
|
|
160
|
+
executionDetailsHash: executionDetailsHash as `0x${string}`,
|
|
154
161
|
extraTransfers: params.extraTransfers,
|
|
155
162
|
stopLossMaxOut: params.stopLossMaxOut,
|
|
156
163
|
takeProfitMinOut: params.takeProfitMinOut,
|
|
@@ -158,7 +165,7 @@ export function createEvmCrossChainOrderIntentRequest(
|
|
|
158
165
|
|
|
159
166
|
return {
|
|
160
167
|
genericData,
|
|
161
|
-
executionDetails,
|
|
168
|
+
executionDetails: executionDetailsString,
|
|
162
169
|
chainSpecificData: {
|
|
163
170
|
EVM: {
|
|
164
171
|
nonce: params.nonce || String(Math.floor(Math.random() * 10000000)),
|
|
@@ -259,14 +259,6 @@ export class CrossChainOrder {
|
|
|
259
259
|
extraTransfers: this.extraTransfers,
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
-
if (this.stopLossMaxOut !== undefined) {
|
|
263
|
-
data.stopLossMaxOut = this.stopLossMaxOut;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (this.takeProfitMinOut !== undefined) {
|
|
267
|
-
data.takeProfitMinOut = this.takeProfitMinOut;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
262
|
return data;
|
|
271
263
|
}
|
|
272
264
|
|
|
@@ -289,8 +281,6 @@ export class CrossChainOrder {
|
|
|
289
281
|
deadline: this.deadline,
|
|
290
282
|
executionDetailsHash: this.getExecutionDetailsHash(),
|
|
291
283
|
extraTransfers: this.extraTransfers,
|
|
292
|
-
stopLossMaxOut: this.stopLossMaxOut,
|
|
293
|
-
takeProfitMinOut: this.takeProfitMinOut,
|
|
294
284
|
};
|
|
295
285
|
}
|
|
296
286
|
|
|
@@ -8,6 +8,8 @@ import { getSolanaCrossChainOrderInstructions, getSolanaSingleChainOrderInstruct
|
|
|
8
8
|
import { getSolanaDcaSingleChainOrderInstructions } from './dca/create-order.js';
|
|
9
9
|
import { prepareDcaSecretData } from './dca/single-chain-dca-order.js';
|
|
10
10
|
import { prepareSecretData } from './dca/single-chain-limit-order.js';
|
|
11
|
+
import { generateExecutionDetailsHash } from '../../utils/generate-execution-details-hash.js';
|
|
12
|
+
import { Parsers } from '../../utils/parsers.js';
|
|
11
13
|
|
|
12
14
|
export type CreateSolanaSingleChainLimitOrderIntentParams = {
|
|
13
15
|
user: string;
|
|
@@ -136,16 +138,19 @@ export function createSolanaSingleChainDcaOrderIntentRequest(
|
|
|
136
138
|
export function createSolanaCrossChainOrderIntentRequest(
|
|
137
139
|
params: CreateSolanaCrossChainOrderIntentParams
|
|
138
140
|
): CrossChainUserIntentRequest {
|
|
139
|
-
const executionDetails =
|
|
141
|
+
const executionDetails = {
|
|
140
142
|
destChainId: params.destinationChainId,
|
|
141
143
|
tokenOut: params.destinationTokenAddress,
|
|
142
|
-
amountOutMin: params.destinationTokenMinAmount ||
|
|
144
|
+
amountOutMin: params.destinationTokenMinAmount?.toString() || '1',
|
|
143
145
|
destinationAddress: params.destinationAddress,
|
|
144
146
|
extraTransfers: params.extraTransfers,
|
|
145
|
-
|
|
147
|
+
stopLossMaxOut: params.stopLossMaxOut?.toString(),
|
|
148
|
+
takeProfitMinOut: params.takeProfitMinOut?.toString()
|
|
149
|
+
}
|
|
150
|
+
const executionDetailsString = JSON.stringify(executionDetails, Parsers.bigIntReplacer);
|
|
146
151
|
|
|
147
152
|
// Calculate execution details hash
|
|
148
|
-
const executionDetailsHash =
|
|
153
|
+
const executionDetailsHash = generateExecutionDetailsHash(executionDetails);
|
|
149
154
|
|
|
150
155
|
const genericData = {
|
|
151
156
|
user: params.user,
|
|
@@ -154,15 +159,13 @@ export function createSolanaCrossChainOrderIntentRequest(
|
|
|
154
159
|
amountIn: params.sourceTokenAmount,
|
|
155
160
|
minStablecoinsAmount: params.minStablecoinAmount || 1n,
|
|
156
161
|
deadline: params.deadline,
|
|
157
|
-
executionDetailsHash
|
|
162
|
+
executionDetailsHash: executionDetailsHash as `0x${string}`,
|
|
158
163
|
extraTransfers: params.extraTransfers,
|
|
159
|
-
stopLossMaxOut: params.stopLossMaxOut,
|
|
160
|
-
takeProfitMinOut: params.takeProfitMinOut,
|
|
161
164
|
};
|
|
162
165
|
|
|
163
166
|
return {
|
|
164
167
|
genericData,
|
|
165
|
-
executionDetails,
|
|
168
|
+
executionDetails: executionDetailsString,
|
|
166
169
|
chainSpecificData: {
|
|
167
170
|
Solana: {
|
|
168
171
|
orderPubkey: params.orderPubkey || 'DFNAjFAvS4GF98Tp1kiyLvEHM3wjGXibCfF86nnmhuVc',
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { createHash } from "crypto";
|
|
2
|
-
import type { Hex } from "viem";
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Generates random U64 number
|
|
6
3
|
*/
|
|
@@ -10,25 +7,3 @@ export function getRandomU64Number() {
|
|
|
10
7
|
.join("")).toString();
|
|
11
8
|
}
|
|
12
9
|
|
|
13
|
-
/**
|
|
14
|
-
* Generate execution details hash for cross-chain orders
|
|
15
|
-
* @param destChainId Destination chain ID
|
|
16
|
-
* @param destinationAddress Destination address on target chain
|
|
17
|
-
* @param tokenOut Token address on destination chain
|
|
18
|
-
* @param amountOutMin Minimum amount out
|
|
19
|
-
*/
|
|
20
|
-
export function generateExecutionDetailsHash(
|
|
21
|
-
destChainId: number,
|
|
22
|
-
destinationAddress: string,
|
|
23
|
-
tokenOut: string,
|
|
24
|
-
amountOutMin: string,
|
|
25
|
-
): Hex {
|
|
26
|
-
const executionDetails = JSON.stringify({
|
|
27
|
-
destChainId,
|
|
28
|
-
destinationAddress,
|
|
29
|
-
tokenOut,
|
|
30
|
-
amountOutMin,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return ("0x" + createHash('sha256').update(executionDetails).digest('hex')) as `0x${string}`;
|
|
34
|
-
}
|
|
@@ -5,7 +5,8 @@ import type { DcaSingleChainOrder } from '../orders/dca-single-chain.js';
|
|
|
5
5
|
import type { ExtraTransfer } from '../orders/common.js';
|
|
6
6
|
import { getSecretHash, getRandomU64Number } from './single-chain-limit-order.js';
|
|
7
7
|
import { getDcaSecretHash } from './single-chain-dca-order.js';
|
|
8
|
-
import { generateExecutionDetailsHash } from '
|
|
8
|
+
import { generateExecutionDetailsHash } from '../../utils/generate-execution-details-hash.js';
|
|
9
|
+
import { Parsers } from '../../utils/parsers.js';
|
|
9
10
|
|
|
10
11
|
export type CreateSuiSingleChainLimitOrderIntentParams = {
|
|
11
12
|
user: string;
|
|
@@ -52,6 +53,7 @@ export type CreateSuiCrossChainOrderIntentParams = {
|
|
|
52
53
|
transactionHash: string;
|
|
53
54
|
stopLossMaxOut?: bigint;
|
|
54
55
|
takeProfitMinOut?: bigint;
|
|
56
|
+
extraTransfers?: ExtraTransfer[];
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
/**
|
|
@@ -133,19 +135,19 @@ export function createSuiSingleChainDcaOrderIntentRequest(
|
|
|
133
135
|
export function createSuiCrossChainOrderIntentRequest(
|
|
134
136
|
params: CreateSuiCrossChainOrderIntentParams
|
|
135
137
|
): CrossChainUserIntentRequest {
|
|
136
|
-
|
|
138
|
+
|
|
139
|
+
const executionDetails = {
|
|
137
140
|
destChainId: params.destChainId,
|
|
138
141
|
tokenOut: params.tokenOut,
|
|
139
|
-
amountOutMin: params.amountOutMin,
|
|
142
|
+
amountOutMin: params.amountOutMin.toString(),
|
|
140
143
|
destinationAddress: params.destinationAddress,
|
|
141
|
-
|
|
144
|
+
stopLossMaxOut: params.stopLossMaxOut?.toString(),
|
|
145
|
+
takeProfitMinOut: params.takeProfitMinOut?.toString(),
|
|
146
|
+
extraTransfers: params.extraTransfers,
|
|
147
|
+
};
|
|
148
|
+
const executionDetailsString = JSON.stringify(executionDetails, Parsers.bigIntReplacer);
|
|
142
149
|
|
|
143
|
-
const executionDetailsHash = generateExecutionDetailsHash(
|
|
144
|
-
params.destChainId,
|
|
145
|
-
params.destinationAddress,
|
|
146
|
-
params.tokenOut,
|
|
147
|
-
params.amountOutMin.toString()
|
|
148
|
-
);
|
|
150
|
+
const executionDetailsHash = generateExecutionDetailsHash(executionDetails);
|
|
149
151
|
|
|
150
152
|
const genericData = {
|
|
151
153
|
user: params.user,
|
|
@@ -155,13 +157,12 @@ export function createSuiCrossChainOrderIntentRequest(
|
|
|
155
157
|
minStablecoinsAmount: params.minStablecoinsAmount,
|
|
156
158
|
deadline: params.deadline,
|
|
157
159
|
executionDetailsHash: executionDetailsHash as `0x${string}`,
|
|
158
|
-
|
|
159
|
-
takeProfitMinOut: params.takeProfitMinOut,
|
|
160
|
+
extraTransfers: params.extraTransfers,
|
|
160
161
|
};
|
|
161
162
|
|
|
162
163
|
return {
|
|
163
164
|
genericData,
|
|
164
|
-
executionDetails,
|
|
165
|
+
executionDetails: executionDetailsString,
|
|
165
166
|
chainSpecificData: {
|
|
166
167
|
Sui: {
|
|
167
168
|
transactionHash: params.transactionHash,
|
package/src/index.ts
CHANGED
|
@@ -50,8 +50,12 @@ export {
|
|
|
50
50
|
export { getSuiOrderTransaction } from './core/sui/order-transaction.js';
|
|
51
51
|
export { getSuiCancelCrossChainOrder } from './core/sui/cancel.js';
|
|
52
52
|
export { getDcaSecretHash, getSuiSingleChainDcaOrderTransaction } from './core/sui/single-chain-dca-order.js';
|
|
53
|
-
export {
|
|
54
|
-
|
|
53
|
+
export {
|
|
54
|
+
getSecretHash,
|
|
55
|
+
getRandomU64Number as getSuiRandomU64Number,
|
|
56
|
+
getSuiSingleChainLimitOrderTransaction,
|
|
57
|
+
} from './core/sui/single-chain-limit-order.js';
|
|
58
|
+
export { generateExecutionDetailsHash } from './utils/generate-execution-details-hash.js';
|
|
55
59
|
export {
|
|
56
60
|
createSuiSingleChainLimitOrderIntentRequest,
|
|
57
61
|
createSuiSingleChainDcaOrderIntentRequest,
|
|
@@ -63,20 +67,23 @@ export {
|
|
|
63
67
|
type CreateSuiCrossChainOrderIntentParams,
|
|
64
68
|
} from './core/sui/intent-helpers.js';
|
|
65
69
|
|
|
66
|
-
export * from './constants.js'
|
|
70
|
+
export * from './constants.js';
|
|
67
71
|
|
|
68
72
|
export { getSolanaDcaSingleChainOrderInstructions } from './core/solana/dca/create-order.js';
|
|
69
73
|
|
|
70
74
|
export { signSingleChainDcaOrder } from './core/evm/single-chain-dca-order.js';
|
|
71
75
|
export { signSingleChainLimitOrder } from './core/evm/single-chain-limit-order.js';
|
|
72
76
|
|
|
73
|
-
export { QuoteProvider } from './utils/quote/aggregator.js';
|
|
74
|
-
export type { QuoteResponse } from './utils/quote/aggregator.js';
|
|
77
|
+
export { QuoteProvider, type IntentsQuoteParams, type QuoteResponse } from './utils/quote/aggregator.js';
|
|
75
78
|
|
|
76
79
|
export { CROSS_CHAIN_GUARD_ADDRESSES, SINGLE_CHAIN_GUARD_ADDRESSES, PERMIT2_ADDRESS } from './constants.js';
|
|
77
80
|
|
|
78
|
-
export { prepareDcaSecretData
|
|
79
|
-
export { prepareSecretData } from './core/solana/dca/single-chain-limit-order.js'
|
|
81
|
+
export { prepareDcaSecretData } from './core/solana/dca/single-chain-dca-order.js';
|
|
82
|
+
export { prepareSecretData } from './core/solana/dca/single-chain-limit-order.js';
|
|
83
|
+
|
|
84
|
+
// Token List and Search Helper
|
|
85
|
+
export { getTokenList } from './utils/tokens/index.js';
|
|
86
|
+
export { type TokenSearchParams, type TokenInfo, type TokenSearchResponse } from './types/token-list.js';
|
|
80
87
|
|
|
81
88
|
// EVM Intent Helpers
|
|
82
89
|
export {
|
package/src/types/intent.ts
CHANGED
|
@@ -19,6 +19,9 @@ export type ExecutionDetails = {
|
|
|
19
19
|
destinationAddress: string;
|
|
20
20
|
/** Extra transfers to be made */
|
|
21
21
|
extraTransfers?: ExtraTransfer[];
|
|
22
|
+
|
|
23
|
+
stopLossMaxOut?: bigint;
|
|
24
|
+
takeProfitMinOut?: bigint;
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
export type Hash = `0x${string}`;
|
|
@@ -65,8 +68,6 @@ export type SourceChainData = {
|
|
|
65
68
|
deadline: number;
|
|
66
69
|
/** Hash of execution details for cross-chain verification */
|
|
67
70
|
executionDetailsHash: ExecutionDetailsHash;
|
|
68
|
-
stopLossMaxOut?: bigint;
|
|
69
|
-
takeProfitMinOut?: bigint;
|
|
70
71
|
extraTransfers?: ExtraTransfer[];
|
|
71
72
|
};
|
|
72
73
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface TokenSearchParams {
|
|
2
|
+
/** Optional: search phrase (symbol, token name, or address) */
|
|
3
|
+
q?: string;
|
|
4
|
+
|
|
5
|
+
/** Optional: Chain ID filter (e.g. 8453 = Base, 42161 = Arbitrum, 7565164 = Solana, 101 = Sui) */
|
|
6
|
+
networkId?: number;
|
|
7
|
+
|
|
8
|
+
/** Optional: page number for pagination (default = 1) */
|
|
9
|
+
page?: number;
|
|
10
|
+
|
|
11
|
+
/** Optional: number of results per page (default = 20) */
|
|
12
|
+
limit?: number;
|
|
13
|
+
|
|
14
|
+
/** Optional: Abort signal to cancel requests (useful in UI search inputs) */
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Normalized token shape returned by the API */
|
|
19
|
+
export interface TokenInfo {
|
|
20
|
+
address: string;
|
|
21
|
+
symbol: string;
|
|
22
|
+
name: string;
|
|
23
|
+
chainId: number;
|
|
24
|
+
decimals: number;
|
|
25
|
+
image: string;
|
|
26
|
+
isVerified: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Paginated API response */
|
|
30
|
+
export interface TokenSearchResponse {
|
|
31
|
+
count: number;
|
|
32
|
+
page: number;
|
|
33
|
+
limit: number;
|
|
34
|
+
results: TokenInfo[];
|
|
35
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createHash } from "crypto";
|
|
2
|
+
import type { ExtraTransfer } from "../core/orders/common.js";
|
|
3
|
+
import { Parsers } from "./parsers.js";
|
|
4
|
+
|
|
5
|
+
export function generateExecutionDetailsHash({
|
|
6
|
+
destChainId,
|
|
7
|
+
destinationAddress,
|
|
8
|
+
tokenOut,
|
|
9
|
+
amountOutMin,
|
|
10
|
+
stopLossMaxOut,
|
|
11
|
+
takeProfitMinOut,
|
|
12
|
+
extraTransfers,
|
|
13
|
+
}: {
|
|
14
|
+
destChainId: number,
|
|
15
|
+
destinationAddress: string,
|
|
16
|
+
tokenOut: string,
|
|
17
|
+
amountOutMin: string,
|
|
18
|
+
stopLossMaxOut?: string,
|
|
19
|
+
takeProfitMinOut?: string,
|
|
20
|
+
extraTransfers?: ExtraTransfer[],
|
|
21
|
+
}
|
|
22
|
+
): string {
|
|
23
|
+
const executionDetails = JSON.stringify({
|
|
24
|
+
destChainId,
|
|
25
|
+
destinationAddress,
|
|
26
|
+
tokenOut,
|
|
27
|
+
amountOutMin,
|
|
28
|
+
stopLossMaxOut,
|
|
29
|
+
takeProfitMinOut,
|
|
30
|
+
extraTransfers,
|
|
31
|
+
}, Parsers.bigIntReplacer);
|
|
32
|
+
|
|
33
|
+
return "0x" + createHash('sha256').update(executionDetails).digest('hex');
|
|
34
|
+
}
|