@symmetry-hq/temp-v3-sdk 0.0.35 → 0.0.37
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/src/constants.d.ts +2 -0
- package/dist/src/constants.js +3 -1
- package/dist/src/index.d.ts +17 -6
- package/dist/src/index.js +154 -44
- package/dist/src/instructions/automation/priceUpdate.d.ts +1 -0
- package/dist/src/instructions/automation/priceUpdate.js +8 -0
- package/dist/src/instructions/management/claimFees.js +2 -1
- package/dist/src/instructions/management/edit.js +3 -3
- package/dist/src/jup.d.ts +49 -0
- package/dist/src/jup.js +69 -0
- package/dist/src/keeperMonitor.d.ts +22 -0
- package/dist/src/keeperMonitor.js +214 -0
- package/dist/src/layouts/basket.d.ts +3 -1
- package/dist/src/layouts/basket.js +5 -1
- package/dist/src/layouts/fraction.d.ts +11 -0
- package/dist/src/layouts/fraction.js +135 -0
- package/dist/src/layouts/intents/intent.d.ts +2 -2
- package/dist/src/layouts/intents/intent.js +32 -2
- package/dist/src/layouts/intents/rebalanceIntent.d.ts +4 -4
- package/dist/src/layouts/intents/rebalanceIntent.js +14 -3
- package/dist/src/layouts/oracle.d.ts +2 -2
- package/dist/src/layouts/oracle.js +7 -1
- package/dist/src/states/basket.js +29 -26
- package/dist/src/states/intents/intent.js +32 -39
- package/dist/src/states/intents/rebalanceIntent.d.ts +8 -0
- package/dist/src/states/intents/rebalanceIntent.js +269 -2
- package/dist/src/txUtils.d.ts +0 -1
- package/dist/src/txUtils.js +0 -2
- package/dist/test.js +68 -125
- package/package.json +1 -1
- package/src/constants.ts +2 -1
- package/src/index.ts +161 -30
- package/src/instructions/automation/priceUpdate.ts +12 -2
- package/src/instructions/management/claimFees.ts +2 -1
- package/src/instructions/management/edit.ts +1 -1
- package/src/jup.ts +103 -0
- package/src/keeperMonitor.ts +179 -0
- package/src/layouts/basket.ts +7 -1
- package/src/layouts/fraction.ts +136 -0
- package/src/layouts/intents/intent.ts +33 -2
- package/src/layouts/intents/rebalanceIntent.ts +16 -4
- package/src/layouts/oracle.ts +8 -3
- package/src/states/basket.ts +3 -3
- package/src/states/intents/intent.ts +11 -22
- package/src/states/intents/rebalanceIntent.ts +342 -6
- package/src/txUtils.ts +0 -1
- package/test.ts +70 -119
package/dist/src/constants.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
import Decimal from 'decimal.js';
|
|
3
|
+
export declare const COMPUTE_UNITS = 1000000;
|
|
4
|
+
export declare const PRIORITY_FEE = 100000;
|
|
3
5
|
export declare const BASKETS_V3_PROGRAM_ID: PublicKey;
|
|
4
6
|
export declare const METADATA_PROGRAM_ID: PublicKey;
|
|
5
7
|
export declare const ADDRESS_LOOKUP_TABLE_PROGRAM_ID: PublicKey;
|
package/dist/src/constants.js
CHANGED
|
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MAX_EXTRA_DATA_PER_ORACLE = exports.MAX_ORACLES_PER_TOKEN = exports.MAX_SUPPORTED_TOKENS_PER_BASKET = exports.USDC_DECIMALS = exports.WSOL_DECIMALS = exports.HUNDRED_PERCENT_BPS = exports.X64 = exports.MAX_TRANSFER_TOKENS = exports.MAX_MANAGERS_PER_BASKET = exports.INTENT_TASK_DATA_SIZE = exports.PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT = exports.PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT = exports.MINTS = exports.RENT_SYSVAR_ID = exports.ADDRESS_LOOKUP_TABLE_PROGRAM_ID = exports.METADATA_PROGRAM_ID = exports.BASKETS_V3_PROGRAM_ID = void 0;
|
|
6
|
+
exports.MAX_EXTRA_DATA_PER_ORACLE = exports.MAX_ORACLES_PER_TOKEN = exports.MAX_SUPPORTED_TOKENS_PER_BASKET = exports.USDC_DECIMALS = exports.WSOL_DECIMALS = exports.HUNDRED_PERCENT_BPS = exports.X64 = exports.MAX_TRANSFER_TOKENS = exports.MAX_MANAGERS_PER_BASKET = exports.INTENT_TASK_DATA_SIZE = exports.PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT = exports.PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT = exports.MINTS = exports.RENT_SYSVAR_ID = exports.ADDRESS_LOOKUP_TABLE_PROGRAM_ID = exports.METADATA_PROGRAM_ID = exports.BASKETS_V3_PROGRAM_ID = exports.PRIORITY_FEE = exports.COMPUTE_UNITS = void 0;
|
|
7
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
8
8
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
9
|
+
exports.COMPUTE_UNITS = 1000000;
|
|
10
|
+
exports.PRIORITY_FEE = 100000;
|
|
9
11
|
exports.BASKETS_V3_PROGRAM_ID = new web3_js_1.PublicKey("BASKT7aKd8n7ibpUbwLP3Wiyxyi3yoiXsxBk4Hpumate");
|
|
10
12
|
exports.METADATA_PROGRAM_ID = new web3_js_1.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
|
|
11
13
|
exports.ADDRESS_LOOKUP_TABLE_PROGRAM_ID = new web3_js_1.PublicKey("AddressLookupTab1e1111111111111111111111111");
|
package/dist/src/index.d.ts
CHANGED
|
@@ -10,18 +10,13 @@ import { IntentFilter } from './states/intents/intent';
|
|
|
10
10
|
import { RebalanceIntentFilter } from './states/intents/rebalanceIntent';
|
|
11
11
|
import { TxPayloadBatchSequence, VersionedTxs, Wallet } from './txUtils';
|
|
12
12
|
import { FormattedOracleType } from './layouts/oracle';
|
|
13
|
-
|
|
14
|
-
export declare const PRIORITY_FEE = 100000;
|
|
15
|
-
export declare const JUPITER_API_KEY = "https://quote-api.jup.ag/v6/";
|
|
16
|
-
export declare const MAX_JUPITER_ACCOUNTS = 35;
|
|
13
|
+
import { getJupTokenLedgerAndSwapInstructions } from './jup';
|
|
17
14
|
export declare class SymmetryCore {
|
|
18
15
|
private sdkParams;
|
|
19
16
|
constructor(params: {
|
|
20
17
|
connection: Connection;
|
|
21
18
|
network: "devnet" | "mainnet";
|
|
22
19
|
priorityFee?: number;
|
|
23
|
-
jupiterApiKey?: string;
|
|
24
|
-
maxAllowedAccounts?: number;
|
|
25
20
|
});
|
|
26
21
|
fetchGlobalConfig(): Promise<GlobalConfig>;
|
|
27
22
|
fetchBasket(basketPubkey: string): Promise<Basket>;
|
|
@@ -124,6 +119,15 @@ export declare class SymmetryCore {
|
|
|
124
119
|
min_bounty_amount?: number;
|
|
125
120
|
max_bounty_amount?: number;
|
|
126
121
|
}): Promise<TxPayloadBatchSequence>;
|
|
122
|
+
rebalanceBasketTx(params: {
|
|
123
|
+
keeper: string;
|
|
124
|
+
basket_mint: string;
|
|
125
|
+
rebalance_slippage_bps?: number;
|
|
126
|
+
per_trade_rebalance_slippage_bps?: number;
|
|
127
|
+
execution_start_time?: number;
|
|
128
|
+
min_bounty_amount?: number;
|
|
129
|
+
max_bounty_amount?: number;
|
|
130
|
+
}): Promise<TxPayloadBatchSequence>;
|
|
127
131
|
startPriceUpdatesTx(params: {
|
|
128
132
|
keeper: string;
|
|
129
133
|
basket: string;
|
|
@@ -146,6 +150,7 @@ export declare class SymmetryCore {
|
|
|
146
150
|
mode?: number;
|
|
147
151
|
jup_token_ledger_ix?: TransactionInstruction;
|
|
148
152
|
jup_swap_ix?: TransactionInstruction;
|
|
153
|
+
jup_address_lookup_table_addresses?: PublicKey[];
|
|
149
154
|
}): Promise<TxPayloadBatchSequence>;
|
|
150
155
|
mintTx(params: {
|
|
151
156
|
keeper: string;
|
|
@@ -159,6 +164,10 @@ export declare class SymmetryCore {
|
|
|
159
164
|
keeper: string;
|
|
160
165
|
rebalance_intent: string;
|
|
161
166
|
}): Promise<TxPayloadBatchSequence>;
|
|
167
|
+
claimBasketFeesTx(params: {
|
|
168
|
+
claimer: string;
|
|
169
|
+
basket: string;
|
|
170
|
+
}): Promise<TxPayloadBatchSequence>;
|
|
162
171
|
signAndSendVersionedTxs(params: {
|
|
163
172
|
versionedTxs: VersionedTxs;
|
|
164
173
|
wallet: Wallet;
|
|
@@ -173,3 +182,5 @@ export { FormattedGlobalConfig, FormattedIntentStatus, FormattedTaskType, Format
|
|
|
173
182
|
export { FormattedRebalanceType, FormattedRebalanceAction, FormattedOraclePrice, FormattedTokenAuction, FormattedTaskCompletion, FormattedRebalanceIntent, };
|
|
174
183
|
export { FormattedCreatorSettings, FormattedManagersSettings, FormattedFeeSettings, FormattedScheduleSettings, FormattedAutomationSettings, FormattedLpSettings, FormattedMetadataSettings, FormattedDepositsSettings, FormattedForceRebalanceSettings, FormattedCustomRebalanceSettings, FormattedAddTokenSettings, FormattedUpdateWeightsSettings, FormattedMakeDirectSwapSettings, FormattedAccumulatedFees, FormattedLookupTables, FormattedAsset, FormattedOracleSettings, FormattedOracleAggregator, FormattedOracle, FormattedOracleType, FormattedBasket, };
|
|
175
184
|
export { EditCreatorSettings, EditManagerSettings, EditFeeSettings, EditScheduleSettings, EditAutomationSettings, EditLpSettings, EditMetadataSettings, EditDepositsSettings, EditForceRebalanceSettings, EditCustomRebalanceSettings, EditAddTokenSettings, EditUpdateWeightsSettings, EditMakeDirectSwapSettings, AddOrEditTokenInput, OracleInput, UpdateWeightsInput, MakeDirectSwapInput, Settings, TaskContext, TaskType, };
|
|
185
|
+
export { getJupTokenLedgerAndSwapInstructions, };
|
|
186
|
+
export { KeeperMonitor } from './keeperMonitor';
|
package/dist/src/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.KeeperMonitor = exports.getJupTokenLedgerAndSwapInstructions = exports.TaskType = exports.SymmetryCore = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
18
18
|
const spl_token_1 = require("@solana/spl-token");
|
|
@@ -36,26 +36,19 @@ const rebalanceIntent_3 = require("./states/intents/rebalanceIntent");
|
|
|
36
36
|
const txUtils_1 = require("./txUtils");
|
|
37
37
|
const config_1 = require("./states/config");
|
|
38
38
|
const flashSwap_1 = require("./instructions/automation/flashSwap");
|
|
39
|
+
const claimFees_1 = require("./instructions/management/claimFees");
|
|
40
|
+
const jup_1 = require("./jup");
|
|
41
|
+
Object.defineProperty(exports, "getJupTokenLedgerAndSwapInstructions", { enumerable: true, get: function () { return jup_1.getJupTokenLedgerAndSwapInstructions; } });
|
|
39
42
|
const constants_1 = require("./constants");
|
|
40
|
-
exports.COMPUTE_UNITS = 1000000;
|
|
41
|
-
exports.PRIORITY_FEE = 100000;
|
|
42
|
-
exports.JUPITER_API_KEY = "https://quote-api.jup.ag/v6/";
|
|
43
|
-
exports.MAX_JUPITER_ACCOUNTS = 35;
|
|
44
43
|
class SymmetryCore {
|
|
45
44
|
constructor(params) {
|
|
46
|
-
var _a
|
|
45
|
+
var _a;
|
|
47
46
|
this.sdkParams = {
|
|
48
47
|
connection: params.connection,
|
|
49
48
|
network: params.network,
|
|
50
|
-
|
|
51
|
-
priorityFee: (_a = params.priorityFee) !== null && _a !== void 0 ? _a : exports.PRIORITY_FEE,
|
|
52
|
-
jupiterApiKey: (_b = params.jupiterApiKey) !== null && _b !== void 0 ? _b : exports.JUPITER_API_KEY,
|
|
53
|
-
maxAllowedAccounts: (_c = params.maxAllowedAccounts) !== null && _c !== void 0 ? _c : exports.MAX_JUPITER_ACCOUNTS,
|
|
49
|
+
priorityFee: (_a = params.priorityFee) !== null && _a !== void 0 ? _a : constants_1.PRIORITY_FEE,
|
|
54
50
|
};
|
|
55
51
|
}
|
|
56
|
-
// async setPayer(payer: PublicKey) {
|
|
57
|
-
// this.sdkParams.payer = payer;
|
|
58
|
-
// }
|
|
59
52
|
fetchGlobalConfig() {
|
|
60
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
54
|
return yield (0, config_1.fetchGlobalConfig)(this.sdkParams.connection);
|
|
@@ -185,7 +178,7 @@ class SymmetryCore {
|
|
|
185
178
|
payer: params.signer,
|
|
186
179
|
instructions: [
|
|
187
180
|
ix,
|
|
188
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
181
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
189
182
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
190
183
|
],
|
|
191
184
|
lookupTables: [],
|
|
@@ -202,7 +195,7 @@ class SymmetryCore {
|
|
|
202
195
|
payer: params.signer,
|
|
203
196
|
instructions: [
|
|
204
197
|
ix,
|
|
205
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
198
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
206
199
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
207
200
|
],
|
|
208
201
|
lookupTables: [],
|
|
@@ -257,7 +250,7 @@ class SymmetryCore {
|
|
|
257
250
|
payer: creator,
|
|
258
251
|
instructions: [
|
|
259
252
|
preIx, preIx2, preIx2, ix, createBasketFeesAccountIx,
|
|
260
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
253
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
261
254
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
262
255
|
],
|
|
263
256
|
lookupTables: [],
|
|
@@ -408,7 +401,7 @@ class SymmetryCore {
|
|
|
408
401
|
instructions: [
|
|
409
402
|
...wsolIxs,
|
|
410
403
|
openBasketIntentIx,
|
|
411
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
404
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
412
405
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
413
406
|
],
|
|
414
407
|
lookupTables: [],
|
|
@@ -446,7 +439,7 @@ class SymmetryCore {
|
|
|
446
439
|
ixWithdraw,
|
|
447
440
|
params.jup_swap_ix,
|
|
448
441
|
ixDeposit,
|
|
449
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
442
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
450
443
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
451
444
|
],
|
|
452
445
|
lookupTables: [],
|
|
@@ -455,7 +448,7 @@ class SymmetryCore {
|
|
|
455
448
|
payer: manager,
|
|
456
449
|
instructions: [
|
|
457
450
|
executeBasketIntentIx,
|
|
458
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
451
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
459
452
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
460
453
|
],
|
|
461
454
|
lookupTables: [],
|
|
@@ -466,7 +459,7 @@ class SymmetryCore {
|
|
|
466
459
|
...wsolIxs,
|
|
467
460
|
openBasketIntentIx,
|
|
468
461
|
executeBasketIntentIx,
|
|
469
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
462
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
470
463
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
471
464
|
];
|
|
472
465
|
}
|
|
@@ -498,7 +491,7 @@ class SymmetryCore {
|
|
|
498
491
|
payer: keeper,
|
|
499
492
|
instructions: [
|
|
500
493
|
ix,
|
|
501
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
494
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
502
495
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
503
496
|
],
|
|
504
497
|
lookupTables: [],
|
|
@@ -524,7 +517,7 @@ class SymmetryCore {
|
|
|
524
517
|
payer: keeper,
|
|
525
518
|
instructions: [
|
|
526
519
|
ix,
|
|
527
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
520
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
528
521
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
529
522
|
],
|
|
530
523
|
lookupTables: [],
|
|
@@ -547,7 +540,7 @@ class SymmetryCore {
|
|
|
547
540
|
payer: keeper,
|
|
548
541
|
instructions: [
|
|
549
542
|
ix,
|
|
550
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
543
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
551
544
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
552
545
|
],
|
|
553
546
|
lookupTables: [],
|
|
@@ -617,7 +610,7 @@ class SymmetryCore {
|
|
|
617
610
|
minBountyAmount: minBountyAmount,
|
|
618
611
|
maxBountyAmount: maxBountyAmount,
|
|
619
612
|
}),
|
|
620
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
613
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
621
614
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
622
615
|
],
|
|
623
616
|
lookupTables: [],
|
|
@@ -631,7 +624,7 @@ class SymmetryCore {
|
|
|
631
624
|
payer: buyer,
|
|
632
625
|
instructions: [
|
|
633
626
|
ix,
|
|
634
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
627
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
635
628
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee })
|
|
636
629
|
],
|
|
637
630
|
lookupTables: [],
|
|
@@ -648,8 +641,8 @@ class SymmetryCore {
|
|
|
648
641
|
keeper: buyer,
|
|
649
642
|
basket: basket.ownAddress,
|
|
650
643
|
rebalanceIntent: rebalanceIntent,
|
|
651
|
-
}) : web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
652
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
644
|
+
}) : web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
645
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
653
646
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
654
647
|
],
|
|
655
648
|
lookupTables: [],
|
|
@@ -750,7 +743,7 @@ class SymmetryCore {
|
|
|
750
743
|
withdrawParamsKeepTokensBitmask: keepTokensBitmask,
|
|
751
744
|
withdrawParamsKeepAllTokens: keepAllTokensFlag,
|
|
752
745
|
}),
|
|
753
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
746
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
754
747
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
755
748
|
],
|
|
756
749
|
lookupTables: [],
|
|
@@ -762,8 +755,8 @@ class SymmetryCore {
|
|
|
762
755
|
keeper: seller,
|
|
763
756
|
basket: basket.ownAddress,
|
|
764
757
|
rebalanceIntent: rebalanceIntent,
|
|
765
|
-
}) : web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
766
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
758
|
+
}) : web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
759
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
767
760
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
768
761
|
],
|
|
769
762
|
lookupTables: [],
|
|
@@ -774,6 +767,70 @@ class SymmetryCore {
|
|
|
774
767
|
return txPayloadBatchSequence;
|
|
775
768
|
});
|
|
776
769
|
}
|
|
770
|
+
rebalanceBasketTx(params) {
|
|
771
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
772
|
+
var _a, _b, _c, _d, _e, _f;
|
|
773
|
+
let keeper = new web3_js_1.PublicKey(params.keeper);
|
|
774
|
+
let rebalanceSlippageBps = (_a = params.rebalance_slippage_bps) !== null && _a !== void 0 ? _a : 100;
|
|
775
|
+
let perTradeRebalanceSlippageBps = (_b = params.per_trade_rebalance_slippage_bps) !== null && _b !== void 0 ? _b : 100;
|
|
776
|
+
let executionStartTime = (_c = params.execution_start_time) !== null && _c !== void 0 ? _c : 0;
|
|
777
|
+
let minBountyAmount = (_d = params.min_bounty_amount) !== null && _d !== void 0 ? _d : 0;
|
|
778
|
+
let maxBountyAmount = (_e = params.max_bounty_amount) !== null && _e !== void 0 ? _e : 0;
|
|
779
|
+
const basket = yield this.fetchBasket((0, pda_1.getBasketState)(new web3_js_1.PublicKey(params.basket_mint)).toBase58());
|
|
780
|
+
let globalConfig = yield this.fetchGlobalConfig();
|
|
781
|
+
let bountyWsolAmount = 0;
|
|
782
|
+
if (globalConfig.bountyMint.equals(constants_1.MINTS["mainnet"].WSOL)) {
|
|
783
|
+
let boundBounty = parseInt(globalConfig.bountyBondAmount.toString());
|
|
784
|
+
let maxBountyPerTask = parseInt(globalConfig.bountyPerTask.maxBounty.toString());
|
|
785
|
+
let bountyPerPriceUpdateTaskDivisor = parseInt(globalConfig.bountyPerPriceUpdateTaskDivisor.toString());
|
|
786
|
+
if (maxBountyAmount > maxBountyPerTask)
|
|
787
|
+
maxBountyPerTask = maxBountyAmount;
|
|
788
|
+
bountyWsolAmount = (0, rebalanceIntent_3.computeRebalanceIntentBountyAmount)(rebalanceIntent_2.RebalanceType.Basket, basket.numTokens, boundBounty, maxBountyPerTask, Math.floor(maxBountyPerTask / bountyPerPriceUpdateTaskDivisor));
|
|
789
|
+
}
|
|
790
|
+
let wsolIxs = yield (0, txUtils_1.wrapWsolIxs)(this.sdkParams.connection, keeper, bountyWsolAmount);
|
|
791
|
+
const rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket.ownAddress, basket.ownAddress);
|
|
792
|
+
let rentPayer = (0, pda_1.getRentPayerPda)();
|
|
793
|
+
let renPayerAi = yield this.sdkParams.connection.getAccountInfo(rentPayer);
|
|
794
|
+
let rebalanceIntentRentPayer = keeper;
|
|
795
|
+
// TODO: check actual lamports required for rent
|
|
796
|
+
if ((_f = renPayerAi === null || renPayerAi === void 0 ? void 0 : renPayerAi.lamports) !== null && _f !== void 0 ? _f : 0 > 0)
|
|
797
|
+
rebalanceIntentRentPayer = rentPayer;
|
|
798
|
+
let bountyMint = basket.settings.bountyMint;
|
|
799
|
+
let txBatchData = { batches: [[{
|
|
800
|
+
payer: keeper,
|
|
801
|
+
instructions: [
|
|
802
|
+
...wsolIxs,
|
|
803
|
+
(0, rebalanceIntent_1.createRebalanceIntentIx)({
|
|
804
|
+
signer: keeper,
|
|
805
|
+
owner: basket.ownAddress,
|
|
806
|
+
basket: basket.ownAddress,
|
|
807
|
+
}),
|
|
808
|
+
(0, rebalanceIntent_1.resizeRebalanceIntentIx)(rebalanceIntent),
|
|
809
|
+
(0, rebalanceIntent_1.initRebalanceIntentIx)({
|
|
810
|
+
signer: keeper,
|
|
811
|
+
owner: basket.ownAddress,
|
|
812
|
+
basket: basket.ownAddress,
|
|
813
|
+
basketTokenMint: basket.mint,
|
|
814
|
+
rebalanceIntentRentPayer: rebalanceIntentRentPayer,
|
|
815
|
+
bountyMint: bountyMint,
|
|
816
|
+
rebalanceType: rebalanceIntent_2.RebalanceType.Basket,
|
|
817
|
+
basketRebalanceIntent: undefined,
|
|
818
|
+
rebalanceSlippageBps: rebalanceSlippageBps,
|
|
819
|
+
perTradeRebalanceSlippageBps: perTradeRebalanceSlippageBps,
|
|
820
|
+
executionStartTime: executionStartTime,
|
|
821
|
+
minBountyAmount: minBountyAmount,
|
|
822
|
+
maxBountyAmount: maxBountyAmount,
|
|
823
|
+
}),
|
|
824
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
825
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
826
|
+
],
|
|
827
|
+
lookupTables: [],
|
|
828
|
+
}]] };
|
|
829
|
+
let versionedTxs = yield (0, txUtils_1.prepareVersionedTxs)(this.sdkParams.connection, txBatchData);
|
|
830
|
+
let txPayloadBatchSequence = (0, txUtils_1.prepareTxPayloadBatchSequence)(txBatchData, versionedTxs);
|
|
831
|
+
return txPayloadBatchSequence;
|
|
832
|
+
});
|
|
833
|
+
}
|
|
777
834
|
startPriceUpdatesTx(params) {
|
|
778
835
|
return __awaiter(this, void 0, void 0, function* () {
|
|
779
836
|
let keeper = new web3_js_1.PublicKey(params.keeper);
|
|
@@ -787,7 +844,7 @@ class SymmetryCore {
|
|
|
787
844
|
basket: basket,
|
|
788
845
|
rebalanceIntent: rebalanceIntent,
|
|
789
846
|
}),
|
|
790
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
847
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
791
848
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
792
849
|
],
|
|
793
850
|
lookupTables: [],
|
|
@@ -827,6 +884,7 @@ class SymmetryCore {
|
|
|
827
884
|
while (tokenIndices.length < 20)
|
|
828
885
|
tokenIndices.push(0);
|
|
829
886
|
// TODO: in last instruction we should include performance fee accounts
|
|
887
|
+
let performanceFees = basket.settings.fees.hostPerformanceFeeBps + basket.settings.fees.creatorPerformanceFeeBps + basket.settings.fees.managersPerformanceFeeBps;
|
|
830
888
|
ixs.push((0, priceUpdate_1.updateTokenPricesIx)({
|
|
831
889
|
keeper: keeper,
|
|
832
890
|
basket: basket.ownAddress,
|
|
@@ -836,13 +894,14 @@ class SymmetryCore {
|
|
|
836
894
|
tokenIndices: tokenIndices,
|
|
837
895
|
additionalOracleAccounts: allKeys,
|
|
838
896
|
basketRebalanceIntent: basket.settings.activeRebalance.eq(new anchor_1.BN(0)) ? undefined : basketRebalanceIntent,
|
|
897
|
+
basketMint: performanceFees > 0 ? basket.mint : undefined,
|
|
839
898
|
}));
|
|
840
899
|
}
|
|
841
900
|
let txBatchData = { batches: [ixs.map(ix => ({
|
|
842
901
|
payer: keeper,
|
|
843
902
|
instructions: [
|
|
844
903
|
ix,
|
|
845
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
904
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
846
905
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
847
906
|
],
|
|
848
907
|
lookupTables: [basket.lookupTables.active[0], basket.lookupTables.active[1]],
|
|
@@ -854,6 +913,7 @@ class SymmetryCore {
|
|
|
854
913
|
}
|
|
855
914
|
flashSwapTx(params) {
|
|
856
915
|
return __awaiter(this, void 0, void 0, function* () {
|
|
916
|
+
var _a;
|
|
857
917
|
let keeper = new web3_js_1.PublicKey(params.keeper);
|
|
858
918
|
let basket = new web3_js_1.PublicKey(params.basket);
|
|
859
919
|
let rebalanceIntent = params.rebalance_intent ? new web3_js_1.PublicKey(params.rebalance_intent) : undefined;
|
|
@@ -877,7 +937,7 @@ class SymmetryCore {
|
|
|
877
937
|
let ixWithdraw = (0, flashSwap_1.flashWithdrawIx)(flashParams);
|
|
878
938
|
let ixDeposit = (0, flashSwap_1.flashDepositIx)(flashParams);
|
|
879
939
|
let ixs = [];
|
|
880
|
-
ixs.concat([
|
|
940
|
+
ixs = ixs.concat([
|
|
881
941
|
(0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(keeper, (0, pda_1.getAta)(keeper, mintIn), keeper, mintIn),
|
|
882
942
|
(0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(keeper, (0, pda_1.getAta)(keeper, mintOut), keeper, mintOut),
|
|
883
943
|
]);
|
|
@@ -890,13 +950,13 @@ class SymmetryCore {
|
|
|
890
950
|
}
|
|
891
951
|
ixs.push(ixDeposit);
|
|
892
952
|
ixs = ixs.concat([
|
|
893
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
953
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
894
954
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
895
955
|
]);
|
|
896
956
|
let txBatchData = { batches: [[{
|
|
897
957
|
payer: keeper,
|
|
898
958
|
instructions: ixs,
|
|
899
|
-
lookupTables: [],
|
|
959
|
+
lookupTables: (_a = params.jup_address_lookup_table_addresses) !== null && _a !== void 0 ? _a : [],
|
|
900
960
|
}]] };
|
|
901
961
|
let versionedTxs = yield (0, txUtils_1.prepareVersionedTxs)(this.sdkParams.connection, txBatchData);
|
|
902
962
|
let txPayloadBatchSequence = (0, txUtils_1.prepareTxPayloadBatchSequence)(txBatchData, versionedTxs);
|
|
@@ -920,7 +980,7 @@ class SymmetryCore {
|
|
|
920
980
|
payer: keeper,
|
|
921
981
|
instructions: [
|
|
922
982
|
ix,
|
|
923
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
983
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
924
984
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
925
985
|
],
|
|
926
986
|
lookupTables: [],
|
|
@@ -954,7 +1014,7 @@ class SymmetryCore {
|
|
|
954
1014
|
payer: keeper,
|
|
955
1015
|
instructions: [
|
|
956
1016
|
ix,
|
|
957
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
1017
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
958
1018
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
959
1019
|
],
|
|
960
1020
|
lookupTables: [],
|
|
@@ -970,17 +1030,17 @@ class SymmetryCore {
|
|
|
970
1030
|
let rebalanceIntent = yield this.fetchRebalanceIntent(params.rebalance_intent);
|
|
971
1031
|
let keepersArray = [];
|
|
972
1032
|
if (!rebalanceIntent.startPriceUpdateTask.completedBy.equals(web3_js_1.PublicKey.default))
|
|
973
|
-
keepersArray.push(rebalanceIntent.startPriceUpdateTask.completedBy);
|
|
1033
|
+
keepersArray.push(rebalanceIntent.startPriceUpdateTask.completedBy.toBase58());
|
|
974
1034
|
if (!rebalanceIntent.finishPriceUpdateTask.completedBy.equals(web3_js_1.PublicKey.default))
|
|
975
|
-
keepersArray.push(rebalanceIntent.finishPriceUpdateTask.completedBy);
|
|
1035
|
+
keepersArray.push(rebalanceIntent.finishPriceUpdateTask.completedBy.toBase58());
|
|
976
1036
|
if (!rebalanceIntent.mintBasketTask.completedBy.equals(web3_js_1.PublicKey.default))
|
|
977
|
-
keepersArray.push(rebalanceIntent.mintBasketTask.completedBy);
|
|
1037
|
+
keepersArray.push(rebalanceIntent.mintBasketTask.completedBy.toBase58());
|
|
978
1038
|
for (let i = 0; i < rebalanceIntent.priceUpdateTasks.length; i++)
|
|
979
1039
|
if (!rebalanceIntent.priceUpdateTasks[i].completedBy.equals(web3_js_1.PublicKey.default))
|
|
980
|
-
keepersArray.push(rebalanceIntent.priceUpdateTasks[i].completedBy);
|
|
1040
|
+
keepersArray.push(rebalanceIntent.priceUpdateTasks[i].completedBy.toBase58());
|
|
981
1041
|
for (let i = 0; i < rebalanceIntent.tokenSettlementTasks.length; i++)
|
|
982
1042
|
if (!rebalanceIntent.tokenSettlementTasks[i].completedBy.equals(web3_js_1.PublicKey.default))
|
|
983
|
-
keepersArray.push(rebalanceIntent.tokenSettlementTasks[i].completedBy);
|
|
1043
|
+
keepersArray.push(rebalanceIntent.tokenSettlementTasks[i].completedBy.toBase58());
|
|
984
1044
|
keepersArray = Array.from(new Set(keepersArray));
|
|
985
1045
|
let batchSize = 10;
|
|
986
1046
|
let ixs = [];
|
|
@@ -992,13 +1052,13 @@ class SymmetryCore {
|
|
|
992
1052
|
bountyMint: rebalanceIntent.bounty.bountyMint,
|
|
993
1053
|
bountyDepositor: rebalanceIntent.bounty.bountyDepositor,
|
|
994
1054
|
rentPayer: rebalanceIntent.rentPayer,
|
|
995
|
-
keepers: keepersArray.slice(batchStart, batchStart + batchSize),
|
|
1055
|
+
keepers: keepersArray.map(keeper => new web3_js_1.PublicKey(keeper)).slice(batchStart, batchStart + batchSize),
|
|
996
1056
|
}));
|
|
997
1057
|
let txBatchData = { batches: [ixs.map(ix => ({
|
|
998
1058
|
payer: keeper,
|
|
999
1059
|
instructions: [
|
|
1000
1060
|
ix,
|
|
1001
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units:
|
|
1061
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
1002
1062
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
1003
1063
|
],
|
|
1004
1064
|
lookupTables: [],
|
|
@@ -1008,6 +1068,54 @@ class SymmetryCore {
|
|
|
1008
1068
|
return txPayloadBatchSequence;
|
|
1009
1069
|
});
|
|
1010
1070
|
}
|
|
1071
|
+
claimBasketFeesTx(params) {
|
|
1072
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1073
|
+
let claimer = new web3_js_1.PublicKey(params.claimer);
|
|
1074
|
+
let basket = yield this.fetchBasket(params.basket);
|
|
1075
|
+
let globalConfig = yield this.fetchGlobalConfig();
|
|
1076
|
+
let ixs = [];
|
|
1077
|
+
if (claimer.equals(globalConfig.symmetryFeeCollector))
|
|
1078
|
+
ixs.push((0, claimFees_1.claimFeesIx)({
|
|
1079
|
+
claimer: claimer,
|
|
1080
|
+
basketTokenMint: basket.mint,
|
|
1081
|
+
feeType: 0,
|
|
1082
|
+
managers: [],
|
|
1083
|
+
}));
|
|
1084
|
+
if (claimer.equals(basket.settings.creator))
|
|
1085
|
+
ixs.push((0, claimFees_1.claimFeesIx)({
|
|
1086
|
+
claimer: claimer,
|
|
1087
|
+
basketTokenMint: basket.mint,
|
|
1088
|
+
feeType: 1,
|
|
1089
|
+
managers: [],
|
|
1090
|
+
}));
|
|
1091
|
+
if (claimer.equals(basket.settings.host))
|
|
1092
|
+
ixs.push((0, claimFees_1.claimFeesIx)({
|
|
1093
|
+
claimer: claimer,
|
|
1094
|
+
basketTokenMint: basket.mint,
|
|
1095
|
+
feeType: 2,
|
|
1096
|
+
managers: [],
|
|
1097
|
+
}));
|
|
1098
|
+
if (basket.settings.managers.managers.find(manager => manager.equals(claimer)))
|
|
1099
|
+
ixs.push((0, claimFees_1.claimFeesIx)({
|
|
1100
|
+
claimer: claimer,
|
|
1101
|
+
basketTokenMint: basket.mint,
|
|
1102
|
+
feeType: 3,
|
|
1103
|
+
managers: basket.settings.managers.managers,
|
|
1104
|
+
}));
|
|
1105
|
+
let txBatchData = { batches: [[{
|
|
1106
|
+
payer: claimer,
|
|
1107
|
+
instructions: [
|
|
1108
|
+
...ixs,
|
|
1109
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
|
|
1110
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
|
|
1111
|
+
],
|
|
1112
|
+
lookupTables: [],
|
|
1113
|
+
}]] };
|
|
1114
|
+
let versionedTxs = yield (0, txUtils_1.prepareVersionedTxs)(this.sdkParams.connection, txBatchData);
|
|
1115
|
+
let txPayloadBatchSequence = (0, txUtils_1.prepareTxPayloadBatchSequence)(txBatchData, versionedTxs);
|
|
1116
|
+
return txPayloadBatchSequence;
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1011
1119
|
signAndSendVersionedTxs(params) {
|
|
1012
1120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1013
1121
|
let { versionedTxs, wallet } = params;
|
|
@@ -1024,3 +1132,5 @@ class SymmetryCore {
|
|
|
1024
1132
|
}
|
|
1025
1133
|
}
|
|
1026
1134
|
exports.SymmetryCore = SymmetryCore;
|
|
1135
|
+
var keeperMonitor_1 = require("./keeperMonitor");
|
|
1136
|
+
Object.defineProperty(exports, "KeeperMonitor", { enumerable: true, get: function () { return keeperMonitor_1.KeeperMonitor; } });
|
|
@@ -14,6 +14,7 @@ export declare function updateTokenPricesIx(params: {
|
|
|
14
14
|
lookupTable1: PublicKey;
|
|
15
15
|
tokenIndices: number[];
|
|
16
16
|
additionalOracleAccounts: PublicKey[];
|
|
17
|
+
basketMint?: PublicKey;
|
|
17
18
|
}): TransactionInstruction;
|
|
18
19
|
export declare function updateTokenPricesCustomIx(params: {
|
|
19
20
|
manager: PublicKey;
|
|
@@ -8,6 +8,7 @@ const constants_1 = require("../../constants");
|
|
|
8
8
|
const oracle_1 = require("../../layouts/oracle");
|
|
9
9
|
const pda_1 = require("../pda");
|
|
10
10
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
11
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
11
12
|
const START_PRICE_UPDATES_DISCRIMINATOR = Buffer.from([240, 67, 241, 88, 0, 32, 224, 184]);
|
|
12
13
|
const UPDATE_TOKEN_PRICES_DISCRIMINATOR = Buffer.from([147, 87, 140, 33, 214, 189, 181, 242]);
|
|
13
14
|
const UPDATE_TOKEN_PRICES_CUSTOM_DISCRIMINATOR = Buffer.from([71, 100, 35, 136, 116, 239, 54, 126]);
|
|
@@ -50,6 +51,13 @@ function updateTokenPricesIx(params) {
|
|
|
50
51
|
];
|
|
51
52
|
// remaining accounts
|
|
52
53
|
keys.push(...params.additionalOracleAccounts.map((pubkey) => ({ pubkey, isSigner: false, isWritable: false })));
|
|
54
|
+
if (params.basketMint) {
|
|
55
|
+
let basketFeesWallet = (0, pda_1.getBasketFeesPda)(params.basket);
|
|
56
|
+
let basketFeesTokenAccount = (0, pda_1.getAta)(basketFeesWallet, params.basketMint);
|
|
57
|
+
keys.push({ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false });
|
|
58
|
+
keys.push({ pubkey: params.basketMint, isSigner: false, isWritable: true });
|
|
59
|
+
keys.push({ pubkey: basketFeesTokenAccount, isSigner: false, isWritable: true });
|
|
60
|
+
}
|
|
53
61
|
return new web3_js_1.TransactionInstruction({
|
|
54
62
|
keys,
|
|
55
63
|
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
@@ -7,7 +7,8 @@ const constants_1 = require("../../constants");
|
|
|
7
7
|
const pda_1 = require("../pda");
|
|
8
8
|
const CLAIM_FEES_DISCRIMINATOR = Buffer.from([97, 50, 216, 3, 144, 118, 13, 164]);
|
|
9
9
|
function claimFeesIx(params) {
|
|
10
|
-
|
|
10
|
+
let { claimer, basketTokenMint, feeType, managers } = params;
|
|
11
|
+
managers = managers.filter(manager => !manager.equals(web3_js_1.PublicKey.default));
|
|
11
12
|
let basket = (0, pda_1.getBasketState)(basketTokenMint);
|
|
12
13
|
let basketFeesWallet = (0, pda_1.getBasketFeesPda)(basket);
|
|
13
14
|
let basketFeesTokenAccount = (0, pda_1.getAta)(basketFeesWallet, basketTokenMint);
|
|
@@ -67,7 +67,7 @@ function editPrivateBasketSettingsIx(params) {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
function createEditBasketIntentIx(params) {
|
|
70
|
-
var _a;
|
|
70
|
+
var _a, _b, _c;
|
|
71
71
|
const { manager, basket, intent, intentSeedArray, useBounty, activationTimestamp, editType, editData, } = params;
|
|
72
72
|
let globalConfig = (0, pda_1.getGlobalConfigPda)();
|
|
73
73
|
let bountyVault = (0, pda_1.getBountyVaultPda)();
|
|
@@ -266,7 +266,7 @@ function createEditBasketIntentIx(params) {
|
|
|
266
266
|
for (let i = 0; i < addTokenData.oracles.length; i++) {
|
|
267
267
|
let oracleData = {
|
|
268
268
|
oracleSettings: {
|
|
269
|
-
oracleType: oracle_1.ORACLE_TYPES_STRINGS.
|
|
269
|
+
oracleType: (_b = (_a = [...oracle_1.ORACLE_TYPES_STRINGS.entries()].find(([, name]) => name === addTokenData.oracles[i].oracle_type)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 255,
|
|
270
270
|
numRequiredAccounts: addTokenData.oracles[i].num_required_accounts,
|
|
271
271
|
weight: addTokenData.oracles[i].weight,
|
|
272
272
|
isRequired: addTokenData.oracles[i].is_required ? 1 : 0,
|
|
@@ -342,7 +342,7 @@ function createEditBasketIntentIx(params) {
|
|
|
342
342
|
const weights = updateWeightsData.token_weights.slice(0, constants_1.MAX_SUPPORTED_TOKENS_PER_BASKET);
|
|
343
343
|
while (weights.length < constants_1.MAX_SUPPORTED_TOKENS_PER_BASKET)
|
|
344
344
|
weights.push({ mint: '', weight_bps: 0 });
|
|
345
|
-
let tokenMintsHash = (
|
|
345
|
+
let tokenMintsHash = (_c = updateWeightsData.token_mints_hash) !== null && _c !== void 0 ? _c : (0, basket_1.computeTokenMintsHash)(basket.composition.slice(0, basket.numTokens)
|
|
346
346
|
.filter((asset) => asset.active === 1)
|
|
347
347
|
.map((asset) => asset.mint.toBase58()));
|
|
348
348
|
let updateWeights = {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
export declare function processJupInstruction(instruction: {
|
|
3
|
+
programId: string;
|
|
4
|
+
accounts: {
|
|
5
|
+
pubkey: string;
|
|
6
|
+
isSigner: boolean;
|
|
7
|
+
isWritable: boolean;
|
|
8
|
+
}[];
|
|
9
|
+
data: string;
|
|
10
|
+
}): TransactionInstruction;
|
|
11
|
+
export declare function getJupQuote(params: {
|
|
12
|
+
keeper: PublicKey;
|
|
13
|
+
basketMintIn: PublicKey;
|
|
14
|
+
basketMintOut: PublicKey;
|
|
15
|
+
basketAmountIn: number;
|
|
16
|
+
basketAmountOut: number;
|
|
17
|
+
swapMode: "exact_in" | "exact_out" | "ioc";
|
|
18
|
+
apiKey: string;
|
|
19
|
+
maxJupAccounts: number;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
mode: string;
|
|
22
|
+
inputMint: string;
|
|
23
|
+
outputMint: string;
|
|
24
|
+
inAmount: number;
|
|
25
|
+
outAmount: number;
|
|
26
|
+
swapUsdValue: number;
|
|
27
|
+
routePlan: any;
|
|
28
|
+
transaction: string;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function getJupSwapInstructions(params: {
|
|
31
|
+
keeper: PublicKey;
|
|
32
|
+
quoteResponse: any;
|
|
33
|
+
apiKey: string;
|
|
34
|
+
}): Promise<any>;
|
|
35
|
+
export declare function getJupTokenLedgerAndSwapInstructions(params: {
|
|
36
|
+
keeper: PublicKey;
|
|
37
|
+
basketMintIn: PublicKey;
|
|
38
|
+
basketMintOut: PublicKey;
|
|
39
|
+
basketAmountIn: number;
|
|
40
|
+
basketAmountOut: number;
|
|
41
|
+
swapMode: "exact_in" | "exact_out" | "ioc";
|
|
42
|
+
apiKey: string;
|
|
43
|
+
maxJupAccounts: number;
|
|
44
|
+
}): Promise<{
|
|
45
|
+
tokenLedgerInstruction: TransactionInstruction;
|
|
46
|
+
swapInstruction: TransactionInstruction;
|
|
47
|
+
addressLookupTableAddresses: PublicKey[];
|
|
48
|
+
quoteResponse: any;
|
|
49
|
+
}>;
|