@symmetry-hq/temp-v3-sdk 0.0.60 → 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.
Files changed (58) hide show
  1. package/dist/src/index.js +27 -23
  2. package/dist/src/instructions/automation/flashSwap.d.ts +1 -1
  3. package/dist/src/instructions/automation/priceUpdate.js +7 -4
  4. package/dist/src/instructions/automation/rebalanceIntent.d.ts +1 -1
  5. package/dist/src/instructions/automation/rebalanceIntent.js +11 -8
  6. package/dist/src/instructions/management/addBounty.js +5 -2
  7. package/dist/src/instructions/management/createBasket.js +5 -2
  8. package/dist/src/instructions/management/edit.d.ts +1 -1
  9. package/dist/src/instructions/management/edit.js +27 -27
  10. package/dist/src/instructions/management/luts.js +5 -2
  11. package/dist/src/instructions/pda.js +7 -4
  12. package/dist/src/instructions/user/deposit.js +5 -2
  13. package/dist/src/layouts/basket.d.ts +1 -1
  14. package/dist/src/layouts/config.d.ts +1 -1
  15. package/dist/src/layouts/fraction.d.ts +1 -1
  16. package/dist/src/layouts/fraction.js +7 -7
  17. package/dist/src/layouts/intents/bounty.d.ts +1 -1
  18. package/dist/src/layouts/intents/intent.d.ts +1 -1
  19. package/dist/src/layouts/intents/rebalanceIntent.d.ts +1 -1
  20. package/dist/src/layouts/oracle.d.ts +1 -1
  21. package/dist/src/layouts/oracle.js +8 -5
  22. package/dist/src/states/intents/intent.js +6 -3
  23. package/dist/src/states/intents/rebalanceIntent.js +27 -24
  24. package/dist/src/states/oracles/constants.d.ts +6 -5
  25. package/dist/src/states/oracles/constants.js +9 -6
  26. package/dist/src/states/oracles/oracle.js +2 -3
  27. package/dist/src/states/oracles/pythOracle.d.ts +1 -1
  28. package/dist/src/states/oracles/pythOracle.js +12 -12
  29. package/dist/src/states/oracles/raydiumClmmOracle.d.ts +2 -2
  30. package/dist/src/states/oracles/raydiumClmmOracle.js +68 -68
  31. package/dist/src/states/oracles/raydiumCpmmOracle.d.ts +1 -1
  32. package/dist/src/states/oracles/raydiumCpmmOracle.js +20 -20
  33. package/package.json +7 -5
  34. package/src/index.ts +10 -6
  35. package/src/instructions/automation/flashSwap.ts +1 -1
  36. package/src/instructions/automation/priceUpdate.ts +1 -1
  37. package/src/instructions/automation/rebalanceIntent.ts +1 -1
  38. package/src/instructions/management/addBounty.ts +1 -1
  39. package/src/instructions/management/createBasket.ts +1 -1
  40. package/src/instructions/management/edit.ts +1 -1
  41. package/src/instructions/management/luts.ts +1 -1
  42. package/src/instructions/pda.ts +3 -3
  43. package/src/instructions/user/deposit.ts +1 -1
  44. package/src/layouts/basket.ts +1 -1
  45. package/src/layouts/config.ts +1 -1
  46. package/src/layouts/fraction.ts +1 -1
  47. package/src/layouts/intents/bounty.ts +1 -1
  48. package/src/layouts/intents/intent.ts +1 -1
  49. package/src/layouts/intents/rebalanceIntent.ts +1 -1
  50. package/src/layouts/oracle.ts +1 -1
  51. package/src/states/intents/intent.ts +1 -1
  52. package/src/states/intents/rebalanceIntent.ts +1 -1
  53. package/src/states/oracles/constants.ts +1 -1
  54. package/src/states/oracles/oracle.ts +3 -3
  55. package/src/states/oracles/pythOracle.ts +2 -3
  56. package/src/states/oracles/raydiumClmmOracle.ts +5 -5
  57. package/src/states/oracles/raydiumCpmmOracle.ts +1 -1
  58. 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 anchor_1 = require("@coral-xyz/anchor");
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, _c, _d;
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 anchor_1.BN((_a = params.context.activation_timestamp) !== null && _a !== void 0 ? _a : 0);
684
- let expirationTimestamp = new anchor_1.BN((_b = params.context.expiration_timestamp) !== null && _b !== void 0 ? _b : 0);
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 anchor_1.BN(0);
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 anchor_1.BN(0);
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 anchor_1.BN(0);
705
+ default: return new bn_js_1.default(0);
706
706
  }
