@symmetry-hq/temp-v3-sdk 0.0.59 → 0.0.61
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/index.js +27 -23
- package/dist/src/instructions/automation/flashSwap.d.ts +1 -1
- package/dist/src/instructions/automation/priceUpdate.js +7 -4
- package/dist/src/instructions/automation/rebalanceIntent.d.ts +1 -1
- package/dist/src/instructions/automation/rebalanceIntent.js +11 -8
- package/dist/src/instructions/management/addBounty.js +5 -2
- package/dist/src/instructions/management/createBasket.js +5 -2
- package/dist/src/instructions/management/edit.d.ts +1 -1
- package/dist/src/instructions/management/edit.js +27 -27
- package/dist/src/instructions/management/luts.js +5 -2
- package/dist/src/instructions/pda.d.ts +1 -0
- package/dist/src/instructions/pda.js +14 -8
- package/dist/src/instructions/user/deposit.js +5 -2
- package/dist/src/layouts/basket.d.ts +1 -1
- package/dist/src/layouts/config.d.ts +1 -1
- package/dist/src/layouts/fraction.d.ts +1 -1
- package/dist/src/layouts/fraction.js +7 -7
- package/dist/src/layouts/intents/bounty.d.ts +1 -1
- package/dist/src/layouts/intents/intent.d.ts +1 -1
- package/dist/src/layouts/intents/rebalanceIntent.d.ts +1 -1
- package/dist/src/layouts/oracle.d.ts +1 -1
- package/dist/src/layouts/oracle.js +8 -5
- package/dist/src/states/intents/intent.js +6 -3
- package/dist/src/states/intents/rebalanceIntent.js +27 -24
- package/dist/src/states/oracles/constants.d.ts +6 -5
- package/dist/src/states/oracles/constants.js +9 -6
- package/dist/src/states/oracles/oracle.js +2 -3
- package/dist/src/states/oracles/pythOracle.d.ts +1 -1
- package/dist/src/states/oracles/pythOracle.js +12 -12
- package/dist/src/states/oracles/raydiumClmmOracle.d.ts +2 -2
- package/dist/src/states/oracles/raydiumClmmOracle.js +68 -68
- package/dist/src/states/oracles/raydiumCpmmOracle.d.ts +1 -1
- package/dist/src/states/oracles/raydiumCpmmOracle.js +20 -20
- package/package.json +7 -6
- package/src/index.ts +10 -6
- package/src/instructions/automation/flashSwap.ts +1 -1
- package/src/instructions/automation/priceUpdate.ts +1 -1
- package/src/instructions/automation/rebalanceIntent.ts +1 -1
- package/src/instructions/management/addBounty.ts +1 -1
- package/src/instructions/management/createBasket.ts +1 -1
- package/src/instructions/management/edit.ts +1 -1
- package/src/instructions/management/luts.ts +1 -1
- package/src/instructions/pda.ts +13 -7
- package/src/instructions/user/deposit.ts +1 -1
- package/src/layouts/basket.ts +1 -1
- package/src/layouts/config.ts +1 -1
- package/src/layouts/fraction.ts +1 -1
- package/src/layouts/intents/bounty.ts +1 -1
- package/src/layouts/intents/intent.ts +1 -1
- package/src/layouts/intents/rebalanceIntent.ts +1 -1
- package/src/layouts/oracle.ts +1 -1
- package/src/states/intents/intent.ts +1 -1
- package/src/states/intents/rebalanceIntent.ts +1 -1
- package/src/states/oracles/constants.ts +1 -1
- package/src/states/oracles/oracle.ts +3 -3
- package/src/states/oracles/pythOracle.ts +2 -3
- package/src/states/oracles/raydiumClmmOracle.ts +5 -5
- package/src/states/oracles/raydiumCpmmOracle.ts +1 -1
- package/scripts/run-keeper-monitor.cjs +0 -122
package/dist/src/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.KeeperMonitor = exports.getJupTokenLedgerAndSwapInstructions = exports.TaskType = exports.SymmetryCore = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
|
-
const
|
|
17
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
18
18
|
const spl_token_1 = require("@solana/spl-token");
|
|
19
19
|
const web3_js_1 = require("@solana/web3.js");
|
|
20
20
|
const constants_1 = require("./constants");
|
|
@@ -677,23 +677,23 @@ class SymmetryCore {
|
|
|
677
677
|
*/
|
|
678
678
|
openBasketIntentTx(params) {
|
|
679
679
|
return __awaiter(this, void 0, void 0, function* () {
|
|
680
|
-
var _a, _b
|
|
680
|
+
var _a, _b;
|
|
681
681
|
let basket = yield this.fetchBasket(params.context.basket);
|
|
682
682
|
let manager = new web3_js_1.PublicKey(params.context.manager);
|
|
683
|
-
let activationTimestamp = new
|
|
684
|
-
let expirationTimestamp = new
|
|
683
|
+
let activationTimestamp = new bn_js_1.default((_a = params.context.activation_timestamp) !== null && _a !== void 0 ? _a : 0);
|
|
684
|
+
let expirationTimestamp = new bn_js_1.default((_b = params.context.expiration_timestamp) !== null && _b !== void 0 ? _b : 0);
|
|
685
685
|
let editType = params.type;
|
|
686
686
|
let editData = params.settings;
|
|
687
687
|
let modificationDelay = (() => {
|
|
688
688
|
switch (editType) {
|
|
689
|
-
case intent_1.TaskType.EditCreator: return new
|
|
689
|
+
case intent_1.TaskType.EditCreator: return new bn_js_1.default(0);
|
|
690
690
|
case intent_1.TaskType.EditManagerSettings: return basket.settings.managers.modificationDelay;
|
|
691
691
|
case intent_1.TaskType.EditFeeSettings: return basket.settings.fees.modificationDelay;
|
|
692
692
|
case intent_1.TaskType.EditScheduleSettings: return basket.settings.schedule.modificationDelay;
|
|
693
693
|
case intent_1.TaskType.EditAutomationSettings: return basket.settings.automation.modificationDelay;
|
|
694
694
|
case intent_1.TaskType.EditLpSettings: return basket.settings.lp.modificationDelay;
|
|
695
695
|
case intent_1.TaskType.EditMetadataSettings: return basket.settings.metadata.modificationDelay;
|
|
696
|
-
case intent_1.TaskType.EditDepositsSettings: return new
|
|
696
|
+
case intent_1.TaskType.EditDepositsSettings: return new bn_js_1.default(0);
|
|
697
697
|
case intent_1.TaskType.EditForceRebalanceSettings: return basket.settings.forceRebalanceModificationDelay;
|
|
698
698
|
case intent_1.TaskType.EditCustomRebalanceSettings: return basket.settings.customRebalanceModificationDelay;
|
|
699
699
|
case intent_1.TaskType.EditAddTokenDelay: return basket.settings.addTokenDelay;
|
|
@@ -702,14 +702,18 @@ class SymmetryCore {
|
|
|
702
702
|
case intent_1.TaskType.AddToken: return basket.settings.addTokenDelay;
|
|
703
703
|
case intent_1.TaskType.UpdateWeights: return basket.settings.updateWeightsDelay;
|
|
704
704
|
case intent_1.TaskType.MakeDirectSwap: return basket.settings.makeDirectSwapDelay;
|
|
705
|
-
default: return new
|
|
705
|
+
default: return new bn_js_1.default(0);
|
|
706
706
|
}
|
|
707
707
|
})();
|
|
708
708
|
let globalConfig = yield this.fetchGlobalConfig();
|
|
709
|
-
let minBounty =
|
|
710
|
-
|
|
709
|
+
let minBounty = params.context.min_bounty !== undefined
|
|
710
|
+
? new bn_js_1.default(params.context.min_bounty)
|
|
711
|
+
: globalConfig.bountyPerTask.minBounty;
|
|
712
|
+
let maxBounty = params.context.max_bounty !== undefined
|
|
713
|
+
? new bn_js_1.default(params.context.max_bounty)
|
|
714
|
+
: globalConfig.bountyPerTask.maxBounty;
|
|
711
715
|
if (parseInt(minBounty.toString()) > parseInt(maxBounty.toString()))
|
|
712
|
-
minBounty = maxBounty.div(2);
|
|
716
|
+
minBounty = maxBounty.div(new bn_js_1.default(2));
|
|
713
717
|
let bountyWsolAmount = 0;
|
|
714
718
|
if (globalConfig.bountyMint.equals(constants_1.MINTS["mainnet"].WSOL)) {
|
|
715
719
|
let boundBounty = parseInt(globalConfig.bountyBondAmount.toString());
|
|
@@ -752,7 +756,7 @@ class SymmetryCore {
|
|
|
752
756
|
lookupTables: [],
|
|
753
757
|
}]] };
|
|
754
758
|
// Only execute in the same transaction when there is no delay and no scheduled activation.
|
|
755
|
-
if (modificationDelay.eq(new
|
|
759
|
+
if (modificationDelay.eq(new bn_js_1.default(0)) && activationTimestamp.eq(new bn_js_1.default(0))) {
|
|
756
760
|
let executeBasketIntentIx = (0, edit_1.executeEditBasketIntentIx)({
|
|
757
761
|
basket: basket.ownAddress,
|
|
758
762
|
intent: intent,
|
|
@@ -770,8 +774,8 @@ class SymmetryCore {
|
|
|
770
774
|
intent: intent,
|
|
771
775
|
mintIn: new web3_js_1.PublicKey(editData.make_direct_swap.from_token_mint),
|
|
772
776
|
mintOut: new web3_js_1.PublicKey(editData.make_direct_swap.to_token_mint),
|
|
773
|
-
amountIn: new
|
|
774
|
-
amountOut: new
|
|
777
|
+
amountIn: new bn_js_1.default(editData.make_direct_swap.amount_from),
|
|
778
|
+
amountOut: new bn_js_1.default(editData.make_direct_swap.amount_to),
|
|
775
779
|
mode: undefined,
|
|
776
780
|
};
|
|
777
781
|
let ixWithdraw = (0, flashSwap_1.flashWithdrawIx)(flashParams);
|
|
@@ -951,7 +955,7 @@ class SymmetryCore {
|
|
|
951
955
|
let buyer = new web3_js_1.PublicKey(params.buyer);
|
|
952
956
|
let contributions = params.contributions.map(contribution => ({
|
|
953
957
|
mint: new web3_js_1.PublicKey(contribution.mint),
|
|
954
|
-
amount:
|
|
958
|
+
amount: contribution.amount,
|
|
955
959
|
}));
|
|
956
960
|
let rebalanceSlippageBps = (_a = params.rebalance_slippage_bps) !== null && _a !== void 0 ? _a : 100;
|
|
957
961
|
let perTradeRebalanceSlippageBps = (_b = params.per_trade_rebalance_slippage_bps) !== null && _b !== void 0 ? _b : 100;
|
|
@@ -1160,7 +1164,7 @@ class SymmetryCore {
|
|
|
1160
1164
|
var _a, _b, _c, _d, _e, _f;
|
|
1161
1165
|
let seller = new web3_js_1.PublicKey(params.seller);
|
|
1162
1166
|
let basketMint = new web3_js_1.PublicKey(params.basket_mint);
|
|
1163
|
-
let withdrawAmount =
|
|
1167
|
+
let withdrawAmount = params.withdraw_amount;
|
|
1164
1168
|
let keepTokens = params.keep_tokens;
|
|
1165
1169
|
let rebalanceSlippageBps = (_a = params.rebalance_slippage_bps) !== null && _a !== void 0 ? _a : 100;
|
|
1166
1170
|
let perTradeRebalanceSlippageBps = (_b = params.per_trade_rebalance_slippage_bps) !== null && _b !== void 0 ? _b : 100;
|
|
@@ -1196,7 +1200,7 @@ class SymmetryCore {
|
|
|
1196
1200
|
}
|
|
1197
1201
|
let tokenMintsHash = (0, basket_1.computeTokenMintsHash)(basket.composition.slice(0, basket.numTokens)
|
|
1198
1202
|
.map(asset => asset.mint.toBase58()));
|
|
1199
|
-
let keepTokensBitmask = new
|
|
1203
|
+
let keepTokensBitmask = new bn_js_1.default(0);
|
|
1200
1204
|
if (keepTokens && keepTokens.length > 0) {
|
|
1201
1205
|
for (const mint of keepTokens) {
|
|
1202
1206
|
let tokenIndex = -1;
|
|
@@ -1209,10 +1213,10 @@ class SymmetryCore {
|
|
|
1209
1213
|
if (tokenIndex === -1) {
|
|
1210
1214
|
throw new Error(`Token mint not in basket: ${mint}`);
|
|
1211
1215
|
}
|
|
1212
|
-
keepTokensBitmask = keepTokensBitmask.or(new
|
|
1216
|
+
keepTokensBitmask = keepTokensBitmask.or(new bn_js_1.default(1).shln(tokenIndex));
|
|
1213
1217
|
}
|
|
1214
1218
|
}
|
|
1215
|
-
const basketRebalanceIntent = basket.settings.activeRebalance.gt(new
|
|
1219
|
+
const basketRebalanceIntent = basket.settings.activeRebalance.gt(new bn_js_1.default(0))
|
|
1216
1220
|
? (0, pda_1.getRebalanceIntentPda)(basket.ownAddress, basket.ownAddress)
|
|
1217
1221
|
: undefined;
|
|
1218
1222
|
let txBatchData = { batches: [
|
|
@@ -1415,7 +1419,7 @@ class SymmetryCore {
|
|
|
1415
1419
|
lookupTable1: basket.lookupTables.active[1],
|
|
1416
1420
|
tokenIndices: tokenIndices,
|
|
1417
1421
|
additionalOracleAccounts: allKeys,
|
|
1418
|
-
basketRebalanceIntent: basket.settings.activeRebalance.eq(new
|
|
1422
|
+
basketRebalanceIntent: basket.settings.activeRebalance.eq(new bn_js_1.default(0)) ? undefined : basketRebalanceIntent,
|
|
1419
1423
|
basketMint: performanceFees > 0 ? basket.mint : undefined,
|
|
1420
1424
|
}));
|
|
1421
1425
|
}
|
|
@@ -1613,8 +1617,8 @@ class SymmetryCore {
|
|
|
1613
1617
|
let intent = params.intent ? new web3_js_1.PublicKey(params.intent) : undefined;
|
|
1614
1618
|
let mintIn = new web3_js_1.PublicKey(params.mint_in);
|
|
1615
1619
|
let mintOut = new web3_js_1.PublicKey(params.mint_out);
|
|
1616
|
-
let amountIn = new
|
|
1617
|
-
let amountOut = new
|
|
1620
|
+
let amountIn = new bn_js_1.default(params.amount_in);
|
|
1621
|
+
let amountOut = new bn_js_1.default(params.amount_out);
|
|
1618
1622
|
let mode = params.mode ? params.mode : 0;
|
|
1619
1623
|
let flashParams = {
|
|
1620
1624
|
keeper: keeper,
|
|
@@ -1677,7 +1681,7 @@ class SymmetryCore {
|
|
|
1677
1681
|
basket: basket.ownAddress,
|
|
1678
1682
|
basketTokenMint: basket.mint,
|
|
1679
1683
|
buyer: rebalanceIntent.owner,
|
|
1680
|
-
basketRebalanceIntent: basket.settings.activeRebalance.eq(new
|
|
1684
|
+
basketRebalanceIntent: basket.settings.activeRebalance.eq(new bn_js_1.default(0)) ? undefined : basketRebalanceIntent,
|
|
1681
1685
|
});
|
|
1682
1686
|
let txBatchData = { batches: [[{
|
|
1683
1687
|
payer: keeper,
|
|
@@ -1712,7 +1716,7 @@ class SymmetryCore {
|
|
|
1712
1716
|
for (let batchStart = 0; batchStart < rebalanceIntent.tokens.length; batchStart += batchSize) {
|
|
1713
1717
|
let tokenMints = [];
|
|
1714
1718
|
for (let i = batchStart; i < rebalanceIntent.tokens.length && i < batchStart + batchSize; i++)
|
|
1715
|
-
if (rebalanceIntent.tokens[i].amount.gt(new
|
|
1719
|
+
if (rebalanceIntent.tokens[i].amount.gt(new bn_js_1.default(0)))
|
|
1716
1720
|
tokenMints.push(rebalanceIntent.tokens[i].mint);
|
|
1717
1721
|
if (tokenMints.length > 0) {
|
|
1718
1722
|
ixs.push((0, withdraw_1.redeemTokensIx)({
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.updateTokenPricesIx = updateTokenPricesIx;
|
|
4
7
|
exports.updateTokenPricesCustomIx = updateTokenPricesCustomIx;
|
|
@@ -6,7 +9,7 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
6
9
|
const constants_1 = require("../../constants");
|
|
7
10
|
const oracle_1 = require("../../layouts/oracle");
|
|
8
11
|
const pda_1 = require("../pda");
|
|
9
|
-
const
|
|
12
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
10
13
|
const spl_token_1 = require("@solana/spl-token");
|
|
11
14
|
const UPDATE_TOKEN_PRICES_DISCRIMINATOR = Buffer.from([147, 87, 140, 33, 214, 189, 181, 242]);
|
|
12
15
|
const UPDATE_TOKEN_PRICES_CUSTOM_DISCRIMINATOR = Buffer.from([71, 100, 35, 136, 116, 239, 54, 126]);
|
|
@@ -57,9 +60,9 @@ function updateTokenPricesCustomIx(params) {
|
|
|
57
60
|
const tokenPrices = params.tokenPrices.slice(0, 10);
|
|
58
61
|
while (tokenPrices.length < 10) {
|
|
59
62
|
tokenPrices.push({
|
|
60
|
-
price: { high: new
|
|
61
|
-
conf: { high: new
|
|
62
|
-
updateTime: new
|
|
63
|
+
price: { high: new bn_js_1.default(0), low: new bn_js_1.default(0) },
|
|
64
|
+
conf: { high: new bn_js_1.default(0), low: new bn_js_1.default(0) },
|
|
65
|
+
updateTime: new bn_js_1.default(0),
|
|
63
66
|
});
|
|
64
67
|
}
|
|
65
68
|
const pricesBufs = tokenPrices.map((p) => {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.createRebalanceIntentIx = createRebalanceIntentIx;
|
|
4
7
|
exports.resizeRebalanceIntentIx = resizeRebalanceIntentIx;
|
|
5
8
|
exports.initRebalanceIntentIx = initRebalanceIntentIx;
|
|
6
9
|
exports.cancelRebalanceIx = cancelRebalanceIx;
|
|
7
|
-
const
|
|
10
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
8
11
|
const spl_token_1 = require("@solana/spl-token");
|
|
9
12
|
const web3_js_1 = require("@solana/web3.js");
|
|
10
13
|
const constants_1 = require("../../constants");
|
|
@@ -47,7 +50,7 @@ function resizeRebalanceIntentIx(rebalanceIntent) {
|
|
|
47
50
|
});
|
|
48
51
|
}
|
|
49
52
|
function initRebalanceIntentIx(params) {
|
|
50
|
-
const { signer, owner, basket, basketTokenMint, rebalanceIntentRentPayer, bountyMint, rebalanceType, rebalanceSlippageBps, perTradeRebalanceSlippageBps, executionStartTime, minBountyAmount, maxBountyAmount, withdrawParamsBurnAmount = 0, withdrawParamsTokenMintsHash = new Array(32).fill(0), withdrawParamsKeepTokensBitmask = new
|
|
53
|
+
const { signer, owner, basket, basketTokenMint, rebalanceIntentRentPayer, bountyMint, rebalanceType, rebalanceSlippageBps, perTradeRebalanceSlippageBps, executionStartTime, minBountyAmount, maxBountyAmount, withdrawParamsBurnAmount = 0, withdrawParamsTokenMintsHash = new Array(32).fill(0), withdrawParamsKeepTokensBitmask = new bn_js_1.default(0), withdrawParamsKeepAllTokens = 0, basketRebalanceIntent, } = params;
|
|
51
54
|
const rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket, owner);
|
|
52
55
|
const rentPayerPda = (0, pda_1.getRentPayerPda)();
|
|
53
56
|
const globalConfig = (0, pda_1.getGlobalConfigPda)();
|
|
@@ -61,12 +64,12 @@ function initRebalanceIntentIx(params) {
|
|
|
61
64
|
INIT_REBALANCE_INTENT_DISCRIMINATOR,
|
|
62
65
|
rebalanceIntentRentPayer.toBuffer(),
|
|
63
66
|
Buffer.from([rebalanceType]),
|
|
64
|
-
Buffer.from(new
|
|
65
|
-
Buffer.from(new
|
|
66
|
-
Buffer.from(new
|
|
67
|
-
Buffer.from(new
|
|
68
|
-
Buffer.from(new
|
|
69
|
-
Buffer.from(new
|
|
67
|
+
Buffer.from(new bn_js_1.default(rebalanceSlippageBps).toArray("le", 2)),
|
|
68
|
+
Buffer.from(new bn_js_1.default(perTradeRebalanceSlippageBps).toArray("le", 2)),
|
|
69
|
+
Buffer.from(new bn_js_1.default(executionStartTime).toArray("le", 8)),
|
|
70
|
+
Buffer.from(new bn_js_1.default(minBountyAmount).toArray("le", 8)),
|
|
71
|
+
Buffer.from(new bn_js_1.default(maxBountyAmount).toArray("le", 8)),
|
|
72
|
+
Buffer.from(new bn_js_1.default(withdrawParamsBurnAmount).toArray("le", 8)),
|
|
70
73
|
Buffer.from(withdrawParamsTokenMintsHash),
|
|
71
74
|
Buffer.from(withdrawParamsKeepTokensBitmask.toArray("le", 16)),
|
|
72
75
|
Buffer.from([withdrawParamsKeepAllTokens]),
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.addBountyIx = addBountyIx;
|
|
4
|
-
const
|
|
7
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
5
8
|
const spl_token_1 = require("@solana/spl-token");
|
|
6
9
|
const web3_js_1 = require("@solana/web3.js");
|
|
7
10
|
const constants_1 = require("../../constants");
|
|
@@ -15,7 +18,7 @@ function addBountyIx(params) {
|
|
|
15
18
|
let bountyVaultAta = (0, pda_1.getAta)(bountyVault, bountyMint);
|
|
16
19
|
const data = Buffer.concat([
|
|
17
20
|
ADD_BOUNTY_DISCRIMINATOR,
|
|
18
|
-
Buffer.from(new
|
|
21
|
+
Buffer.from(new bn_js_1.default(amount).toArray("le", 8)), // u64 LE
|
|
19
22
|
]);
|
|
20
23
|
const keys = [
|
|
21
24
|
{ pubkey: keeper, isSigner: true, isWritable: true },
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.createBasketStateAccountIx = createBasketStateAccountIx;
|
|
4
7
|
exports.resizeBasketStateIx = resizeBasketStateIx;
|
|
5
8
|
exports.createBasketIx = createBasketIx;
|
|
6
|
-
const
|
|
9
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
7
10
|
const spl_token_1 = require("@solana/spl-token");
|
|
8
11
|
const web3_js_1 = require("@solana/web3.js");
|
|
9
12
|
const constants_1 = require("../../constants");
|
|
@@ -57,7 +60,7 @@ function createBasketIx(params) {
|
|
|
57
60
|
config_1.HostFeesLayout.encode(hostFees, hostFeesBuffer);
|
|
58
61
|
const data = Buffer.concat([
|
|
59
62
|
CREATE_BASKET_DISCRIMINATOR,
|
|
60
|
-
Buffer.from(new
|
|
63
|
+
Buffer.from(new bn_js_1.default(slot).toArray("le", 8)),
|
|
61
64
|
host.toBuffer(),
|
|
62
65
|
Buffer.from(startPrice.high.toArray("le", 8)),
|
|
63
66
|
Buffer.from(startPrice.low.toArray("le", 8)),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BN from 'bn.js';
|
|
2
2
|
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { Basket } from '../../layouts/basket';
|
|
4
4
|
import { AuthorityBitmasks, AutomationSettings, FeeSettings, LpSettings, ManagerSettings, MetadataParams, ScheduleSettings } from '../../layouts/config';
|
|
@@ -7,7 +7,7 @@ exports.editPrivateBasketSettingsIx = editPrivateBasketSettingsIx;
|
|
|
7
7
|
exports.createEditBasketIntentIx = createEditBasketIntentIx;
|
|
8
8
|
exports.executeEditBasketIntentIx = executeEditBasketIntentIx;
|
|
9
9
|
exports.cancelIntentIx = cancelIntentIx;
|
|
10
|
-
const
|
|
10
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
11
11
|
const spl_token_1 = require("@solana/spl-token");
|
|
12
12
|
const web3_js_1 = require("@solana/web3.js");
|
|
13
13
|
const constants_1 = require("../../constants");
|
|
@@ -142,7 +142,7 @@ function createEditBasketIntentIx(params) {
|
|
|
142
142
|
config_1.AuthorityBitmasksLayout.encode(authorityBitmasks, authorityBitmasksBuffer);
|
|
143
143
|
editDataBuf.set(authorityBitmasksBuffer, startIndex);
|
|
144
144
|
startIndex += config_1.AuthorityBitmasksLayout.span;
|
|
145
|
-
let modificationDelayBN = new
|
|
145
|
+
let modificationDelayBN = new bn_js_1.default(managerSettings.modification_delay);
|
|
146
146
|
editDataBuf.writeBigUint64LE(BigInt(modificationDelayBN.toString()), startIndex);
|
|
147
147
|
startIndex += 8;
|
|
148
148
|
break;
|
|
@@ -164,22 +164,22 @@ function createEditBasketIntentIx(params) {
|
|
|
164
164
|
basketDepositFeeBps: feeSettings.basket_deposit_fee_bps,
|
|
165
165
|
basketWithdrawFeeBps: feeSettings.basket_withdraw_fee_bps,
|
|
166
166
|
extraData: new Array(32).fill(0),
|
|
167
|
-
modificationDelay: new
|
|
167
|
+
modificationDelay: new bn_js_1.default(feeSettings.modification_delay),
|
|
168
168
|
};
|
|
169
169
|
config_1.FeeSettingsLayout.encode(editFeeSettings, editDataBuf);
|
|
170
170
|
break;
|
|
171
171
|
case intent_1.TaskType.EditScheduleSettings: // 4
|
|
172
172
|
let scheduleSettings = editData;
|
|
173
173
|
let editScheduleSettings = {
|
|
174
|
-
cycleStartTime: new
|
|
175
|
-
cycleDuration: new
|
|
176
|
-
depositsStart: new
|
|
177
|
-
depositsEnd: new
|
|
178
|
-
automationStart: new
|
|
179
|
-
automationEnd: new
|
|
180
|
-
managementStart: new
|
|
181
|
-
managementEnd: new
|
|
182
|
-
modificationDelay: new
|
|
174
|
+
cycleStartTime: new bn_js_1.default(scheduleSettings.cycle_start_time),
|
|
175
|
+
cycleDuration: new bn_js_1.default(scheduleSettings.cycle_duration),
|
|
176
|
+
depositsStart: new bn_js_1.default(scheduleSettings.deposits_start),
|
|
177
|
+
depositsEnd: new bn_js_1.default(scheduleSettings.deposits_end),
|
|
178
|
+
automationStart: new bn_js_1.default(scheduleSettings.automation_start),
|
|
179
|
+
automationEnd: new bn_js_1.default(scheduleSettings.automation_end),
|
|
180
|
+
managementStart: new bn_js_1.default(scheduleSettings.management_start),
|
|
181
|
+
managementEnd: new bn_js_1.default(scheduleSettings.management_end),
|
|
182
|
+
modificationDelay: new bn_js_1.default(scheduleSettings.modification_delay),
|
|
183
183
|
};
|
|
184
184
|
config_1.ScheduleSettingsLayout.encode(editScheduleSettings, editDataBuf);
|
|
185
185
|
break;
|
|
@@ -191,9 +191,9 @@ function createEditBasketIntentIx(params) {
|
|
|
191
191
|
perTradeRebalanceSlippageThresholdBps: automationSettings.per_trade_rebalance_slippage_threshold_bps,
|
|
192
192
|
rebalanceActivationThresholdAbsBps: automationSettings.rebalance_activation_threshold_abs_bps,
|
|
193
193
|
rebalanceActivationThresholdRelBps: automationSettings.rebalance_activation_threshold_rel_bps,
|
|
194
|
-
rebalanceActivationCooldown: new
|
|
194
|
+
rebalanceActivationCooldown: new bn_js_1.default(automationSettings.rebalance_activation_cooldown),
|
|
195
195
|
extraData: new Array(4).fill(web3_js_1.PublicKey.default),
|
|
196
|
-
modificationDelay: new
|
|
196
|
+
modificationDelay: new bn_js_1.default(automationSettings.modification_delay),
|
|
197
197
|
};
|
|
198
198
|
config_1.AutomationSettingsLayout.encode(editAutomationSettings, editDataBuf);
|
|
199
199
|
break;
|
|
@@ -203,7 +203,7 @@ function createEditBasketIntentIx(params) {
|
|
|
203
203
|
allowLp: lpSettings.enabled ? 1 : 0,
|
|
204
204
|
lpThresholdBps: lpSettings.lp_threshold_bps,
|
|
205
205
|
extraData: new Array(32).fill(0),
|
|
206
|
-
modificationDelay: new
|
|
206
|
+
modificationDelay: new bn_js_1.default(lpSettings.modification_delay),
|
|
207
207
|
};
|
|
208
208
|
config_1.LpSettingsLayout.encode(editLpSettings, editDataBuf);
|
|
209
209
|
break;
|
|
@@ -216,7 +216,7 @@ function createEditBasketIntentIx(params) {
|
|
|
216
216
|
name: metadataSettings.name.split('').map((char) => char.charCodeAt(0)),
|
|
217
217
|
uriLength: metadataSettings.uri.length,
|
|
218
218
|
uri: metadataSettings.uri.split('').map((char) => char.charCodeAt(0)),
|
|
219
|
-
modificationDelay: new
|
|
219
|
+
modificationDelay: new bn_js_1.default(metadataSettings.modification_delay),
|
|
220
220
|
};
|
|
221
221
|
config_1.MetadataSettingsLayout.encode(editMetadataSettings, editDataBuf);
|
|
222
222
|
break;
|
|
@@ -228,35 +228,35 @@ function createEditBasketIntentIx(params) {
|
|
|
228
228
|
case intent_1.TaskType.EditForceRebalanceSettings: // 9
|
|
229
229
|
let forceRebalanceSettings = editData;
|
|
230
230
|
let editForceRebalanceSettings = forceRebalanceSettings.enabled ? 1 : 0;
|
|
231
|
-
let editForceRebalanceModificationDelayBN = new
|
|
231
|
+
let editForceRebalanceModificationDelayBN = new bn_js_1.default(forceRebalanceSettings.modification_delay);
|
|
232
232
|
editDataBuf[0] = editForceRebalanceSettings;
|
|
233
233
|
editDataBuf.writeBigUint64LE(BigInt(editForceRebalanceModificationDelayBN.toString()), 1);
|
|
234
234
|
break;
|
|
235
235
|
case intent_1.TaskType.EditCustomRebalanceSettings: // 10
|
|
236
236
|
let customRebalanceSettings = editData;
|
|
237
237
|
let editCustomRebalanceSettings = customRebalanceSettings.enabled ? 1 : 0;
|
|
238
|
-
let editCustomRebalanceModificationDelayBN = new
|
|
238
|
+
let editCustomRebalanceModificationDelayBN = new bn_js_1.default(customRebalanceSettings.modification_delay);
|
|
239
239
|
editDataBuf[0] = editCustomRebalanceSettings;
|
|
240
240
|
editDataBuf.writeBigUint64LE(BigInt(editCustomRebalanceModificationDelayBN.toString()), 1);
|
|
241
241
|
break;
|
|
242
242
|
case intent_1.TaskType.EditAddTokenDelay: // 11 - 101
|
|
243
243
|
let addTokenDelay = editData;
|
|
244
244
|
let editAddTokenDelay = {
|
|
245
|
-
modificationDelay: new
|
|
245
|
+
modificationDelay: new bn_js_1.default(addTokenDelay.modification_delay),
|
|
246
246
|
};
|
|
247
247
|
config_1.EditAddTokenDelayLayout.encode(editAddTokenDelay, editDataBuf);
|
|
248
248
|
break;
|
|
249
249
|
case intent_1.TaskType.EditUpdateWeightsDelay: // 12 - 102
|
|
250
250
|
let updateWeightsDelay = editData;
|
|
251
251
|
let editUpdateWeightsDelay = {
|
|
252
|
-
modificationDelay: new
|
|
252
|
+
modificationDelay: new bn_js_1.default(updateWeightsDelay.modification_delay),
|
|
253
253
|
};
|
|
254
254
|
config_1.EditUpdateWeightsDelayLayout.encode(editUpdateWeightsDelay, editDataBuf);
|
|
255
255
|
break;
|
|
256
256
|
case intent_1.TaskType.EditMakeDirectSwapDelay: // 13 - 103
|
|
257
257
|
let makeDirectSwapDelay = editData;
|
|
258
258
|
let editMakeDirectSwapDelay = {
|
|
259
|
-
modificationDelay: new
|
|
259
|
+
modificationDelay: new bn_js_1.default(makeDirectSwapDelay.modification_delay),
|
|
260
260
|
};
|
|
261
261
|
config_1.EditMakeDirectSwapDelayLayout.encode(editMakeDirectSwapDelay, editDataBuf);
|
|
262
262
|
break;
|
|
@@ -273,12 +273,12 @@ function createEditBasketIntentIx(params) {
|
|
|
273
273
|
confThreshBps: addTokenData.oracles[i].conf_thresh_bps,
|
|
274
274
|
volatilityThreshBps: addTokenData.oracles[i].volatility_thresh_bps,
|
|
275
275
|
maxSlippageBps: addTokenData.oracles[i].max_slippage_bps,
|
|
276
|
-
minLiquidity: new
|
|
277
|
-
stalenessThresh: new
|
|
276
|
+
minLiquidity: new bn_js_1.default(addTokenData.oracles[i].min_liquidity),
|
|
277
|
+
stalenessThresh: new bn_js_1.default(addTokenData.oracles[i].staleness_thresh),
|
|
278
278
|
stalenessConfRateBps: addTokenData.oracles[i].staleness_conf_rate_bps,
|
|
279
279
|
tokenDecimals: addTokenData.oracles[i].token_decimals,
|
|
280
|
-
twapSecondsAgo: new
|
|
281
|
-
twapSecondarySecondsAgo: new
|
|
280
|
+
twapSecondsAgo: new bn_js_1.default(addTokenData.oracles[i].twap_seconds_ago),
|
|
281
|
+
twapSecondarySecondsAgo: new bn_js_1.default(addTokenData.oracles[i].twap_secondary_seconds_ago),
|
|
282
282
|
quote: oracle_1.Quote.Wsol,
|
|
283
283
|
side: oracle_1.Side.Base,
|
|
284
284
|
},
|
|
@@ -357,8 +357,8 @@ function createEditBasketIntentIx(params) {
|
|
|
357
357
|
let makeDirectSwap = {
|
|
358
358
|
fromTokenMint: new web3_js_1.PublicKey(makeDirectSwapData.from_token_mint),
|
|
359
359
|
toTokenMint: new web3_js_1.PublicKey(makeDirectSwapData.to_token_mint),
|
|
360
|
-
amountFrom: new
|
|
361
|
-
amountTo: new
|
|
360
|
+
amountFrom: new bn_js_1.default(makeDirectSwapData.amount_from),
|
|
361
|
+
amountTo: new bn_js_1.default(makeDirectSwapData.amount_to),
|
|
362
362
|
};
|
|
363
363
|
config_1.MakeDirectSwapLayout.encode(makeDirectSwap, editDataBuf);
|
|
364
364
|
break;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.createBasketLookupTablesInstruction = createBasketLookupTablesInstruction;
|
|
4
7
|
exports.extendBasketLookupTablesIx = extendBasketLookupTablesIx;
|
|
5
8
|
exports.overwriteBasketLookupTablesIx = overwriteBasketLookupTablesIx;
|
|
6
9
|
exports.closeDeactivatedLookupTableIx = closeDeactivatedLookupTableIx;
|
|
7
|
-
const
|
|
10
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
8
11
|
const web3_js_1 = require("@solana/web3.js");
|
|
9
12
|
const constants_1 = require("../../constants");
|
|
10
13
|
const pda_1 = require("../pda");
|
|
@@ -19,7 +22,7 @@ function createBasketLookupTablesInstruction(params) {
|
|
|
19
22
|
&& !oldTempLookupTable1.equals(web3_js_1.PublicKey.default);
|
|
20
23
|
const data = Buffer.concat([
|
|
21
24
|
CREATE_BASKET_LOOKUP_TABLES_DISCRIMINATOR,
|
|
22
|
-
Buffer.from(new
|
|
25
|
+
Buffer.from(new bn_js_1.default(slot).toArray("le", 8)),
|
|
23
26
|
]);
|
|
24
27
|
const keys = [
|
|
25
28
|
{ pubkey: signer, isSigner: true, isWritable: true },
|
|
@@ -7,6 +7,7 @@ export declare const MINT_SEED: Buffer;
|
|
|
7
7
|
export declare const RENT_PAYER_SEED: Buffer;
|
|
8
8
|
export declare const BOUNTY_VAULT_SEED: Buffer;
|
|
9
9
|
export declare const REBALANCE_INTENT_SEED: Buffer;
|
|
10
|
+
export declare const TOKEN_METADATA_PROGRAM_ID: PublicKey;
|
|
10
11
|
export declare function serializeString(input: string): Uint8Array;
|
|
11
12
|
export declare function getRandomSeed(): number[];
|
|
12
13
|
export declare function getBasketTokenMintPda(basketId: number): PublicKey;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REBALANCE_INTENT_SEED = exports.BOUNTY_VAULT_SEED = exports.RENT_PAYER_SEED = exports.MINT_SEED = exports.BASKET_SEED = exports.WITHDRAW_BASKET_FEES_SEED = exports.BASKET_FEES_SEED = exports.GLOBAL_CONFIG_SEED = void 0;
|
|
6
|
+
exports.TOKEN_METADATA_PROGRAM_ID = exports.REBALANCE_INTENT_SEED = exports.BOUNTY_VAULT_SEED = exports.RENT_PAYER_SEED = exports.MINT_SEED = exports.BASKET_SEED = exports.WITHDRAW_BASKET_FEES_SEED = exports.BASKET_FEES_SEED = exports.GLOBAL_CONFIG_SEED = void 0;
|
|
4
7
|
exports.serializeString = serializeString;
|
|
5
8
|
exports.getRandomSeed = getRandomSeed;
|
|
6
9
|
exports.getBasketTokenMintPda = getBasketTokenMintPda;
|
|
@@ -16,9 +19,8 @@ exports.getMetadataAccount = getMetadataAccount;
|
|
|
16
19
|
exports.getLookupTableAccount = getLookupTableAccount;
|
|
17
20
|
exports.getLookupTableInfoAccount = getLookupTableInfoAccount;
|
|
18
21
|
exports.getAta = getAta;
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const js_1 = require("@metaplex-foundation/js");
|
|
22
|
+
const crypto_1 = require("crypto");
|
|
23
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
22
24
|
const spl_token_1 = require("@solana/spl-token");
|
|
23
25
|
const web3_js_1 = require("@solana/web3.js");
|
|
24
26
|
const constants_1 = require("../constants");
|
|
@@ -30,6 +32,7 @@ exports.MINT_SEED = Buffer.from("mint");
|
|
|
30
32
|
exports.RENT_PAYER_SEED = Buffer.from("rent_payer");
|
|
31
33
|
exports.BOUNTY_VAULT_SEED = Buffer.from("bounty_vault");
|
|
32
34
|
exports.REBALANCE_INTENT_SEED = Buffer.from("rebalance_intent");
|
|
35
|
+
exports.TOKEN_METADATA_PROGRAM_ID = new web3_js_1.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
|
|
33
36
|
function serializeString(input) {
|
|
34
37
|
const utf8 = new TextEncoder().encode(input);
|
|
35
38
|
const length = utf8.length;
|
|
@@ -44,12 +47,12 @@ function serializeString(input) {
|
|
|
44
47
|
return out;
|
|
45
48
|
}
|
|
46
49
|
function getRandomSeed() {
|
|
47
|
-
return Array.from((0,
|
|
50
|
+
return Array.from((0, crypto_1.randomBytes)(16));
|
|
48
51
|
}
|
|
49
52
|
function getBasketTokenMintPda(basketId) {
|
|
50
53
|
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
51
54
|
exports.MINT_SEED,
|
|
52
|
-
new
|
|
55
|
+
new bn_js_1.default(basketId).toArrayLike(Buffer, "le", 8)
|
|
53
56
|
], constants_1.BASKETS_V3_PROGRAM_ID)[0];
|
|
54
57
|
}
|
|
55
58
|
function getBasketState(mint) {
|
|
@@ -101,8 +104,11 @@ function getRebalanceIntentPda(basket, owner) {
|
|
|
101
104
|
], constants_1.BASKETS_V3_PROGRAM_ID)[0];
|
|
102
105
|
}
|
|
103
106
|
function getMetadataAccount(tokenMint) {
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
108
|
+
Buffer.from("metadata"),
|
|
109
|
+
exports.TOKEN_METADATA_PROGRAM_ID.toBuffer(),
|
|
110
|
+
tokenMint.toBuffer(),
|
|
111
|
+
], exports.TOKEN_METADATA_PROGRAM_ID)[0];
|
|
106
112
|
}
|
|
107
113
|
function getLookupTableAccount(creator, slot) {
|
|
108
114
|
const ixAndPubkey = web3_js_1.AddressLookupTableProgram.createLookupTable({
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.depositTokensIx = depositTokensIx;
|
|
4
7
|
exports.lockDepositsIx = lockDepositsIx;
|
|
5
8
|
exports.mintBasketIx = mintBasketIx;
|
|
6
|
-
const
|
|
9
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
7
10
|
const spl_token_1 = require("@solana/spl-token");
|
|
8
11
|
const web3_js_1 = require("@solana/web3.js");
|
|
9
12
|
const constants_1 = require("../../constants");
|
|
@@ -22,7 +25,7 @@ function depositTokensIx(params) {
|
|
|
22
25
|
let amounts = batch_contributions.map((contribution) => contribution.amount);
|
|
23
26
|
while (amounts.length < 10)
|
|
24
27
|
amounts.push(0);
|
|
25
|
-
const amountsBuffer = Buffer.concat(amounts.map((amount) => Buffer.from(new
|
|
28
|
+
const amountsBuffer = Buffer.concat(amounts.map((amount) => Buffer.from(new bn_js_1.default(amount).toArray("le", 8))));
|
|
26
29
|
const data = Buffer.concat([discriminator, amountsBuffer]);
|
|
27
30
|
const keys = [
|
|
28
31
|
{ pubkey: owner, isSigner: true, isWritable: true },
|