@shogun-sdk/intents-sdk 1.2.6-test.13 → 1.2.6-test.15
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 +401 -268
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -14
- package/dist/index.d.ts +23 -14
- package/dist/index.js +235 -102
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/auth/siwe.ts +5 -6
- package/src/constants.ts +13 -2
- package/src/core/orders/api/fetch.ts +3 -2
- package/src/core/orders/api/index.ts +3 -2
- package/src/core/sdk.ts +3 -2
- package/src/core/solana/dca/create-order.ts +19 -6
- package/src/core/solana/intent-helpers.ts +16 -6
- package/src/core/solana/order-instructions.ts +37 -12
- package/src/core/solana/transaction-options.ts +83 -0
- package/src/index.ts +7 -0
- package/src/utils/auctioneer-headers.ts +32 -0
package/dist/index.cjs
CHANGED
|
@@ -144,7 +144,7 @@ function isNativeEvmToken(tokenAddress) {
|
|
|
144
144
|
const normalizedAddress = tokenAddress.toLowerCase();
|
|
145
145
|
return NATIVE_EVM_ETH_ADDRESSES.some((addr) => addr.toLowerCase() === normalizedAddress);
|
|
146
146
|
}
|
|
147
|
-
var import_kit, 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, 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, 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, TOKEN_SEARCH_API_BASE_URL
|
|
147
|
+
var import_kit, 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, NATIVE_SOLANA_TOKEN_ADDRESS, WRAPPED_SOL_MINT_ADDRESS, SOLANA_TIP_ACCOUNTS, SOLANA_MIN_TIP_LAMPORTS, 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, 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, TOKEN_SEARCH_API_BASE_URL;
|
|
148
148
|
var init_constants = __esm({
|
|
149
149
|
"src/constants.ts"() {
|
|
150
150
|
"use strict";
|
|
@@ -230,6 +230,19 @@ var init_constants = __esm({
|
|
|
230
230
|
DCA_SINGLE_CHAIN_GUARD_ADDRESSES = useProdConfig ? PROD_DCA_SINGLE_CHAIN_GUARD_ADDRESSES : TEST_DCA_SINGLE_CHAIN_GUARD_ADDRESSES;
|
|
231
231
|
NATIVE_SOLANA_TOKEN_ADDRESS = "So11111111111111111111111111111111111111111";
|
|
232
232
|
WRAPPED_SOL_MINT_ADDRESS = "So11111111111111111111111111111111111111112";
|
|
233
|
+
SOLANA_TIP_ACCOUNTS = [
|
|
234
|
+
"4ACfpUFoaSD9bfPdeu6DBt89gB6ENTeHBXCAi87NhDEE",
|
|
235
|
+
"D2L6yPZ2FmmmTKPgzaMKdhu6EWZcTpLy1Vhx8uvZe7NZ",
|
|
236
|
+
"9bnz4RShgq1hAnLnZbP8kbgBg1kEmcJBYQq3gQbmnSta",
|
|
237
|
+
"5VY91ws6B2hMmBFRsXkoAAdsPHBJwRfBht4DXox3xkwn",
|
|
238
|
+
"2nyhqdwKcJZR2vcqCyrYsaPVdAnFoJjiksCXJ7hfEYgD",
|
|
239
|
+
"2q5pghRs6arqVjRvT5gfgWfWcHWmw1ZuCzphgd5KfWGJ",
|
|
240
|
+
"wyvPkWjVZz1M8fHQnMMCDTQDbkManefNNhweYk5WkcF",
|
|
241
|
+
"3KCKozbAaF75qEU33jtzozcJ29yJuaLJTy2jFdzUY8bT",
|
|
242
|
+
"4vieeGHPYPG2MmyPRcYjdiDmmhN3ww7hsFNap8pVN3Ey",
|
|
243
|
+
"4TQLFNWK8AovT1gFvda5jfw2oJeRMKEmw7aH6MGBJ3or"
|
|
244
|
+
];
|
|
245
|
+
SOLANA_MIN_TIP_LAMPORTS = 200000n;
|
|
233
246
|
SOLANA_USDC_MINT = {
|
|
234
247
|
name: "USDC",
|
|
235
248
|
mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
@@ -260,7 +273,6 @@ var init_constants = __esm({
|
|
|
260
273
|
};
|
|
261
274
|
NATIVE_SUI_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
262
275
|
TOKEN_SEARCH_API_BASE_URL = "https://shogun-token-search-api-825534211396.europe-west4.run.app";
|
|
263
|
-
DEV_ACCESS_KEY = process.env.DEV_ACCESS_KEY || process.env.NEXT_PUBLIC_DEV_ACCESS_KEY;
|
|
264
276
|
}
|
|
265
277
|
});
|
|
266
278
|
|
|
@@ -376,7 +388,8 @@ __export(index_exports, {
|
|
|
376
388
|
ChainType: () => ChainType,
|
|
377
389
|
CrossChainOrder: () => CrossChainOrder,
|
|
378
390
|
DCA_SINGLE_CHAIN_GUARD_ADDRESSES: () => DCA_SINGLE_CHAIN_GUARD_ADDRESSES,
|
|
379
|
-
|
|
391
|
+
DEV_ACCESS_HEADER: () => DEV_ACCESS_HEADER,
|
|
392
|
+
DEV_ACCESS_STORAGE_KEY: () => DEV_ACCESS_STORAGE_KEY,
|
|
380
393
|
DcaSingleChainOrder: () => DcaSingleChainOrder,
|
|
381
394
|
EVMSDK: () => EVMSDK,
|
|
382
395
|
IntentsOrderType: () => IntentsOrderType,
|
|
@@ -396,6 +409,8 @@ __export(index_exports, {
|
|
|
396
409
|
QuoteProvider: () => QuoteProvider,
|
|
397
410
|
SINGLE_CHAIN_GUARD_ADDRESSES: () => SINGLE_CHAIN_GUARD_ADDRESSES,
|
|
398
411
|
SOLANA_MINT_TOKEN: () => SOLANA_MINT_TOKEN,
|
|
412
|
+
SOLANA_MIN_TIP_LAMPORTS: () => SOLANA_MIN_TIP_LAMPORTS,
|
|
413
|
+
SOLANA_TIP_ACCOUNTS: () => SOLANA_TIP_ACCOUNTS,
|
|
399
414
|
SOLANA_USDC_MINT: () => SOLANA_USDC_MINT,
|
|
400
415
|
SUI_GUARD_COLLATERAL_TYPE: () => SUI_GUARD_COLLATERAL_TYPE,
|
|
401
416
|
SUI_GUARD_STABLECOIN_TYPE: () => SUI_GUARD_STABLECOIN_TYPE,
|
|
@@ -446,6 +461,7 @@ __export(index_exports, {
|
|
|
446
461
|
getCancelSingleChainOrderRawData: () => getCancelSingleChainOrderRawData,
|
|
447
462
|
getCoinFromResponse: () => getCoinFromResponse,
|
|
448
463
|
getDcaSecretHash: () => getDcaSecretHash,
|
|
464
|
+
getDevAccessHeaderValue: () => getDevAccessHeaderValue,
|
|
449
465
|
getEVMCrossChainOrderTypedData: () => getEVMCrossChainOrderTypedData,
|
|
450
466
|
getEVMSingleChainOrderTypedData: () => getEVMSingleChainOrderTypedData,
|
|
451
467
|
getInvalidateNoncesRawData: () => getInvalidateNoncesRawData,
|
|
@@ -469,7 +485,8 @@ __export(index_exports, {
|
|
|
469
485
|
prepareDcaSecretData: () => prepareDcaSecretData,
|
|
470
486
|
prepareSecretData: () => prepareSecretData,
|
|
471
487
|
signSingleChainDcaOrder: () => signSingleChainDcaOrder,
|
|
472
|
-
signSingleChainLimitOrder: () => signSingleChainLimitOrder
|
|
488
|
+
signSingleChainLimitOrder: () => signSingleChainLimitOrder,
|
|
489
|
+
withAuctioneerHeaders: () => withAuctioneerHeaders
|
|
473
490
|
});
|
|
474
491
|
module.exports = __toCommonJS(index_exports);
|
|
475
492
|
|
|
@@ -554,9 +571,9 @@ var BaseValidator = class {
|
|
|
554
571
|
/**
|
|
555
572
|
* Helper methods that throw specific validation errors
|
|
556
573
|
*/
|
|
557
|
-
validateAddress(
|
|
558
|
-
if (!this.isValidAddress(
|
|
559
|
-
throw new ValidationError(`Invalid ${this.getChainName()} address: ${
|
|
574
|
+
validateAddress(address10) {
|
|
575
|
+
if (!this.isValidAddress(address10)) {
|
|
576
|
+
throw new ValidationError(`Invalid ${this.getChainName()} address: ${address10}`);
|
|
560
577
|
}
|
|
561
578
|
}
|
|
562
579
|
validateTokenAddress(tokenAddress) {
|
|
@@ -3281,9 +3298,9 @@ var ChainProvider = class _ChainProvider {
|
|
|
3281
3298
|
}
|
|
3282
3299
|
});
|
|
3283
3300
|
}
|
|
3284
|
-
getSingleChainAuctioneerContract(
|
|
3301
|
+
getSingleChainAuctioneerContract(address10) {
|
|
3285
3302
|
return (0, import_viem3.getContract)({
|
|
3286
|
-
address:
|
|
3303
|
+
address: address10,
|
|
3287
3304
|
abi: SINGLE_CHAIN_GUARD_LIMIT_ABI,
|
|
3288
3305
|
client: {
|
|
3289
3306
|
wallet: this.walletClient,
|
|
@@ -3322,8 +3339,8 @@ var ChainProvider = class _ChainProvider {
|
|
|
3322
3339
|
|
|
3323
3340
|
// src/core/evm/validator.ts
|
|
3324
3341
|
var EvmValidator = class extends BaseValidator {
|
|
3325
|
-
isValidAddress(
|
|
3326
|
-
return (0, import_viem4.isAddress)(
|
|
3342
|
+
isValidAddress(address10) {
|
|
3343
|
+
return (0, import_viem4.isAddress)(address10);
|
|
3327
3344
|
}
|
|
3328
3345
|
isValidTokenAddress(tokenAddress) {
|
|
3329
3346
|
return (0, import_viem4.isAddress)(tokenAddress);
|
|
@@ -3420,8 +3437,8 @@ var SolanaValidator = class extends BaseValidator {
|
|
|
3420
3437
|
validateSingleChainOrderFeasability() {
|
|
3421
3438
|
return Promise.resolve();
|
|
3422
3439
|
}
|
|
3423
|
-
isValidAddress(
|
|
3424
|
-
return (0, import_kit2.isAddress)(
|
|
3440
|
+
isValidAddress(address10) {
|
|
3441
|
+
return (0, import_kit2.isAddress)(address10);
|
|
3425
3442
|
}
|
|
3426
3443
|
isValidTokenAddress(tokenAddress) {
|
|
3427
3444
|
return (0, import_kit2.isAddress)(tokenAddress);
|
|
@@ -3445,12 +3462,12 @@ var import_utils = require("@mysten/sui/utils");
|
|
|
3445
3462
|
init_constants();
|
|
3446
3463
|
var SUI_TOKEN_ADDRESS_REGEX = /^0x[a-fA-F0-9]{64}::\w+::\w+$/;
|
|
3447
3464
|
var SuiValidator = class extends BaseValidator {
|
|
3448
|
-
isValidAddress(
|
|
3449
|
-
return (0, import_utils.isValidSuiAddress)((0, import_utils.normalizeSuiAddress)(
|
|
3465
|
+
isValidAddress(address10) {
|
|
3466
|
+
return (0, import_utils.isValidSuiAddress)((0, import_utils.normalizeSuiAddress)(address10));
|
|
3450
3467
|
}
|
|
3451
3468
|
isValidTokenAddress(tokenAddress) {
|
|
3452
|
-
const [
|
|
3453
|
-
const isValidAddress =
|
|
3469
|
+
const [address10] = tokenAddress.split("::");
|
|
3470
|
+
const isValidAddress = address10 !== void 0 ? this.isValidAddress(address10) : false;
|
|
3454
3471
|
return isValidAddress && SUI_TOKEN_ADDRESS_REGEX.test(tokenAddress);
|
|
3455
3472
|
}
|
|
3456
3473
|
isValidAmount(amount) {
|
|
@@ -3557,6 +3574,35 @@ var DcaSingleChainOrderValidator = class {
|
|
|
3557
3574
|
init_constants();
|
|
3558
3575
|
init_errors();
|
|
3559
3576
|
|
|
3577
|
+
// src/utils/auctioneer-headers.ts
|
|
3578
|
+
var DEV_ACCESS_STORAGE_KEY = "x-dev-access";
|
|
3579
|
+
var DEV_ACCESS_HEADER = "x-dev-access";
|
|
3580
|
+
function getDevAccessHeaderValue() {
|
|
3581
|
+
try {
|
|
3582
|
+
if (typeof globalThis === "undefined") {
|
|
3583
|
+
return void 0;
|
|
3584
|
+
}
|
|
3585
|
+
const storage = globalThis.localStorage;
|
|
3586
|
+
if (!storage?.getItem) {
|
|
3587
|
+
return void 0;
|
|
3588
|
+
}
|
|
3589
|
+
const value = storage.getItem(DEV_ACCESS_STORAGE_KEY)?.trim();
|
|
3590
|
+
return value ? value : void 0;
|
|
3591
|
+
} catch {
|
|
3592
|
+
return void 0;
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
function withAuctioneerHeaders(headers = {}) {
|
|
3596
|
+
const value = getDevAccessHeaderValue();
|
|
3597
|
+
if (!value) {
|
|
3598
|
+
return headers;
|
|
3599
|
+
}
|
|
3600
|
+
return {
|
|
3601
|
+
...headers,
|
|
3602
|
+
[DEV_ACCESS_HEADER]: value
|
|
3603
|
+
};
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3560
3606
|
// src/utils/parsers.ts
|
|
3561
3607
|
var import_viem5 = require("viem");
|
|
3562
3608
|
var Parsers;
|
|
@@ -3867,7 +3913,7 @@ async function getEVMDcaSingleChainOrderTypedData(order) {
|
|
|
3867
3913
|
// src/core/solana/order-instructions.ts
|
|
3868
3914
|
var import_system = require("@solana-program/system");
|
|
3869
3915
|
var import_token = require("@solana-program/token");
|
|
3870
|
-
var
|
|
3916
|
+
var import_kit5 = require("@solana/kit");
|
|
3871
3917
|
init_constants();
|
|
3872
3918
|
|
|
3873
3919
|
// src/core/solana/client.ts
|
|
@@ -3916,8 +3962,8 @@ function getOrderDecoder() {
|
|
|
3916
3962
|
function decodeOrder(encodedAccount) {
|
|
3917
3963
|
return (0, import_accounts2.decodeAccount)(encodedAccount, getOrderDecoder());
|
|
3918
3964
|
}
|
|
3919
|
-
async function fetchMaybeOrder(rpc,
|
|
3920
|
-
const maybeAccount = await (0, import_accounts2.fetchEncodedAccount)(rpc,
|
|
3965
|
+
async function fetchMaybeOrder(rpc, address10, config) {
|
|
3966
|
+
const maybeAccount = await (0, import_accounts2.fetchEncodedAccount)(rpc, address10, config);
|
|
3921
3967
|
return decodeOrder(maybeAccount);
|
|
3922
3968
|
}
|
|
3923
3969
|
|
|
@@ -4106,8 +4152,8 @@ function getDcaOrderDecoder() {
|
|
|
4106
4152
|
function decodeDcaOrder(encodedAccount) {
|
|
4107
4153
|
return (0, import_accounts3.decodeAccount)(encodedAccount, getDcaOrderDecoder());
|
|
4108
4154
|
}
|
|
4109
|
-
async function fetchMaybeDcaOrder(rpc,
|
|
4110
|
-
const maybeAccount = await (0, import_accounts3.fetchEncodedAccount)(rpc,
|
|
4155
|
+
async function fetchMaybeDcaOrder(rpc, address10, config) {
|
|
4156
|
+
const maybeAccount = await (0, import_accounts3.fetchEncodedAccount)(rpc, address10, config);
|
|
4111
4157
|
return decodeDcaOrder(maybeAccount);
|
|
4112
4158
|
}
|
|
4113
4159
|
|
|
@@ -4132,8 +4178,8 @@ function getLimitOrderDecoder() {
|
|
|
4132
4178
|
function decodeLimitOrder(encodedAccount) {
|
|
4133
4179
|
return (0, import_accounts4.decodeAccount)(encodedAccount, getLimitOrderDecoder());
|
|
4134
4180
|
}
|
|
4135
|
-
async function fetchMaybeLimitOrder(rpc,
|
|
4136
|
-
const maybeAccount = await (0, import_accounts4.fetchEncodedAccount)(rpc,
|
|
4181
|
+
async function fetchMaybeLimitOrder(rpc, address10, config) {
|
|
4182
|
+
const maybeAccount = await (0, import_accounts4.fetchEncodedAccount)(rpc, address10, config);
|
|
4137
4183
|
return decodeLimitOrder(maybeAccount);
|
|
4138
4184
|
}
|
|
4139
4185
|
|
|
@@ -4457,23 +4503,80 @@ function formatTokenPubkey(token) {
|
|
|
4457
4503
|
return token;
|
|
4458
4504
|
}
|
|
4459
4505
|
|
|
4506
|
+
// src/core/solana/transaction-options.ts
|
|
4507
|
+
var import_kit4 = require("@solana/kit");
|
|
4508
|
+
init_constants();
|
|
4509
|
+
function resolveSolanaFeePayer(userSigner, feePayer) {
|
|
4510
|
+
if (!feePayer || feePayer === userSigner.address) {
|
|
4511
|
+
return userSigner;
|
|
4512
|
+
}
|
|
4513
|
+
const feePayerAddress = (0, import_kit4.address)(feePayer);
|
|
4514
|
+
return (0, import_kit4.createNoopSigner)(feePayerAddress);
|
|
4515
|
+
}
|
|
4516
|
+
function resolveSolanaTip(options) {
|
|
4517
|
+
const lamports = normalizeTipLamports(options);
|
|
4518
|
+
if (!lamports) {
|
|
4519
|
+
return void 0;
|
|
4520
|
+
}
|
|
4521
|
+
const selectedTipAccount = options?.tipAccount ?? pickRandomTipAccount(options?.tipAccounts ?? SOLANA_TIP_ACCOUNTS);
|
|
4522
|
+
return {
|
|
4523
|
+
lamports,
|
|
4524
|
+
account: (0, import_kit4.address)(selectedTipAccount)
|
|
4525
|
+
};
|
|
4526
|
+
}
|
|
4527
|
+
function normalizeTipLamports(options) {
|
|
4528
|
+
if (!options) {
|
|
4529
|
+
return void 0;
|
|
4530
|
+
}
|
|
4531
|
+
if (options.tipLamports !== void 0) {
|
|
4532
|
+
if (options.tipLamports <= 0n) {
|
|
4533
|
+
return void 0;
|
|
4534
|
+
}
|
|
4535
|
+
return options.tipLamports < SOLANA_MIN_TIP_LAMPORTS ? SOLANA_MIN_TIP_LAMPORTS : options.tipLamports;
|
|
4536
|
+
}
|
|
4537
|
+
if (options.tipAmountSol === void 0 || options.tipAmountSol === null || options.tipAmountSol === "") {
|
|
4538
|
+
return void 0;
|
|
4539
|
+
}
|
|
4540
|
+
const tipInSol = Number(options.tipAmountSol);
|
|
4541
|
+
if (!Number.isFinite(tipInSol)) {
|
|
4542
|
+
throw new Error("Invalid Solana tip amount");
|
|
4543
|
+
}
|
|
4544
|
+
if (tipInSol <= 0) {
|
|
4545
|
+
return void 0;
|
|
4546
|
+
}
|
|
4547
|
+
const tipLamports = BigInt(Math.round(tipInSol * 1e9));
|
|
4548
|
+
return tipLamports < SOLANA_MIN_TIP_LAMPORTS ? SOLANA_MIN_TIP_LAMPORTS : tipLamports;
|
|
4549
|
+
}
|
|
4550
|
+
function pickRandomTipAccount(accounts) {
|
|
4551
|
+
if (!accounts.length) {
|
|
4552
|
+
throw new Error("No Solana tip accounts configured");
|
|
4553
|
+
}
|
|
4554
|
+
const index = Math.floor(Math.random() * accounts.length);
|
|
4555
|
+
const selected = accounts[index];
|
|
4556
|
+
if (!selected) {
|
|
4557
|
+
throw new Error("No Solana tip account selected");
|
|
4558
|
+
}
|
|
4559
|
+
return selected;
|
|
4560
|
+
}
|
|
4561
|
+
|
|
4460
4562
|
// src/core/solana/order-instructions.ts
|
|
4461
4563
|
async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
4462
|
-
const rpc = options?.rpcUrl ? (0,
|
|
4463
|
-
const orderSigner = await (0,
|
|
4464
|
-
const
|
|
4465
|
-
|
|
4564
|
+
const rpc = options?.rpcUrl ? (0, import_kit5.createSolanaRpc)(options.rpcUrl) : getDefaultSolanaRPC();
|
|
4565
|
+
const orderSigner = await (0, import_kit5.generateKeyPairSigner)();
|
|
4566
|
+
const userSigner = (0, import_kit5.createNoopSigner)(order.user);
|
|
4567
|
+
const feePayerSigner = resolveSolanaFeePayer(userSigner, options?.feePayer);
|
|
4568
|
+
let tokenInMint = (0, import_kit5.address)(order.tokenIn);
|
|
4466
4569
|
const { secretHash, secretNumber } = genSecretHashAndNumber(order);
|
|
4467
|
-
const orderUserAddress = (0,
|
|
4570
|
+
const orderUserAddress = (0, import_kit5.address)(order.user);
|
|
4468
4571
|
const spendingNative = tokenInMint === NATIVE_SOLANA_TOKEN_ADDRESS;
|
|
4469
4572
|
if (spendingNative) {
|
|
4470
4573
|
tokenInMint = WRAPPED_SOL_MINT_ADDRESS;
|
|
4471
4574
|
}
|
|
4472
4575
|
const tokenMintProgram = await (0, import_token.fetchMint)(rpc, tokenInMint);
|
|
4473
|
-
const guardAddress = (0,
|
|
4474
|
-
const addressEncoder = (0,
|
|
4576
|
+
const guardAddress = (0, import_kit5.address)(SINGLE_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */]);
|
|
4577
|
+
const addressEncoder = (0, import_kit5.getAddressEncoder)();
|
|
4475
4578
|
const instructions = [];
|
|
4476
|
-
const [tokenInProgramAccount] = await (0,
|
|
4579
|
+
const [tokenInProgramAccount] = await (0, import_kit5.getProgramDerivedAddress)({
|
|
4477
4580
|
programAddress: import_token.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
4478
4581
|
seeds: [
|
|
4479
4582
|
addressEncoder.encode(orderUserAddress),
|
|
@@ -4481,10 +4584,10 @@ async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
|
4481
4584
|
addressEncoder.encode(tokenInMint)
|
|
4482
4585
|
]
|
|
4483
4586
|
});
|
|
4484
|
-
const userTokenInAccount = await (0,
|
|
4587
|
+
const userTokenInAccount = await (0, import_kit5.fetchEncodedAccount)(rpc, tokenInProgramAccount);
|
|
4485
4588
|
if (!userTokenInAccount.exists) {
|
|
4486
4589
|
const createAccountIx = await (0, import_token.getCreateAssociatedTokenInstructionAsync)({
|
|
4487
|
-
payer:
|
|
4590
|
+
payer: feePayerSigner,
|
|
4488
4591
|
ata: tokenInProgramAccount,
|
|
4489
4592
|
owner: orderUserAddress,
|
|
4490
4593
|
mint: tokenMintProgram.address,
|
|
@@ -4496,7 +4599,7 @@ async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
|
4496
4599
|
const transferIx = (0, import_system.getTransferSolInstruction)({
|
|
4497
4600
|
amount: order.amountIn,
|
|
4498
4601
|
destination: userTokenInAccount.address,
|
|
4499
|
-
source:
|
|
4602
|
+
source: userSigner
|
|
4500
4603
|
});
|
|
4501
4604
|
instructions.push(transferIx);
|
|
4502
4605
|
const syncNativeIx = (0, import_token.getSyncNativeInstruction)({
|
|
@@ -4505,7 +4608,7 @@ async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
|
4505
4608
|
instructions.push(syncNativeIx);
|
|
4506
4609
|
}
|
|
4507
4610
|
const createSingleChainLimitOrderIx = await getCreateLimitOrderInstructionAsync({
|
|
4508
|
-
user:
|
|
4611
|
+
user: userSigner,
|
|
4509
4612
|
order: orderSigner,
|
|
4510
4613
|
guard: guardAddress,
|
|
4511
4614
|
tokenInMint,
|
|
@@ -4519,16 +4622,26 @@ async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
|
4519
4622
|
// TODO
|
|
4520
4623
|
});
|
|
4521
4624
|
instructions.push(createSingleChainLimitOrderIx);
|
|
4625
|
+
const tip = resolveSolanaTip(options);
|
|
4626
|
+
if (tip) {
|
|
4627
|
+
instructions.push(
|
|
4628
|
+
(0, import_system.getTransferSolInstruction)({
|
|
4629
|
+
source: feePayerSigner,
|
|
4630
|
+
destination: tip.account,
|
|
4631
|
+
amount: tip.lamports
|
|
4632
|
+
})
|
|
4633
|
+
);
|
|
4634
|
+
}
|
|
4522
4635
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
|
|
4523
|
-
const txMessage = (0,
|
|
4524
|
-
(0,
|
|
4525
|
-
(tx) => (0,
|
|
4526
|
-
(tx) => (0,
|
|
4527
|
-
(tx) => (0,
|
|
4528
|
-
(tx) => (0,
|
|
4636
|
+
const txMessage = (0, import_kit5.pipe)(
|
|
4637
|
+
(0, import_kit5.createTransactionMessage)({ version: 0 }),
|
|
4638
|
+
(tx) => (0, import_kit5.setTransactionMessageFeePayerSigner)(feePayerSigner, tx),
|
|
4639
|
+
(tx) => (0, import_kit5.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, tx),
|
|
4640
|
+
(tx) => (0, import_kit5.appendTransactionMessageInstructions)(instructions, tx),
|
|
4641
|
+
(tx) => (0, import_kit5.addSignersToTransactionMessage)([orderSigner], tx)
|
|
4529
4642
|
);
|
|
4530
|
-
const partiallySignedTransaction = await (0,
|
|
4531
|
-
const txBytes = (0,
|
|
4643
|
+
const partiallySignedTransaction = await (0, import_kit5.partiallySignTransactionMessageWithSigners)(txMessage);
|
|
4644
|
+
const txBytes = (0, import_kit5.getTransactionCodec)().encode(partiallySignedTransaction);
|
|
4532
4645
|
return {
|
|
4533
4646
|
orderAddress: orderSigner.address,
|
|
4534
4647
|
txBytes,
|
|
@@ -4536,19 +4649,20 @@ async function getSolanaSingleChainOrderInstructions(order, options) {
|
|
|
4536
4649
|
};
|
|
4537
4650
|
}
|
|
4538
4651
|
async function getSolanaCrossChainOrderInstructions(order, options) {
|
|
4539
|
-
const rpc = options?.rpcUrl ? (0,
|
|
4540
|
-
const orderSigner = await (0,
|
|
4541
|
-
const
|
|
4542
|
-
|
|
4543
|
-
|
|
4652
|
+
const rpc = options?.rpcUrl ? (0, import_kit5.createSolanaRpc)(options.rpcUrl) : getDefaultSolanaRPC();
|
|
4653
|
+
const orderSigner = await (0, import_kit5.generateKeyPairSigner)();
|
|
4654
|
+
const userSigner = (0, import_kit5.createNoopSigner)(order.user);
|
|
4655
|
+
const feePayerSigner = resolveSolanaFeePayer(userSigner, options?.feePayer);
|
|
4656
|
+
let tokenInMint = (0, import_kit5.address)(order.sourceTokenAddress);
|
|
4657
|
+
const orderUserAddress = (0, import_kit5.address)(order.user);
|
|
4544
4658
|
const spendingNative = tokenInMint === NATIVE_SOLANA_TOKEN_ADDRESS;
|
|
4545
4659
|
if (spendingNative) {
|
|
4546
4660
|
tokenInMint = WRAPPED_SOL_MINT_ADDRESS;
|
|
4547
4661
|
}
|
|
4548
4662
|
const tokenMintProgram = await (0, import_token.fetchMint)(rpc, tokenInMint);
|
|
4549
|
-
const guardAddress = (0,
|
|
4550
|
-
const addressEncoder = (0,
|
|
4551
|
-
const [tokenInProgramAccount] = await (0,
|
|
4663
|
+
const guardAddress = (0, import_kit5.address)(CROSS_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */]);
|
|
4664
|
+
const addressEncoder = (0, import_kit5.getAddressEncoder)();
|
|
4665
|
+
const [tokenInProgramAccount] = await (0, import_kit5.getProgramDerivedAddress)({
|
|
4552
4666
|
programAddress: import_token.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
4553
4667
|
seeds: [
|
|
4554
4668
|
addressEncoder.encode(orderUserAddress),
|
|
@@ -4556,7 +4670,7 @@ async function getSolanaCrossChainOrderInstructions(order, options) {
|
|
|
4556
4670
|
addressEncoder.encode(tokenInMint)
|
|
4557
4671
|
]
|
|
4558
4672
|
});
|
|
4559
|
-
const [guardProgramAccount] = await (0,
|
|
4673
|
+
const [guardProgramAccount] = await (0, import_kit5.getProgramDerivedAddress)({
|
|
4560
4674
|
programAddress: import_token.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
4561
4675
|
seeds: [
|
|
4562
4676
|
// Owner
|
|
@@ -4568,12 +4682,12 @@ async function getSolanaCrossChainOrderInstructions(order, options) {
|
|
|
4568
4682
|
]
|
|
4569
4683
|
});
|
|
4570
4684
|
const instructions = [];
|
|
4571
|
-
const userTokenInAccount = await (0,
|
|
4685
|
+
const userTokenInAccount = await (0, import_kit5.fetchEncodedAccount)(rpc, tokenInProgramAccount);
|
|
4572
4686
|
if (spendingNative) {
|
|
4573
4687
|
order.sourceTokenAddress = WRAPPED_SOL_MINT_ADDRESS;
|
|
4574
4688
|
if (!userTokenInAccount.exists) {
|
|
4575
4689
|
const createAccountIx = await (0, import_token.getCreateAssociatedTokenInstructionAsync)({
|
|
4576
|
-
payer:
|
|
4690
|
+
payer: feePayerSigner,
|
|
4577
4691
|
ata: tokenInProgramAccount,
|
|
4578
4692
|
owner: orderUserAddress,
|
|
4579
4693
|
mint: tokenMintProgram.address,
|
|
@@ -4582,7 +4696,7 @@ async function getSolanaCrossChainOrderInstructions(order, options) {
|
|
|
4582
4696
|
instructions.push(createAccountIx);
|
|
4583
4697
|
}
|
|
4584
4698
|
const transferIx = (0, import_system.getTransferSolInstruction)({
|
|
4585
|
-
source:
|
|
4699
|
+
source: userSigner,
|
|
4586
4700
|
destination: userTokenInAccount.address,
|
|
4587
4701
|
amount: order.sourceTokenAmount
|
|
4588
4702
|
});
|
|
@@ -4594,9 +4708,9 @@ async function getSolanaCrossChainOrderInstructions(order, options) {
|
|
|
4594
4708
|
}
|
|
4595
4709
|
const executionHashUint8Array = order.executionDetailsHashToBytes();
|
|
4596
4710
|
const createOrderIx = getCreateOrderInstruction({
|
|
4597
|
-
user:
|
|
4711
|
+
user: userSigner,
|
|
4598
4712
|
order: orderSigner,
|
|
4599
|
-
guard: (0,
|
|
4713
|
+
guard: (0, import_kit5.address)(CROSS_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */]),
|
|
4600
4714
|
systemProgram: import_system.SYSTEM_PROGRAM_ADDRESS,
|
|
4601
4715
|
associatedTokenProgram: import_token.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
4602
4716
|
tokenInMint,
|
|
@@ -4609,16 +4723,26 @@ async function getSolanaCrossChainOrderInstructions(order, options) {
|
|
|
4609
4723
|
minStablecoinsAmount: order.minStablecoinAmount
|
|
4610
4724
|
});
|
|
4611
4725
|
instructions.push(createOrderIx);
|
|
4726
|
+
const tip = resolveSolanaTip(options);
|
|
4727
|
+
if (tip) {
|
|
4728
|
+
instructions.push(
|
|
4729
|
+
(0, import_system.getTransferSolInstruction)({
|
|
4730
|
+
source: feePayerSigner,
|
|
4731
|
+
destination: tip.account,
|
|
4732
|
+
amount: tip.lamports
|
|
4733
|
+
})
|
|
4734
|
+
);
|
|
4735
|
+
}
|
|
4612
4736
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
|
|
4613
|
-
const txMessage = (0,
|
|
4614
|
-
(0,
|
|
4615
|
-
(tx) => (0,
|
|
4616
|
-
(tx) => (0,
|
|
4617
|
-
(tx) => (0,
|
|
4618
|
-
(tx) => (0,
|
|
4737
|
+
const txMessage = (0, import_kit5.pipe)(
|
|
4738
|
+
(0, import_kit5.createTransactionMessage)({ version: 0 }),
|
|
4739
|
+
(tx) => (0, import_kit5.setTransactionMessageFeePayerSigner)(feePayerSigner, tx),
|
|
4740
|
+
(tx) => (0, import_kit5.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, tx),
|
|
4741
|
+
(tx) => (0, import_kit5.appendTransactionMessageInstructions)(instructions, tx),
|
|
4742
|
+
(tx) => (0, import_kit5.addSignersToTransactionMessage)([orderSigner], tx)
|
|
4619
4743
|
);
|
|
4620
|
-
const partiallySignedTransaction = await (0,
|
|
4621
|
-
const txBytes = (0,
|
|
4744
|
+
const partiallySignedTransaction = await (0, import_kit5.partiallySignTransactionMessageWithSigners)(txMessage);
|
|
4745
|
+
const txBytes = (0, import_kit5.getTransactionCodec)().encode(partiallySignedTransaction);
|
|
4622
4746
|
return {
|
|
4623
4747
|
orderAddress: orderSigner.address,
|
|
4624
4748
|
txBytes: Uint8Array.from(txBytes)
|
|
@@ -5212,113 +5336,113 @@ var RaydiumQuoteProvider = class {
|
|
|
5212
5336
|
};
|
|
5213
5337
|
|
|
5214
5338
|
// src/utils/quote/pumpfun/index.ts
|
|
5215
|
-
var
|
|
5339
|
+
var import_kit8 = require("@solana/kit");
|
|
5216
5340
|
|
|
5217
5341
|
// src/utils/quote/pumpfun/utils.ts
|
|
5218
|
-
var
|
|
5342
|
+
var import_kit7 = require("@solana/kit");
|
|
5219
5343
|
|
|
5220
5344
|
// src/utils/quote/pumpfun/models.ts
|
|
5221
|
-
var
|
|
5345
|
+
var import_kit6 = require("@solana/kit");
|
|
5222
5346
|
function getPumpPoolDataDecoder() {
|
|
5223
|
-
return (0,
|
|
5224
|
-
["poolBump", (0,
|
|
5225
|
-
["index", (0,
|
|
5226
|
-
["creator", (0,
|
|
5227
|
-
["baseMint", (0,
|
|
5228
|
-
["quoteMint", (0,
|
|
5229
|
-
["lpMint", (0,
|
|
5230
|
-
["poolBaseTokenAccount", (0,
|
|
5231
|
-
["poolQuoteTokenAccount", (0,
|
|
5232
|
-
["lpSupply", (0,
|
|
5233
|
-
["coinCreator", (0,
|
|
5347
|
+
return (0, import_kit6.getStructDecoder)([
|
|
5348
|
+
["poolBump", (0, import_kit6.getU8Decoder)()],
|
|
5349
|
+
["index", (0, import_kit6.getU16Decoder)()],
|
|
5350
|
+
["creator", (0, import_kit6.getAddressDecoder)()],
|
|
5351
|
+
["baseMint", (0, import_kit6.getAddressDecoder)()],
|
|
5352
|
+
["quoteMint", (0, import_kit6.getAddressDecoder)()],
|
|
5353
|
+
["lpMint", (0, import_kit6.getAddressDecoder)()],
|
|
5354
|
+
["poolBaseTokenAccount", (0, import_kit6.getAddressDecoder)()],
|
|
5355
|
+
["poolQuoteTokenAccount", (0, import_kit6.getAddressDecoder)()],
|
|
5356
|
+
["lpSupply", (0, import_kit6.getU64Decoder)()],
|
|
5357
|
+
["coinCreator", (0, import_kit6.getAddressDecoder)()]
|
|
5234
5358
|
]);
|
|
5235
5359
|
}
|
|
5236
5360
|
function getBondingCurveDecoder() {
|
|
5237
|
-
return (0,
|
|
5238
|
-
["virtualTokenReserves", (0,
|
|
5239
|
-
["virtualSolReserves", (0,
|
|
5240
|
-
["realTokenReserves", (0,
|
|
5241
|
-
["realSolReserves", (0,
|
|
5242
|
-
["tokenTotalSupply", (0,
|
|
5243
|
-
["complete", (0,
|
|
5244
|
-
["creator", (0,
|
|
5361
|
+
return (0, import_kit6.getStructDecoder)([
|
|
5362
|
+
["virtualTokenReserves", (0, import_kit6.getU64Decoder)()],
|
|
5363
|
+
["virtualSolReserves", (0, import_kit6.getU64Decoder)()],
|
|
5364
|
+
["realTokenReserves", (0, import_kit6.getU64Decoder)()],
|
|
5365
|
+
["realSolReserves", (0, import_kit6.getU64Decoder)()],
|
|
5366
|
+
["tokenTotalSupply", (0, import_kit6.getU64Decoder)()],
|
|
5367
|
+
["complete", (0, import_kit6.getBooleanDecoder)()],
|
|
5368
|
+
["creator", (0, import_kit6.getAddressDecoder)()]
|
|
5245
5369
|
]);
|
|
5246
5370
|
}
|
|
5247
5371
|
function getGlobalAccountDecoder() {
|
|
5248
|
-
return (0,
|
|
5249
|
-
["initialized", (0,
|
|
5250
|
-
["authority", (0,
|
|
5251
|
-
["feeRecipient", (0,
|
|
5252
|
-
["initialVirtualTokenReserves", (0,
|
|
5253
|
-
["initialVirtualSolReserves", (0,
|
|
5254
|
-
["initialRealTokenReserves", (0,
|
|
5255
|
-
["tokenTotalSupply", (0,
|
|
5256
|
-
["feeBasisPoints", (0,
|
|
5257
|
-
["withdrawAuthority", (0,
|
|
5258
|
-
["enableMigrate", (0,
|
|
5259
|
-
["poolMigrationFee", (0,
|
|
5260
|
-
["creatorFeeBasisPoints", (0,
|
|
5261
|
-
["feeRecipients", (0,
|
|
5372
|
+
return (0, import_kit6.getStructDecoder)([
|
|
5373
|
+
["initialized", (0, import_kit6.getBooleanDecoder)()],
|
|
5374
|
+
["authority", (0, import_kit6.getAddressDecoder)()],
|
|
5375
|
+
["feeRecipient", (0, import_kit6.getAddressDecoder)()],
|
|
5376
|
+
["initialVirtualTokenReserves", (0, import_kit6.getU64Decoder)()],
|
|
5377
|
+
["initialVirtualSolReserves", (0, import_kit6.getU64Decoder)()],
|
|
5378
|
+
["initialRealTokenReserves", (0, import_kit6.getU64Decoder)()],
|
|
5379
|
+
["tokenTotalSupply", (0, import_kit6.getU64Decoder)()],
|
|
5380
|
+
["feeBasisPoints", (0, import_kit6.getU64Decoder)()],
|
|
5381
|
+
["withdrawAuthority", (0, import_kit6.getAddressDecoder)()],
|
|
5382
|
+
["enableMigrate", (0, import_kit6.getBooleanDecoder)()],
|
|
5383
|
+
["poolMigrationFee", (0, import_kit6.getU64Decoder)()],
|
|
5384
|
+
["creatorFeeBasisPoints", (0, import_kit6.getU64Decoder)()],
|
|
5385
|
+
["feeRecipients", (0, import_kit6.getArrayDecoder)((0, import_kit6.getAddressDecoder)(), { size: 7 })],
|
|
5262
5386
|
// Fixed array of 7 Pubkeys
|
|
5263
|
-
["setCreatorAuthority", (0,
|
|
5264
|
-
["adminSetCreatorAuthority", (0,
|
|
5387
|
+
["setCreatorAuthority", (0, import_kit6.getAddressDecoder)()],
|
|
5388
|
+
["adminSetCreatorAuthority", (0, import_kit6.getAddressDecoder)()]
|
|
5265
5389
|
]);
|
|
5266
5390
|
}
|
|
5267
5391
|
function getGlobalConfigDecoder() {
|
|
5268
|
-
return (0,
|
|
5269
|
-
["admin", (0,
|
|
5270
|
-
["lpFeeBasisPoints", (0,
|
|
5271
|
-
["protocolFeeBasisPoints", (0,
|
|
5272
|
-
["disableFlags", (0,
|
|
5273
|
-
["protocolFeeRecipients", (0,
|
|
5392
|
+
return (0, import_kit6.getStructDecoder)([
|
|
5393
|
+
["admin", (0, import_kit6.getAddressDecoder)()],
|
|
5394
|
+
["lpFeeBasisPoints", (0, import_kit6.getU64Decoder)()],
|
|
5395
|
+
["protocolFeeBasisPoints", (0, import_kit6.getU64Decoder)()],
|
|
5396
|
+
["disableFlags", (0, import_kit6.getU8Decoder)()],
|
|
5397
|
+
["protocolFeeRecipients", (0, import_kit6.getArrayDecoder)((0, import_kit6.getAddressDecoder)(), { size: 8 })],
|
|
5274
5398
|
// Fixed array of 8 Pubkeys
|
|
5275
|
-
["coinCreatorFeeBasisPoints", (0,
|
|
5276
|
-
["adminSetCoinCreatorAuthority", (0,
|
|
5399
|
+
["coinCreatorFeeBasisPoints", (0, import_kit6.getU64Decoder)()],
|
|
5400
|
+
["adminSetCoinCreatorAuthority", (0, import_kit6.getAddressDecoder)()]
|
|
5277
5401
|
]);
|
|
5278
5402
|
}
|
|
5279
5403
|
|
|
5280
5404
|
// src/utils/quote/pumpfun/utils.ts
|
|
5281
5405
|
var import_token2 = require("@solana-program/token");
|
|
5282
|
-
var PUMP_FUN_PROGRAM_ADDRESS = (0,
|
|
5283
|
-
var PUMP_FUN_AMM_PROGRAM_ADDRESS = (0,
|
|
5284
|
-
var WRAPPED_NATIVE_TOKEN_PUBKEY = (0,
|
|
5285
|
-
var GLOBAL_CONFIG_AMM = (0,
|
|
5406
|
+
var PUMP_FUN_PROGRAM_ADDRESS = (0, import_kit7.address)("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P");
|
|
5407
|
+
var PUMP_FUN_AMM_PROGRAM_ADDRESS = (0, import_kit7.address)("pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA");
|
|
5408
|
+
var WRAPPED_NATIVE_TOKEN_PUBKEY = (0, import_kit7.address)("So11111111111111111111111111111111111111112");
|
|
5409
|
+
var GLOBAL_CONFIG_AMM = (0, import_kit7.address)("ADyA8hdefvWN2dbGGWFotbzWxrAvLW83WG6QCVXvJKqw");
|
|
5286
5410
|
var ANCHOR_DISCRIMINATOR_SIZE = 8;
|
|
5287
5411
|
var globalAccountCache = null;
|
|
5288
5412
|
var globalConfigCache = null;
|
|
5289
5413
|
var migratedPoolCache = /* @__PURE__ */ new Map();
|
|
5290
5414
|
var poolTokensInfoCache = /* @__PURE__ */ new Map();
|
|
5291
5415
|
async function findBondingCurvePda(tokenMint) {
|
|
5292
|
-
const [pda] = await (0,
|
|
5416
|
+
const [pda] = await (0, import_kit7.getProgramDerivedAddress)({
|
|
5293
5417
|
programAddress: PUMP_FUN_PROGRAM_ADDRESS,
|
|
5294
|
-
seeds: [new TextEncoder().encode("bonding-curve"), (0,
|
|
5418
|
+
seeds: [new TextEncoder().encode("bonding-curve"), (0, import_kit7.getAddressEncoder)().encode(tokenMint)]
|
|
5295
5419
|
});
|
|
5296
5420
|
return pda;
|
|
5297
5421
|
}
|
|
5298
5422
|
async function findGlobalAccountPda() {
|
|
5299
|
-
const [pda] = await (0,
|
|
5423
|
+
const [pda] = await (0, import_kit7.getProgramDerivedAddress)({
|
|
5300
5424
|
programAddress: PUMP_FUN_PROGRAM_ADDRESS,
|
|
5301
5425
|
seeds: [new TextEncoder().encode("global")]
|
|
5302
5426
|
});
|
|
5303
5427
|
return pda;
|
|
5304
5428
|
}
|
|
5305
5429
|
async function findPoolAuthorityPdaAmm(mint) {
|
|
5306
|
-
const [pda] = await (0,
|
|
5430
|
+
const [pda] = await (0, import_kit7.getProgramDerivedAddress)({
|
|
5307
5431
|
programAddress: PUMP_FUN_PROGRAM_ADDRESS,
|
|
5308
|
-
seeds: [new TextEncoder().encode("pool-authority"), (0,
|
|
5432
|
+
seeds: [new TextEncoder().encode("pool-authority"), (0, import_kit7.getAddressEncoder)().encode(mint)]
|
|
5309
5433
|
});
|
|
5310
5434
|
return pda;
|
|
5311
5435
|
}
|
|
5312
5436
|
async function findPoolPdaAmm(poolAuthority, baseMint, quoteMint) {
|
|
5313
|
-
const [pda] = await (0,
|
|
5437
|
+
const [pda] = await (0, import_kit7.getProgramDerivedAddress)({
|
|
5314
5438
|
programAddress: PUMP_FUN_AMM_PROGRAM_ADDRESS,
|
|
5315
5439
|
seeds: [
|
|
5316
5440
|
new TextEncoder().encode("pool"),
|
|
5317
5441
|
new Uint8Array([0, 0]),
|
|
5318
5442
|
// Pool type bytes
|
|
5319
|
-
(0,
|
|
5320
|
-
(0,
|
|
5321
|
-
(0,
|
|
5443
|
+
(0, import_kit7.getAddressEncoder)().encode(poolAuthority),
|
|
5444
|
+
(0, import_kit7.getAddressEncoder)().encode(baseMint),
|
|
5445
|
+
(0, import_kit7.getAddressEncoder)().encode(quoteMint)
|
|
5322
5446
|
]
|
|
5323
5447
|
});
|
|
5324
5448
|
return pda;
|
|
@@ -5327,7 +5451,7 @@ async function getPumpFunBondingCurve(tokenMint) {
|
|
|
5327
5451
|
const rpc = getDefaultSolanaRPC();
|
|
5328
5452
|
try {
|
|
5329
5453
|
const pda = await findBondingCurvePda(tokenMint);
|
|
5330
|
-
const encodedAccount = await (0,
|
|
5454
|
+
const encodedAccount = await (0, import_kit7.fetchEncodedAccount)(rpc, pda);
|
|
5331
5455
|
if (!encodedAccount.exists) {
|
|
5332
5456
|
throw new Error(`Bonding curve account not found for token mint: ${tokenMint}`);
|
|
5333
5457
|
}
|
|
@@ -5351,7 +5475,7 @@ async function getPumpFunGlobalAccount() {
|
|
|
5351
5475
|
}
|
|
5352
5476
|
const rpc = getDefaultSolanaRPC();
|
|
5353
5477
|
const pda = await findGlobalAccountPda();
|
|
5354
|
-
const encodedAccount = await (0,
|
|
5478
|
+
const encodedAccount = await (0, import_kit7.fetchEncodedAccount)(rpc, pda);
|
|
5355
5479
|
if (!encodedAccount.exists) {
|
|
5356
5480
|
throw new Error(`GlobalAccount not found: ${pda}`);
|
|
5357
5481
|
}
|
|
@@ -5378,7 +5502,7 @@ async function getPumpFunGlobalConfig() {
|
|
|
5378
5502
|
return globalConfigCache.data;
|
|
5379
5503
|
}
|
|
5380
5504
|
const rpc = getDefaultSolanaRPC();
|
|
5381
|
-
const encodedAccount = await (0,
|
|
5505
|
+
const encodedAccount = await (0, import_kit7.fetchEncodedAccount)(rpc, GLOBAL_CONFIG_AMM);
|
|
5382
5506
|
if (!encodedAccount.exists) {
|
|
5383
5507
|
throw new Error(`GlobalConfig account not found: ${GLOBAL_CONFIG_AMM}`);
|
|
5384
5508
|
}
|
|
@@ -5408,7 +5532,7 @@ async function getPumpFunMigratedPool(baseMint) {
|
|
|
5408
5532
|
try {
|
|
5409
5533
|
const poolAuthorityPda = await findPoolAuthorityPdaAmm(baseMint);
|
|
5410
5534
|
const poolPda = await findPoolPdaAmm(poolAuthorityPda, baseMint, WRAPPED_NATIVE_TOKEN_PUBKEY);
|
|
5411
|
-
const encodedAccount = await (0,
|
|
5535
|
+
const encodedAccount = await (0, import_kit7.fetchEncodedAccount)(rpc, poolPda);
|
|
5412
5536
|
if (!encodedAccount.exists) {
|
|
5413
5537
|
throw new Error(`Migrated pool not found for token mint: ${baseMint}`);
|
|
5414
5538
|
}
|
|
@@ -5437,7 +5561,7 @@ async function getPoolTokensInfo(poolBaseTokenAccount, poolQuoteTokenAccount) {
|
|
|
5437
5561
|
return cached.data;
|
|
5438
5562
|
}
|
|
5439
5563
|
const rpc = getDefaultSolanaRPC();
|
|
5440
|
-
const accountsInfo = await (0,
|
|
5564
|
+
const accountsInfo = await (0, import_kit7.fetchEncodedAccounts)(rpc, [poolBaseTokenAccount, poolQuoteTokenAccount]);
|
|
5441
5565
|
const baseAccountInfo = accountsInfo[0];
|
|
5442
5566
|
if (!baseAccountInfo || !baseAccountInfo.exists) {
|
|
5443
5567
|
throw new Error(`Base token account not found: ${poolBaseTokenAccount}`);
|
|
@@ -5452,22 +5576,22 @@ async function getPoolTokensInfo(poolBaseTokenAccount, poolQuoteTokenAccount) {
|
|
|
5452
5576
|
mint: baseDecoded.mint,
|
|
5453
5577
|
owner: baseDecoded.owner,
|
|
5454
5578
|
amount: baseDecoded.amount,
|
|
5455
|
-
delegate: (0,
|
|
5579
|
+
delegate: (0, import_kit7.unwrapOption)(baseDecoded.delegate),
|
|
5456
5580
|
state: baseDecoded.state,
|
|
5457
|
-
isNative: (0,
|
|
5581
|
+
isNative: (0, import_kit7.unwrapOption)(baseDecoded.isNative),
|
|
5458
5582
|
delegatedAmount: baseDecoded.delegatedAmount,
|
|
5459
|
-
closeAuthority: (0,
|
|
5583
|
+
closeAuthority: (0, import_kit7.unwrapOption)(baseDecoded.closeAuthority)
|
|
5460
5584
|
};
|
|
5461
5585
|
const quoteDecoded = tokenDecoder.decode(quoteAccountInfo.data);
|
|
5462
5586
|
const quoteTokenAccount = {
|
|
5463
5587
|
mint: quoteDecoded.mint,
|
|
5464
5588
|
owner: quoteDecoded.owner,
|
|
5465
5589
|
amount: quoteDecoded.amount,
|
|
5466
|
-
delegate: (0,
|
|
5590
|
+
delegate: (0, import_kit7.unwrapOption)(quoteDecoded.delegate),
|
|
5467
5591
|
state: quoteDecoded.state,
|
|
5468
|
-
isNative: (0,
|
|
5592
|
+
isNative: (0, import_kit7.unwrapOption)(quoteDecoded.isNative),
|
|
5469
5593
|
delegatedAmount: quoteDecoded.delegatedAmount,
|
|
5470
|
-
closeAuthority: (0,
|
|
5594
|
+
closeAuthority: (0, import_kit7.unwrapOption)(quoteDecoded.closeAuthority)
|
|
5471
5595
|
};
|
|
5472
5596
|
poolTokensInfoCache.set(cacheKey, {
|
|
5473
5597
|
data: [baseTokenAccount, quoteTokenAccount],
|
|
@@ -5688,8 +5812,8 @@ function estimatePumpFunAmm(baseToken, quoteToken, globalConfig, amount, tradeTy
|
|
|
5688
5812
|
// src/utils/quote/pumpfun/index.ts
|
|
5689
5813
|
var PumpFunQuoteProvider = class {
|
|
5690
5814
|
async getQuote(raydiumParams) {
|
|
5691
|
-
const inputMint = (0,
|
|
5692
|
-
const outputMint = (0,
|
|
5815
|
+
const inputMint = (0, import_kit8.address)(raydiumParams.inputMint);
|
|
5816
|
+
const outputMint = (0, import_kit8.address)(raydiumParams.outputMint);
|
|
5693
5817
|
const [inputBondingCurve, outputBondingCurve] = await this.getTokensBondingCurve(inputMint, outputMint);
|
|
5694
5818
|
const { bondingCurve, isInputPrebonded } = this.ensureSinglePrebondedToken(inputBondingCurve, outputBondingCurve);
|
|
5695
5819
|
let isInputSol = inputMint === NATIVE_SOLANA_TOKEN_ADDRESS || inputMint === WRAPPED_SOL_MINT_ADDRESS;
|
|
@@ -6724,7 +6848,7 @@ var BaseSDK = class _BaseSDK {
|
|
|
6724
6848
|
static async makeRequest(url, body) {
|
|
6725
6849
|
const response = await fetch(url, {
|
|
6726
6850
|
method: "POST",
|
|
6727
|
-
headers: { "Content-Type": "application/json"
|
|
6851
|
+
headers: withAuctioneerHeaders({ "Content-Type": "application/json" }),
|
|
6728
6852
|
body
|
|
6729
6853
|
});
|
|
6730
6854
|
console.debug(`url`, url, `body`, body);
|
|
@@ -6796,26 +6920,27 @@ var BaseSDK = class _BaseSDK {
|
|
|
6796
6920
|
};
|
|
6797
6921
|
|
|
6798
6922
|
// src/core/solana/dca/create-order.ts
|
|
6799
|
-
var
|
|
6923
|
+
var import_kit9 = require("@solana/kit");
|
|
6800
6924
|
init_constants();
|
|
6801
6925
|
var import_token3 = require("@solana-program/token");
|
|
6802
6926
|
var import_system2 = require("@solana-program/system");
|
|
6803
6927
|
async function getSolanaDcaSingleChainOrderInstructions(order, options) {
|
|
6804
|
-
const rpc = options?.rpcUrl ? (0,
|
|
6805
|
-
const orderSigner = await (0,
|
|
6806
|
-
const
|
|
6807
|
-
|
|
6928
|
+
const rpc = options?.rpcUrl ? (0, import_kit9.createSolanaRpc)(options.rpcUrl) : getDefaultSolanaRPC();
|
|
6929
|
+
const orderSigner = await (0, import_kit9.generateKeyPairSigner)();
|
|
6930
|
+
const userSigner = (0, import_kit9.createNoopSigner)(order.user);
|
|
6931
|
+
const feePayerSigner = resolveSolanaFeePayer(userSigner, options?.feePayer);
|
|
6932
|
+
let tokenInMint = (0, import_kit9.address)(order.tokenIn);
|
|
6808
6933
|
const { secretHash, secretNumber } = genSecretHashAndNumber(order);
|
|
6809
|
-
const orderUserAddress = (0,
|
|
6934
|
+
const orderUserAddress = (0, import_kit9.address)(order.user);
|
|
6810
6935
|
const spendingNative = tokenInMint === NATIVE_SOLANA_TOKEN_ADDRESS;
|
|
6811
6936
|
if (spendingNative) {
|
|
6812
6937
|
tokenInMint = WRAPPED_SOL_MINT_ADDRESS;
|
|
6813
6938
|
}
|
|
6814
6939
|
const tokenMintProgram = await (0, import_token3.fetchMint)(rpc, tokenInMint);
|
|
6815
|
-
const guardAddress = (0,
|
|
6816
|
-
const addressEncoder = (0,
|
|
6940
|
+
const guardAddress = (0, import_kit9.address)(SINGLE_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */]);
|
|
6941
|
+
const addressEncoder = (0, import_kit9.getAddressEncoder)();
|
|
6817
6942
|
const instructions = [];
|
|
6818
|
-
const [tokenInProgramAccount] = await (0,
|
|
6943
|
+
const [tokenInProgramAccount] = await (0, import_kit9.getProgramDerivedAddress)({
|
|
6819
6944
|
programAddress: import_token3.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
6820
6945
|
seeds: [
|
|
6821
6946
|
addressEncoder.encode(orderUserAddress),
|
|
@@ -6823,10 +6948,10 @@ async function getSolanaDcaSingleChainOrderInstructions(order, options) {
|
|
|
6823
6948
|
addressEncoder.encode(tokenInMint)
|
|
6824
6949
|
]
|
|
6825
6950
|
});
|
|
6826
|
-
const userTokenInAccount = await (0,
|
|
6951
|
+
const userTokenInAccount = await (0, import_kit9.fetchEncodedAccount)(rpc, tokenInProgramAccount);
|
|
6827
6952
|
if (!userTokenInAccount.exists) {
|
|
6828
6953
|
const createAccountIx = await (0, import_token3.getCreateAssociatedTokenInstructionAsync)({
|
|
6829
|
-
payer:
|
|
6954
|
+
payer: feePayerSigner,
|
|
6830
6955
|
ata: tokenInProgramAccount,
|
|
6831
6956
|
owner: orderUserAddress,
|
|
6832
6957
|
mint: tokenMintProgram.address,
|
|
@@ -6839,7 +6964,7 @@ async function getSolanaDcaSingleChainOrderInstructions(order, options) {
|
|
|
6839
6964
|
const transferIx = (0, import_system2.getTransferSolInstruction)({
|
|
6840
6965
|
amount: totalAmountIn,
|
|
6841
6966
|
destination: userTokenInAccount.address,
|
|
6842
|
-
source:
|
|
6967
|
+
source: userSigner
|
|
6843
6968
|
});
|
|
6844
6969
|
instructions.push(transferIx);
|
|
6845
6970
|
const syncNativeIx = (0, import_token3.getSyncNativeInstruction)({
|
|
@@ -6848,7 +6973,7 @@ async function getSolanaDcaSingleChainOrderInstructions(order, options) {
|
|
|
6848
6973
|
instructions.push(syncNativeIx);
|
|
6849
6974
|
}
|
|
6850
6975
|
const createDcaOrderIx = await getCreateDcaOrderInstructionAsync({
|
|
6851
|
-
user:
|
|
6976
|
+
user: userSigner,
|
|
6852
6977
|
order: orderSigner,
|
|
6853
6978
|
guard: guardAddress,
|
|
6854
6979
|
tokenInMint,
|
|
@@ -6864,16 +6989,26 @@ async function getSolanaDcaSingleChainOrderInstructions(order, options) {
|
|
|
6864
6989
|
// TODO: Implement extra transfers
|
|
6865
6990
|
});
|
|
6866
6991
|
instructions.push(createDcaOrderIx);
|
|
6992
|
+
const tip = resolveSolanaTip(options);
|
|
6993
|
+
if (tip) {
|
|
6994
|
+
instructions.push(
|
|
6995
|
+
(0, import_system2.getTransferSolInstruction)({
|
|
6996
|
+
source: feePayerSigner,
|
|
6997
|
+
destination: tip.account,
|
|
6998
|
+
amount: tip.lamports
|
|
6999
|
+
})
|
|
7000
|
+
);
|
|
7001
|
+
}
|
|
6867
7002
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
|
|
6868
|
-
const txMessage = (0,
|
|
6869
|
-
(0,
|
|
6870
|
-
(tx) => (0,
|
|
6871
|
-
(tx) => (0,
|
|
6872
|
-
(tx) => (0,
|
|
6873
|
-
(tx) => (0,
|
|
7003
|
+
const txMessage = (0, import_kit9.pipe)(
|
|
7004
|
+
(0, import_kit9.createTransactionMessage)({ version: 0 }),
|
|
7005
|
+
(tx) => (0, import_kit9.setTransactionMessageFeePayerSigner)(feePayerSigner, tx),
|
|
7006
|
+
(tx) => (0, import_kit9.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, tx),
|
|
7007
|
+
(tx) => (0, import_kit9.appendTransactionMessageInstructions)(instructions, tx),
|
|
7008
|
+
(tx) => (0, import_kit9.addSignersToTransactionMessage)([orderSigner], tx)
|
|
6874
7009
|
);
|
|
6875
|
-
const partiallySignedTransaction = await (0,
|
|
6876
|
-
const txBytes = (0,
|
|
7010
|
+
const partiallySignedTransaction = await (0, import_kit9.partiallySignTransactionMessageWithSigners)(txMessage);
|
|
7011
|
+
const txBytes = (0, import_kit9.getTransactionCodec)().encode(partiallySignedTransaction);
|
|
6877
7012
|
return {
|
|
6878
7013
|
orderAddress: orderSigner.address,
|
|
6879
7014
|
txBytes,
|
|
@@ -6999,9 +7134,7 @@ init_constants();
|
|
|
6999
7134
|
async function fetchSiweMessage(params) {
|
|
7000
7135
|
const url = `${AUCTIONEER_URL}/siwe?wallet=${params.wallet}&chainId=${params.chainId}`;
|
|
7001
7136
|
const response = await fetch(url, {
|
|
7002
|
-
headers:
|
|
7003
|
-
"x-dev-access": DEV_ACCESS_KEY
|
|
7004
|
-
}
|
|
7137
|
+
headers: withAuctioneerHeaders()
|
|
7005
7138
|
});
|
|
7006
7139
|
if (!response.ok) {
|
|
7007
7140
|
throw new Error(`Failed to fetch SIWE message: ${response.status} ${response.statusText}`);
|
|
@@ -7014,9 +7147,9 @@ async function fetchJWTToken(params, token) {
|
|
|
7014
7147
|
const response = await fetch(url, {
|
|
7015
7148
|
method: "POST",
|
|
7016
7149
|
body: JSON.stringify(params),
|
|
7017
|
-
headers: {
|
|
7150
|
+
headers: withAuctioneerHeaders({
|
|
7018
7151
|
Authorization: `Bearer ${token}`
|
|
7019
|
-
}
|
|
7152
|
+
})
|
|
7020
7153
|
});
|
|
7021
7154
|
if (!response.ok) {
|
|
7022
7155
|
throw new Error(`Failed to fetch JWT token: ${response.status} ${response.statusText}`);
|
|
@@ -7182,15 +7315,15 @@ var EVMSDK = class extends BaseSDK {
|
|
|
7182
7315
|
};
|
|
7183
7316
|
|
|
7184
7317
|
// src/core/solana/sdk.ts
|
|
7185
|
-
var
|
|
7318
|
+
var import_kit12 = require("@solana/kit");
|
|
7186
7319
|
|
|
7187
7320
|
// src/core/solana/cancel-order.ts
|
|
7188
|
-
var
|
|
7321
|
+
var import_kit10 = require("@solana/kit");
|
|
7189
7322
|
var import_token4 = require("@solana-program/token");
|
|
7190
7323
|
init_constants();
|
|
7191
7324
|
async function cancelSingleChainOrderInstructions(orderAddress, options) {
|
|
7192
|
-
const rpc = options?.rpcUrl ? (0,
|
|
7193
|
-
const orderId = (0,
|
|
7325
|
+
const rpc = options?.rpcUrl ? (0, import_kit10.createSolanaRpc)(options.rpcUrl) : getDefaultSolanaRPC();
|
|
7326
|
+
const orderId = (0, import_kit10.address)(orderAddress);
|
|
7194
7327
|
const chainOrder = await fetchMaybeLimitOrder(rpc, orderId);
|
|
7195
7328
|
if (!chainOrder.exists) {
|
|
7196
7329
|
throw new Error(`Order with address ${orderAddress} not found`);
|
|
@@ -7199,8 +7332,8 @@ async function cancelSingleChainOrderInstructions(orderAddress, options) {
|
|
|
7199
7332
|
const orderUserAddress = chainOrder.data.user;
|
|
7200
7333
|
const tokenInMint = chainOrder.data.tokenInMint;
|
|
7201
7334
|
const tokenMintProgram = await (0, import_token4.fetchMint)(rpc, tokenInMint);
|
|
7202
|
-
const addressEncoder = (0,
|
|
7203
|
-
const [tokenInProgramAccount] = await (0,
|
|
7335
|
+
const addressEncoder = (0, import_kit10.getAddressEncoder)();
|
|
7336
|
+
const [tokenInProgramAccount] = await (0, import_kit10.getProgramDerivedAddress)({
|
|
7204
7337
|
programAddress: import_token4.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
7205
7338
|
seeds: [
|
|
7206
7339
|
addressEncoder.encode(orderUserAddress),
|
|
@@ -7209,7 +7342,7 @@ async function cancelSingleChainOrderInstructions(orderAddress, options) {
|
|
|
7209
7342
|
]
|
|
7210
7343
|
});
|
|
7211
7344
|
const guardAddress = SINGLE_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */];
|
|
7212
|
-
const [guardProgramAccount] = await (0,
|
|
7345
|
+
const [guardProgramAccount] = await (0, import_kit10.getProgramDerivedAddress)({
|
|
7213
7346
|
programAddress: import_token4.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
7214
7347
|
seeds: [
|
|
7215
7348
|
// Owner
|
|
@@ -7220,12 +7353,12 @@ async function cancelSingleChainOrderInstructions(orderAddress, options) {
|
|
|
7220
7353
|
addressEncoder.encode(tokenInMint)
|
|
7221
7354
|
]
|
|
7222
7355
|
});
|
|
7223
|
-
const userTokenInAccount = await (0,
|
|
7356
|
+
const userTokenInAccount = await (0, import_kit10.fetchEncodedAccount)(rpc, tokenInProgramAccount);
|
|
7224
7357
|
if (!userTokenInAccount.exists) {
|
|
7225
7358
|
const createTokenIx = await (0, import_token4.getCreateAssociatedTokenInstructionAsync)({
|
|
7226
7359
|
mint: tokenInMint,
|
|
7227
7360
|
owner: orderUserAddress,
|
|
7228
|
-
payer: (0,
|
|
7361
|
+
payer: (0, import_kit10.createNoopSigner)(orderUserAddress),
|
|
7229
7362
|
tokenProgram: tokenMintProgram.programAddress
|
|
7230
7363
|
});
|
|
7231
7364
|
instructions.push(createTokenIx);
|
|
@@ -7237,43 +7370,43 @@ async function cancelSingleChainOrderInstructions(orderAddress, options) {
|
|
|
7237
7370
|
userTokenInAccount: userTokenInAccount.address,
|
|
7238
7371
|
guardTokenInAccount: guardProgramAccount,
|
|
7239
7372
|
tokenInProgram: tokenMintProgram.programAddress,
|
|
7240
|
-
signer: (0,
|
|
7373
|
+
signer: (0, import_kit10.createNoopSigner)(orderUserAddress),
|
|
7241
7374
|
user: orderUserAddress
|
|
7242
7375
|
});
|
|
7243
7376
|
instructions.push(cancelLimitOrderIx);
|
|
7244
7377
|
return instructions;
|
|
7245
7378
|
}
|
|
7246
7379
|
async function cancelCrossChainOrderInstructionsAsBytes(orderAddress, signerAddress, options) {
|
|
7247
|
-
const rpc = options?.rpcUrl ? (0,
|
|
7380
|
+
const rpc = options?.rpcUrl ? (0, import_kit10.createSolanaRpc)(options.rpcUrl) : getDefaultSolanaRPC();
|
|
7248
7381
|
const instructions = await cancelCrossChainOrderInstructions(orderAddress, options);
|
|
7249
7382
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
|
|
7250
|
-
const txMessage = (0,
|
|
7251
|
-
(0,
|
|
7252
|
-
(tx) => (0,
|
|
7253
|
-
(tx) => (0,
|
|
7254
|
-
(tx) => (0,
|
|
7383
|
+
const txMessage = (0, import_kit10.pipe)(
|
|
7384
|
+
(0, import_kit10.createTransactionMessage)({ version: 0 }),
|
|
7385
|
+
(tx) => (0, import_kit10.setTransactionMessageFeePayerSigner)((0, import_kit10.createNoopSigner)((0, import_kit10.address)(signerAddress)), tx),
|
|
7386
|
+
(tx) => (0, import_kit10.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, tx),
|
|
7387
|
+
(tx) => (0, import_kit10.appendTransactionMessageInstructions)(instructions, tx)
|
|
7255
7388
|
);
|
|
7256
|
-
const compiledTxMessage = (0,
|
|
7257
|
-
const txBytes = (0,
|
|
7389
|
+
const compiledTxMessage = (0, import_kit10.compileTransactionMessage)(txMessage);
|
|
7390
|
+
const txBytes = (0, import_kit10.getCompiledTransactionMessageEncoder)().encode(compiledTxMessage);
|
|
7258
7391
|
return { versionedMessageBytes: txBytes };
|
|
7259
7392
|
}
|
|
7260
7393
|
async function cancelSingleChainOrderInstructionsAsBytes(orderAddress, signerAddress, options) {
|
|
7261
|
-
const rpc = options?.rpcUrl ? (0,
|
|
7394
|
+
const rpc = options?.rpcUrl ? (0, import_kit10.createSolanaRpc)(options.rpcUrl) : getDefaultSolanaRPC();
|
|
7262
7395
|
const instructions = await cancelSingleChainOrderInstructions(orderAddress, options);
|
|
7263
7396
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
|
|
7264
|
-
const txMessage = (0,
|
|
7265
|
-
(0,
|
|
7266
|
-
(tx) => (0,
|
|
7267
|
-
(tx) => (0,
|
|
7268
|
-
(tx) => (0,
|
|
7397
|
+
const txMessage = (0, import_kit10.pipe)(
|
|
7398
|
+
(0, import_kit10.createTransactionMessage)({ version: 0 }),
|
|
7399
|
+
(tx) => (0, import_kit10.setTransactionMessageFeePayerSigner)((0, import_kit10.createNoopSigner)((0, import_kit10.address)(signerAddress)), tx),
|
|
7400
|
+
(tx) => (0, import_kit10.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, tx),
|
|
7401
|
+
(tx) => (0, import_kit10.appendTransactionMessageInstructions)(instructions, tx)
|
|
7269
7402
|
);
|
|
7270
|
-
const compiledTxMessage = (0,
|
|
7271
|
-
const txBytes = (0,
|
|
7403
|
+
const compiledTxMessage = (0, import_kit10.compileTransactionMessage)(txMessage);
|
|
7404
|
+
const txBytes = (0, import_kit10.getCompiledTransactionMessageEncoder)().encode(compiledTxMessage);
|
|
7272
7405
|
return { versionedMessageBytes: txBytes };
|
|
7273
7406
|
}
|
|
7274
7407
|
async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
7275
|
-
const rpc = options?.rpcUrl ? (0,
|
|
7276
|
-
const orderId = (0,
|
|
7408
|
+
const rpc = options?.rpcUrl ? (0, import_kit10.createSolanaRpc)(options.rpcUrl) : getDefaultSolanaRPC();
|
|
7409
|
+
const orderId = (0, import_kit10.address)(orderAddress);
|
|
7277
7410
|
const chainOrder = await fetchMaybeOrder(rpc, orderId);
|
|
7278
7411
|
if (!chainOrder.exists) {
|
|
7279
7412
|
throw new Error(`Order with address ${orderAddress} not found`);
|
|
@@ -7281,11 +7414,11 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7281
7414
|
const instructions = [];
|
|
7282
7415
|
const orderUserAddress = chainOrder.data.user;
|
|
7283
7416
|
const guardAddress = CROSS_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */];
|
|
7284
|
-
const addressEncoder = (0,
|
|
7417
|
+
const addressEncoder = (0, import_kit10.getAddressEncoder)();
|
|
7285
7418
|
const isRecoveringTokenIn = chainOrder.data.lockedStablecoins === 0n;
|
|
7286
|
-
const recoverTokenMint = isRecoveringTokenIn ? chainOrder.data.tokenInMint : (0,
|
|
7419
|
+
const recoverTokenMint = isRecoveringTokenIn ? chainOrder.data.tokenInMint : (0, import_kit10.address)(SOLANA_MINT_TOKEN.mint);
|
|
7287
7420
|
const recoverTokenMintProgram = await (0, import_token4.fetchMint)(rpc, recoverTokenMint);
|
|
7288
|
-
const [userRecoveredTokenAccount] = await (0,
|
|
7421
|
+
const [userRecoveredTokenAccount] = await (0, import_kit10.getProgramDerivedAddress)({
|
|
7289
7422
|
programAddress: import_token4.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
7290
7423
|
seeds: [
|
|
7291
7424
|
addressEncoder.encode(orderUserAddress),
|
|
@@ -7293,7 +7426,7 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7293
7426
|
addressEncoder.encode(recoverTokenMint)
|
|
7294
7427
|
]
|
|
7295
7428
|
});
|
|
7296
|
-
const [guardRecoveredTokenAccount] = await (0,
|
|
7429
|
+
const [guardRecoveredTokenAccount] = await (0, import_kit10.getProgramDerivedAddress)({
|
|
7297
7430
|
programAddress: import_token4.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
7298
7431
|
seeds: [
|
|
7299
7432
|
addressEncoder.encode(guardAddress),
|
|
@@ -7301,10 +7434,10 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7301
7434
|
addressEncoder.encode(recoverTokenMint)
|
|
7302
7435
|
]
|
|
7303
7436
|
});
|
|
7304
|
-
const userRecoveredTokenAccountInfo = await (0,
|
|
7437
|
+
const userRecoveredTokenAccountInfo = await (0, import_kit10.fetchEncodedAccount)(rpc, userRecoveredTokenAccount);
|
|
7305
7438
|
if (!userRecoveredTokenAccountInfo.exists) {
|
|
7306
7439
|
const createRecoveredTokenAccountIx = await (0, import_token4.getCreateAssociatedTokenInstructionAsync)({
|
|
7307
|
-
payer: (0,
|
|
7440
|
+
payer: (0, import_kit10.createNoopSigner)(orderUserAddress),
|
|
7308
7441
|
ata: userRecoveredTokenAccount,
|
|
7309
7442
|
owner: orderUserAddress,
|
|
7310
7443
|
mint: recoverTokenMint,
|
|
@@ -7315,9 +7448,9 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7315
7448
|
let userCollateralTokenAccount;
|
|
7316
7449
|
const willClaimCollateral = chainOrder.data.lockedCollateral > 0n;
|
|
7317
7450
|
if (willClaimCollateral) {
|
|
7318
|
-
const collateralTokenMint2 = (0,
|
|
7451
|
+
const collateralTokenMint2 = (0, import_kit10.address)(SOLANA_MINT_TOKEN.mint);
|
|
7319
7452
|
const collateralTokenMintProgram2 = await (0, import_token4.fetchMint)(rpc, collateralTokenMint2);
|
|
7320
|
-
const [userCollateralAccount] = await (0,
|
|
7453
|
+
const [userCollateralAccount] = await (0, import_kit10.getProgramDerivedAddress)({
|
|
7321
7454
|
programAddress: import_token4.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
7322
7455
|
seeds: [
|
|
7323
7456
|
addressEncoder.encode(orderUserAddress),
|
|
@@ -7326,10 +7459,10 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7326
7459
|
]
|
|
7327
7460
|
});
|
|
7328
7461
|
userCollateralTokenAccount = userCollateralAccount;
|
|
7329
|
-
const userCollateralTokenAccountInfo = await (0,
|
|
7462
|
+
const userCollateralTokenAccountInfo = await (0, import_kit10.fetchEncodedAccount)(rpc, userCollateralTokenAccount);
|
|
7330
7463
|
if (!userCollateralTokenAccountInfo.exists) {
|
|
7331
7464
|
const createCollateralTokenAccountIx = await (0, import_token4.getCreateAssociatedTokenInstructionAsync)({
|
|
7332
|
-
payer: (0,
|
|
7465
|
+
payer: (0, import_kit10.createNoopSigner)(orderUserAddress),
|
|
7333
7466
|
ata: userCollateralTokenAccount,
|
|
7334
7467
|
owner: orderUserAddress,
|
|
7335
7468
|
mint: collateralTokenMint2,
|
|
@@ -7338,9 +7471,9 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7338
7471
|
instructions.push(createCollateralTokenAccountIx);
|
|
7339
7472
|
}
|
|
7340
7473
|
}
|
|
7341
|
-
const collateralTokenMint = (0,
|
|
7474
|
+
const collateralTokenMint = (0, import_kit10.address)(SOLANA_MINT_TOKEN.mint);
|
|
7342
7475
|
const collateralTokenMintProgram = await (0, import_token4.fetchMint)(rpc, collateralTokenMint);
|
|
7343
|
-
const [guardCollateralTokenAccount] = await (0,
|
|
7476
|
+
const [guardCollateralTokenAccount] = await (0, import_kit10.getProgramDerivedAddress)({
|
|
7344
7477
|
programAddress: import_token4.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
7345
7478
|
seeds: [
|
|
7346
7479
|
addressEncoder.encode(guardAddress),
|
|
@@ -7360,7 +7493,7 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7360
7493
|
userCollateralTokenAccount,
|
|
7361
7494
|
guardCollateralTokenAccount,
|
|
7362
7495
|
collateralTokenProgram: collateralTokenMintProgram.programAddress,
|
|
7363
|
-
signer: (0,
|
|
7496
|
+
signer: (0, import_kit10.createNoopSigner)(orderUserAddress)
|
|
7364
7497
|
});
|
|
7365
7498
|
instructions.push(cancelOrderIx);
|
|
7366
7499
|
return instructions;
|
|
@@ -7370,12 +7503,12 @@ async function cancelCrossChainOrderInstructions(orderAddress, options) {
|
|
|
7370
7503
|
var import_viem11 = require("viem");
|
|
7371
7504
|
|
|
7372
7505
|
// src/core/solana/dca/cancel-order.ts
|
|
7373
|
-
var
|
|
7506
|
+
var import_kit11 = require("@solana/kit");
|
|
7374
7507
|
var import_token5 = require("@solana-program/token");
|
|
7375
7508
|
init_constants();
|
|
7376
7509
|
async function cancelDcaSingleChainOrderInstructions(orderAddress, options) {
|
|
7377
|
-
const rpc = options?.rpcUrl ? (0,
|
|
7378
|
-
const orderId = (0,
|
|
7510
|
+
const rpc = options?.rpcUrl ? (0, import_kit11.createSolanaRpc)(options.rpcUrl) : getDefaultSolanaRPC();
|
|
7511
|
+
const orderId = (0, import_kit11.address)(orderAddress);
|
|
7379
7512
|
const chainOrder = await fetchMaybeDcaOrder(rpc, orderId);
|
|
7380
7513
|
if (!chainOrder.exists) {
|
|
7381
7514
|
throw new Error(`Order with address ${orderAddress} not found`);
|
|
@@ -7384,8 +7517,8 @@ async function cancelDcaSingleChainOrderInstructions(orderAddress, options) {
|
|
|
7384
7517
|
const orderUserAddress = chainOrder.data.user;
|
|
7385
7518
|
const tokenInMint = chainOrder.data.tokenInMint;
|
|
7386
7519
|
const tokenMintProgram = await (0, import_token5.fetchMint)(rpc, tokenInMint);
|
|
7387
|
-
const addressEncoder = (0,
|
|
7388
|
-
const [tokenInProgramAccount] = await (0,
|
|
7520
|
+
const addressEncoder = (0, import_kit11.getAddressEncoder)();
|
|
7521
|
+
const [tokenInProgramAccount] = await (0, import_kit11.getProgramDerivedAddress)({
|
|
7389
7522
|
programAddress: import_token5.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
7390
7523
|
seeds: [
|
|
7391
7524
|
addressEncoder.encode(orderUserAddress),
|
|
@@ -7394,7 +7527,7 @@ async function cancelDcaSingleChainOrderInstructions(orderAddress, options) {
|
|
|
7394
7527
|
]
|
|
7395
7528
|
});
|
|
7396
7529
|
const guardAddress = SINGLE_CHAIN_GUARD_ADDRESSES[7565164 /* Solana */];
|
|
7397
|
-
const [guardProgramAccount] = await (0,
|
|
7530
|
+
const [guardProgramAccount] = await (0, import_kit11.getProgramDerivedAddress)({
|
|
7398
7531
|
programAddress: import_token5.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
7399
7532
|
seeds: [
|
|
7400
7533
|
// Owner
|
|
@@ -7405,19 +7538,19 @@ async function cancelDcaSingleChainOrderInstructions(orderAddress, options) {
|
|
|
7405
7538
|
addressEncoder.encode(tokenInMint)
|
|
7406
7539
|
]
|
|
7407
7540
|
});
|
|
7408
|
-
const userTokenInAccount = await (0,
|
|
7541
|
+
const userTokenInAccount = await (0, import_kit11.fetchEncodedAccount)(rpc, tokenInProgramAccount);
|
|
7409
7542
|
if (!userTokenInAccount.exists) {
|
|
7410
7543
|
const createTokenIx = await (0, import_token5.getCreateAssociatedTokenInstructionAsync)({
|
|
7411
7544
|
mint: tokenInMint,
|
|
7412
7545
|
owner: orderUserAddress,
|
|
7413
|
-
payer: (0,
|
|
7546
|
+
payer: (0, import_kit11.createNoopSigner)(orderUserAddress),
|
|
7414
7547
|
tokenProgram: tokenMintProgram.programAddress
|
|
7415
7548
|
});
|
|
7416
7549
|
instructions.push(createTokenIx);
|
|
7417
7550
|
}
|
|
7418
7551
|
const cancelLimitOrderIx = getCancelDcaOrderInstruction({
|
|
7419
7552
|
user: orderUserAddress,
|
|
7420
|
-
signer: (0,
|
|
7553
|
+
signer: (0, import_kit11.createNoopSigner)(orderUserAddress),
|
|
7421
7554
|
order: orderId,
|
|
7422
7555
|
guard: guardAddress,
|
|
7423
7556
|
tokenInMint: chainOrder.data.tokenInMint,
|
|
@@ -7461,17 +7594,17 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7461
7594
|
const instructions = await cancelCrossChainOrderInstructions(orderId, { rpcUrl: this.config.rpcProviderUrl });
|
|
7462
7595
|
const signer = await this.getUserSigner();
|
|
7463
7596
|
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
7464
|
-
const noopSigner = (0,
|
|
7597
|
+
const noopSigner = (0, import_kit12.createNoopSigner)(signer.address);
|
|
7465
7598
|
const { value: latestBlockhash } = await this.client.rpc.getLatestBlockhash({ commitment: this.config.commitment }).send();
|
|
7466
|
-
const transactionMessage = (0,
|
|
7467
|
-
(0,
|
|
7468
|
-
(tx) => (0,
|
|
7469
|
-
(tx) => (0,
|
|
7470
|
-
(tx) => (0,
|
|
7599
|
+
const transactionMessage = (0, import_kit12.pipe)(
|
|
7600
|
+
(0, import_kit12.createTransactionMessage)({ version: 0 }),
|
|
7601
|
+
(tx) => (0, import_kit12.setTransactionMessageFeePayerSigner)(noopSigner, tx),
|
|
7602
|
+
(tx) => (0, import_kit12.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, tx),
|
|
7603
|
+
(tx) => (0, import_kit12.appendTransactionMessageInstructions)(instructions, tx)
|
|
7471
7604
|
);
|
|
7472
|
-
const myTx = (0,
|
|
7473
|
-
const signature = await (0,
|
|
7474
|
-
(0,
|
|
7605
|
+
const myTx = (0, import_kit12.compileTransaction)(transactionMessage);
|
|
7606
|
+
const signature = await (0, import_kit12.signTransaction)([signerKeyPair], myTx);
|
|
7607
|
+
(0, import_kit12.assertIsSendableTransaction)(signature);
|
|
7475
7608
|
await this.client.sendAndConfirmTransaction(signature, {
|
|
7476
7609
|
commitment: this.config.commitment
|
|
7477
7610
|
});
|
|
@@ -7481,17 +7614,17 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7481
7614
|
const instructions = await cancelSingleChainOrderInstructions(orderId, { rpcUrl: this.config.rpcProviderUrl });
|
|
7482
7615
|
const signer = await this.getUserSigner();
|
|
7483
7616
|
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
7484
|
-
const noopSigner = (0,
|
|
7617
|
+
const noopSigner = (0, import_kit12.createNoopSigner)(signer.address);
|
|
7485
7618
|
const { value: latestBlockhash } = await this.client.rpc.getLatestBlockhash({ commitment: this.config.commitment }).send();
|
|
7486
|
-
const transactionMessage = (0,
|
|
7487
|
-
(0,
|
|
7488
|
-
(tx) => (0,
|
|
7489
|
-
(tx) => (0,
|
|
7490
|
-
(tx) => (0,
|
|
7619
|
+
const transactionMessage = (0, import_kit12.pipe)(
|
|
7620
|
+
(0, import_kit12.createTransactionMessage)({ version: 0 }),
|
|
7621
|
+
(tx) => (0, import_kit12.setTransactionMessageFeePayerSigner)(noopSigner, tx),
|
|
7622
|
+
(tx) => (0, import_kit12.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, tx),
|
|
7623
|
+
(tx) => (0, import_kit12.appendTransactionMessageInstructions)(instructions, tx)
|
|
7491
7624
|
);
|
|
7492
|
-
const myTx = (0,
|
|
7493
|
-
const signature = await (0,
|
|
7494
|
-
(0,
|
|
7625
|
+
const myTx = (0, import_kit12.compileTransaction)(transactionMessage);
|
|
7626
|
+
const signature = await (0, import_kit12.signTransaction)([signerKeyPair], myTx);
|
|
7627
|
+
(0, import_kit12.assertIsSendableTransaction)(signature);
|
|
7495
7628
|
await this.client.sendAndConfirmTransaction(signature, {
|
|
7496
7629
|
commitment: this.config.commitment
|
|
7497
7630
|
});
|
|
@@ -7506,9 +7639,9 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7506
7639
|
* @private
|
|
7507
7640
|
*/
|
|
7508
7641
|
async getUserCryptoKeypair() {
|
|
7509
|
-
const encoder = (0,
|
|
7642
|
+
const encoder = (0, import_kit12.getBase58Encoder)();
|
|
7510
7643
|
const bytesWithPrefix = encoder.encode(this.config.privateKey);
|
|
7511
|
-
return (0,
|
|
7644
|
+
return (0, import_kit12.createKeyPairFromBytes)(bytesWithPrefix);
|
|
7512
7645
|
}
|
|
7513
7646
|
/**
|
|
7514
7647
|
* Creates a KeyPairSigner from the user's crypto keypair
|
|
@@ -7520,7 +7653,7 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7520
7653
|
*/
|
|
7521
7654
|
async getUserSigner() {
|
|
7522
7655
|
const signer = await this.getUserCryptoKeypair();
|
|
7523
|
-
return (0,
|
|
7656
|
+
return (0, import_kit12.createSignerFromKeyPair)(signer);
|
|
7524
7657
|
}
|
|
7525
7658
|
async authenticate(token) {
|
|
7526
7659
|
const wallet = await this.getUserAddress();
|
|
@@ -7529,10 +7662,10 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7529
7662
|
wallet
|
|
7530
7663
|
});
|
|
7531
7664
|
const message = response.data;
|
|
7532
|
-
const signableMessage = (0,
|
|
7665
|
+
const signableMessage = (0, import_kit12.createSignableMessage)(message);
|
|
7533
7666
|
const signer = await this.getUserSigner();
|
|
7534
7667
|
const signatureArray = await signer.signMessages([signableMessage]);
|
|
7535
|
-
const signatureBytes = signatureArray.map((signature) => signature[(0,
|
|
7668
|
+
const signatureBytes = signatureArray.map((signature) => signature[(0, import_kit12.address)(wallet)])[0];
|
|
7536
7669
|
if (!signatureBytes) {
|
|
7537
7670
|
throw new Error("No signature bytes found");
|
|
7538
7671
|
}
|
|
@@ -7563,10 +7696,10 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7563
7696
|
async prepareCrossChainOrder(order) {
|
|
7564
7697
|
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
7565
7698
|
const { orderAddress, txBytes } = await getSolanaCrossChainOrderInstructions(order);
|
|
7566
|
-
const transactionCodec = (0,
|
|
7699
|
+
const transactionCodec = (0, import_kit12.getTransactionCodec)();
|
|
7567
7700
|
const tx = transactionCodec.decode(txBytes);
|
|
7568
|
-
const signedTx = await (0,
|
|
7569
|
-
const encodedTransaction = (0,
|
|
7701
|
+
const signedTx = await (0, import_kit12.signTransaction)([signerKeyPair], tx);
|
|
7702
|
+
const encodedTransaction = (0, import_kit12.getBase64EncodedWireTransaction)(signedTx);
|
|
7570
7703
|
await this.client.rpc.sendTransaction(encodedTransaction, { preflightCommitment: this.config.commitment, encoding: "base64" }).send();
|
|
7571
7704
|
return {
|
|
7572
7705
|
order,
|
|
@@ -7578,10 +7711,10 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7578
7711
|
async prepareSingleChainOrder(order) {
|
|
7579
7712
|
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
7580
7713
|
const { orderAddress, txBytes, secretNumber } = await getSolanaSingleChainOrderInstructions(order);
|
|
7581
|
-
const transactionCodec = (0,
|
|
7714
|
+
const transactionCodec = (0, import_kit12.getTransactionCodec)();
|
|
7582
7715
|
const tx = transactionCodec.decode(txBytes);
|
|
7583
|
-
const signedTx = await (0,
|
|
7584
|
-
const encodedTransaction = (0,
|
|
7716
|
+
const signedTx = await (0, import_kit12.partiallySignTransaction)([signerKeyPair], tx);
|
|
7717
|
+
const encodedTransaction = (0, import_kit12.getBase64EncodedWireTransaction)(signedTx);
|
|
7585
7718
|
await this.client.rpc.sendTransaction(encodedTransaction, { preflightCommitment: this.config.commitment, encoding: "base64" }).send();
|
|
7586
7719
|
return {
|
|
7587
7720
|
order,
|
|
@@ -7595,17 +7728,17 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7595
7728
|
const instructions = await cancelDcaSingleChainOrderInstructions(orderId, { rpcUrl: this.config.rpcProviderUrl });
|
|
7596
7729
|
const signer = await this.getUserSigner();
|
|
7597
7730
|
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
7598
|
-
const noopSigner = (0,
|
|
7731
|
+
const noopSigner = (0, import_kit12.createNoopSigner)(signer.address);
|
|
7599
7732
|
const { value: latestBlockhash } = await this.client.rpc.getLatestBlockhash({ commitment: this.config.commitment }).send();
|
|
7600
|
-
const transactionMessage = (0,
|
|
7601
|
-
(0,
|
|
7602
|
-
(tx) => (0,
|
|
7603
|
-
(tx) => (0,
|
|
7604
|
-
(tx) => (0,
|
|
7733
|
+
const transactionMessage = (0, import_kit12.pipe)(
|
|
7734
|
+
(0, import_kit12.createTransactionMessage)({ version: 0 }),
|
|
7735
|
+
(tx) => (0, import_kit12.setTransactionMessageFeePayerSigner)(noopSigner, tx),
|
|
7736
|
+
(tx) => (0, import_kit12.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, tx),
|
|
7737
|
+
(tx) => (0, import_kit12.appendTransactionMessageInstructions)(instructions, tx)
|
|
7605
7738
|
);
|
|
7606
|
-
const myTx = (0,
|
|
7607
|
-
const signature = await (0,
|
|
7608
|
-
(0,
|
|
7739
|
+
const myTx = (0, import_kit12.compileTransaction)(transactionMessage);
|
|
7740
|
+
const signature = await (0, import_kit12.signTransaction)([signerKeyPair], myTx);
|
|
7741
|
+
(0, import_kit12.assertIsSendableTransaction)(signature);
|
|
7609
7742
|
await this.client.sendAndConfirmTransaction(signature, {
|
|
7610
7743
|
commitment: this.config.commitment
|
|
7611
7744
|
});
|
|
@@ -7614,10 +7747,10 @@ var SolanaSDK = class extends BaseSDK {
|
|
|
7614
7747
|
async prepareDcaSingleChainOrder(order) {
|
|
7615
7748
|
const signerKeyPair = await this.getUserCryptoKeypair();
|
|
7616
7749
|
const { orderAddress, txBytes, secretNumber } = await getSolanaDcaSingleChainOrderInstructions(order);
|
|
7617
|
-
const transactionCodec = (0,
|
|
7750
|
+
const transactionCodec = (0, import_kit12.getTransactionCodec)();
|
|
7618
7751
|
const tx = transactionCodec.decode(txBytes);
|
|
7619
|
-
const signedTx = await (0,
|
|
7620
|
-
const encodedTransaction = (0,
|
|
7752
|
+
const signedTx = await (0, import_kit12.partiallySignTransaction)([signerKeyPair], tx);
|
|
7753
|
+
const encodedTransaction = (0, import_kit12.getBase64EncodedWireTransaction)(signedTx);
|
|
7621
7754
|
await this.client.rpc.sendTransaction(encodedTransaction, { preflightCommitment: this.config.commitment, encoding: "base64" }).send();
|
|
7622
7755
|
return {
|
|
7623
7756
|
order,
|
|
@@ -7782,7 +7915,7 @@ async function fetchUserOrders(evmAddress, solAddress, suiAddress) {
|
|
|
7782
7915
|
const url = `${AUCTIONEER_URL}/user_intent?${params.toString()}`;
|
|
7783
7916
|
const response = await fetch(url, {
|
|
7784
7917
|
method: "GET",
|
|
7785
|
-
headers: { "Content-Type": "application/json"
|
|
7918
|
+
headers: withAuctioneerHeaders({ "Content-Type": "application/json" })
|
|
7786
7919
|
});
|
|
7787
7920
|
if (!response.ok) {
|
|
7788
7921
|
throw new Error(`Failed to fetch user orders: ${response.status} ${response.statusText}`);
|
|
@@ -7808,10 +7941,10 @@ var AuctioneerAPI = class {
|
|
|
7808
7941
|
const url = `${AUCTIONEER_URL}/user_intent`;
|
|
7809
7942
|
const response = await fetch(url, {
|
|
7810
7943
|
method: "GET",
|
|
7811
|
-
headers: {
|
|
7944
|
+
headers: withAuctioneerHeaders({
|
|
7812
7945
|
"Content-Type": "application/json",
|
|
7813
7946
|
Authorization: `Bearer ${this.aggregatedToken}`
|
|
7814
|
-
}
|
|
7947
|
+
})
|
|
7815
7948
|
});
|
|
7816
7949
|
const data = await response.json();
|
|
7817
7950
|
if (!data.success) {
|
|
@@ -8039,7 +8172,7 @@ function getInvalidateNoncesRawData(nonce) {
|
|
|
8039
8172
|
}
|
|
8040
8173
|
|
|
8041
8174
|
// src/core/solana/inspect.ts
|
|
8042
|
-
var
|
|
8175
|
+
var import_kit13 = require("@solana/kit");
|
|
8043
8176
|
|
|
8044
8177
|
// src/utils/logger.ts
|
|
8045
8178
|
init_errors();
|
|
@@ -8134,8 +8267,8 @@ var logger = Logger.getInstance();
|
|
|
8134
8267
|
|
|
8135
8268
|
// src/core/solana/inspect.ts
|
|
8136
8269
|
async function getSolanaOrdersWithLockedFunds(userAddress, config) {
|
|
8137
|
-
const rpc = config?.rpcUrl ? (0,
|
|
8138
|
-
const programAccountAddress = (0,
|
|
8270
|
+
const rpc = config?.rpcUrl ? (0, import_kit13.createSolanaRpc)(config.rpcUrl) : getDefaultSolanaRPC();
|
|
8271
|
+
const programAccountAddress = (0, import_kit13.address)("DQZQGiVa1PBXesdbCRzmJpZ7AyntLXfAwP5Qty1hgFqQ");
|
|
8139
8272
|
const programAccountsConfig = {
|
|
8140
8273
|
encoding: "base64",
|
|
8141
8274
|
filters: [
|
|
@@ -8753,14 +8886,14 @@ function createSolanaCrossChainOrderIntentRequest(params) {
|
|
|
8753
8886
|
}
|
|
8754
8887
|
};
|
|
8755
8888
|
}
|
|
8756
|
-
async function generateSolanaSingleChainLimitOrderInstructions(order) {
|
|
8757
|
-
return getSolanaSingleChainOrderInstructions(order);
|
|
8889
|
+
async function generateSolanaSingleChainLimitOrderInstructions(order, options) {
|
|
8890
|
+
return getSolanaSingleChainOrderInstructions(order, options);
|
|
8758
8891
|
}
|
|
8759
|
-
async function generateSolanaSingleChainDcaOrderInstructions(order) {
|
|
8760
|
-
return getSolanaDcaSingleChainOrderInstructions(order);
|
|
8892
|
+
async function generateSolanaSingleChainDcaOrderInstructions(order, options) {
|
|
8893
|
+
return getSolanaDcaSingleChainOrderInstructions(order, options);
|
|
8761
8894
|
}
|
|
8762
|
-
async function generateSolanaCrossChainOrderInstructions(order) {
|
|
8763
|
-
return getSolanaCrossChainOrderInstructions(order);
|
|
8895
|
+
async function generateSolanaCrossChainOrderInstructions(order, options) {
|
|
8896
|
+
return getSolanaCrossChainOrderInstructions(order, options);
|
|
8764
8897
|
}
|
|
8765
8898
|
function generateSolanaLimitOrderSecretData(tokenOut, receiver, secretNumber, extraTransfers) {
|
|
8766
8899
|
const secret = secretNumber || generateSolanaRandomSecretNumber();
|