707
707
  })();
708
708
  let globalConfig = yield this.fetchGlobalConfig();
709
- let minBounty = (_c = new anchor_1.BN(params.context.min_bounty)) !== null && _c !== void 0 ? _c : globalConfig.bountyPerTask.minBounty;
710
- let maxBounty = (_d = new anchor_1.BN(params.context.max_bounty)) !== null && _d !== void 0 ? _d : globalConfig.bountyPerTask.maxBounty;
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 anchor_1.BN(0)) && activationTimestamp.eq(new anchor_1.BN(0))) {
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 anchor_1.BN(editData.make_direct_swap.amount_from),
774
- amountOut: new anchor_1.BN(editData.make_direct_swap.amount_to),
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: new anchor_1.BN(contribution.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 = new anchor_1.BN(params.withdraw_amount);
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 anchor_1.BN(0);
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 anchor_1.BN(1).shln(tokenIndex));
1216
+ keepTokensBitmask = keepTokensBitmask.or(new bn_js_1.default(1).shln(tokenIndex));
1213
1217
  }
1214
1218
  }
1215
- const basketRebalanceIntent = basket.settings.activeRebalance.gt(new anchor_1.BN(0))
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 anchor_1.BN(0)) ? undefined : basketRebalanceIntent,
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 anchor_1.BN(params.amount_in);
1617
- let amountOut = new anchor_1.BN(params.amount_out);
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 anchor_1.BN(0)) ? undefined : basketRebalanceIntent,
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 anchor_1.BN(0)))
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,4 @@
1
- import { BN } from '@coral-xyz/anchor';
1
+ import BN from 'bn.js';
2
2
  import { PublicKey, TransactionInstruction } from '@solana/web3.js';
