@shogun-sdk/intents-sdk 1.2.6-test.14 → 1.2.6-test.16
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/index.cjs +277 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +109 -22
- package/dist/index.d.ts +109 -22
- package/dist/index.js +277 -99
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- package/src/auth/siwe.ts +10 -11
- package/src/constants.ts +32 -8
- package/src/core/evm/intent-helpers.ts +131 -8
- package/src/core/evm/intent-provider.ts +5 -4
- package/src/core/evm/permit2.ts +36 -0
- package/src/core/orders/api/fetch.ts +12 -39
- package/src/core/orders/cross-chain.ts +3 -0
- package/src/core/orders/single-chain.ts +21 -8
- package/src/core/sdk.ts +12 -6
- package/src/core/solana/intent-helpers.ts +6 -4
- package/src/core/sui/intent-helpers.ts +4 -1
- package/src/index.ts +4 -0
- package/src/types/api.ts +14 -3
- package/src/types/intent.ts +36 -2
- package/src/utils/base-validator.ts +0 -4
- package/src/utils/generate-execution-details-hash.ts +9 -32
- package/src/utils/quote/address.ts +4 -0
- package/src/utils/quote/aggregator.ts +29 -9
- package/src/utils/quote/pricing/constants.ts +33 -0
- package/src/utils/quote/pricing/decimals.ts +11 -0
- package/src/utils/quote/pricing/estimate-amount-out.ts +36 -0
- package/src/utils/quote/pricing/expenses.ts +62 -0
- package/src/utils/quote/pricing/gas.ts +28 -0
package/dist/index.d.cts
CHANGED
|
@@ -93,6 +93,7 @@ declare const TEST_DCA_SINGLE_CHAIN_GUARD_ADDRESSES: Record<SupportedEvmChain, A
|
|
|
93
93
|
declare const CROSS_CHAIN_GUARD_ADDRESSES: Record<SupportedChain, `0x${string}` | Address>;
|
|
94
94
|
declare const SINGLE_CHAIN_GUARD_ADDRESSES: Record<ChainID.Arbitrum | ChainID.Optimism | ChainID.Base | ChainID.Hyperliquid | ChainID.Solana | ChainID.BSC | ChainID.MONAD, `0x${string}` | Address>;
|
|
95
95
|
declare const DCA_SINGLE_CHAIN_GUARD_ADDRESSES: Record<SupportedEvmChain, `0x${string}`>;
|
|
96
|
+
declare const DCA_CROSS_CHAIN_GUARD_ADDRESSES: Record<SupportedEvmChain, `0x${string}`>;
|
|
96
97
|
declare const NATIVE_SOLANA_TOKEN_ADDRESS: Address<"So11111111111111111111111111111111111111111">;
|
|
97
98
|
declare const WRAPPED_SOL_MINT_ADDRESS: Address<"So11111111111111111111111111111111111111112">;
|
|
98
99
|
type SolanaMint = {
|
|
@@ -116,8 +117,18 @@ declare const NATIVE_EVM_ETH_ADDRESSES: string[];
|
|
|
116
117
|
declare const WRAPPED_ETH_ADDRESSES: Record<SupportedEvmChain, Address$1>;
|
|
117
118
|
declare const NATIVE_SUI_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
118
119
|
declare function isNativeEvmToken(tokenAddress: string): boolean;
|
|
120
|
+
declare const EVM_ZERO_ADDRESS: Address$1;
|
|
121
|
+
/** Placeholder signature (32 zero bytes) for unsigned/validate-only intent requests. */
|
|
122
|
+
declare const EVM_ZERO_SIGNATURE = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
123
|
+
/**
|
|
124
|
+
* Output-token addresses must be normalized to the zero address before signing the EIP-712
|
|
125
|
+
* witness: the auctioneer collapses any native sentinel (`0xeee…`/`0x0…`) to `Address::default()`
|
|
126
|
+
* when it reconstructs `requestedOutput`/`extraTransfers` to recover the signer. Signing the raw
|
|
127
|
+
* sentinel instead would yield a different hash → signature recovery fails. (`tokenIn` is NOT
|
|
128
|
+
* normalized on either side, so leave it untouched.)
|
|
129
|
+
*/
|
|
130
|
+
declare function normalizeNativeEvmTokenForSigning(tokenAddress: string): string;
|
|
119
131
|
declare const TOKEN_SEARCH_API_BASE_URL = "https://shogun-token-search-api-825534211396.europe-west4.run.app";
|
|
120
|
-
declare const DEV_ACCESS_KEY: string | null;
|
|
121
132
|
|
|
122
133
|
type StopLossType = 'FIXED' | 'TRAILING_ABSOLUTE' | 'TRAILING_PERCENT';
|
|
123
134
|
type ExtraTransfer$1 = {
|
|
@@ -129,7 +140,7 @@ type ExtraTransfer$1 = {
|
|
|
129
140
|
amount: bigint;
|
|
130
141
|
};
|
|
131
142
|
|
|
132
|
-
type ChainOrderStatus = 'Auction' | 'NoBids' | 'Executing' | 'Fulfilled' | 'Cancelled' | 'Outdated';
|
|
143
|
+
type ChainOrderStatus = 'Auction' | 'NoBids' | 'Executing' | 'Fulfilled' | 'Cancelled' | 'Outdated' | 'DcaIntervalFulfilled';
|
|
133
144
|
type ApiCrossChainOrder = {
|
|
134
145
|
orderId: string;
|
|
135
146
|
user: string;
|
|
@@ -182,8 +193,12 @@ type ApiUserOrders = {
|
|
|
182
193
|
interface ApiIntentResponse {
|
|
183
194
|
/** Unique identifier for the created intent */
|
|
184
195
|
intentId: string;
|
|
185
|
-
/**
|
|
186
|
-
|
|
196
|
+
/**
|
|
197
|
+
* JWT token used for authorization or subsequent requests.
|
|
198
|
+
* Optional: order-creation responses only return `intentId`; obtain a JWT via the
|
|
199
|
+
* SIWE flow (`EVMSDK.authenticate()` / `fetchJWTToken`) instead.
|
|
200
|
+
*/
|
|
201
|
+
jwt?: string;
|
|
187
202
|
}
|
|
188
203
|
type ValidResponseData = ApiUserOrders | string | ApiIntentResponse | null;
|
|
189
204
|
type ApiResponse<T extends ValidResponseData = ValidResponseData> = {
|
|
@@ -262,7 +277,11 @@ type ExecutionDetails = {
|
|
|
262
277
|
destinationAddress: string;
|
|
263
278
|
/** Extra transfers to be made */
|
|
264
279
|
extraTransfers?: ExtraTransfer$1[];
|
|
265
|
-
|
|
280
|
+
/** Stop loss type, must match the auctioneer's `stopLossType` field */
|
|
281
|
+
stopLossType?: StopLossType;
|
|
282
|
+
/** Initial trigger price (tokenIn/tokenOut) that arms the stop loss */
|
|
283
|
+
stopLossTriggerPrice?: string;
|
|
284
|
+
/** Take profit minimum amount out */
|
|
266
285
|
takeProfitMinOut?: bigint;
|
|
267
286
|
};
|
|
268
287
|
type Hash = `0x${string}`;
|
|
@@ -330,6 +349,34 @@ type SingleChainUserIntentRequest = {
|
|
|
330
349
|
Sui?: SuiPreparedData;
|
|
331
350
|
};
|
|
332
351
|
};
|
|
352
|
+
/**
|
|
353
|
+
* Source chain data for a cross-chain DCA order. Mirrors the auctioneer's
|
|
354
|
+
* `CrossChainDcaOrderGenericRequestData` (common cross-chain fields + flattened
|
|
355
|
+
* `CommonDcaOrderData`). The destination fields live in `executionDetails`.
|
|
356
|
+
*/
|
|
357
|
+
type DcaCrossChainSourceChainData = {
|
|
358
|
+
user: string;
|
|
359
|
+
srcChainId: SupportedChain;
|
|
360
|
+
tokenIn: string;
|
|
361
|
+
minStablecoinsAmount: bigint;
|
|
362
|
+
deadline: number;
|
|
363
|
+
executionDetailsHash: ExecutionDetailsHash;
|
|
364
|
+
/** Flattened CommonDcaOrderData */
|
|
365
|
+
startTime: number;
|
|
366
|
+
amountInPerInterval: bigint;
|
|
367
|
+
totalIntervals: number;
|
|
368
|
+
intervalDuration: number;
|
|
369
|
+
};
|
|
370
|
+
type DcaCrossChainUserIntentRequest = {
|
|
371
|
+
genericData: DcaCrossChainSourceChainData;
|
|
372
|
+
/** JSON-stringified execution details for the destination chain */
|
|
373
|
+
executionDetails: string;
|
|
374
|
+
chainSpecificData: {
|
|
375
|
+
EVM?: DcaSingleChainEVMPreparedData;
|
|
376
|
+
Solana?: DcaSingleChainSolanaPreparedData;
|
|
377
|
+
Sui?: DcaSingleChainSuiPreparedData;
|
|
378
|
+
};
|
|
379
|
+
};
|
|
333
380
|
type ChainPreparedData = EvmPreparedData | SuiPreparedData | SolanaPreparedData;
|
|
334
381
|
type CrossChainOrderPrepared = {
|
|
335
382
|
order: CrossChainOrder;
|
|
@@ -596,6 +643,8 @@ declare abstract class BaseSDK {
|
|
|
596
643
|
createAndSendDcaSingleChainOrder(params: CreateDcaSingleChainOrderParams): Promise<ApiResponse>;
|
|
597
644
|
static sendDcaSingleChainOrder(preparedOrder: DcaSingleChainOrderPrepared): Promise<ApiResponse>;
|
|
598
645
|
static validateDcaSingleChainOrder(intentRequest: DcaSingleChainUserIntentRequest): Promise<void>;
|
|
646
|
+
static validateDcaCrossChainOrder(intentRequest: DcaCrossChainUserIntentRequest): Promise<void>;
|
|
647
|
+
static sendDcaCrossChainOrder(intentRequest: DcaCrossChainUserIntentRequest): Promise<ApiResponse>;
|
|
599
648
|
}
|
|
600
649
|
|
|
601
650
|
type CancelSingleChainOrderParams$1 = {
|
|
@@ -773,10 +822,14 @@ declare class SuiSDK extends BaseSDK {
|
|
|
773
822
|
}
|
|
774
823
|
|
|
775
824
|
/**
|
|
776
|
-
* Fetches
|
|
777
|
-
*
|
|
825
|
+
* Fetches the orders owned by the wallets encoded in a SIWE-issued JWT.
|
|
826
|
+
*
|
|
827
|
+
* The auctioneer derives the queried wallets from the verified JWT claims, never from
|
|
828
|
+
* caller-supplied params — a caller can only read intents for wallets it proved control
|
|
829
|
+
* of via SIWE. Obtain the token with `EVMSDK.authenticate()` (or the `fetchSiweMessage` +
|
|
830
|
+
* `fetchJWTToken` pair) and pass it here.
|
|
778
831
|
*/
|
|
779
|
-
declare function fetchUserOrders(
|
|
832
|
+
declare function fetchUserOrders(aggregatedToken: string): Promise<ApiUserOrders>;
|
|
780
833
|
|
|
781
834
|
declare class AuctioneerAPI {
|
|
782
835
|
aggregatedToken: string;
|
|
@@ -972,15 +1025,15 @@ declare function getSecretHash(coinOutType: string, receiver: string, secretNumb
|
|
|
972
1025
|
*/
|
|
973
1026
|
declare function getSuiSingleChainLimitOrderTransaction(order: SingleChainOrder, secretHash: Uint8Array, guardAddress: string, client?: ReturnType<typeof createSuiClient>): Promise<Transaction>;
|
|
974
1027
|
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1028
|
+
/**
|
|
1029
|
+
* Computes the SHA-256 hash the auctioneer expects for cross-chain execution details.
|
|
1030
|
+
*
|
|
1031
|
+
* The auctioneer recomputes sha256 over the exact `executionDetails` JSON string it
|
|
1032
|
+
* receives and rejects the order when it differs (hash mismatch). Callers therefore MUST
|
|
1033
|
+
* hash the same serialized string they send on the wire — pass that string here directly
|
|
1034
|
+
* instead of re-serializing a parallel object, which is how key-order/field drift creeps in.
|
|
1035
|
+
*/
|
|
1036
|
+
declare function generateExecutionDetailsHash(executionDetails: string): string;
|
|
984
1037
|
|
|
985
1038
|
type CreateSuiSingleChainLimitOrderIntentParams = {
|
|
986
1039
|
user: string;
|
|
@@ -1390,7 +1443,7 @@ declare function createEvmCrossChainOrderIntentRequest(params: CreateEvmCrossCha
|
|
|
1390
1443
|
* @returns Object containing typed data and nonce for signing
|
|
1391
1444
|
*/
|
|
1392
1445
|
declare function generateEvmSingleChainLimitOrderTypedData(order: SingleChainOrder): Promise<{
|
|
1393
|
-
orderTypedData:
|
|
1446
|
+
orderTypedData: TypedDataDefinition;
|
|
1394
1447
|
nonce: bigint;
|
|
1395
1448
|
}>;
|
|
1396
1449
|
/**
|
|
@@ -1399,7 +1452,7 @@ declare function generateEvmSingleChainLimitOrderTypedData(order: SingleChainOrd
|
|
|
1399
1452
|
* @returns Object containing typed data and nonce for signing
|
|
1400
1453
|
*/
|
|
1401
1454
|
declare function generateEvmSingleChainDcaOrderTypedData(order: DcaSingleChainOrder): Promise<{
|
|
1402
|
-
orderTypedData:
|
|
1455
|
+
orderTypedData: TypedDataDefinition;
|
|
1403
1456
|
nonce: bigint;
|
|
1404
1457
|
}>;
|
|
1405
1458
|
/**
|
|
@@ -1408,7 +1461,7 @@ declare function generateEvmSingleChainDcaOrderTypedData(order: DcaSingleChainOr
|
|
|
1408
1461
|
* @returns Object containing typed data and nonce for signing
|
|
1409
1462
|
*/
|
|
1410
1463
|
declare function generateEvmCrossChainOrderTypedData(order: CrossChainOrder): Promise<{
|
|
1411
|
-
orderTypedData:
|
|
1464
|
+
orderTypedData: TypedDataDefinition;
|
|
1412
1465
|
nonce: bigint;
|
|
1413
1466
|
}>;
|
|
1414
1467
|
/**
|
|
@@ -1416,6 +1469,39 @@ declare function generateEvmCrossChainOrderTypedData(order: CrossChainOrder): Pr
|
|
|
1416
1469
|
* @returns Random nonce as string
|
|
1417
1470
|
*/
|
|
1418
1471
|
declare function generateEvmRandomNonce(): string;
|
|
1472
|
+
type CreateEvmCrossChainDcaOrderIntentParams = {
|
|
1473
|
+
user: `0x${string}`;
|
|
1474
|
+
sourceChainId: SupportedEvmChain;
|
|
1475
|
+
sourceTokenAddress: string;
|
|
1476
|
+
destinationChainId: number;
|
|
1477
|
+
destinationTokenAddress: string;
|
|
1478
|
+
destinationTokenMinAmount?: bigint;
|
|
1479
|
+
destinationAddress: string;
|
|
1480
|
+
minStablecoinAmount?: bigint;
|
|
1481
|
+
deadline: number;
|
|
1482
|
+
startTime: number;
|
|
1483
|
+
amountInPerInterval: bigint;
|
|
1484
|
+
totalIntervals: number;
|
|
1485
|
+
intervalDuration: number;
|
|
1486
|
+
extraTransfers?: ExtraTransfer$1[];
|
|
1487
|
+
nonce?: string;
|
|
1488
|
+
signature?: string;
|
|
1489
|
+
};
|
|
1490
|
+
/**
|
|
1491
|
+
* Creates an EVM cross-chain DCA order intent request, ready to POST to
|
|
1492
|
+
* `/user_intent/cross_chain/dca_order`. Pass `nonce`/`signature` from
|
|
1493
|
+
* {@link getEVMCrossChainDcaOrderTypedData} for an executable order.
|
|
1494
|
+
*/
|
|
1495
|
+
declare function createEvmCrossChainDcaOrderIntentRequest(params: CreateEvmCrossChainDcaOrderIntentParams): DcaCrossChainUserIntentRequest;
|
|
1496
|
+
/**
|
|
1497
|
+
* Generates the EIP-712 typed data (and nonce) for a cross-chain DCA order's Permit2 witness.
|
|
1498
|
+
* Sign `orderTypedData`, then pass the resulting `nonce`/`signature` into
|
|
1499
|
+
* {@link createEvmCrossChainDcaOrderIntentRequest} — both share the same execution-details hash.
|
|
1500
|
+
*/
|
|
1501
|
+
declare function getEVMCrossChainDcaOrderTypedData(params: CreateEvmCrossChainDcaOrderIntentParams, providedNonce?: bigint): {
|
|
1502
|
+
orderTypedData: TypedDataDefinition;
|
|
1503
|
+
nonce: bigint;
|
|
1504
|
+
};
|
|
1419
1505
|
|
|
1420
1506
|
type CreateSolanaSingleChainLimitOrderIntentParams = {
|
|
1421
1507
|
user: string;
|
|
@@ -1460,7 +1546,8 @@ type CreateSolanaCrossChainOrderIntentParams = {
|
|
|
1460
1546
|
deadline: number;
|
|
1461
1547
|
extraTransfers?: ExtraTransfer$1[];
|
|
1462
1548
|
orderPubkey?: string;
|
|
1463
|
-
|
|
1549
|
+
stopLossType?: StopLossType;
|
|
1550
|
+
stopLossTriggerPrice?: string;
|
|
1464
1551
|
takeProfitMinOut?: bigint;
|
|
1465
1552
|
};
|
|
1466
1553
|
/**
|
|
@@ -1533,4 +1620,4 @@ declare function generateSolanaDcaOrderSecretData(tokenOut: string, receiver: st
|
|
|
1533
1620
|
*/
|
|
1534
1621
|
declare function generateSolanaRandomSecretNumber(): string;
|
|
1535
1622
|
|
|
1536
|
-
export { AUCTIONEER_URL, type ApiCrossChainOrder, type ApiIntentResponse, type ApiResponse, type ApiSingleChainOrder, type ApiUserOrders, AuctioneerAPI, CROSS_CHAIN_GUARD_ADDRESSES, type CancelCrossChainOrderParams, type CancelSingleChainOrderParams, ChainID, type ChainOrderStatus, ChainType, type CreateCrossChainOrderParams, type CreateDcaSingleChainOrderParams, type CreateEvmCrossChainOrderIntentParams, type CreateEvmSingleChainDcaOrderIntentParams, type CreateEvmSingleChainLimitOrderIntentParams, type CreateSingleChainOrderParams, type CreateSolanaCrossChainOrderIntentParams, type CreateSolanaSingleChainDcaOrderIntentParams, type CreateSolanaSingleChainLimitOrderIntentParams, type CreateSuiCrossChainOrderIntentParams, type CreateSuiSingleChainDcaOrderIntentParams, type CreateSuiSingleChainLimitOrderIntentParams, CrossChainOrder,
|
|
1623
|
+
export { AUCTIONEER_URL, type ApiCrossChainOrder, type ApiIntentResponse, type ApiResponse, type ApiSingleChainOrder, type ApiUserOrders, AuctioneerAPI, CROSS_CHAIN_GUARD_ADDRESSES, type CancelCrossChainOrderParams, type CancelSingleChainOrderParams, ChainID, type ChainOrderStatus, ChainType, type CreateCrossChainOrderParams, type CreateDcaSingleChainOrderParams, type CreateEvmCrossChainDcaOrderIntentParams, type CreateEvmCrossChainOrderIntentParams, type CreateEvmSingleChainDcaOrderIntentParams, type CreateEvmSingleChainLimitOrderIntentParams, type CreateSingleChainOrderParams, type CreateSolanaCrossChainOrderIntentParams, type CreateSolanaSingleChainDcaOrderIntentParams, type CreateSolanaSingleChainLimitOrderIntentParams, type CreateSuiCrossChainOrderIntentParams, type CreateSuiSingleChainDcaOrderIntentParams, type CreateSuiSingleChainLimitOrderIntentParams, CrossChainOrder, DCA_CROSS_CHAIN_GUARD_ADDRESSES, DCA_SINGLE_CHAIN_GUARD_ADDRESSES, DcaSingleChainOrder, type DefiLlamaCoinData, type DefiLlamaTokensResponse, type EVMConfig, EVMSDK, EVM_ZERO_ADDRESS, EVM_ZERO_SIGNATURE, type FetchJWTParams, type FetchSiweMessageParams, IntentsOrderType, type IntentsQuoteParams, MAX_UINT_128, MAX_UINT_256, MAX_UINT_32, MAX_UINT_64, NATIVE_EVM_ETH_ADDRESSES, NATIVE_SOLANA_TOKEN_ADDRESS, NATIVE_SUI_TOKEN_ADDRESS, PERMIT2_ADDRESS, PROD_CROSS_CHAIN_GUARD_ADDRESSES, PROD_DCA_CROSS_CHAIN_GUARD_ADDRESSES, PROD_DCA_SINGLE_CHAIN_GUARD_ADDRESSES, PROD_SINGLE_CHAIN_GUARD_ADDRESSES, PROD_SUI_PACKAGE_ID, QuoteProvider, type QuoteResponse, SINGLE_CHAIN_GUARD_ADDRESSES, SOLANA_MINT_TOKEN, SOLANA_USDC_MINT, SUI_GUARD_COLLATERAL_TYPE, SUI_GUARD_STABLECOIN_TYPE, SUI_PACKAGE_ID, SingleChainOrder, type SolanaConfig, type SolanaOrderInstructionResult, SolanaSDK, type StopLossType, type SuiConfig, SuiSDK, type SupportedChain, SupportedChains, type SupportedEvmChain, TEST_CROSS_CHAIN_GUARD_ADDRESSES, TEST_DCA_SINGLE_CHAIN_GUARD_ADDRESSES, TEST_SINGLE_CHAIN_GUARD_ADDRESSES, TEST_SUI_PACKAGE_ID, TOKEN_SEARCH_API_BASE_URL, type TokenInfo, type TokenSearchParams, type TokenSearchResponse, ValidationError, WRAPPED_ETH_ADDRESSES, WRAPPED_SOL_MINT_ADDRESS, calculateAmounts, cancelCrossChainOrderInstructionsAsBytes, cancelDcaSingleChainOrderInstructions, cancelSingleChainOrderInstructionsAsBytes, chainIdToChainTypeMap, createEvmCrossChainDcaOrderIntentRequest, createEvmCrossChainOrderIntentRequest, createEvmSingleChainDcaOrderIntentRequest, createEvmSingleChainLimitOrderIntentRequest, createSolanaCrossChainOrderIntentRequest, createSolanaSingleChainDcaOrderIntentRequest, createSolanaSingleChainLimitOrderIntentRequest, createSuiCrossChainOrderIntentRequest, createSuiSingleChainDcaOrderIntentRequest, createSuiSingleChainLimitOrderIntentRequest, fetchJWTToken, fetchSiweMessage, fetchUserOrders, generateEvmCrossChainOrderTypedData, generateEvmRandomNonce, generateEvmSingleChainDcaOrderTypedData, generateEvmSingleChainLimitOrderTypedData, generateExecutionDetailsHash, generateSolanaCrossChainOrderInstructions, generateSolanaDcaOrderSecretData, generateSolanaLimitOrderSecretData, generateSolanaRandomSecretNumber, generateSolanaSingleChainDcaOrderInstructions, generateSolanaSingleChainLimitOrderInstructions, generateSuiDcaOrderSecretData, generateSuiLimitOrderSecretData, getCancelCrossChainOrderRawData, getCancelSingleChainOrderRawData, getCoinFromResponse, getDcaSecretHash, getEVMCrossChainDcaOrderTypedData, getEVMCrossChainOrderTypedData, getEVMSingleChainOrderTypedData, getInvalidateNoncesRawData, getSecretHash, getSolanaCrossChainOrderInstructions, getSolanaDcaSingleChainOrderInstructions, getSolanaOrdersWithLockedFunds, getSolanaSingleChainOrderInstructions, getSuiCancelCrossChainOrder, getSuiOrderTransaction, getRandomU64Number as getSuiRandomU64Number, getSuiSingleChainDcaOrderTransaction, getSuiSingleChainLimitOrderTransaction, getTokenList, getTokensData, isErrorApiResponse, isEvmChain, isNativeEvmToken, isSuccessApiResponse, isSupportedChain, normalizeNativeEvmTokenForSigning, prepareDcaSecretData, prepareSecretData, signSingleChainDcaOrder, signSingleChainLimitOrder };
|
package/dist/index.d.ts
CHANGED
|
@@ -93,6 +93,7 @@ declare const TEST_DCA_SINGLE_CHAIN_GUARD_ADDRESSES: Record<SupportedEvmChain, A
|
|
|
93
93
|
declare const CROSS_CHAIN_GUARD_ADDRESSES: Record<SupportedChain, `0x${string}` | Address>;
|
|
94
94
|
declare const SINGLE_CHAIN_GUARD_ADDRESSES: Record<ChainID.Arbitrum | ChainID.Optimism | ChainID.Base | ChainID.Hyperliquid | ChainID.Solana | ChainID.BSC | ChainID.MONAD, `0x${string}` | Address>;
|
|
95
95
|
declare const DCA_SINGLE_CHAIN_GUARD_ADDRESSES: Record<SupportedEvmChain, `0x${string}`>;
|
|
96
|
+
declare const DCA_CROSS_CHAIN_GUARD_ADDRESSES: Record<SupportedEvmChain, `0x${string}`>;
|
|
96
97
|
declare const NATIVE_SOLANA_TOKEN_ADDRESS: Address<"So11111111111111111111111111111111111111111">;
|
|
97
98
|
declare const WRAPPED_SOL_MINT_ADDRESS: Address<"So11111111111111111111111111111111111111112">;
|
|
98
99
|
type SolanaMint = {
|
|
@@ -116,8 +117,18 @@ declare const NATIVE_EVM_ETH_ADDRESSES: string[];
|
|
|
116
117
|
declare const WRAPPED_ETH_ADDRESSES: Record<SupportedEvmChain, Address$1>;
|
|
117
118
|
declare const NATIVE_SUI_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
118
119
|
declare function isNativeEvmToken(tokenAddress: string): boolean;
|
|
120
|
+
declare const EVM_ZERO_ADDRESS: Address$1;
|
|
121
|
+
/** Placeholder signature (32 zero bytes) for unsigned/validate-only intent requests. */
|
|
122
|
+
declare const EVM_ZERO_SIGNATURE = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
123
|
+
/**
|
|
124
|
+
* Output-token addresses must be normalized to the zero address before signing the EIP-712
|
|
125
|
+
* witness: the auctioneer collapses any native sentinel (`0xeee…`/`0x0…`) to `Address::default()`
|
|
126
|
+
* when it reconstructs `requestedOutput`/`extraTransfers` to recover the signer. Signing the raw
|
|
127
|
+
* sentinel instead would yield a different hash → signature recovery fails. (`tokenIn` is NOT
|
|
128
|
+
* normalized on either side, so leave it untouched.)
|
|
129
|
+
*/
|
|
130
|
+
declare function normalizeNativeEvmTokenForSigning(tokenAddress: string): string;
|
|
119
131
|
declare const TOKEN_SEARCH_API_BASE_URL = "https://shogun-token-search-api-825534211396.europe-west4.run.app";
|
|
120
|
-
declare const DEV_ACCESS_KEY: string | null;
|
|
121
132
|
|
|
122
133
|
type StopLossType = 'FIXED' | 'TRAILING_ABSOLUTE' | 'TRAILING_PERCENT';
|
|
123
134
|
type ExtraTransfer$1 = {
|
|
@@ -129,7 +140,7 @@ type ExtraTransfer$1 = {
|
|
|
129
140
|
amount: bigint;
|
|
130
141
|
};
|
|
131
142
|
|
|
132
|
-
type ChainOrderStatus = 'Auction' | 'NoBids' | 'Executing' | 'Fulfilled' | 'Cancelled' | 'Outdated';
|
|
143
|
+
type ChainOrderStatus = 'Auction' | 'NoBids' | 'Executing' | 'Fulfilled' | 'Cancelled' | 'Outdated' | 'DcaIntervalFulfilled';
|
|
133
144
|
type ApiCrossChainOrder = {
|
|
134
145
|
orderId: string;
|
|
135
146
|
user: string;
|
|
@@ -182,8 +193,12 @@ type ApiUserOrders = {
|
|
|
182
193
|
interface ApiIntentResponse {
|
|
183
194
|
/** Unique identifier for the created intent */
|
|
184
195
|
intentId: string;
|
|
185
|
-
/**
|
|
186
|
-
|
|
196
|
+
/**
|
|
197
|
+
* JWT token used for authorization or subsequent requests.
|
|
198
|
+
* Optional: order-creation responses only return `intentId`; obtain a JWT via the
|
|
199
|
+
* SIWE flow (`EVMSDK.authenticate()` / `fetchJWTToken`) instead.
|
|
200
|
+
*/
|
|
201
|
+
jwt?: string;
|
|
187
202
|
}
|
|
188
203
|
type ValidResponseData = ApiUserOrders | string | ApiIntentResponse | null;
|
|
189
204
|
type ApiResponse<T extends ValidResponseData = ValidResponseData> = {
|
|
@@ -262,7 +277,11 @@ type ExecutionDetails = {
|
|
|
262
277
|
destinationAddress: string;
|
|
263
278
|
/** Extra transfers to be made */
|
|
264
279
|
extraTransfers?: ExtraTransfer$1[];
|
|
265
|
-
|
|
280
|
+
/** Stop loss type, must match the auctioneer's `stopLossType` field */
|
|
281
|
+
stopLossType?: StopLossType;
|
|
282
|
+
/** Initial trigger price (tokenIn/tokenOut) that arms the stop loss */
|
|
283
|
+
stopLossTriggerPrice?: string;
|
|
284
|
+
/** Take profit minimum amount out */
|
|
266
285
|
takeProfitMinOut?: bigint;
|
|
267
286
|
};
|
|
268
287
|
type Hash = `0x${string}`;
|
|
@@ -330,6 +349,34 @@ type SingleChainUserIntentRequest = {
|
|
|
330
349
|
Sui?: SuiPreparedData;
|
|
331
350
|
};
|
|
332
351
|
};
|
|
352
|
+
/**
|
|
353
|
+
* Source chain data for a cross-chain DCA order. Mirrors the auctioneer's
|
|
354
|
+
* `CrossChainDcaOrderGenericRequestData` (common cross-chain fields + flattened
|
|
355
|
+
* `CommonDcaOrderData`). The destination fields live in `executionDetails`.
|
|
356
|
+
*/
|
|
357
|
+
type DcaCrossChainSourceChainData = {
|
|
358
|
+
user: string;
|
|
359
|
+
srcChainId: SupportedChain;
|
|
360
|
+
tokenIn: string;
|
|
361
|
+
minStablecoinsAmount: bigint;
|
|
362
|
+
deadline: number;
|
|
363
|
+
executionDetailsHash: ExecutionDetailsHash;
|
|
364
|
+
/** Flattened CommonDcaOrderData */
|
|
365
|
+
startTime: number;
|
|
366
|
+
amountInPerInterval: bigint;
|
|
367
|
+
totalIntervals: number;
|
|
368
|
+
intervalDuration: number;
|
|
369
|
+
};
|
|
370
|
+
type DcaCrossChainUserIntentRequest = {
|
|
371
|
+
genericData: DcaCrossChainSourceChainData;
|
|
372
|
+
/** JSON-stringified execution details for the destination chain */
|
|
373
|
+
executionDetails: string;
|
|
374
|
+
chainSpecificData: {
|
|
375
|
+
EVM?: DcaSingleChainEVMPreparedData;
|
|
376
|
+
Solana?: DcaSingleChainSolanaPreparedData;
|
|
377
|
+
Sui?: DcaSingleChainSuiPreparedData;
|
|
378
|
+
};
|
|
379
|
+
};
|
|
333
380
|
type ChainPreparedData = EvmPreparedData | SuiPreparedData | SolanaPreparedData;
|
|
334
381
|
type CrossChainOrderPrepared = {
|
|
335
382
|
order: CrossChainOrder;
|
|
@@ -596,6 +643,8 @@ declare abstract class BaseSDK {
|
|
|
596
643
|
createAndSendDcaSingleChainOrder(params: CreateDcaSingleChainOrderParams): Promise<ApiResponse>;
|
|
597
644
|
static sendDcaSingleChainOrder(preparedOrder: DcaSingleChainOrderPrepared): Promise<ApiResponse>;
|
|
598
645
|
static validateDcaSingleChainOrder(intentRequest: DcaSingleChainUserIntentRequest): Promise<void>;
|
|
646
|
+
static validateDcaCrossChainOrder(intentRequest: DcaCrossChainUserIntentRequest): Promise<void>;
|
|
647
|
+
static sendDcaCrossChainOrder(intentRequest: DcaCrossChainUserIntentRequest): Promise<ApiResponse>;
|
|
599
648
|
}
|
|
600
649
|
|
|
601
650
|
type CancelSingleChainOrderParams$1 = {
|
|
@@ -773,10 +822,14 @@ declare class SuiSDK extends BaseSDK {
|
|
|
773
822
|
}
|
|
774
823
|
|
|
775
824
|
/**
|
|
776
|
-
* Fetches
|
|
777
|
-
*
|
|
825
|
+
* Fetches the orders owned by the wallets encoded in a SIWE-issued JWT.
|
|
826
|
+
*
|
|
827
|
+
* The auctioneer derives the queried wallets from the verified JWT claims, never from
|
|
828
|
+
* caller-supplied params — a caller can only read intents for wallets it proved control
|
|
829
|
+
* of via SIWE. Obtain the token with `EVMSDK.authenticate()` (or the `fetchSiweMessage` +
|
|
830
|
+
* `fetchJWTToken` pair) and pass it here.
|
|
778
831
|
*/
|
|
779
|
-
declare function fetchUserOrders(
|
|
832
|
+
declare function fetchUserOrders(aggregatedToken: string): Promise<ApiUserOrders>;
|
|
780
833
|
|
|
781
834
|
declare class AuctioneerAPI {
|
|
782
835
|
aggregatedToken: string;
|
|
@@ -972,15 +1025,15 @@ declare function getSecretHash(coinOutType: string, receiver: string, secretNumb
|
|
|
972
1025
|
*/
|
|
973
1026
|
declare function getSuiSingleChainLimitOrderTransaction(order: SingleChainOrder, secretHash: Uint8Array, guardAddress: string, client?: ReturnType<typeof createSuiClient>): Promise<Transaction>;
|
|
974
1027
|
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1028
|
+
/**
|
|
1029
|
+
* Computes the SHA-256 hash the auctioneer expects for cross-chain execution details.
|
|
1030
|
+
*
|
|
1031
|
+
* The auctioneer recomputes sha256 over the exact `executionDetails` JSON string it
|
|
1032
|
+
* receives and rejects the order when it differs (hash mismatch). Callers therefore MUST
|
|
1033
|
+
* hash the same serialized string they send on the wire — pass that string here directly
|
|
1034
|
+
* instead of re-serializing a parallel object, which is how key-order/field drift creeps in.
|
|
1035
|
+
*/
|
|
1036
|
+
declare function generateExecutionDetailsHash(executionDetails: string): string;
|
|
984
1037
|
|
|
985
1038
|
type CreateSuiSingleChainLimitOrderIntentParams = {
|
|
986
1039
|
user: string;
|
|
@@ -1390,7 +1443,7 @@ declare function createEvmCrossChainOrderIntentRequest(params: CreateEvmCrossCha
|
|
|
1390
1443
|
* @returns Object containing typed data and nonce for signing
|
|
1391
1444
|
*/
|
|
1392
1445
|
declare function generateEvmSingleChainLimitOrderTypedData(order: SingleChainOrder): Promise<{
|
|
1393
|
-
orderTypedData:
|
|
1446
|
+
orderTypedData: TypedDataDefinition;
|
|
1394
1447
|
nonce: bigint;
|
|
1395
1448
|
}>;
|
|
1396
1449
|
/**
|
|
@@ -1399,7 +1452,7 @@ declare function generateEvmSingleChainLimitOrderTypedData(order: SingleChainOrd
|
|
|
1399
1452
|
* @returns Object containing typed data and nonce for signing
|
|
1400
1453
|
*/
|
|
1401
1454
|
declare function generateEvmSingleChainDcaOrderTypedData(order: DcaSingleChainOrder): Promise<{
|
|
1402
|
-
orderTypedData:
|
|
1455
|
+
orderTypedData: TypedDataDefinition;
|
|
1403
1456
|
nonce: bigint;
|
|
1404
1457
|
}>;
|
|
1405
1458
|
/**
|
|
@@ -1408,7 +1461,7 @@ declare function generateEvmSingleChainDcaOrderTypedData(order: DcaSingleChainOr
|
|
|
1408
1461
|
* @returns Object containing typed data and nonce for signing
|
|
1409
1462
|
*/
|
|
1410
1463
|
declare function generateEvmCrossChainOrderTypedData(order: CrossChainOrder): Promise<{
|
|
1411
|
-
orderTypedData:
|
|
1464
|
+
orderTypedData: TypedDataDefinition;
|
|
1412
1465
|
nonce: bigint;
|
|
1413
1466
|
}>;
|
|
1414
1467
|
/**
|
|
@@ -1416,6 +1469,39 @@ declare function generateEvmCrossChainOrderTypedData(order: CrossChainOrder): Pr
|
|
|
1416
1469
|
* @returns Random nonce as string
|
|
1417
1470
|
*/
|
|
1418
1471
|
declare function generateEvmRandomNonce(): string;
|
|
1472
|
+
type CreateEvmCrossChainDcaOrderIntentParams = {
|
|
1473
|
+
user: `0x${string}`;
|
|
1474
|
+
sourceChainId: SupportedEvmChain;
|
|
1475
|
+
sourceTokenAddress: string;
|
|
1476
|
+
destinationChainId: number;
|
|
1477
|
+
destinationTokenAddress: string;
|
|
1478
|
+
destinationTokenMinAmount?: bigint;
|
|
1479
|
+
destinationAddress: string;
|
|
1480
|
+
minStablecoinAmount?: bigint;
|
|
1481
|
+
deadline: number;
|
|
1482
|
+
startTime: number;
|
|
1483
|
+
amountInPerInterval: bigint;
|
|
1484
|
+
totalIntervals: number;
|
|
1485
|
+
intervalDuration: number;
|
|
1486
|
+
extraTransfers?: ExtraTransfer$1[];
|
|
1487
|
+
nonce?: string;
|
|
1488
|
+
signature?: string;
|
|
1489
|
+
};
|
|
1490
|
+
/**
|
|
1491
|
+
* Creates an EVM cross-chain DCA order intent request, ready to POST to
|
|
1492
|
+
* `/user_intent/cross_chain/dca_order`. Pass `nonce`/`signature` from
|
|
1493
|
+
* {@link getEVMCrossChainDcaOrderTypedData} for an executable order.
|
|
1494
|
+
*/
|
|
1495
|
+
declare function createEvmCrossChainDcaOrderIntentRequest(params: CreateEvmCrossChainDcaOrderIntentParams): DcaCrossChainUserIntentRequest;
|
|
1496
|
+
/**
|
|
1497
|
+
* Generates the EIP-712 typed data (and nonce) for a cross-chain DCA order's Permit2 witness.
|
|
1498
|
+
* Sign `orderTypedData`, then pass the resulting `nonce`/`signature` into
|
|
1499
|
+
* {@link createEvmCrossChainDcaOrderIntentRequest} — both share the same execution-details hash.
|
|
1500
|
+
*/
|
|
1501
|
+
declare function getEVMCrossChainDcaOrderTypedData(params: CreateEvmCrossChainDcaOrderIntentParams, providedNonce?: bigint): {
|
|
1502
|
+
orderTypedData: TypedDataDefinition;
|
|
1503
|
+
nonce: bigint;
|
|
1504
|
+
};
|
|
1419
1505
|
|
|
1420
1506
|
type CreateSolanaSingleChainLimitOrderIntentParams = {
|
|
1421
1507
|
user: string;
|
|
@@ -1460,7 +1546,8 @@ type CreateSolanaCrossChainOrderIntentParams = {
|
|
|
1460
1546
|
deadline: number;
|
|
1461
1547
|
extraTransfers?: ExtraTransfer$1[];
|
|
1462
1548
|
orderPubkey?: string;
|
|
1463
|
-
|
|
1549
|
+
stopLossType?: StopLossType;
|
|
1550
|
+
stopLossTriggerPrice?: string;
|
|
1464
1551
|
takeProfitMinOut?: bigint;
|
|
1465
1552
|
};
|
|
1466
1553
|
/**
|
|
@@ -1533,4 +1620,4 @@ declare function generateSolanaDcaOrderSecretData(tokenOut: string, receiver: st
|
|
|
1533
1620
|
*/
|
|
1534
1621
|
declare function generateSolanaRandomSecretNumber(): string;
|
|
1535
1622
|
|
|
1536
|
-
export { AUCTIONEER_URL, type ApiCrossChainOrder, type ApiIntentResponse, type ApiResponse, type ApiSingleChainOrder, type ApiUserOrders, AuctioneerAPI, CROSS_CHAIN_GUARD_ADDRESSES, type CancelCrossChainOrderParams, type CancelSingleChainOrderParams, ChainID, type ChainOrderStatus, ChainType, type CreateCrossChainOrderParams, type CreateDcaSingleChainOrderParams, type CreateEvmCrossChainOrderIntentParams, type CreateEvmSingleChainDcaOrderIntentParams, type CreateEvmSingleChainLimitOrderIntentParams, type CreateSingleChainOrderParams, type CreateSolanaCrossChainOrderIntentParams, type CreateSolanaSingleChainDcaOrderIntentParams, type CreateSolanaSingleChainLimitOrderIntentParams, type CreateSuiCrossChainOrderIntentParams, type CreateSuiSingleChainDcaOrderIntentParams, type CreateSuiSingleChainLimitOrderIntentParams, CrossChainOrder,
|
|
1623
|
+
export { AUCTIONEER_URL, type ApiCrossChainOrder, type ApiIntentResponse, type ApiResponse, type ApiSingleChainOrder, type ApiUserOrders, AuctioneerAPI, CROSS_CHAIN_GUARD_ADDRESSES, type CancelCrossChainOrderParams, type CancelSingleChainOrderParams, ChainID, type ChainOrderStatus, ChainType, type CreateCrossChainOrderParams, type CreateDcaSingleChainOrderParams, type CreateEvmCrossChainDcaOrderIntentParams, type CreateEvmCrossChainOrderIntentParams, type CreateEvmSingleChainDcaOrderIntentParams, type CreateEvmSingleChainLimitOrderIntentParams, type CreateSingleChainOrderParams, type CreateSolanaCrossChainOrderIntentParams, type CreateSolanaSingleChainDcaOrderIntentParams, type CreateSolanaSingleChainLimitOrderIntentParams, type CreateSuiCrossChainOrderIntentParams, type CreateSuiSingleChainDcaOrderIntentParams, type CreateSuiSingleChainLimitOrderIntentParams, CrossChainOrder, DCA_CROSS_CHAIN_GUARD_ADDRESSES, DCA_SINGLE_CHAIN_GUARD_ADDRESSES, DcaSingleChainOrder, type DefiLlamaCoinData, type DefiLlamaTokensResponse, type EVMConfig, EVMSDK, EVM_ZERO_ADDRESS, EVM_ZERO_SIGNATURE, type FetchJWTParams, type FetchSiweMessageParams, IntentsOrderType, type IntentsQuoteParams, MAX_UINT_128, MAX_UINT_256, MAX_UINT_32, MAX_UINT_64, NATIVE_EVM_ETH_ADDRESSES, NATIVE_SOLANA_TOKEN_ADDRESS, NATIVE_SUI_TOKEN_ADDRESS, PERMIT2_ADDRESS, PROD_CROSS_CHAIN_GUARD_ADDRESSES, PROD_DCA_CROSS_CHAIN_GUARD_ADDRESSES, PROD_DCA_SINGLE_CHAIN_GUARD_ADDRESSES, PROD_SINGLE_CHAIN_GUARD_ADDRESSES, PROD_SUI_PACKAGE_ID, QuoteProvider, type QuoteResponse, SINGLE_CHAIN_GUARD_ADDRESSES, SOLANA_MINT_TOKEN, SOLANA_USDC_MINT, SUI_GUARD_COLLATERAL_TYPE, SUI_GUARD_STABLECOIN_TYPE, SUI_PACKAGE_ID, SingleChainOrder, type SolanaConfig, type SolanaOrderInstructionResult, SolanaSDK, type StopLossType, type SuiConfig, SuiSDK, type SupportedChain, SupportedChains, type SupportedEvmChain, TEST_CROSS_CHAIN_GUARD_ADDRESSES, TEST_DCA_SINGLE_CHAIN_GUARD_ADDRESSES, TEST_SINGLE_CHAIN_GUARD_ADDRESSES, TEST_SUI_PACKAGE_ID, TOKEN_SEARCH_API_BASE_URL, type TokenInfo, type TokenSearchParams, type TokenSearchResponse, ValidationError, WRAPPED_ETH_ADDRESSES, WRAPPED_SOL_MINT_ADDRESS, calculateAmounts, cancelCrossChainOrderInstructionsAsBytes, cancelDcaSingleChainOrderInstructions, cancelSingleChainOrderInstructionsAsBytes, chainIdToChainTypeMap, createEvmCrossChainDcaOrderIntentRequest, createEvmCrossChainOrderIntentRequest, createEvmSingleChainDcaOrderIntentRequest, createEvmSingleChainLimitOrderIntentRequest, createSolanaCrossChainOrderIntentRequest, createSolanaSingleChainDcaOrderIntentRequest, createSolanaSingleChainLimitOrderIntentRequest, createSuiCrossChainOrderIntentRequest, createSuiSingleChainDcaOrderIntentRequest, createSuiSingleChainLimitOrderIntentRequest, fetchJWTToken, fetchSiweMessage, fetchUserOrders, generateEvmCrossChainOrderTypedData, generateEvmRandomNonce, generateEvmSingleChainDcaOrderTypedData, generateEvmSingleChainLimitOrderTypedData, generateExecutionDetailsHash, generateSolanaCrossChainOrderInstructions, generateSolanaDcaOrderSecretData, generateSolanaLimitOrderSecretData, generateSolanaRandomSecretNumber, generateSolanaSingleChainDcaOrderInstructions, generateSolanaSingleChainLimitOrderInstructions, generateSuiDcaOrderSecretData, generateSuiLimitOrderSecretData, getCancelCrossChainOrderRawData, getCancelSingleChainOrderRawData, getCoinFromResponse, getDcaSecretHash, getEVMCrossChainDcaOrderTypedData, getEVMCrossChainOrderTypedData, getEVMSingleChainOrderTypedData, getInvalidateNoncesRawData, getSecretHash, getSolanaCrossChainOrderInstructions, getSolanaDcaSingleChainOrderInstructions, getSolanaOrdersWithLockedFunds, getSolanaSingleChainOrderInstructions, getSuiCancelCrossChainOrder, getSuiOrderTransaction, getRandomU64Number as getSuiRandomU64Number, getSuiSingleChainDcaOrderTransaction, getSuiSingleChainLimitOrderTransaction, getTokenList, getTokensData, isErrorApiResponse, isEvmChain, isNativeEvmToken, isSuccessApiResponse, isSupportedChain, normalizeNativeEvmTokenForSigning, prepareDcaSecretData, prepareSecretData, signSingleChainDcaOrder, signSingleChainLimitOrder };
|