@shogun-sdk/intents-sdk 1.2.6-test.15 → 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 +535 -484
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -43
- package/dist/index.d.ts +121 -43
- package/dist/index.js +369 -318
- package/dist/index.js.map +1 -1
- package/package.json +10 -7
- package/src/auth/siwe.ts +9 -7
- package/src/constants.ts +32 -17
- 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 -36
- package/src/core/orders/api/index.ts +2 -3
- package/src/core/orders/cross-chain.ts +3 -0
- package/src/core/orders/single-chain.ts +21 -8
- package/src/core/sdk.ts +11 -2
- package/src/core/solana/dca/create-order.ts +6 -19
- package/src/core/solana/intent-helpers.ts +12 -20
- package/src/core/solana/order-instructions.ts +12 -37
- package/src/core/sui/intent-helpers.ts +4 -1
- package/src/index.ts +4 -7
- 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/src/core/solana/transaction-options.ts +0 -83
- package/src/utils/auctioneer-headers.ts +0 -32
package/dist/index.js
CHANGED
|
@@ -129,7 +129,10 @@ function isNativeEvmToken(tokenAddress) {
|
|
|
129
129
|
const normalizedAddress = tokenAddress.toLowerCase();
|
|
130
130
|
return NATIVE_EVM_ETH_ADDRESSES.some((addr) => addr.toLowerCase() === normalizedAddress);
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
function normalizeNativeEvmTokenForSigning(tokenAddress) {
|
|
133
|
+
return isNativeEvmToken(tokenAddress) ? EVM_ZERO_ADDRESS : tokenAddress;
|
|
134
|
+
}
|
|
135
|
+
var useProdConfig, IntentsOrderType, PERMIT2_ADDRESS, PROD_CROSS_CHAIN_GUARD_ADDRESSES, TEST_CROSS_CHAIN_GUARD_ADDRESSES, PROD_SINGLE_CHAIN_GUARD_ADDRESSES, TEST_SINGLE_CHAIN_GUARD_ADDRESSES, PROD_DCA_SINGLE_CHAIN_GUARD_ADDRESSES, PROD_DCA_CROSS_CHAIN_GUARD_ADDRESSES, TEST_DCA_SINGLE_CHAIN_GUARD_ADDRESSES, CROSS_CHAIN_GUARD_ADDRESSES, SINGLE_CHAIN_GUARD_ADDRESSES, DCA_SINGLE_CHAIN_GUARD_ADDRESSES, DCA_CROSS_CHAIN_GUARD_ADDRESSES, NATIVE_SOLANA_TOKEN_ADDRESS, WRAPPED_SOL_MINT_ADDRESS, SOLANA_USDC_MINT, SOLANA_MINT_TOKEN, PROD_SUI_PACKAGE_ID, TEST_SUI_PACKAGE_ID, SUI_PACKAGE_ID, SUI_GUARD_COLLATERAL_TYPE, SUI_GUARD_STABLECOIN_TYPE, auctioneerUrlOverride, AUCTIONEER_URL, MAX_UINT_32, MAX_UINT_64, MAX_UINT_128, MAX_UINT_256, NATIVE_EVM_ETH_ADDRESSES, WRAPPED_ETH_ADDRESSES, NATIVE_SUI_TOKEN_ADDRESS, EVM_ZERO_ADDRESS, EVM_ZERO_SIGNATURE, TOKEN_SEARCH_API_BASE_URL;
|
|
133
136
|
var init_constants = __esm({
|
|
134
137
|
"src/constants.ts"() {
|
|
135
138
|
"use strict";
|
|
@@ -189,7 +192,9 @@ var init_constants = __esm({
|
|
|
189
192
|
[42161 /* Arbitrum */]: "0x0000000000000000000000000000000000000000",
|
|
190
193
|
[10 /* Optimism */]: "0x1b754840f058b78e412156d2674b5954728cb86e",
|
|
191
194
|
[8453 /* Base */]: "0x2df3ab1bb8b9d48769718003de2d8ca8e9d3c465",
|
|
192
|
-
|
|
195
|
+
// HyperEVM SingleChainGuardDca per the on-chain deployment + auctioneer config.
|
|
196
|
+
// (0x618ee9… is the SingleChainGuardLimit, which previously sat here by mistake.)
|
|
197
|
+
[999 /* Hyperliquid */]: "0xdcbb658910b5192a43b79fd8244bdf27940d3b6b",
|
|
193
198
|
[56 /* BSC */]: "0x11ef880e2e8d17c114b9eb87369ce3d1311c62e1",
|
|
194
199
|
[143 /* MONAD */]: "0x418302C3bef14D405A9B30381a9cb9d4d82EB2d4"
|
|
195
200
|
};
|
|
@@ -212,21 +217,9 @@ var init_constants = __esm({
|
|
|
212
217
|
CROSS_CHAIN_GUARD_ADDRESSES = useProdConfig ? PROD_CROSS_CHAIN_GUARD_ADDRESSES : TEST_CROSS_CHAIN_GUARD_ADDRESSES;
|
|
213
218
|
SINGLE_CHAIN_GUARD_ADDRESSES = useProdConfig ? PROD_SINGLE_CHAIN_GUARD_ADDRESSES : TEST_SINGLE_CHAIN_GUARD_ADDRESSES;
|
|
214
219
|
DCA_SINGLE_CHAIN_GUARD_ADDRESSES = useProdConfig ? PROD_DCA_SINGLE_CHAIN_GUARD_ADDRESSES : TEST_DCA_SINGLE_CHAIN_GUARD_ADDRESSES;
|
|
220
|
+
DCA_CROSS_CHAIN_GUARD_ADDRESSES = PROD_DCA_CROSS_CHAIN_GUARD_ADDRESSES;
|
|
215
221
|
NATIVE_SOLANA_TOKEN_ADDRESS = "So11111111111111111111111111111111111111111";
|
|
216
222
|
WRAPPED_SOL_MINT_ADDRESS = "So11111111111111111111111111111111111111112";
|
|
217
|
-
SOLANA_TIP_ACCOUNTS = [
|
|
218
|
-
"4ACfpUFoaSD9bfPdeu6DBt89gB6ENTeHBXCAi87NhDEE",
|
|
219
|
-
"D2L6yPZ2FmmmTKPgzaMKdhu6EWZcTpLy1Vhx8uvZe7NZ",
|
|
220
|
-
"9bnz4RShgq1hAnLnZbP8kbgBg1kEmcJBYQq3gQbmnSta",
|
|
221
|
-
"5VY91ws6B2hMmBFRsXkoAAdsPHBJwRfBht4DXox3xkwn",
|
|
222
|
-
"2nyhqdwKcJZR2vcqCyrYsaPVdAnFoJjiksCXJ7hfEYgD",
|
|
223
|
-
"2q5pghRs6arqVjRvT5gfgWfWcHWmw1ZuCzphgd5KfWGJ",
|
|
224
|
-
"wyvPkWjVZz1M8fHQnMMCDTQDbkManefNNhweYk5WkcF",
|
|
225
|
-
"3KCKozbAaF75qEU33jtzozcJ29yJuaLJTy2jFdzUY8bT",
|
|
226
|
-
"4vieeGHPYPG2MmyPRcYjdiDmmhN3ww7hsFNap8pVN3Ey",
|
|
227
|
-
"4TQLFNWK8AovT1gFvda5jfw2oJeRMKEmw7aH6MGBJ3or"
|
|
228
|
-
];
|
|
229
|
-
SOLANA_MIN_TIP_LAMPORTS = 200000n;
|
|
230
223
|
SOLANA_USDC_MINT = {
|
|
231
224
|
name: "USDC",
|
|
232
225
|
mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
@@ -238,7 +231,8 @@ var init_constants = __esm({
|
|
|
238
231
|
SUI_PACKAGE_ID = useProdConfig ? PROD_SUI_PACKAGE_ID : TEST_SUI_PACKAGE_ID;
|
|
239
232
|
SUI_GUARD_COLLATERAL_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
|
|
240
233
|
SUI_GUARD_STABLECOIN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
|
|
241
|
-
|
|
234
|
+
auctioneerUrlOverride = typeof process !== "undefined" ? process.env?.INTENTS_AUCTIONEER_URL : void 0;
|
|
235
|
+
AUCTIONEER_URL = auctioneerUrlOverride || (useProdConfig ? "https://auctioneer-825534211396.us-central1.run.app" : "http://127.0.0.1:8080");
|
|
242
236
|
MAX_UINT_32 = 2n ** 32n - 1n;
|
|
243
237
|
MAX_UINT_64 = 2n ** 64n - 1n;
|
|
244
238
|
MAX_UINT_128 = 2n ** 128n - 1n;
|
|
@@ -256,6 +250,8 @@ var init_constants = __esm({
|
|
|
256
250
|
[143 /* MONAD */]: "0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A"
|
|
257
251
|
};
|
|
258
252
|
NATIVE_SUI_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
253
|
+
EVM_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
254
|
+
EVM_ZERO_SIGNATURE = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
259
255
|
TOKEN_SEARCH_API_BASE_URL = "https://shogun-token-search-api-825534211396.europe-west4.run.app";
|
|
260
256
|
}
|
|
261
257
|
});
|
|
@@ -391,9 +387,6 @@ var BaseValidator = class {
|
|
|
391
387
|
this.validateTokenAddress(order.tokenOut);
|
|
392
388
|
this.validateAmount(order.amountIn);
|
|
393
389
|
this.validateAmount(order.amountOutMin ?? 1n);
|
|
394
|
-
if (order.stopLossMaxOut) {
|
|
395
|
-
this.validateAmount(order.stopLossMaxOut);
|
|
396
|
-
}
|
|
397
390
|
if (order.takeProfitMinOut) {
|
|
398
391
|
this.validateAmount(order.takeProfitMinOut);
|
|
399
392
|
}
|
|
@@ -443,9 +436,9 @@ var BaseValidator = class {
|
|
|
443
436
|
/**
|
|
444
437
|
* Helper methods that throw specific validation errors
|
|
445
438
|
*/
|
|
446
|
-
validateAddress(
|
|
447
|
-
if (!this.isValidAddress(
|
|
448
|
-
throw new ValidationError(`Invalid ${this.getChainName()} address: ${
|
|
439
|
+
validateAddress(address9) {
|
|
440
|
+
if (!this.isValidAddress(address9)) {
|
|
441
|
+
throw new ValidationError(`Invalid ${this.getChainName()} address: ${address9}`);
|
|
449
442
|
}
|
|
450
443
|
}
|
|
451
444
|
validateTokenAddress(tokenAddress) {
|
|
@@ -3175,9 +3168,9 @@ var ChainProvider = class _ChainProvider {
|
|
|
3175
3168
|
}
|
|
3176
3169
|
});
|
|
3177
3170
|
}
|
|
3178
|
-
getSingleChainAuctioneerContract(
|
|
3171
|
+
getSingleChainAuctioneerContract(address9) {
|
|
3179
3172
|
return getContract({
|
|
3180
|
-
address:
|
|
3173
|
+
address: address9,
|
|
3181
3174
|
abi: SINGLE_CHAIN_GUARD_LIMIT_ABI,
|
|
3182
3175
|
client: {
|
|
3183
3176
|
wallet: this.walletClient,
|
|
@@ -3216,8 +3209,8 @@ var ChainProvider = class _ChainProvider {
|
|
|
3216
3209
|
|
|
3217
3210
|
// src/core/evm/validator.ts
|
|
3218
3211
|
var EvmValidator = class extends BaseValidator {
|
|
3219
|
-
isValidAddress(
|
|
3220
|
-
return isEvmAddress(
|
|
3212
|
+
isValidAddress(address9) {
|
|
3213
|
+
return isEvmAddress(address9);
|
|
3221
3214
|
}
|
|
3222
3215
|
isValidTokenAddress(tokenAddress) {
|
|
3223
3216
|
return isEvmAddress(tokenAddress);
|
|
@@ -3314,8 +3307,8 @@ var SolanaValidator = class extends BaseValidator {
|
|
|
3314
3307
|
validateSingleChainOrderFeasability() {
|
|
3315
3308
|
return Promise.resolve();
|
|
3316
3309
|
}
|
|
3317
|
-
isValidAddress(
|
|
3318
|
-
return isSolanaAddress(
|
|
3310
|
+
isValidAddress(address9) {
|
|
3311
|
+
return isSolanaAddress(address9);
|
|
3319
3312
|
}
|
|
3320
3313
|
isValidTokenAddress(tokenAddress) {
|
|
3321
3314
|
return isSolanaAddress(tokenAddress);
|
|
@@ -3339,12 +3332,12 @@ init_constants();
|
|
|
3339
3332
|
import { isValidSuiAddress, normalizeSuiAddress } from "@mysten/sui/utils";
|
|
3340
3333
|
var SUI_TOKEN_ADDRESS_REGEX = /^0x[a-fA-F0-9]{64}::\w+::\w+$/;
|
|
3341
3334
|
var SuiValidator = class extends BaseValidator {
|
|
3342
|
-
isValidAddress(
|
|
3343
|
-
return isValidSuiAddress(normalizeSuiAddress(
|
|
3335
|
+
isValidAddress(address9) {
|
|
3336
|
+
return isValidSuiAddress(normalizeSuiAddress(address9));
|
|
3344
3337
|
}
|
|
3345
3338
|
isValidTokenAddress(tokenAddress) {
|
|
3346
|
-
const [
|
|
3347
|
-
const isValidAddress =
|
|
3339
|
+
const [address9] = tokenAddress.split("::");
|
|
3340
|
+
const isValidAddress = address9 !== void 0 ? this.isValidAddress(address9) : false;
|
|
3348
3341
|
return isValidAddress && SUI_TOKEN_ADDRESS_REGEX.test(tokenAddress);
|
|
3349
3342
|
}
|
|
3350
3343
|
isValidAmount(amount) {
|
|
@@ -3451,35 +3444,6 @@ var DcaSingleChainOrderValidator = class {
|
|
|
3451
3444
|
init_constants();
|
|
3452
3445
|
init_errors();
|
|
3453
3446
|
|
|
3454
|
-
// src/utils/auctioneer-headers.ts
|
|
3455
|
-
var DEV_ACCESS_STORAGE_KEY = "x-dev-access";
|
|
3456
|
-
var DEV_ACCESS_HEADER = "x-dev-access";
|
|
3457
|
-
function getDevAccessHeaderValue() {
|
|
3458
|
-
try {
|
|
3459
|
-
if (typeof globalThis === "undefined") {
|
|
3460
|
-
return void 0;
|
|
3461
|
-
}
|
|
3462
|
-
const storage = globalThis.localStorage;
|
|
3463
|
-
if (!storage?.getItem) {
|
|
3464
|
-
return void 0;
|
|
3465
|
-
}
|
|
3466
|
-
const value = storage.getItem(DEV_ACCESS_STORAGE_KEY)?.trim();
|
|
3467
|
-
return value ? value : void 0;
|
|
3468
|
-
} catch {
|
|
3469
|
-
return void 0;
|
|
3470
|
-
}
|
|
3471
|
-
}
|
|
3472
|
-
function withAuctioneerHeaders(headers = {}) {
|
|
3473
|
-
const value = getDevAccessHeaderValue();
|
|
3474
|
-
if (!value) {
|
|
3475
|
-
return headers;
|
|
3476
|
-
}
|
|
3477
|
-
return {
|
|
3478
|
-
...headers,
|
|
3479
|
-
[DEV_ACCESS_HEADER]: value
|
|
3480
|
-
};
|
|
3481
|
-
}
|
|
3482
|
-
|
|
3483
3447
|
// src/utils/parsers.ts
|
|
3484
3448
|
import { formatUnits, parseUnits } from "viem";
|
|
3485
3449
|
var Parsers;
|
|
@@ -3597,6 +3561,29 @@ var DCA_SINGLE_CHAIN_PERMIT2_TYPES = {
|
|
|
3597
3561
|
{ name: "witness", type: "SingleChainDcaOrder" }
|
|
3598
3562
|
]
|
|
3599
3563
|
};
|
|
3564
|
+
var CROSS_CHAIN_DCA_PERMIT2_TYPES = {
|
|
3565
|
+
TokenPermissions: TOKEN_PERMISSIONS_TYPE,
|
|
3566
|
+
DcaOrderInfo: [
|
|
3567
|
+
{ name: "user", type: "address" },
|
|
3568
|
+
{ name: "tokenIn", type: "address" },
|
|
3569
|
+
{ name: "srcChainId", type: "uint32" },
|
|
3570
|
+
{ name: "startTime", type: "uint32" },
|
|
3571
|
+
{ name: "deadline", type: "uint32" },
|
|
3572
|
+
{ name: "totalIntervals", type: "uint24" },
|
|
3573
|
+
{ name: "intervalDuration", type: "uint32" },
|
|
3574
|
+
{ name: "amountInPerInterval", type: "uint128" },
|
|
3575
|
+
{ name: "minStablecoinsAmountPerInterval", type: "uint128" },
|
|
3576
|
+
{ name: "executionDetailsHash", type: "bytes32" },
|
|
3577
|
+
{ name: "nonce", type: "uint256" }
|
|
3578
|
+
],
|
|
3579
|
+
PermitWitnessTransferFrom: [
|
|
3580
|
+
{ name: "permitted", type: "TokenPermissions" },
|
|
3581
|
+
{ name: "spender", type: "address" },
|
|
3582
|
+
{ name: "nonce", type: "uint256" },
|
|
3583
|
+
{ name: "deadline", type: "uint256" },
|
|
3584
|
+
{ name: "witness", type: "DcaOrderInfo" }
|
|
3585
|
+
]
|
|
3586
|
+
};
|
|
3600
3587
|
|
|
3601
3588
|
// src/core/evm/intent-provider.ts
|
|
3602
3589
|
var EVMIntentProvider = class {
|
|
@@ -3663,12 +3650,12 @@ var EVMIntentProvider = class {
|
|
|
3663
3650
|
static getSingleChainLimitPermissionMessage(order, nonce) {
|
|
3664
3651
|
const spender = SINGLE_CHAIN_GUARD_ADDRESSES[order.chainId];
|
|
3665
3652
|
const requestedOutput = {
|
|
3666
|
-
token: order.tokenOut,
|
|
3653
|
+
token: normalizeNativeEvmTokenForSigning(order.tokenOut),
|
|
3667
3654
|
receiver: order.destinationAddress,
|
|
3668
3655
|
amount: order.amountOutMin
|
|
3669
3656
|
};
|
|
3670
3657
|
const extraTransfers = order.extraTransfers?.map((transfer) => ({
|
|
3671
|
-
token: transfer.token,
|
|
3658
|
+
token: normalizeNativeEvmTokenForSigning(transfer.token),
|
|
3672
3659
|
receiver: transfer.receiver,
|
|
3673
3660
|
amount: transfer.amount
|
|
3674
3661
|
})) || [];
|
|
@@ -3716,12 +3703,12 @@ var EVMIntentProvider = class {
|
|
|
3716
3703
|
static getDcaSingleChainPermissionMessage(order, nonce) {
|
|
3717
3704
|
const spender = DCA_SINGLE_CHAIN_GUARD_ADDRESSES[order.chainId];
|
|
3718
3705
|
const requestedOutput = {
|
|
3719
|
-
token: order.tokenOut,
|
|
3706
|
+
token: normalizeNativeEvmTokenForSigning(order.tokenOut),
|
|
3720
3707
|
receiver: order.destinationAddress,
|
|
3721
3708
|
amount: BigInt(order.amountOutMin)
|
|
3722
3709
|
};
|
|
3723
3710
|
const extraTransfers = order.extraTransfers?.map((transfer) => ({
|
|
3724
|
-
token: transfer.token,
|
|
3711
|
+
token: normalizeNativeEvmTokenForSigning(transfer.token),
|
|
3725
3712
|
receiver: transfer.receiver,
|
|
3726
3713
|
amount: transfer.amount
|
|
3727
3714
|
})) || [];
|
|
@@ -3796,10 +3783,10 @@ import {
|
|
|
3796
3783
|
getSyncNativeInstruction
|
|
3797
3784
|
} from "@solana-program/token";
|
|
3798
3785
|
import {
|
|
3799
|
-
address
|
|
3786
|
+
address,
|
|
3800
3787
|
addSignersToTransactionMessage,
|
|
3801
3788
|
appendTransactionMessageInstructions,
|
|
3802
|
-
createNoopSigner
|
|
3789
|
+
createNoopSigner,
|
|
3803
3790
|
createSolanaRpc as createSolanaRpc2,
|
|
3804
3791
|
createTransactionMessage,
|
|
3805
3792
|
fetchEncodedAccount as fetchEncodedAccount4,
|
|
@@ -3885,8 +3872,8 @@ function getOrderDecoder() {
|
|
|
3885
3872
|
function decodeOrder(encodedAccount) {
|
|
3886
3873
|
return decodeAccount(encodedAccount, getOrderDecoder());
|
|
3887
3874
|
}
|
|
3888
|
-
async function fetchMaybeOrder(rpc,
|
|
3889
|
-
const maybeAccount = await fetchEncodedAccount(rpc,
|
|
3875
|
+
async function fetchMaybeOrder(rpc, address9, config) {
|
|
3876
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address9, config);
|
|
3890
3877
|
return decodeOrder(maybeAccount);
|
|
3891
3878
|
}
|
|
3892
3879
|
|
|
@@ -4126,8 +4113,8 @@ function getDcaOrderDecoder() {
|
|
|
4126
4113
|
function decodeDcaOrder(encodedAccount) {
|
|
4127
4114
|
return decodeAccount2(encodedAccount, getDcaOrderDecoder());
|
|
4128
4115
|
}
|
|
4129
|
-
async function fetchMaybeDcaOrder(rpc,
|
|
4130
|
-
const maybeAccount = await fetchEncodedAccount2(rpc,
|
|
4116
|
+
async function fetchMaybeDcaOrder(rpc, address9, config) {
|
|
4117
|
+
const maybeAccount = await fetchEncodedAccount2(rpc, address9, config);
|
|
4131
4118
|
return decodeDcaOrder(maybeAccount);
|
|
4132
4119
|
}
|
|
4133
4120
|
|
|
@@ -4173,8 +4160,8 @@ function getLimitOrderDecoder() {
|
|
|
4173
4160
|
function decodeLimitOrder(encodedAccount) {
|
|
4174
4161
|
return decodeAccount3(encodedAccount, getLimitOrderDecoder());
|
|
4175
4162
|
}
|
|
4176
|
-
async function fetchMaybeLimitOrder(rpc,
|
|
4177
|
-
const maybeAccount = await fetchEncodedAccount3(rpc,
|
|
4163
|
+
async function fetchMaybeLimitOrder(rpc, address9, config) {
|
|
4164
|
+
const maybeAccount = await fetchEncodedAccount3(rpc, address9, config);
|
|
4178
4165
|
return decodeLimitOrder(maybeAccount);
|
|
4179
4166
|
}
|
|
4180
4167
|
|
|
@@ -4554,77 +4541,20 @@ function formatTokenPubkey(token) {
|
|
|
4554
4541
|
return token;
|
|
4555
4542
|
}
|
|
4556
4543
|
|
|
4557
|
-
// src/core/solana/transaction-options.ts
|
|
4558
|
-
init_constants();
|
|
4559
|
-
import { address, createNoopSigner } from "@solana/kit";
|
|
4560
|
-
function resolveSolanaFeePayer(userSigner, feePayer) {
|
|
4561
|
-
if (!feePayer || feePayer === userSigner.address) {
|
|
4562
|
-
return userSigner;
|
|
4563
|
-
}
|
|
4564
|
-
const feePayerAddress = address(feePayer);
|
|
4565
|
-
return createNoopSigner(feePayerAddress);
|
|
4566
|
-
}
|
|
4567
|
-
function resolveSolanaTip(options) {
|
|
4568
|
-
const lamports = normalizeTipLamports(options);
|
|
4569
|
-
if (!lamports) {
|
|
4570
|
-
return void 0;
|
|
4571
|
-
}
|
|
4572
|
-
const selectedTipAccount = options?.tipAccount ?? pickRandomTipAccount(options?.tipAccounts ?? SOLANA_TIP_ACCOUNTS);
|
|
4573
|
-
return {
|
|
4574
|
-
lamports,
|
|
4575
|
-
account: address(selectedTipAccount)
|
|
4576
|
-
};
|
|
4577
|
-
}
|
|
4578
|
-
function normalizeTipLamports(options) {
|
|
4579
|
-
if (!options) {
|
|
4580
|
-
return void 0;
|
|
4581
|
-
}
|
|
4582
|
-
if (options.tipLamports !== void 0) {
|
|
4583
|
-
if (options.tipLamports <= 0n) {
|
|
4584
|
-
return void 0;
|
|
4585
|
-
}
|
|
4586
|
-
return options.tipLamports < SOLANA_MIN_TIP_LAMPORTS ? SOLANA_MIN_TIP_LAMPORTS : options.tipLamports;
|
|
4587
|
-
}
|
|
4588
|
-
if (options.tipAmountSol === void 0 || options.tipAmountSol === null || options.tipAmountSol === "") {
|
|
4589
|
-
return void 0;
|
|
4590
|
-
}
|
|
4591
|
-
const tipInSol = Number(options.tipAmountSol);
|
|
4592
|
-
if (!Number.isFinite(tipInSol)) {
|
|
4593
|
-
throw new Error("Invalid Solana tip amount");
|
|
4594
|
-
}
|
|
4595
|
-
if (tipInSol <= 0) {
|
|
4596
|
-
return void 0;
|
|
4597
|
-
}
|
|
4598
|
-
const tipLamports = BigInt(Math.round(tipInSol * 1e9));
|
|
4599
|
-
return tipLamports < SOLANA_MIN_TIP_LAMPORTS ? SOLANA_MIN_TIP_LAMPORTS : tipLamports;
|
|
4600
|
-
}
|
|
4601
|
-
function pickRandomTipAccount(accounts) {
|
|
4602
|
-
if (!accounts.length) {
|
|
4603
|
-
throw new Error("No Solana tip accounts configured");
|
|
4604
|
-
}
|
|
4605
|
-
const index = Math.floor(Math.random() * accounts.length);
|
|
4606
|
-
const selected = accounts[index];
|
|
4607
|
-
if (!selected) {
|
|
4608
|
-
throw new Error("No Solana tip account selected");
|
|
4609
|
-
}
|
|
4610
|
-
return selected;
|
|
4611
|
-
}
|
|
4612
|
-
|
|
4613
4544
|
// src/core/solana/order-instructions.ts
|
|
4614
4545
|
async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
4615
4546
|
const rpc = options?.rpcUrl ? createSolanaRpc2(options.rpcUrl) : getDefaultSolanaRPC();
|
|
4616
4547
|
const orderSigner = await generateKeyPairSigner();
|
|
4617
|
-
const
|
|
4618
|
-
|
|
4619
|
-
let tokenInMint = address2(order.tokenIn);
|
|
4548
|
+
const signer = createNoopSigner(order.user);
|
|
4549
|
+
let tokenInMint = address(order.tokenIn);
|
|
4620
4550
|
const { secretHash, secretNumber } = genSecretHashAndNumber(order);
|
|
4621
|
-
const orderUserAddress =
|
|
4551
|
+
const orderUserAddress = address(order.user);
|
|
4622
4552
|
const spendingNative = tokenInMint === NATIVE_SOLANA_TOKEN_ADDRESS;
|
|
4623
4553
|
if (spendingNative) {
|
|
4624
4554
|
tokenInMint = WRAPPED_SOL_MINT_ADDRESS;
|
|
4625
4555
|
}
|
|
4626
4556
|
const tokenMintProgram = await fetchMint(rpc, tokenInMint);
|
|
4627
|
-
const guardAddress =
|
|
4557
|
+
const guardAddress = address(SINGLE_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */]);
|
|
4628
4558
|
const addressEncoder = getAddressEncoder7();
|
|
4629
4559
|
const instructions = [];
|
|
4630
4560
|
const [tokenInProgramAccount] = await getProgramDerivedAddress4({
|
|
@@ -4638,7 +4568,7 @@ async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
|
4638
4568
|
const userTokenInAccount = await fetchEncodedAccount4(rpc, tokenInProgramAccount);
|
|
4639
4569
|
if (!userTokenInAccount.exists) {
|
|
4640
4570
|
const createAccountIx = await getCreateAssociatedTokenInstructionAsync({
|
|
4641
|
-
payer:
|
|
4571
|
+
payer: signer,
|
|
4642
4572
|
ata: tokenInProgramAccount,
|
|
4643
4573
|
owner: orderUserAddress,
|
|
4644
4574
|
mint: tokenMintProgram.address,
|
|
@@ -4650,7 +4580,7 @@ async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
|
4650
4580
|
const transferIx = getTransferSolInstruction({
|
|
4651
4581
|
amount: order.amountIn,
|
|
4652
4582
|
destination: userTokenInAccount.address,
|
|
4653
|
-
source:
|
|
4583
|
+
source: signer
|
|
4654
4584
|
});
|
|
4655
4585
|
instructions.push(transferIx);
|
|
4656
4586
|
const syncNativeIx = getSyncNativeInstruction({
|
|
@@ -4659,7 +4589,7 @@ async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
|
4659
4589
|
instructions.push(syncNativeIx);
|
|
4660
4590
|
}
|
|
4661
4591
|
const createSingleChainLimitOrderIx = await getCreateLimitOrderInstructionAsync({
|
|
4662
|
-
user:
|
|
4592
|
+
user: signer,
|
|
4663
4593
|
order: orderSigner,
|
|
4664
4594
|
guard: guardAddress,
|
|
4665
4595
|
tokenInMint,
|
|
@@ -4673,20 +4603,10 @@ async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
|
4673
4603
|
// TODO
|
|
4674
4604
|
});
|
|
4675
4605
|
instructions.push(createSingleChainLimitOrderIx);
|
|
4676
|
-
const tip = resolveSolanaTip(options);
|
|
4677
|
-
if (tip) {
|
|
4678
|
-
instructions.push(
|
|
4679
|
-
getTransferSolInstruction({
|
|
4680
|
-
source: feePayerSigner,
|
|
4681
|
-
destination: tip.account,
|
|
4682
|
-
amount: tip.lamports
|
|
4683
|
-
})
|
|
4684
|
-
);
|
|
4685
|
-
}
|
|
4686
4606
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
|
|
4687
4607
|
const txMessage = pipe(
|
|
4688
4608
|
createTransactionMessage({ version: 0 }),
|
|
4689
|
-
(tx) => setTransactionMessageFeePayerSigner(
|
|
4609
|
+
(tx) => setTransactionMessageFeePayerSigner(signer, tx),
|
|
4690
4610
|
(tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
|
|
4691
4611
|
(tx) => appendTransactionMessageInstructions(instructions, tx),
|
|
4692
4612
|
(tx) => addSignersToTransactionMessage([orderSigner], tx)
|
|
@@ -4702,16 +4622,15 @@ async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
|
4702
4622
|
async function getSolanaCrossChainOrderInstructions(order, options) {
|
|
4703
4623
|
const rpc = options?.rpcUrl ? createSolanaRpc2(options.rpcUrl) : getDefaultSolanaRPC();
|
|
4704
4624
|
const orderSigner = await generateKeyPairSigner();
|
|
4705
|
-
const
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
const orderUserAddress = address2(order.user);
|
|
4625
|
+
const signer = createNoopSigner(order.user);
|
|
4626
|
+
let tokenInMint = address(order.sourceTokenAddress);
|
|
4627
|
+
const orderUserAddress = address(order.user);
|
|
4709
4628
|
const spendingNative = tokenInMint === NATIVE_SOLANA_TOKEN_ADDRESS;
|
|
4710
4629
|
if (spendingNative) {
|
|
4711
4630
|
tokenInMint = WRAPPED_SOL_MINT_ADDRESS;
|
|
4712
4631
|
}
|
|
4713
4632
|
const tokenMintProgram = await fetchMint(rpc, tokenInMint);
|
|
4714
|
-
const guardAddress =
|
|
4633
|
+
const guardAddress = address(CROSS_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */]);
|
|
4715
4634
|
const addressEncoder = getAddressEncoder7();
|
|
4716
4635
|
const [tokenInProgramAccount] = await getProgramDerivedAddress4({
|
|
4717
4636
|
programAddress: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
@@ -4738,7 +4657,7 @@ async function getSolanaCrossChainOrderInstructions(order, options) {
|
|
|
4738
4657
|
order.sourceTokenAddress = WRAPPED_SOL_MINT_ADDRESS;
|
|
4739
4658
|
if (!userTokenInAccount.exists) {
|
|
4740
4659
|
const createAccountIx = await getCreateAssociatedTokenInstructionAsync({
|
|
4741
|
-
payer:
|
|
4660
|
+
payer: signer,
|
|
4742
4661
|
ata: tokenInProgramAccount,
|
|
4743
4662
|
owner: orderUserAddress,
|
|
4744
4663
|
mint: tokenMintProgram.address,
|
|
@@ -4747,7 +4666,7 @@ async function getSolanaCrossChainOrderInstructions(order, options) {
|
|
|
4747
4666
|
instructions.push(createAccountIx);
|
|
4748
4667
|
}
|
|
4749
4668
|
const transferIx = getTransferSolInstruction({
|
|
4750
|
-
source:
|
|
4669
|
+
source: signer,
|
|
4751
4670
|
destination: userTokenInAccount.address,
|
|
4752
4671
|
amount: order.sourceTokenAmount
|
|
4753
4672
|
});
|
|
@@ -4759,9 +4678,9 @@ async function getSolanaCrossChainOrderInstructions(order, options) {
|
|
|
4759
4678
|
}
|
|
4760
4679
|
const executionHashUint8Array = order.executionDetailsHashToBytes();
|
|
4761
4680
|
const createOrderIx = getCreateOrderInstruction({
|
|
4762
|
-
user:
|
|
4681
|
+
user: signer,
|
|
4763
4682
|
order: orderSigner,
|
|
4764
|
-
guard:
|
|
4683
|
+
guard: address(CROSS_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */]),
|
|
4765
4684
|
systemProgram: SYSTEM_PROGRAM_ADDRESS,
|
|
4766
4685
|
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
4767
4686
|
tokenInMint,
|
|
@@ -4774,20 +4693,10 @@ async function getSolanaCrossChainOrderInstructions(order, options) {
|
|
|
4774
4693
|
minStablecoinsAmount: order.minStablecoinAmount
|
|
4775
4694
|
});
|
|
4776
4695
|
instructions.push(createOrderIx);
|
|
4777
|
-
const tip = resolveSolanaTip(options);
|
|
4778
|
-
if (tip) {
|
|
4779
|
-
instructions.push(
|
|
4780
|
-
getTransferSolInstruction({
|
|
4781
|
-
source: feePayerSigner,
|
|
4782
|
-
destination: tip.account,
|
|
4783
|
-
amount: tip.lamports
|
|
4784
|
-
})
|
|
4785
|
-
);
|
|
4786
|
-
}
|
|
4787
4696
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
|
|
4788
4697
|
const txMessage = pipe(
|
|
4789
4698
|
createTransactionMessage({ version: 0 }),
|
|
4790
|
-
(tx) => setTransactionMessageFeePayerSigner(
|
|
4699
|
+
(tx) => setTransactionMessageFeePayerSigner(signer, tx),
|
|
4791
4700
|
(tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
|
|
4792
4701
|
(tx) => appendTransactionMessageInstructions(instructions, tx),
|
|
4793
4702
|
(tx) => addSignersToTransactionMessage([orderSigner], tx)
|
|
@@ -5394,11 +5303,11 @@ var RaydiumQuoteProvider = class {
|
|
|
5394
5303
|
};
|
|
5395
5304
|
|
|
5396
5305
|
// src/utils/quote/pumpfun/index.ts
|
|
5397
|
-
import { address as
|
|
5306
|
+
import { address as address3 } from "@solana/kit";
|
|
5398
5307
|
|
|
5399
5308
|
// src/utils/quote/pumpfun/utils.ts
|
|
5400
5309
|
import {
|
|
5401
|
-
address as
|
|
5310
|
+
address as address2,
|
|
5402
5311
|
fetchEncodedAccount as fetchEncodedAccount5,
|
|
5403
5312
|
fetchEncodedAccounts as fetchEncodedAccounts4,
|
|
5404
5313
|
getAddressEncoder as getAddressEncoder8,
|
|
@@ -5476,10 +5385,10 @@ function getGlobalConfigDecoder() {
|
|
|
5476
5385
|
|
|
5477
5386
|
// src/utils/quote/pumpfun/utils.ts
|
|
5478
5387
|
import { getTokenDecoder } from "@solana-program/token";
|
|
5479
|
-
var PUMP_FUN_PROGRAM_ADDRESS =
|
|
5480
|
-
var PUMP_FUN_AMM_PROGRAM_ADDRESS =
|
|
5481
|
-
var WRAPPED_NATIVE_TOKEN_PUBKEY =
|
|
5482
|
-
var GLOBAL_CONFIG_AMM =
|
|
5388
|
+
var PUMP_FUN_PROGRAM_ADDRESS = address2("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P");
|
|
5389
|
+
var PUMP_FUN_AMM_PROGRAM_ADDRESS = address2("pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA");
|
|
5390
|
+
var WRAPPED_NATIVE_TOKEN_PUBKEY = address2("So11111111111111111111111111111111111111112");
|
|
5391
|
+
var GLOBAL_CONFIG_AMM = address2("ADyA8hdefvWN2dbGGWFotbzWxrAvLW83WG6QCVXvJKqw");
|
|
5483
5392
|
var ANCHOR_DISCRIMINATOR_SIZE = 8;
|
|
5484
5393
|
var globalAccountCache = null;
|
|
5485
5394
|
var globalConfigCache = null;
|
|
@@ -5885,8 +5794,8 @@ function estimatePumpFunAmm(baseToken, quoteToken, globalConfig, amount, tradeTy
|
|
|
5885
5794
|
// src/utils/quote/pumpfun/index.ts
|
|
5886
5795
|
var PumpFunQuoteProvider = class {
|
|
5887
5796
|
async getQuote(raydiumParams) {
|
|
5888
|
-
const inputMint =
|
|
5889
|
-
const outputMint =
|
|
5797
|
+
const inputMint = address3(raydiumParams.inputMint);
|
|
5798
|
+
const outputMint = address3(raydiumParams.outputMint);
|
|
5890
5799
|
const [inputBondingCurve, outputBondingCurve] = await this.getTokensBondingCurve(inputMint, outputMint);
|
|
5891
5800
|
const { bondingCurve, isInputPrebonded } = this.ensureSinglePrebondedToken(inputBondingCurve, outputBondingCurve);
|
|
5892
5801
|
let isInputSol = inputMint === NATIVE_SOLANA_TOKEN_ADDRESS || inputMint === WRAPPED_SOL_MINT_ADDRESS;
|
|
@@ -6147,10 +6056,93 @@ var RelayQuoteProvider = class {
|
|
|
6147
6056
|
}
|
|
6148
6057
|
};
|
|
6149
6058
|
|
|
6150
|
-
// src/utils/quote/
|
|
6151
|
-
|
|
6059
|
+
// src/utils/quote/pricing/decimals.ts
|
|
6060
|
+
function convertDecimals(amount, fromDecimals, toDecimals) {
|
|
6061
|
+
const diff = toDecimals - fromDecimals;
|
|
6062
|
+
if (diff >= 0) {
|
|
6063
|
+
return amount * 10n ** BigInt(diff);
|
|
6064
|
+
}
|
|
6065
|
+
return amount / 10n ** BigInt(-diff);
|
|
6066
|
+
}
|
|
6067
|
+
|
|
6068
|
+
// src/utils/quote/pricing/estimate-amount-out.ts
|
|
6069
|
+
var IntentNotViableError = class extends Error {
|
|
6070
|
+
constructor(message) {
|
|
6071
|
+
super(message);
|
|
6072
|
+
this.name = "IntentNotViableError";
|
|
6073
|
+
}
|
|
6074
|
+
};
|
|
6075
|
+
function estimateAmountOut(swapOutput, commissionBps, expenses, commissionDenominator = 10000n) {
|
|
6076
|
+
const commissionFee = swapOutput * commissionBps / commissionDenominator;
|
|
6077
|
+
const total = expenses.gasInTokenOut + expenses.protocolFeeInTokenOut + expenses.extraTransfersInTokenOut + commissionFee;
|
|
6078
|
+
if (total >= swapOutput) {
|
|
6079
|
+
throw new IntentNotViableError(`Total expenses (${total}) meet or exceed swap output (${swapOutput})`);
|
|
6080
|
+
}
|
|
6081
|
+
return swapOutput - total;
|
|
6082
|
+
}
|
|
6083
|
+
|
|
6084
|
+
// src/utils/quote/pricing/expenses.ts
|
|
6085
|
+
init_constants();
|
|
6086
|
+
|
|
6087
|
+
// src/utils/quote/address.ts
|
|
6088
|
+
function compareAddresses2(firstAddress, secondAddress) {
|
|
6152
6089
|
return !!firstAddress && !!secondAddress && firstAddress.toLowerCase() === secondAddress.toLowerCase();
|
|
6090
|
+
}
|
|
6091
|
+
|
|
6092
|
+
// src/utils/quote/pricing/gas.ts
|
|
6093
|
+
init_chains();
|
|
6094
|
+
import { getGasPrice } from "viem/actions";
|
|
6095
|
+
|
|
6096
|
+
// src/utils/quote/pricing/constants.ts
|
|
6097
|
+
var DEFAULT_COMMISSION_BPS = 50n;
|
|
6098
|
+
var SINGLE_CHAIN_COMMISSION_DENOMINATOR = 10000n;
|
|
6099
|
+
var CROSS_CHAIN_COMMISSION_DENOMINATOR = 100000n;
|
|
6100
|
+
var EVM_SINGLE_CHAIN_GAS_LIMIT = 3000000n;
|
|
6101
|
+
var EVM_CROSS_CHAIN_GAS_LIMIT = 2000000n;
|
|
6102
|
+
var NON_EVM_FIXED_NATIVE_GAS_COST = {
|
|
6103
|
+
[101 /* Sui */]: 20000000n,
|
|
6104
|
+
[7565164 /* Solana */]: 200000n
|
|
6153
6105
|
};
|
|
6106
|
+
|
|
6107
|
+
// src/utils/quote/pricing/gas.ts
|
|
6108
|
+
async function getNativeGasCost(params) {
|
|
6109
|
+
const { chainId, gasLimit, rpcProviderUrl } = params;
|
|
6110
|
+
if (isEvmChain(chainId)) {
|
|
6111
|
+
const client = ChainProvider.getClient(chainId, rpcProviderUrl);
|
|
6112
|
+
const gasPrice = await getGasPrice(client);
|
|
6113
|
+
return gasLimit * gasPrice;
|
|
6114
|
+
}
|
|
6115
|
+
const fixed = NON_EVM_FIXED_NATIVE_GAS_COST[chainId];
|
|
6116
|
+
if (fixed === void 0) {
|
|
6117
|
+
throw new Error(`No fixed native gas cost configured for chain ${chainId}`);
|
|
6118
|
+
}
|
|
6119
|
+
return fixed;
|
|
6120
|
+
}
|
|
6121
|
+
|
|
6122
|
+
// src/utils/quote/pricing/expenses.ts
|
|
6123
|
+
function nativeTokenAddressForChain(chainId) {
|
|
6124
|
+
if (chainId === 7565164 /* Solana */) return NATIVE_SOLANA_TOKEN_ADDRESS;
|
|
6125
|
+
if (chainId === 101 /* Sui */) return NATIVE_SUI_TOKEN_ADDRESS;
|
|
6126
|
+
return NATIVE_EVM_ETH_ADDRESSES[0];
|
|
6127
|
+
}
|
|
6128
|
+
function isNativeToken(chainId, address9) {
|
|
6129
|
+
if (chainId === 7565164 /* Solana */) return compareAddresses2(address9, NATIVE_SOLANA_TOKEN_ADDRESS);
|
|
6130
|
+
if (chainId === 101 /* Sui */) return compareAddresses2(address9, NATIVE_SUI_TOKEN_ADDRESS);
|
|
6131
|
+
return isNativeEvmToken(address9);
|
|
6132
|
+
}
|
|
6133
|
+
async function estimateExpensesInTokenOut(params) {
|
|
6134
|
+
const { chainId, tokenOut, gasLimit, getQuote, rpcProviderUrl } = params;
|
|
6135
|
+
const nativeGasCost = await getNativeGasCost({ chainId, gasLimit, rpcProviderUrl });
|
|
6136
|
+
const gasInTokenOut = isNativeToken(chainId, tokenOut) ? nativeGasCost : (await getQuote({
|
|
6137
|
+
chainId,
|
|
6138
|
+
amount: nativeGasCost,
|
|
6139
|
+
tokenIn: nativeTokenAddressForChain(chainId),
|
|
6140
|
+
tokenOut
|
|
6141
|
+
})).amountOut;
|
|
6142
|
+
return { gasInTokenOut, protocolFeeInTokenOut: 0n, extraTransfersInTokenOut: 0n };
|
|
6143
|
+
}
|
|
6144
|
+
|
|
6145
|
+
// src/utils/quote/aggregator.ts
|
|
6154
6146
|
var QuoteProvider = class _QuoteProvider {
|
|
6155
6147
|
static async getQuote(params) {
|
|
6156
6148
|
try {
|
|
@@ -6167,6 +6159,7 @@ var QuoteProvider = class _QuoteProvider {
|
|
|
6167
6159
|
}
|
|
6168
6160
|
};
|
|
6169
6161
|
} catch (e) {
|
|
6162
|
+
if (e instanceof IntentNotViableError) throw e;
|
|
6170
6163
|
console.error("Error getting quote from routers:", e);
|
|
6171
6164
|
throw new Error("Failed to get quote from routers");
|
|
6172
6165
|
}
|
|
@@ -6196,9 +6189,19 @@ var QuoteProvider = class _QuoteProvider {
|
|
|
6196
6189
|
tokenIn: params.tokenIn,
|
|
6197
6190
|
tokenOut: sourceStable.address
|
|
6198
6191
|
};
|
|
6199
|
-
const sourceQuote = await
|
|
6200
|
-
|
|
6201
|
-
|
|
6192
|
+
const [sourceQuote, expenses] = await Promise.all([
|
|
6193
|
+
this.getSingleChainQuote(sourceSingleChainQuoteParams),
|
|
6194
|
+
estimateExpensesInTokenOut({
|
|
6195
|
+
chainId: params.destChainId,
|
|
6196
|
+
tokenOut: params.tokenOut,
|
|
6197
|
+
gasLimit: EVM_CROSS_CHAIN_GAS_LIMIT,
|
|
6198
|
+
getQuote: (p) => this.getSingleChainQuote(p)
|
|
6199
|
+
})
|
|
6200
|
+
]);
|
|
6201
|
+
const normalizedBridgeAmount = convertDecimals(
|
|
6202
|
+
sourceQuote.amountOut,
|
|
6203
|
+
sourceStable.decimals,
|
|
6204
|
+
destStable.decimals
|
|
6202
6205
|
);
|
|
6203
6206
|
const destSingleChainQuoteParams = {
|
|
6204
6207
|
chainId: params.destChainId,
|
|
@@ -6210,12 +6213,19 @@ var QuoteProvider = class _QuoteProvider {
|
|
|
6210
6213
|
const estimatedAmountInAsMinStablecoinAmount = BigInt(
|
|
6211
6214
|
Math.floor(sourceQuote.amountInUsd * 10 ** sourceStable.decimals)
|
|
6212
6215
|
);
|
|
6216
|
+
const swapOutput = destQuote.amountOutMin ?? destQuote.amountOut;
|
|
6217
|
+
const estimatedAmountOutReduced = estimateAmountOut(
|
|
6218
|
+
swapOutput,
|
|
6219
|
+
DEFAULT_COMMISSION_BPS,
|
|
6220
|
+
expenses,
|
|
6221
|
+
CROSS_CHAIN_COMMISSION_DENOMINATOR
|
|
6222
|
+
);
|
|
6213
6223
|
return {
|
|
6214
6224
|
estimatedAmountOut: destQuote.amountOut,
|
|
6215
6225
|
estimatedAmountOutUsd: destQuote.amountOutUsd,
|
|
6216
6226
|
amountInUsd: sourceQuote.amountInUsd,
|
|
6217
6227
|
estimatedAmountInAsMinStablecoinAmount,
|
|
6218
|
-
estimatedAmountOutReduced
|
|
6228
|
+
estimatedAmountOutReduced,
|
|
6219
6229
|
estimatedAmountOutUsdReduced: destQuote.amountOutUsd
|
|
6220
6230
|
};
|
|
6221
6231
|
}
|
|
@@ -6674,7 +6684,10 @@ var CrossChainOrder = class _CrossChainOrder {
|
|
|
6674
6684
|
tokenOut: this.destinationTokenAddress,
|
|
6675
6685
|
destinationAddress: this.destinationAddress,
|
|
6676
6686
|
amountOutMin: this.destinationTokenMinAmount,
|
|
6677
|
-
extraTransfers: this.extraTransfers
|
|
6687
|
+
extraTransfers: this.extraTransfers,
|
|
6688
|
+
stopLossType: this.stopLossType,
|
|
6689
|
+
stopLossTriggerPrice: this.stopLossTriggerPrice,
|
|
6690
|
+
takeProfitMinOut: this.takeProfitMinOut
|
|
6678
6691
|
};
|
|
6679
6692
|
}
|
|
6680
6693
|
executionDetailsHashToBytes() {
|
|
@@ -6855,13 +6868,22 @@ var SingleChainOrder = class _SingleChainOrder {
|
|
|
6855
6868
|
});
|
|
6856
6869
|
switch (scenario) {
|
|
6857
6870
|
case "QUOTE_REQUIRED": {
|
|
6858
|
-
const quote = await
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6871
|
+
const [quote, expenses] = await Promise.all([
|
|
6872
|
+
QuoteProvider.getSingleChainQuote({
|
|
6873
|
+
tokenIn: input.tokenIn,
|
|
6874
|
+
amount: input.amountIn,
|
|
6875
|
+
chainId: input.chainId,
|
|
6876
|
+
tokenOut: input.tokenOut
|
|
6877
|
+
}),
|
|
6878
|
+
estimateExpensesInTokenOut({
|
|
6879
|
+
chainId: input.chainId,
|
|
6880
|
+
tokenOut: input.tokenOut,
|
|
6881
|
+
gasLimit: EVM_SINGLE_CHAIN_GAS_LIMIT,
|
|
6882
|
+
getQuote: (p) => QuoteProvider.getSingleChainQuote(p)
|
|
6883
|
+
})
|
|
6884
|
+
]);
|
|
6885
|
+
const swapOutput = quote.amountOutMin ?? quote.amountOut;
|
|
6886
|
+
return estimateAmountOut(swapOutput, DEFAULT_COMMISSION_BPS, expenses, SINGLE_CHAIN_COMMISSION_DENOMINATOR);
|
|
6865
6887
|
}
|
|
6866
6888
|
case "USE_PROVIDED_AMOUNT":
|
|
6867
6889
|
return amountOutMin;
|
|
@@ -6921,7 +6943,7 @@ var BaseSDK = class _BaseSDK {
|
|
|
6921
6943
|
static async makeRequest(url, body) {
|
|
6922
6944
|
const response = await fetch(url, {
|
|
6923
6945
|
method: "POST",
|
|
6924
|
-
headers:
|
|
6946
|
+
headers: { "Content-Type": "application/json" },
|
|
6925
6947
|
body
|
|
6926
6948
|
});
|
|
6927
6949
|
console.debug(`url`, url, `body`, body);
|
|
@@ -6990,14 +7012,21 @@ var BaseSDK = class _BaseSDK {
|
|
|
6990
7012
|
static async validateDcaSingleChainOrder(intentRequest) {
|
|
6991
7013
|
return _BaseSDK.validateOrder(intentRequest, "/validate_intent/single_chain/dca_order");
|
|
6992
7014
|
}
|
|
7015
|
+
static async validateDcaCrossChainOrder(intentRequest) {
|
|
7016
|
+
return _BaseSDK.validateOrder(intentRequest, "/validate_intent/cross_chain/dca_order");
|
|
7017
|
+
}
|
|
7018
|
+
static async sendDcaCrossChainOrder(intentRequest) {
|
|
7019
|
+
const body = JSON.stringify(intentRequest, Parsers.bigIntReplacer);
|
|
7020
|
+
return _BaseSDK.makeRequest(`${AUCTIONEER_URL}/user_intent/cross_chain/dca_order`, body);
|
|
7021
|
+
}
|
|
6993
7022
|
};
|
|
6994
7023
|
|
|
6995
7024
|
// src/core/solana/dca/create-order.ts
|
|
6996
7025
|
import {
|
|
6997
|
-
address as
|
|
7026
|
+
address as address4,
|
|
6998
7027
|
addSignersToTransactionMessage as addSignersToTransactionMessage2,
|
|
6999
7028
|
appendTransactionMessageInstructions as appendTransactionMessageInstructions2,
|
|
7000
|
-
createNoopSigner as
|
|
7029
|
+
createNoopSigner as createNoopSigner2,
|
|
7001
7030
|
createSolanaRpc as createSolanaRpc3,
|
|
7002
7031
|
createTransactionMessage as createTransactionMessage2,
|
|
7003
7032
|
fetchEncodedAccount as fetchEncodedAccount6,
|
|
@@ -7021,17 +7050,16 @@ import { getTransferSolInstruction as getTransferSolInstruction2 } from "@solana
|
|
|
7021
7050
|
async function getSolanaDcaSingleChainOrderInstructions(order, options) {
|
|
7022
7051
|
const rpc = options?.rpcUrl ? createSolanaRpc3(options.rpcUrl) : getDefaultSolanaRPC();
|
|
7023
7052
|
const orderSigner = await generateKeyPairSigner2();
|
|
7024
|
-
const
|
|
7025
|
-
|
|
7026
|
-
let tokenInMint = address5(order.tokenIn);
|
|
7053
|
+
const signer = createNoopSigner2(order.user);
|
|
7054
|
+
let tokenInMint = address4(order.tokenIn);
|
|
7027
7055
|
const { secretHash, secretNumber } = genSecretHashAndNumber(order);
|
|
7028
|
-
const orderUserAddress =
|
|
7056
|
+
const orderUserAddress = address4(order.user);
|
|
7029
7057
|
const spendingNative = tokenInMint === NATIVE_SOLANA_TOKEN_ADDRESS;
|
|
7030
7058
|
if (spendingNative) {
|
|
7031
7059
|
tokenInMint = WRAPPED_SOL_MINT_ADDRESS;
|
|
7032
7060
|
}
|
|
7033
7061
|
const tokenMintProgram = await fetchMint2(rpc, tokenInMint);
|
|
7034
|
-
const guardAddress =
|
|
7062
|
+
const guardAddress = address4(SINGLE_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */]);
|
|
7035
7063
|
const addressEncoder = getAddressEncoder9();
|
|
7036
7064
|
const instructions = [];
|
|
7037
7065
|
const [tokenInProgramAccount] = await getProgramDerivedAddress6({
|
|
@@ -7045,7 +7073,7 @@ async function getSolanaDcaSingleChainOrderInstructions(order, options) {
|
|
|
7045
7073
|
const userTokenInAccount = await fetchEncodedAccount6(rpc, tokenInProgramAccount);
|
|
7046
7074
|
if (!userTokenInAccount.exists) {
|
|
7047
7075
|
const createAccountIx = await getCreateAssociatedTokenInstructionAsync2({
|
|
7048
|
-
payer:
|
|
7076
|
+
payer: signer,
|
|
7049
7077
|
ata: tokenInProgramAccount,
|
|
7050
7078
|
owner: orderUserAddress,
|
|
7051
7079
|
mint: tokenMintProgram.address,
|
|
@@ -7058,7 +7086,7 @@ async function getSolanaDcaSingleChainOrderInstructions(order, options) {
|
|
|
7058
7086
|
const transferIx = getTransferSolInstruction2({
|
|
7059
7087
|
amount: totalAmountIn,
|
|
7060
7088
|
destination: userTokenInAccount.address,
|
|
7061
|
-
source:
|
|
7089
|
+
source: signer
|
|
7062
7090
|
});
|
|
7063
7091
|
instructions.push(transferIx);
|
|
7064
7092
|
const syncNativeIx = getSyncNativeInstruction2({
|
|
@@ -7067,7 +7095,7 @@ async function getSolanaDcaSingleChainOrderInstructions(order, options) {
|
|
|
7067
7095
|
instructions.push(syncNativeIx);
|
|
7068
7096
|
}
|
|
7069
7097
|
const createDcaOrderIx = await getCreateDcaOrderInstructionAsync({
|
|
7070
|
-
user:
|
|
7098
|
+
user: signer,
|
|
7071
7099
|
order: orderSigner,
|
|
7072
7100
|
guard: guardAddress,
|
|
7073
7101
|
tokenInMint,
|
|
@@ -7083,20 +7111,10 @@ async function getSolanaDcaSingleChainOrderInstructions(order, options) {
|
|
|
7083
7111
|
// TODO: Implement extra transfers
|
|
7084
7112
|
});
|
|
7085
7113
|
instructions.push(createDcaOrderIx);
|
|
7086
|
-
const tip = resolveSolanaTip(options);
|
|
7087
|
-
if (tip) {
|
|
7088
|
-
instructions.push(
|
|
7089
|
-
getTransferSolInstruction2({
|
|
7090
|
-
source: feePayerSigner,
|
|
7091
|
-
destination: tip.account,
|
|
7092
|
-
amount: tip.lamports
|
|
7093
|
-
})
|
|
7094
|
-
);
|
|
7095
|
-
}
|
|
7096
7114
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
|
|
7097
7115
|
const txMessage = pipe2(
|
|
7098
7116
|
createTransactionMessage2({ version: 0 }),
|
|
7099
|
-
(tx) => setTransactionMessageFeePayerSigner2(
|
|
7117
|
+
(tx) => setTransactionMessageFeePayerSigner2(signer, tx),
|
|
7100
7118
|
(tx) => setTransactionMessageLifetimeUsingBlockhash2(latestBlockhash, tx),
|
|
7101
7119
|
(tx) => appendTransactionMessageInstructions2(instructions, tx),
|
|
7102
7120
|
(tx) => addSignersToTransactionMessage2([orderSigner], tx)
|
|
@@ -7227,9 +7245,7 @@ import "viem";
|
|
|
7227
7245
|
init_constants();
|
|
7228
7246
|
async function fetchSiweMessage(params) {
|
|
7229
7247
|
const url = `${AUCTIONEER_URL}/siwe?wallet=${params.wallet}&chainId=${params.chainId}`;
|
|
7230
|
-
const response = await fetch(url
|
|
7231
|
-
headers: withAuctioneerHeaders()
|
|
7232
|
-
});
|
|
7248
|
+
const response = await fetch(url);
|
|
7233
7249
|
if (!response.ok) {
|
|
7234
7250
|
throw new Error(`Failed to fetch SIWE message: ${response.status} ${response.statusText}`);
|
|
7235
7251
|
}
|
|
@@ -7238,12 +7254,14 @@ async function fetchSiweMessage(params) {
|
|
|
7238
7254
|
}
|
|
7239
7255
|
async function fetchJWTToken(params, token) {
|
|
7240
7256
|
const url = `${AUCTIONEER_URL}/siwe`;
|
|
7257
|
+
const headers = { "Content-Type": "application/json" };
|
|
7258
|
+
if (token) {
|
|
7259
|
+
headers.Authorization = `Bearer ${token}`;
|
|
7260
|
+
}
|
|
7241
7261
|
const response = await fetch(url, {
|
|
7242
7262
|
method: "POST",
|
|
7243
7263
|
body: JSON.stringify(params),
|
|
7244
|
-
headers
|
|
7245
|
-
Authorization: `Bearer ${token}`
|
|
7246
|
-
})
|
|
7264
|
+
headers
|
|
7247
7265
|
});
|
|
7248
7266
|
if (!response.ok) {
|
|
7249
7267
|
throw new Error(`Failed to fetch JWT token: ${response.status} ${response.statusText}`);
|
|
@@ -7410,11 +7428,11 @@ var EVMSDK = class extends BaseSDK {
|
|
|
7410
7428
|
|
|
7411
7429
|
// src/core/solana/sdk.ts
|
|
7412
7430
|
import {
|
|
7413
|
-
address as
|
|
7431
|
+
address as address7,
|
|
7414
7432
|
appendTransactionMessageInstructions as appendTransactionMessageInstructions4,
|
|
7415
7433
|
compileTransaction,
|
|
7416
7434
|
createKeyPairFromBytes,
|
|
7417
|
-
createNoopSigner as
|
|
7435
|
+
createNoopSigner as createNoopSigner5,
|
|
7418
7436
|
createSignableMessage,
|
|
7419
7437
|
createSignerFromKeyPair,
|
|
7420
7438
|
createTransactionMessage as createTransactionMessage4,
|
|
@@ -7431,10 +7449,10 @@ import {
|
|
|
7431
7449
|
|
|
7432
7450
|
// src/core/solana/cancel-order.ts
|
|
7433
7451
|
import {
|
|
7434
|
-
address as
|
|
7452
|
+
address as address5,
|
|
7435
7453
|
appendTransactionMessageInstructions as appendTransactionMessageInstructions3,
|
|
7436
7454
|
compileTransactionMessage,
|
|
7437
|
-
createNoopSigner as
|
|
7455
|
+
createNoopSigner as createNoopSigner3,
|
|
7438
7456
|
createSolanaRpc as createSolanaRpc4,
|
|
7439
7457
|
createTransactionMessage as createTransactionMessage3,
|
|
7440
7458
|
fetchEncodedAccount as fetchEncodedAccount7,
|
|
@@ -7453,7 +7471,7 @@ import {
|
|
|
7453
7471
|
} from "@solana-program/token";
|
|
7454
7472
|
async function cancelSingleChainOrderInstructions(orderAddress, options) {
|
|
7455
7473
|
const rpc = options?.rpcUrl ? createSolanaRpc4(options.rpcUrl) : getDefaultSolanaRPC();
|
|
7456
|
-
const orderId =
|
|
7474
|
+
const orderId = address5(orderAddress);
|
|
7457
7475
|
const chainOrder = await fetchMaybeLimitOrder(rpc, orderId);
|
|
7458
7476
|
if (!chainOrder.exists) {
|
|
7459
7477
|
throw new Error(`Order with address ${orderAddress} not found`);
|
|
@@ -7488,7 +7506,7 @@ async function cancelSingleChainOrderInstructions(orderAddress, options) {
|
|
|
7488
7506
|
const createTokenIx = await getCreateAssociatedTokenInstructionAsync3({
|
|
7489
7507
|
mint: tokenInMint,
|
|
7490
7508
|
owner: orderUserAddress,
|
|
7491
|
-
payer:
|
|
7509
|
+
payer: createNoopSigner3(orderUserAddress),
|
|
7492
7510
|
tokenProgram: tokenMintProgram.programAddress
|
|
7493
7511
|
});
|
|
7494
7512
|
instructions.push(createTokenIx);
|
|
@@ -7500,7 +7518,7 @@ async function cancelSingleChainOrderInstructions(orderAddress, options) {
|
|
|
7500
7518
|
userTokenInAccount: userTokenInAccount.address,
|
|
7501
7519
|
guardTokenInAccount: guardProgramAccount,
|
|
7502
7520
|
tokenInProgram: tokenMintProgram.programAddress,
|
|
7503
|
-
signer:
|
|
7521
|
+
signer: createNoopSigner3(orderUserAddress),
|
|
7504
7522
|
user: orderUserAddress
|
|
7505
7523
|
});
|
|
7506
7524
|
instructions.push(cancelLimitOrderIx);
|
|
@@ -7512,7 +7530,7 @@ async function cancelCrossChainOrderInstructionsAsBytes(orderAddress, signerAddr
|
|
|
7512
7530
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
|
|
7513
7531
|
const txMessage = pipe3(
|
|
7514
7532
|
createTransactionMessage3({ version: 0 }),
|
|
7515
|
-
(tx) => setTransactionMessageFeePayerSigner3(
|
|
7533
|
+
(tx) => setTransactionMessageFeePayerSigner3(createNoopSigner3(address5(signerAddress)), tx),
|
|
7516
7534
|
(tx) => setTransactionMessageLifetimeUsingBlockhash3(latestBlockhash, tx),
|
|
7517
7535
|
(tx) => appendTransactionMessageInstructions3(instructions, tx)
|
|
7518
7536
|
);
|
|
@@ -7526,7 +7544,7 @@ async function cancelSingleChainOrderInstructionsAsBytes(orderAddress, signerAdd
|
|
|
7526
7544
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
|
|
7527
7545
|
const txMessage = pipe3(
|
|
7528
7546
|
createTransactionMessage3({ version: 0 }),
|
|
7529
|
-
(tx) => setTransactionMessageFeePayerSigner3(
|
|
7547
|
+
(tx) => setTransactionMessageFeePayerSigner3(createNoopSigner3(address5(signerAddress)), tx),
|
|
7530
7548
|
(tx) => setTransactionMessageLifetimeUsingBlockhash3(latestBlockhash, tx),
|
|
7531
7549
|
(tx) => appendTransactionMessageInstructions3(instructions, tx)
|
|
7532
7550
|
);
|
|
@@ -7536,7 +7554,7 @@ async function cancelSingleChainOrderInstructionsAsBytes(orderAddress, signerAdd
|
|
|
7536
7554
|
}
|
|
7537
7555
|
async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
7538
7556
|
const rpc = options?.rpcUrl ? createSolanaRpc4(options.rpcUrl) : getDefaultSolanaRPC();
|
|
7539
|
-
const orderId =
|
|
7557
|
+
const orderId = address5(orderAddress);
|
|
7540
7558
|
const chainOrder = await fetchMaybeOrder(rpc, orderId);
|
|
7541
7559
|
if (!chainOrder.exists) {
|
|
7542
7560
|
throw new Error(`Order with address ${orderAddress} not found`);
|
|
@@ -7546,7 +7564,7 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7546
7564
|
const guardAddress = CROSS_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */];
|
|
7547
7565
|
const addressEncoder = getAddressEncoder10();
|
|
7548
7566
|
const isRecoveringTokenIn = chainOrder.data.lockedStablecoins === 0n;
|
|
7549
|
-
const recoverTokenMint = isRecoveringTokenIn ? chainOrder.data.tokenInMint :
|
|
7567
|
+
const recoverTokenMint = isRecoveringTokenIn ? chainOrder.data.tokenInMint : address5(SOLANA_MINT_TOKEN.mint);
|
|
7550
7568
|
const recoverTokenMintProgram = await fetchMint3(rpc, recoverTokenMint);
|
|
7551
7569
|
const [userRecoveredTokenAccount] = await getProgramDerivedAddress7({
|
|
7552
7570
|
programAddress: ASSOCIATED_TOKEN_PROGRAM_ADDRESS3,
|
|
@@ -7567,7 +7585,7 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7567
7585
|
const userRecoveredTokenAccountInfo = await fetchEncodedAccount7(rpc, userRecoveredTokenAccount);
|
|
7568
7586
|
if (!userRecoveredTokenAccountInfo.exists) {
|
|
7569
7587
|
const createRecoveredTokenAccountIx = await getCreateAssociatedTokenInstructionAsync3({
|
|
7570
|
-
payer:
|
|
7588
|
+
payer: createNoopSigner3(orderUserAddress),
|
|
7571
7589
|
ata: userRecoveredTokenAccount,
|
|
7572
7590
|
owner: orderUserAddress,
|
|
7573
7591
|
mint: recoverTokenMint,
|
|
@@ -7578,7 +7596,7 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7578
7596
|
let userCollateralTokenAccount;
|
|
7579
7597
|
const willClaimCollateral = chainOrder.data.lockedCollateral > 0n;
|
|
7580
7598
|
if (willClaimCollateral) {
|
|
7581
|
-
const collateralTokenMint2 =
|
|
7599
|
+
const collateralTokenMint2 = address5(SOLANA_MINT_TOKEN.mint);
|
|
7582
7600
|
const collateralTokenMintProgram2 = await fetchMint3(rpc, collateralTokenMint2);
|
|
7583
7601
|
const [userCollateralAccount] = await getProgramDerivedAddress7({
|
|
7584
7602
|
programAddress: ASSOCIATED_TOKEN_PROGRAM_ADDRESS3,
|
|
@@ -7592,7 +7610,7 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7592
7610
|
const userCollateralTokenAccountInfo = await fetchEncodedAccount7(rpc, userCollateralTokenAccount);
|
|
7593
7611
|
if (!userCollateralTokenAccountInfo.exists) {
|
|
7594
7612
|
const createCollateralTokenAccountIx = await getCreateAssociatedTokenInstructionAsync3({
|
|
7595
|
-
payer:
|
|
7613
|
+
payer: createNoopSigner3(orderUserAddress),
|
|
7596
7614
|
ata: userCollateralTokenAccount,
|
|
7597
7615
|
owner: orderUserAddress,
|
|
7598
7616
|
mint: collateralTokenMint2,
|
|
@@ -7601,7 +7619,7 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7601
7619
|
instructions.push(createCollateralTokenAccountIx);
|
|
7602
7620
|
}
|
|
7603
7621
|
}
|
|
7604
|
-
const collateralTokenMint =
|
|
7622
|
+
const collateralTokenMint = address5(SOLANA_MINT_TOKEN.mint);
|
|
7605
7623
|
const collateralTokenMintProgram = await fetchMint3(rpc, collateralTokenMint);
|
|
7606
7624
|
const [guardCollateralTokenAccount] = await getProgramDerivedAddress7({
|
|
7607
7625
|
programAddress: ASSOCIATED_TOKEN_PROGRAM_ADDRESS3,
|
|
@@ -7623,7 +7641,7 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7623
7641
|
userCollateralTokenAccount,
|
|
7624
7642
|
guardCollateralTokenAccount,
|
|
7625
7643
|
collateralTokenProgram: collateralTokenMintProgram.programAddress,
|
|
7626
|
-
signer:
|
|
7644
|
+
signer: createNoopSigner3(orderUserAddress)
|
|
7627
7645
|
});
|
|
7628
7646
|
instructions.push(cancelOrderIx);
|
|
7629
7647
|
return instructions;
|
|
@@ -7634,8 +7652,8 @@ import { bytesToHex } from "viem";
|
|
|
7634
7652
|
|
|
7635
7653
|
// src/core/solana/dca/cancel-order.ts
|
|
7636
7654
|
import {
|
|
7637
|
-
address as
|
|
7638
|
-
createNoopSigner as
|
|
7655
|
+
address as address6,
|
|
7656
|
+
createNoopSigner as createNoopSigner4,
|
|
7639
7657
|
createSolanaRpc as createSolanaRpc5,
|
|
7640
7658
|
fetchEncodedAccount as fetchEncodedAccount8,
|
|
7641
7659
|
getAddressEncoder as getAddressEncoder11,
|
|
@@ -7649,7 +7667,7 @@ import {
|
|
|
7649
7667
|
} from "@solana-program/token";
|
|
7650
7668
|
async function cancelDcaSingleChainOrderInstructions(orderAddress, options) {
|
|
7651
7669
|
const rpc = options?.rpcUrl ? createSolanaRpc5(options.rpcUrl) : getDefaultSolanaRPC();
|
|
7652
|
-
const orderId =
|
|
7670
|
+
const orderId = address6(orderAddress);
|
|
7653
7671
|
const chainOrder = await fetchMaybeDcaOrder(rpc, orderId);
|
|
7654
7672
|
if (!chainOrder.exists) {
|
|
7655
7673
|
throw new Error(`Order with address ${orderAddress} not found`);
|
|
@@ -7684,14 +7702,14 @@ async function cancelDcaSingleChainOrderInstructions(orderAddress, options) {
|
|
|
7684
7702
|
const createTokenIx = await getCreateAssociatedTokenInstructionAsync4({
|
|
7685
7703
|
mint: tokenInMint,
|
|
7686
7704
|
owner: orderUserAddress,
|
|
7687
|
-
payer:
|
|
7705
|
+
payer: createNoopSigner4(orderUserAddress),
|
|
7688
7706
|
tokenProgram: tokenMintProgram.programAddress
|
|
7689
7707
|
});
|
|
7690
7708
|
instructions.push(createTokenIx);
|
|
7691
7709
|
}
|
|
7692
7710
|
const cancelLimitOrderIx = getCancelDcaOrderInstruction({
|
|
7693
7711
|
user: orderUserAddress,
|
|
7694
|
-
signer:
|
|
7712
|
+
signer: createNoopSigner4(orderUserAddress),
|
|
7695
7713
|
order: orderId,
|
|
7696
7714
|
guard: guardAddress,
|
|
7697
7715
|
tokenInMint: chainOrder.data.tokenInMint,
|
|
@@ -7735,7 +7753,7 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7735
7753
|
const instructions = await cancelCrossChainOrderInstructions(orderId, { rpcUrl: this.config.rpcProviderUrl });
|
|
7736
7754
|
const signer = await this.getUserSigner();
|
|
7737
7755
|
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
7738
|
-
const noopSigner =
|
|
7756
|
+
const noopSigner = createNoopSigner5(signer.address);
|
|
7739
7757
|
const { value: latestBlockhash } = await this.client.rpc.getLatestBlockhash({ commitment: this.config.commitment }).send();
|
|
7740
7758
|
const transactionMessage = pipe4(
|
|
7741
7759
|
createTransactionMessage4({ version: 0 }),
|
|
@@ -7755,7 +7773,7 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7755
7773
|
const instructions = await cancelSingleChainOrderInstructions(orderId, { rpcUrl: this.config.rpcProviderUrl });
|
|
7756
7774
|
const signer = await this.getUserSigner();
|
|
7757
7775
|
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
7758
|
-
const noopSigner =
|
|
7776
|
+
const noopSigner = createNoopSigner5(signer.address);
|
|
7759
7777
|
const { value: latestBlockhash } = await this.client.rpc.getLatestBlockhash({ commitment: this.config.commitment }).send();
|
|
7760
7778
|
const transactionMessage = pipe4(
|
|
7761
7779
|
createTransactionMessage4({ version: 0 }),
|
|
@@ -7806,7 +7824,7 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7806
7824
|
const signableMessage = createSignableMessage(message);
|
|
7807
7825
|
const signer = await this.getUserSigner();
|
|
7808
7826
|
const signatureArray = await signer.signMessages([signableMessage]);
|
|
7809
|
-
const signatureBytes = signatureArray.map((signature) => signature[
|
|
7827
|
+
const signatureBytes = signatureArray.map((signature) => signature[address7(wallet)])[0];
|
|
7810
7828
|
if (!signatureBytes) {
|
|
7811
7829
|
throw new Error("No signature bytes found");
|
|
7812
7830
|
}
|
|
@@ -7869,7 +7887,7 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7869
7887
|
const instructions = await cancelDcaSingleChainOrderInstructions(orderId, { rpcUrl: this.config.rpcProviderUrl });
|
|
7870
7888
|
const signer = await this.getUserSigner();
|
|
7871
7889
|
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
7872
|
-
const noopSigner =
|
|
7890
|
+
const noopSigner = createNoopSigner5(signer.address);
|
|
7873
7891
|
const { value: latestBlockhash } = await this.client.rpc.getLatestBlockhash({ commitment: this.config.commitment }).send();
|
|
7874
7892
|
const transactionMessage = pipe4(
|
|
7875
7893
|
createTransactionMessage4({ version: 0 }),
|
|
@@ -8043,31 +8061,6 @@ var SuiSDK = class extends BaseSDK {
|
|
|
8043
8061
|
}
|
|
8044
8062
|
};
|
|
8045
8063
|
|
|
8046
|
-
// src/core/orders/api/fetch.ts
|
|
8047
|
-
init_constants();
|
|
8048
|
-
async function fetchUserOrders(evmAddress, solAddress, suiAddress) {
|
|
8049
|
-
const params = new URLSearchParams();
|
|
8050
|
-
if (evmAddress) params.append("evmWallets", evmAddress);
|
|
8051
|
-
if (solAddress) params.append("solanaWallets", solAddress);
|
|
8052
|
-
if (suiAddress) params.append("suiWallets", suiAddress);
|
|
8053
|
-
if ([evmAddress, solAddress, suiAddress].every((a) => !a)) {
|
|
8054
|
-
throw new Error("At least one wallet address is required");
|
|
8055
|
-
}
|
|
8056
|
-
const url = `${AUCTIONEER_URL}/user_intent?${params.toString()}`;
|
|
8057
|
-
const response = await fetch(url, {
|
|
8058
|
-
method: "GET",
|
|
8059
|
-
headers: withAuctioneerHeaders({ "Content-Type": "application/json" })
|
|
8060
|
-
});
|
|
8061
|
-
if (!response.ok) {
|
|
8062
|
-
throw new Error(`Failed to fetch user orders: ${response.status} ${response.statusText}`);
|
|
8063
|
-
}
|
|
8064
|
-
const data = await response.json();
|
|
8065
|
-
if (!data.success) {
|
|
8066
|
-
throw new Error(`Failed to fetch user orders: ${data.error}`);
|
|
8067
|
-
}
|
|
8068
|
-
return data.data;
|
|
8069
|
-
}
|
|
8070
|
-
|
|
8071
8064
|
// src/core/orders/api/index.ts
|
|
8072
8065
|
init_constants();
|
|
8073
8066
|
var AuctioneerAPI = class {
|
|
@@ -8082,10 +8075,10 @@ var AuctioneerAPI = class {
|
|
|
8082
8075
|
const url = `${AUCTIONEER_URL}/user_intent`;
|
|
8083
8076
|
const response = await fetch(url, {
|
|
8084
8077
|
method: "GET",
|
|
8085
|
-
headers:
|
|
8078
|
+
headers: {
|
|
8086
8079
|
"Content-Type": "application/json",
|
|
8087
8080
|
Authorization: `Bearer ${this.aggregatedToken}`
|
|
8088
|
-
}
|
|
8081
|
+
}
|
|
8089
8082
|
});
|
|
8090
8083
|
const data = await response.json();
|
|
8091
8084
|
if (!data.success) {
|
|
@@ -8095,6 +8088,14 @@ var AuctioneerAPI = class {
|
|
|
8095
8088
|
}
|
|
8096
8089
|
};
|
|
8097
8090
|
|
|
8091
|
+
// src/core/orders/api/fetch.ts
|
|
8092
|
+
async function fetchUserOrders(aggregatedToken) {
|
|
8093
|
+
if (!aggregatedToken) {
|
|
8094
|
+
throw new Error("A SIWE-issued JWT is required to fetch user orders");
|
|
8095
|
+
}
|
|
8096
|
+
return new AuctioneerAPI(aggregatedToken).getUserOrders();
|
|
8097
|
+
}
|
|
8098
|
+
|
|
8098
8099
|
// src/index.ts
|
|
8099
8100
|
init_errors();
|
|
8100
8101
|
|
|
@@ -8313,7 +8314,7 @@ function getInvalidateNoncesRawData(nonce) {
|
|
|
8313
8314
|
}
|
|
8314
8315
|
|
|
8315
8316
|
// src/core/solana/inspect.ts
|
|
8316
|
-
import { address as
|
|
8317
|
+
import { address as address8, createSolanaRpc as createSolanaRpc6 } from "@solana/kit";
|
|
8317
8318
|
|
|
8318
8319
|
// src/utils/logger.ts
|
|
8319
8320
|
init_errors();
|
|
@@ -8409,7 +8410,7 @@ var logger = Logger.getInstance();
|
|
|
8409
8410
|
// src/core/solana/inspect.ts
|
|
8410
8411
|
async function getSolanaOrdersWithLockedFunds(userAddress, config) {
|
|
8411
8412
|
const rpc = config?.rpcUrl ? createSolanaRpc6(config.rpcUrl) : getDefaultSolanaRPC();
|
|
8412
|
-
const programAccountAddress =
|
|
8413
|
+
const programAccountAddress = address8("DQZQGiVa1PBXesdbCRzmJpZ7AyntLXfAwP5Qty1hgFqQ");
|
|
8413
8414
|
const programAccountsConfig = {
|
|
8414
8415
|
encoding: "base64",
|
|
8415
8416
|
filters: [
|
|
@@ -8525,27 +8526,7 @@ init_single_chain_limit_order();
|
|
|
8525
8526
|
|
|
8526
8527
|
// src/utils/generate-execution-details-hash.ts
|
|
8527
8528
|
import { createHash } from "crypto";
|
|
8528
|
-
function generateExecutionDetailsHash({
|
|
8529
|
-
destChainId,
|
|
8530
|
-
destinationAddress,
|
|
8531
|
-
tokenOut,
|
|
8532
|
-
amountOutMin,
|
|
8533
|
-
stopLossMaxOut,
|
|
8534
|
-
takeProfitMinOut,
|
|
8535
|
-
extraTransfers
|
|
8536
|
-
}) {
|
|
8537
|
-
const executionDetails = JSON.stringify(
|
|
8538
|
-
{
|
|
8539
|
-
destChainId,
|
|
8540
|
-
destinationAddress,
|
|
8541
|
-
tokenOut,
|
|
8542
|
-
amountOutMin,
|
|
8543
|
-
stopLossMaxOut,
|
|
8544
|
-
takeProfitMinOut,
|
|
8545
|
-
extraTransfers
|
|
8546
|
-
},
|
|
8547
|
-
Parsers.bigIntReplacer
|
|
8548
|
-
);
|
|
8529
|
+
function generateExecutionDetailsHash(executionDetails) {
|
|
8549
8530
|
return "0x" + createHash("sha256").update(executionDetails).digest("hex");
|
|
8550
8531
|
}
|
|
8551
8532
|
|
|
@@ -8563,7 +8544,9 @@ function createSuiSingleChainLimitOrderIntentRequest(params) {
|
|
|
8563
8544
|
destinationAddress: params.destinationAddress,
|
|
8564
8545
|
extraTransfers: params.extraTransfers,
|
|
8565
8546
|
deadline: params.deadline,
|
|
8566
|
-
takeProfitMinOut: params.takeProfitMinOut
|
|
8547
|
+
takeProfitMinOut: params.takeProfitMinOut,
|
|
8548
|
+
stopLossType: params.stopLossType,
|
|
8549
|
+
stopLossTriggerPrice: params.stopLossTriggerPrice
|
|
8567
8550
|
};
|
|
8568
8551
|
return {
|
|
8569
8552
|
genericData: order,
|
|
@@ -8613,7 +8596,7 @@ function createSuiCrossChainOrderIntentRequest(params) {
|
|
|
8613
8596
|
extraTransfers: params.extraTransfers
|
|
8614
8597
|
};
|
|
8615
8598
|
const executionDetailsString = JSON.stringify(executionDetails, Parsers.bigIntReplacer);
|
|
8616
|
-
const executionDetailsHash = generateExecutionDetailsHash(
|
|
8599
|
+
const executionDetailsHash = generateExecutionDetailsHash(executionDetailsString);
|
|
8617
8600
|
const genericData = {
|
|
8618
8601
|
user: params.user,
|
|
8619
8602
|
srcChainId: params.srcChainId,
|
|
@@ -8842,6 +8825,7 @@ async function getTokenList(params) {
|
|
|
8842
8825
|
}
|
|
8843
8826
|
|
|
8844
8827
|
// src/core/evm/intent-helpers.ts
|
|
8828
|
+
init_constants();
|
|
8845
8829
|
function createEvmSingleChainLimitOrderIntentRequest(params) {
|
|
8846
8830
|
const order = {
|
|
8847
8831
|
user: params.user,
|
|
@@ -8862,7 +8846,7 @@ function createEvmSingleChainLimitOrderIntentRequest(params) {
|
|
|
8862
8846
|
chainSpecificData: {
|
|
8863
8847
|
EVM: {
|
|
8864
8848
|
nonce: params.nonce || String(Math.floor(Math.random() * 1e7)),
|
|
8865
|
-
signature: params.signature ||
|
|
8849
|
+
signature: params.signature || EVM_ZERO_SIGNATURE
|
|
8866
8850
|
}
|
|
8867
8851
|
}
|
|
8868
8852
|
};
|
|
@@ -8887,7 +8871,7 @@ function createEvmSingleChainDcaOrderIntentRequest(params) {
|
|
|
8887
8871
|
chainSpecificData: {
|
|
8888
8872
|
EVM: {
|
|
8889
8873
|
nonce: params.nonce || String(Math.floor(Math.random() * 1e7)),
|
|
8890
|
-
signature: params.signature ||
|
|
8874
|
+
signature: params.signature || EVM_ZERO_SIGNATURE
|
|
8891
8875
|
}
|
|
8892
8876
|
}
|
|
8893
8877
|
};
|
|
@@ -8904,7 +8888,7 @@ function createEvmCrossChainOrderIntentRequest(params) {
|
|
|
8904
8888
|
stopLossTriggerPrice: params.stopLossTriggerPrice
|
|
8905
8889
|
};
|
|
8906
8890
|
const executionDetailsString = JSON.stringify(executionDetails, Parsers.bigIntReplacer);
|
|
8907
|
-
const executionDetailsHash = generateExecutionDetailsHash(
|
|
8891
|
+
const executionDetailsHash = generateExecutionDetailsHash(executionDetailsString);
|
|
8908
8892
|
const genericData = {
|
|
8909
8893
|
user: params.user,
|
|
8910
8894
|
srcChainId: params.sourceChainId,
|
|
@@ -8913,10 +8897,7 @@ function createEvmCrossChainOrderIntentRequest(params) {
|
|
|
8913
8897
|
minStablecoinsAmount: params.minStablecoinAmount || 1n,
|
|
8914
8898
|
deadline: params.deadline,
|
|
8915
8899
|
executionDetailsHash,
|
|
8916
|
-
extraTransfers: params.extraTransfers
|
|
8917
|
-
takeProfitMinOut: params.takeProfitMinOut,
|
|
8918
|
-
stopLossType: params.stopLossType,
|
|
8919
|
-
stopLossTriggerPrice: params.stopLossTriggerPrice
|
|
8900
|
+
extraTransfers: params.extraTransfers
|
|
8920
8901
|
};
|
|
8921
8902
|
return {
|
|
8922
8903
|
genericData,
|
|
@@ -8924,7 +8905,7 @@ function createEvmCrossChainOrderIntentRequest(params) {
|
|
|
8924
8905
|
chainSpecificData: {
|
|
8925
8906
|
EVM: {
|
|
8926
8907
|
nonce: params.nonce || String(Math.floor(Math.random() * 1e7)),
|
|
8927
|
-
signature: params.signature ||
|
|
8908
|
+
signature: params.signature || EVM_ZERO_SIGNATURE
|
|
8928
8909
|
}
|
|
8929
8910
|
}
|
|
8930
8911
|
};
|
|
@@ -8941,6 +8922,75 @@ async function generateEvmCrossChainOrderTypedData(order) {
|
|
|
8941
8922
|
function generateEvmRandomNonce() {
|
|
8942
8923
|
return String(Math.floor(Math.random() * 1e7));
|
|
8943
8924
|
}
|
|
8925
|
+
function buildCrossChainDcaExecutionDetails(params) {
|
|
8926
|
+
const executionDetails = {
|
|
8927
|
+
destChainId: params.destinationChainId,
|
|
8928
|
+
tokenOut: params.destinationTokenAddress,
|
|
8929
|
+
amountOutMin: params.destinationTokenMinAmount?.toString() || "1",
|
|
8930
|
+
destinationAddress: params.destinationAddress,
|
|
8931
|
+
extraTransfers: params.extraTransfers
|
|
8932
|
+
};
|
|
8933
|
+
const executionDetailsString = JSON.stringify(executionDetails, Parsers.bigIntReplacer);
|
|
8934
|
+
return { executionDetailsString, executionDetailsHash: generateExecutionDetailsHash(executionDetailsString) };
|
|
8935
|
+
}
|
|
8936
|
+
function createEvmCrossChainDcaOrderIntentRequest(params) {
|
|
8937
|
+
const { executionDetailsString, executionDetailsHash } = buildCrossChainDcaExecutionDetails(params);
|
|
8938
|
+
return {
|
|
8939
|
+
genericData: {
|
|
8940
|
+
user: params.user,
|
|
8941
|
+
srcChainId: params.sourceChainId,
|
|
8942
|
+
tokenIn: params.sourceTokenAddress,
|
|
8943
|
+
minStablecoinsAmount: params.minStablecoinAmount || 1n,
|
|
8944
|
+
deadline: params.deadline,
|
|
8945
|
+
executionDetailsHash,
|
|
8946
|
+
startTime: params.startTime,
|
|
8947
|
+
amountInPerInterval: params.amountInPerInterval,
|
|
8948
|
+
totalIntervals: params.totalIntervals,
|
|
8949
|
+
intervalDuration: params.intervalDuration
|
|
8950
|
+
},
|
|
8951
|
+
executionDetails: executionDetailsString,
|
|
8952
|
+
chainSpecificData: {
|
|
8953
|
+
EVM: {
|
|
8954
|
+
nonce: params.nonce || generateEvmRandomNonce(),
|
|
8955
|
+
signature: params.signature || EVM_ZERO_SIGNATURE
|
|
8956
|
+
}
|
|
8957
|
+
}
|
|
8958
|
+
};
|
|
8959
|
+
}
|
|
8960
|
+
function getEVMCrossChainDcaOrderTypedData(params, providedNonce) {
|
|
8961
|
+
const { executionDetailsHash } = buildCrossChainDcaExecutionDetails(params);
|
|
8962
|
+
const nonce = providedNonce ?? EVMIntentProvider.getRandomNonce();
|
|
8963
|
+
const totalAmountIn = params.amountInPerInterval * BigInt(params.totalIntervals);
|
|
8964
|
+
const spender = DCA_CROSS_CHAIN_GUARD_ADDRESSES[params.sourceChainId];
|
|
8965
|
+
const message = {
|
|
8966
|
+
permitted: { token: params.sourceTokenAddress, amount: totalAmountIn },
|
|
8967
|
+
spender,
|
|
8968
|
+
nonce,
|
|
8969
|
+
deadline: BigInt(params.deadline),
|
|
8970
|
+
witness: {
|
|
8971
|
+
user: params.user,
|
|
8972
|
+
tokenIn: params.sourceTokenAddress,
|
|
8973
|
+
srcChainId: params.sourceChainId,
|
|
8974
|
+
startTime: params.startTime,
|
|
8975
|
+
deadline: params.deadline,
|
|
8976
|
+
totalIntervals: params.totalIntervals,
|
|
8977
|
+
intervalDuration: params.intervalDuration,
|
|
8978
|
+
amountInPerInterval: params.amountInPerInterval,
|
|
8979
|
+
minStablecoinsAmountPerInterval: params.minStablecoinAmount || 1n,
|
|
8980
|
+
executionDetailsHash,
|
|
8981
|
+
nonce
|
|
8982
|
+
}
|
|
8983
|
+
};
|
|
8984
|
+
return {
|
|
8985
|
+
orderTypedData: {
|
|
8986
|
+
domain: PERMIT2_DOMAIN(params.sourceChainId),
|
|
8987
|
+
types: CROSS_CHAIN_DCA_PERMIT2_TYPES,
|
|
8988
|
+
primaryType: "PermitWitnessTransferFrom",
|
|
8989
|
+
message
|
|
8990
|
+
},
|
|
8991
|
+
nonce
|
|
8992
|
+
};
|
|
8993
|
+
}
|
|
8944
8994
|
|
|
8945
8995
|
// src/core/solana/intent-helpers.ts
|
|
8946
8996
|
function createSolanaSingleChainLimitOrderIntentRequest(params) {
|
|
@@ -9002,11 +9052,12 @@ function createSolanaCrossChainOrderIntentRequest(params) {
|
|
|
9002
9052
|
amountOutMin: params.destinationTokenMinAmount?.toString() || "1",
|
|
9003
9053
|
destinationAddress: params.destinationAddress,
|
|
9004
9054
|
extraTransfers: params.extraTransfers,
|
|
9005
|
-
|
|
9055
|
+
stopLossType: params.stopLossType,
|
|
9056
|
+
stopLossTriggerPrice: params.stopLossTriggerPrice,
|
|
9006
9057
|
takeProfitMinOut: params.takeProfitMinOut?.toString()
|
|
9007
9058
|
};
|
|
9008
9059
|
const executionDetailsString = JSON.stringify(executionDetails, Parsers.bigIntReplacer);
|
|
9009
|
-
const executionDetailsHash = generateExecutionDetailsHash(
|
|
9060
|
+
const executionDetailsHash = generateExecutionDetailsHash(executionDetailsString);
|
|
9010
9061
|
const genericData = {
|
|
9011
9062
|
user: params.user,
|
|
9012
9063
|
srcChainId: params.sourceChainId,
|
|
@@ -9027,14 +9078,14 @@ function createSolanaCrossChainOrderIntentRequest(params) {
|
|
|
9027
9078
|
}
|
|
9028
9079
|
};
|
|
9029
9080
|
}
|
|
9030
|
-
async function generateSolanaSingleChainLimitOrderInstructions(order
|
|
9031
|
-
return getSolanaSingleChainOrderInstructions(order
|
|
9081
|
+
async function generateSolanaSingleChainLimitOrderInstructions(order) {
|
|
9082
|
+
return getSolanaSingleChainOrderInstructions(order);
|
|
9032
9083
|
}
|
|
9033
|
-
async function generateSolanaSingleChainDcaOrderInstructions(order
|
|
9034
|
-
return getSolanaDcaSingleChainOrderInstructions(order
|
|
9084
|
+
async function generateSolanaSingleChainDcaOrderInstructions(order) {
|
|
9085
|
+
return getSolanaDcaSingleChainOrderInstructions(order);
|
|
9035
9086
|
}
|
|
9036
|
-
async function generateSolanaCrossChainOrderInstructions(order
|
|
9037
|
-
return getSolanaCrossChainOrderInstructions(order
|
|
9087
|
+
async function generateSolanaCrossChainOrderInstructions(order) {
|
|
9088
|
+
return getSolanaCrossChainOrderInstructions(order);
|
|
9038
9089
|
}
|
|
9039
9090
|
function generateSolanaLimitOrderSecretData(tokenOut, receiver, secretNumber, extraTransfers) {
|
|
9040
9091
|
const secret = secretNumber || generateSolanaRandomSecretNumber();
|
|
@@ -9080,11 +9131,12 @@ export {
|
|
|
9080
9131
|
ChainID,
|
|
9081
9132
|
ChainType,
|
|
9082
9133
|
CrossChainOrder,
|
|
9134
|
+
DCA_CROSS_CHAIN_GUARD_ADDRESSES,
|
|
9083
9135
|
DCA_SINGLE_CHAIN_GUARD_ADDRESSES,
|
|
9084
|
-
DEV_ACCESS_HEADER,
|
|
9085
|
-
DEV_ACCESS_STORAGE_KEY,
|
|
9086
9136
|
DcaSingleChainOrder,
|
|
9087
9137
|
EVMSDK,
|
|
9138
|
+
EVM_ZERO_ADDRESS,
|
|
9139
|
+
EVM_ZERO_SIGNATURE,
|
|
9088
9140
|
IntentsOrderType,
|
|
9089
9141
|
MAX_UINT_128,
|
|
9090
9142
|
MAX_UINT_256,
|
|
@@ -9102,8 +9154,6 @@ export {
|
|
|
9102
9154
|
QuoteProvider,
|
|
9103
9155
|
SINGLE_CHAIN_GUARD_ADDRESSES,
|
|
9104
9156
|
SOLANA_MINT_TOKEN,
|
|
9105
|
-
SOLANA_MIN_TIP_LAMPORTS,
|
|
9106
|
-
SOLANA_TIP_ACCOUNTS,
|
|
9107
9157
|
SOLANA_USDC_MINT,
|
|
9108
9158
|
SUI_GUARD_COLLATERAL_TYPE,
|
|
9109
9159
|
SUI_GUARD_STABLECOIN_TYPE,
|
|
@@ -9125,6 +9175,7 @@ export {
|
|
|
9125
9175
|
cancelDcaSingleChainOrderInstructions,
|
|
9126
9176
|
cancelSingleChainOrderInstructionsAsBytes,
|
|
9127
9177
|
chainIdToChainTypeMap,
|
|
9178
|
+
createEvmCrossChainDcaOrderIntentRequest,
|
|
9128
9179
|
createEvmCrossChainOrderIntentRequest,
|
|
9129
9180
|
createEvmSingleChainDcaOrderIntentRequest,
|
|
9130
9181
|
createEvmSingleChainLimitOrderIntentRequest,
|
|
@@ -9154,7 +9205,7 @@ export {
|
|
|
9154
9205
|
getCancelSingleChainOrderRawData,
|
|
9155
9206
|
getCoinFromResponse,
|
|
9156
9207
|
getDcaSecretHash,
|
|
9157
|
-
|
|
9208
|
+
getEVMCrossChainDcaOrderTypedData,
|
|
9158
9209
|
getEVMCrossChainOrderTypedData,
|
|
9159
9210
|
getEVMSingleChainOrderTypedData,
|
|
9160
9211
|
getInvalidateNoncesRawData,
|
|
@@ -9175,10 +9226,10 @@ export {
|
|
|
9175
9226
|
isNativeEvmToken,
|
|
9176
9227
|
isSuccessApiResponse,
|
|
9177
9228
|
isSupportedChain,
|
|
9229
|
+
normalizeNativeEvmTokenForSigning,
|
|
9178
9230
|
prepareDcaSecretData,
|
|
9179
9231
|
prepareSecretData,
|
|
9180
9232
|
signSingleChainDcaOrder,
|
|
9181
|
-
signSingleChainLimitOrder
|
|
9182
|
-
withAuctioneerHeaders
|
|
9233
|
+
signSingleChainLimitOrder
|
|
9183
9234
|
};
|
|
9184
9235
|
//# sourceMappingURL=index.js.map
|