3
3
  export declare function flashWithdrawIx(params: {
4
4
  keeper: PublicKey;
@@ -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 anchor_1 = require("@coral-xyz/anchor");
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 anchor_1.BN(0), low: new anchor_1.BN(0) },
61
- conf: { high: new anchor_1.BN(0), low: new anchor_1.BN(0) },
62
- updateTime: new anchor_1.BN(0),
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,4 +1,4 @@
1
- import { BN } from '@coral-xyz/anchor';
1
+ import BN from 'bn.js';
2
2
  import { PublicKey, TransactionInstruction } from '@solana/web3.js';
3
3
  export declare function createRebalanceIntentIx(params: {
4
4
  signer: PublicKey;
@@ -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 anchor_1 = require("@coral-xyz/anchor");
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 anchor_1.BN(0), withdrawParamsKeepAllTokens = 0, basketRebalanceIntent, } = params;
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 anchor_1.BN(rebalanceSlippageBps).toArray("le", 2)),
65
- Buffer.from(new anchor_1.BN(perTradeRebalanceSlippageBps).toArray("le", 2)),
66
- Buffer.from(new anchor_1.BN(executionStartTime).toArray("le", 8)),
67
- Buffer.from(new anchor_1.BN(minBountyAmount).toArray("le", 8)),
68
- Buffer.from(new anchor_1.BN(maxBountyAmount).toArray("le", 8)),
69
- Buffer.from(new anchor_1.BN(withdrawParamsBurnAmount).toArray("le", 8)),
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 anchor_1 = require("@coral-xyz/anchor");
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 anchor_1.BN(amount).toArray("le", 8)), // u64 LE
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 anchor_1 = require("@coral-xyz/anchor");
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 anchor_1.BN(slot).toArray("le", 8)),
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 { BN } from '@coral-xyz/anchor';
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 anchor_1 = require("@coral-xyz/anchor");
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 anchor_1.BN(managerSettings.modification_delay);
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 anchor_1.BN(feeSettings.modification_delay),
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 anchor_1.BN(scheduleSettings.cycle_start_time),
175
- cycleDuration: new anchor_1.BN(scheduleSettings.cycle_duration),
176
- depositsStart: new anchor_1.BN(scheduleSettings.deposits_start),
177
- depositsEnd: new anchor_1.BN(scheduleSettings.deposits_end),
178
- automationStart: new anchor_1.BN(scheduleSettings.automation_start),
179
- automationEnd: new anchor_1.BN(scheduleSettings.automation_end),
180
- managementStart: new anchor_1.BN(scheduleSettings.management_start),
181
- managementEnd: new anchor_1.BN(scheduleSettings.management_end),
182
- modificationDelay: new anchor_1.BN(scheduleSettings.modification_delay),
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 anchor_1.BN(automationSettings.rebalance_activation_cooldown),
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 anchor_1.BN(automationSettings.modification_delay),
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 anchor_1.BN(lpSettings.modification_delay),
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 anchor_1.BN(metadataSettings.modification_delay),
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 anchor_1.BN(forceRebalanceSettings.modification_delay);
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 anchor_1.BN(customRebalanceSettings.modification_delay);
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 anchor_1.BN(addTokenDelay.modification_delay),
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 anchor_1.BN(updateWeightsDelay.modification_delay),
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 anchor_1.BN(makeDirectSwapDelay.modification_delay),
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 anchor_1.BN(addTokenData.oracles[i].min_liquidity),
277
- stalenessThresh: new anchor_1.BN(addTokenData.oracles[i].staleness_thresh),
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 anchor_1.BN(addTokenData.oracles[i].twap_seconds_ago),
281
- twapSecondarySecondsAgo: new anchor_1.BN(addTokenData.oracles[i].twap_secondary_seconds_ago),
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 anchor_1.BN(makeDirectSwapData.amount_from),
361
- amountTo: new anchor_1.BN(makeDirectSwapData.amount_to),
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 anchor_1 = require("@coral-xyz/anchor");
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 anchor_1.BN(slot).toArray("le", 8)),
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 },
@@ -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.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;
@@ -16,8 +19,8 @@ exports.getMetadataAccount = getMetadataAccount;
16
19
  exports.getLookupTableAccount = getLookupTableAccount;
17
20
  exports.getLookupTableInfoAccount = getLookupTableInfoAccount;
18
21
  exports.getAta = getAta;
19
- const uuid_1 = require("uuid");
20
- const anchor_1 = require("@coral-xyz/anchor");
22
+ const crypto_1 = require("crypto");
23
+ const bn_js_1 = __importDefault(require("bn.js"));
21
24
  const spl_token_1 = require("@solana/spl-token");
22
25
  const web3_js_1 = require("@solana/web3.js");
23
26
  const constants_1 = require("../constants");
@@ -44,12 +47,12 @@ function serializeString(input) {
44
47
  return out;
45
48
  }
46
49
  function getRandomSeed() {
47
- return Array.from((0, uuid_1.parse)((0, uuid_1.v4)()));
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 anchor_1.BN(basketId).toArrayLike(Buffer, "le", 8)
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) {
@@ -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 anchor_1 = require("@coral-xyz/anchor");
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 anchor_1.BN(amount).toArray("le", 8))));
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 },
@@ -1,4 +1,4 @@
1
- import { BN } from '@coral-xyz/anchor';
1
+ import BN from 'bn.js';
2
2
  import { AddressLookupTableAccount, PublicKey } from '@solana/web3.js';
3
3
  import { OracleAggregator } from './oracle';
4
4
  import { OraclePrice } from '../states/oracles/oracle';
@@ -1,4 +1,4 @@
1
- import { BN } from '@coral-xyz/anchor';
1
+ import BN from 'bn.js';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
  import { Fraction } from './fraction';
4
4
  import { BountySchedule } from './intents/bounty';
@@ -1,4 +1,4 @@
1
- import { BN } from "@coral-xyz/anchor";
1
+ import BN from "bn.js";
2
2
  import Decimal from "decimal.js";
3
3
  export interface Fraction {
4
4
  high: BN;
@@ -17,7 +17,7 @@ exports.fractionGte = fractionGte;
17
17
  exports.fractionEq = fractionEq;
18
18
  exports.fractionRoundDown = fractionRoundDown;
19
19
  exports.fractionRoundUp = fractionRoundUp;
20
- const anchor_1 = require("@coral-xyz/anchor");
20
+ const bn_js_1 = __importDefault(require("bn.js"));
21
21
  const borsh_1 = require("@coral-xyz/borsh");
22
22
  const decimal_js_1 = __importDefault(require("decimal.js"));
23
23
  const constants_1 = require("../constants");
@@ -36,18 +36,18 @@ function decimalToFraction(decimal) {
36
36
  let res = decimal.mul(constants_1.X64).floor();
37
37
  let high = res.div(constants_1.X64).floor();
38
38
  let low = res.sub(high.mul(constants_1.X64));
39
- return { high: new anchor_1.BN(high.toString()), low: new anchor_1.BN(low.toString()) };
39
+ return { high: new bn_js_1.default(high.toString()), low: new bn_js_1.default(low.toString()) };
40
40
  }
41
41
  // X64 = 2^64
42
- const X64_BN = new anchor_1.BN(2).pow(new anchor_1.BN(64));
43
- const U64_MAX = new anchor_1.BN(2).pow(new anchor_1.BN(64)).sub(new anchor_1.BN(1));
42
+ const X64_BN = new bn_js_1.default(2).pow(new bn_js_1.default(64));
43
+ const U64_MAX = new bn_js_1.default(2).pow(new bn_js_1.default(64)).sub(new bn_js_1.default(1));
44
44
  // Fraction addition: (a + b)
45
45
  // a = high_a * 2^64 + low_a, b = high_b * 2^64 + low_b
46
46
  // result = (high_a + high_b) * 2^64 + (low_a + low_b)
47
47
  // Handle carry from low to high
48
48
  function fractionAdd(a, b) {
49
49
  const lowSum = a.low.add(b.low);
50
- const carry = lowSum.gt(U64_MAX) ? new anchor_1.BN(1) : new anchor_1.BN(0);
50
+ const carry = lowSum.gt(U64_MAX) ? new bn_js_1.default(1) : new bn_js_1.default(0);
51
51
  const low = lowSum.mod(X64_BN);
52
52
  const high = a.high.add(b.high).add(carry);
53
53
  // Check overflow: high should fit in u64
@@ -70,7 +70,7 @@ function fractionSub(a, b) {
70
70
  // Handle borrow if low < 0
71
71
  if (low.isNeg()) {
72
72
  low = low.add(X64_BN);
73
- high = high.sub(new anchor_1.BN(1));
73
+ high = high.sub(new bn_js_1.default(1));
74
74
  }
75
75
  if (high.isNeg()) {
76
76
  throw new Error("MathError");
@@ -160,5 +160,5 @@ function fractionRoundUp(fraction) {
160
160
  if (fraction.low.isZero()) {
161
161
  return fraction.high;
162
162
  }
163
- return fraction.high.add(new anchor_1.BN(1));
163
+ return fraction.high.add(new bn_js_1.default(1));
164
164
  }
@@ -1,4 +1,4 @@
1
- import { BN } from "@coral-xyz/anchor";
1
+ import BN from "bn.js";
2
2
  import { PublicKey } from "@solana/web3.js";
3
3
  export interface BountySchedule {
4
4
  minBounty: BN;
@@ -1,4 +1,4 @@
1
- import { BN } from '@coral-xyz/anchor';
1
+ import BN from 'bn.js';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
  import { Bounty } from './bounty';
4
4
  import { FormattedOracleType } from '../oracle';
@@ -1,4 +1,4 @@
1
- import { BN } from "@coral-xyz/anchor";
1
+ import BN from "bn.js";
2
2
  import { PublicKey } from "@solana/web3.js";
3
3
  import { u8 } from '@coral-xyz/borsh';
4
4
  import { Fraction } from "../fraction";
@@ -1,4 +1,4 @@
1
- import { BN } from '@coral-xyz/anchor';
1
+ import BN from 'bn.js';
2
2
  import { Fraction } from './fraction';
3
3
  export declare const MAX_ORACLES_PER_TOKEN = 4;
4
4
  export declare const MAX_ACCOUNTS_PER_ORACLE = 4;