@symmetry-hq/temp-v3-sdk 0.0.34 → 0.0.36

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 (44) hide show
  1. package/dist/src/constants.d.ts +2 -0
  2. package/dist/src/constants.js +3 -1
  3. package/dist/src/index.d.ts +9 -8
  4. package/dist/src/index.js +83 -41
  5. package/dist/src/instructions/management/claimFees.js +2 -1
  6. package/dist/src/instructions/management/edit.js +3 -3
  7. package/dist/src/jup.d.ts +49 -0
  8. package/dist/src/jup.js +69 -0
  9. package/dist/src/layouts/basket.d.ts +3 -1
  10. package/dist/src/layouts/basket.js +5 -1
  11. package/dist/src/layouts/fraction.d.ts +11 -0
  12. package/dist/src/layouts/fraction.js +135 -0
  13. package/dist/src/layouts/intents/intent.d.ts +2 -2
  14. package/dist/src/layouts/intents/intent.js +32 -2
  15. package/dist/src/layouts/intents/rebalanceIntent.d.ts +4 -4
  16. package/dist/src/layouts/intents/rebalanceIntent.js +14 -3
  17. package/dist/src/layouts/oracle.d.ts +2 -2
  18. package/dist/src/layouts/oracle.js +7 -1
  19. package/dist/src/states/basket.js +29 -26
  20. package/dist/src/states/intents/intent.js +32 -39
  21. package/dist/src/states/intents/rebalanceIntent.d.ts +8 -0
  22. package/dist/src/states/intents/rebalanceIntent.js +269 -2
  23. package/dist/src/states/oracles/pythOracle.js +3 -3
  24. package/dist/src/txUtils.d.ts +0 -1
  25. package/dist/src/txUtils.js +0 -2
  26. package/dist/test.d.ts +22 -1
  27. package/dist/test.js +209 -1
  28. package/package.json +1 -1
  29. package/src/constants.ts +2 -1
  30. package/src/index.ts +66 -28
  31. package/src/instructions/management/claimFees.ts +2 -1
  32. package/src/instructions/management/edit.ts +1 -1
  33. package/src/jup.ts +103 -0
  34. package/src/layouts/basket.ts +7 -1
  35. package/src/layouts/fraction.ts +136 -0
  36. package/src/layouts/intents/intent.ts +33 -2
  37. package/src/layouts/intents/rebalanceIntent.ts +16 -4
  38. package/src/layouts/oracle.ts +8 -3
  39. package/src/states/basket.ts +3 -3
  40. package/src/states/intents/intent.ts +11 -22
  41. package/src/states/intents/rebalanceIntent.ts +342 -6
  42. package/src/states/oracles/pythOracle.ts +3 -3
  43. package/src/txUtils.ts +0 -1
  44. package/test.ts +195 -3
@@ -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;
@@ -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");
@@ -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
- export declare const COMPUTE_UNITS = 1000000;
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>;
@@ -89,12 +84,12 @@ export declare class SymmetryCore {
89
84
  jup_swap_ix?: TransactionInstruction;
90
85
  }): Promise<TxPayloadBatchSequence>;
91
86
  executeBasketIntentTx(params: {
87
+ keeper: string;
92
88
  intent: string;
93
- executor: string;
94
89
  }): Promise<TxPayloadBatchSequence>;
95
90
  cancelBasketIntentTx(params: {
91
+ keeper: string;
96
92
  intent: string;
97
- manager: string;
98
93
  }): Promise<TxPayloadBatchSequence>;
99
94
  cancelRebalanceIntentTx(params: {
100
95
  keeper: string;
@@ -146,6 +141,7 @@ export declare class SymmetryCore {
146
141
  mode?: number;
147
142
  jup_token_ledger_ix?: TransactionInstruction;
148
143
  jup_swap_ix?: TransactionInstruction;
144
+ jup_address_lookup_table_addresses?: PublicKey[];
149
145
  }): Promise<TxPayloadBatchSequence>;
150
146
  mintTx(params: {
151
147
  keeper: string;
@@ -159,6 +155,10 @@ export declare class SymmetryCore {
159
155
  keeper: string;
160
156
  rebalance_intent: string;
161
157
  }): Promise<TxPayloadBatchSequence>;
158
+ claimBasketFeesTx(params: {
159
+ claimer: string;
160
+ basket: string;
161
+ }): Promise<TxPayloadBatchSequence>;
162
162
  signAndSendVersionedTxs(params: {
163
163
  versionedTxs: VersionedTxs;
164
164
  wallet: Wallet;
@@ -173,3 +173,4 @@ export { FormattedGlobalConfig, FormattedIntentStatus, FormattedTaskType, Format
173
173
  export { FormattedRebalanceType, FormattedRebalanceAction, FormattedOraclePrice, FormattedTokenAuction, FormattedTaskCompletion, FormattedRebalanceIntent, };
174
174
  export { FormattedCreatorSettings, FormattedManagersSettings, FormattedFeeSettings, FormattedScheduleSettings, FormattedAutomationSettings, FormattedLpSettings, FormattedMetadataSettings, FormattedDepositsSettings, FormattedForceRebalanceSettings, FormattedCustomRebalanceSettings, FormattedAddTokenSettings, FormattedUpdateWeightsSettings, FormattedMakeDirectSwapSettings, FormattedAccumulatedFees, FormattedLookupTables, FormattedAsset, FormattedOracleSettings, FormattedOracleAggregator, FormattedOracle, FormattedOracleType, FormattedBasket, };
175
175
  export { EditCreatorSettings, EditManagerSettings, EditFeeSettings, EditScheduleSettings, EditAutomationSettings, EditLpSettings, EditMetadataSettings, EditDepositsSettings, EditForceRebalanceSettings, EditCustomRebalanceSettings, EditAddTokenSettings, EditUpdateWeightsSettings, EditMakeDirectSwapSettings, AddOrEditTokenInput, OracleInput, UpdateWeightsInput, MakeDirectSwapInput, Settings, TaskContext, TaskType, };
176
+ export { getJupTokenLedgerAndSwapInstructions, };
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.TaskType = exports.SymmetryCore = exports.MAX_JUPITER_ACCOUNTS = exports.JUPITER_API_KEY = exports.PRIORITY_FEE = exports.COMPUTE_UNITS = void 0;
15
+ 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, _b, _c;
45
+ var _a;
47
46
  this.sdkParams = {
48
47
  connection: params.connection,
49
48
  network: params.network,
50
- // payer: params.payer ?? Keypair.generate().publicKey,
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: exports.COMPUTE_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: exports.COMPUTE_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: exports.COMPUTE_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: exports.COMPUTE_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: exports.COMPUTE_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: exports.COMPUTE_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: exports.COMPUTE_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
  }
@@ -478,7 +471,7 @@ class SymmetryCore {
478
471
  }
479
472
  executeBasketIntentTx(params) {
480
473
  return __awaiter(this, void 0, void 0, function* () {
481
- let keeper = new web3_js_1.PublicKey(params.executor);
474
+ let keeper = new web3_js_1.PublicKey(params.keeper);
482
475
  let intent = yield this.fetchIntent(params.intent);
483
476
  let basketMint;
484
477
  if (intent.taskType === intent_1.TaskType.EditMetadataSettings) {
@@ -498,7 +491,7 @@ class SymmetryCore {
498
491
  payer: keeper,
499
492
  instructions: [
500
493
  ix,
501
- web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_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: [],
@@ -510,10 +503,10 @@ class SymmetryCore {
510
503
  }
511
504
  cancelBasketIntentTx(params) {
512
505
  return __awaiter(this, void 0, void 0, function* () {
513
- let manager = new web3_js_1.PublicKey(params.manager);
506
+ let keeper = new web3_js_1.PublicKey(params.keeper);
514
507
  let intent = yield this.fetchIntent(params.intent);
515
508
  let ix = (0, edit_1.cancelIntentIx)({
516
- keeper: manager,
509
+ keeper: keeper,
517
510
  basket: intent.basket,
518
511
  intent: intent.ownAddress,
519
512
  editType: intent.taskType,
@@ -521,10 +514,10 @@ class SymmetryCore {
521
514
  bountyMint: intent.bounty.bountyMint,
522
515
  });
523
516
  let txBatchData = { batches: [[{
524
- payer: manager,
517
+ payer: keeper,
525
518
  instructions: [
526
519
  ix,
527
- web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_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: exports.COMPUTE_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: exports.COMPUTE_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: exports.COMPUTE_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: exports.COMPUTE_UNITS }),
652
- web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_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: exports.COMPUTE_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: exports.COMPUTE_UNITS }),
766
- web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_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: [],
@@ -787,7 +780,7 @@ class SymmetryCore {
787
780
  basket: basket,
788
781
  rebalanceIntent: rebalanceIntent,
789
782
  }),
790
- web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_UNITS }),
783
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
791
784
  web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
792
785
  ],
793
786
  lookupTables: [],
@@ -842,7 +835,7 @@ class SymmetryCore {
842
835
  payer: keeper,
843
836
  instructions: [
844
837
  ix,
845
- web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_UNITS }),
838
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
846
839
  web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
847
840
  ],
848
841
  lookupTables: [basket.lookupTables.active[0], basket.lookupTables.active[1]],
@@ -854,6 +847,7 @@ class SymmetryCore {
854
847
  }
855
848
  flashSwapTx(params) {
856
849
  return __awaiter(this, void 0, void 0, function* () {
850
+ var _a;
857
851
  let keeper = new web3_js_1.PublicKey(params.keeper);
858
852
  let basket = new web3_js_1.PublicKey(params.basket);
859
853
  let rebalanceIntent = params.rebalance_intent ? new web3_js_1.PublicKey(params.rebalance_intent) : undefined;
@@ -890,13 +884,13 @@ class SymmetryCore {
890
884
  }
891
885
  ixs.push(ixDeposit);
892
886
  ixs = ixs.concat([
893
- web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_UNITS }),
887
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
894
888
  web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
895
889
  ]);
896
890
  let txBatchData = { batches: [[{
897
891
  payer: keeper,
898
892
  instructions: ixs,
899
- lookupTables: [],
893
+ lookupTables: (_a = params.jup_address_lookup_table_addresses) !== null && _a !== void 0 ? _a : [],
900
894
  }]] };
901
895
  let versionedTxs = yield (0, txUtils_1.prepareVersionedTxs)(this.sdkParams.connection, txBatchData);
902
896
  let txPayloadBatchSequence = (0, txUtils_1.prepareTxPayloadBatchSequence)(txBatchData, versionedTxs);
@@ -920,7 +914,7 @@ class SymmetryCore {
920
914
  payer: keeper,
921
915
  instructions: [
922
916
  ix,
923
- web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_UNITS }),
917
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
924
918
  web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
925
919
  ],
926
920
  lookupTables: [],
@@ -954,7 +948,7 @@ class SymmetryCore {
954
948
  payer: keeper,
955
949
  instructions: [
956
950
  ix,
957
- web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_UNITS }),
951
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
958
952
  web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
959
953
  ],
960
954
  lookupTables: [],
@@ -998,7 +992,7 @@ class SymmetryCore {
998
992
  payer: keeper,
999
993
  instructions: [
1000
994
  ix,
1001
- web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: exports.COMPUTE_UNITS }),
995
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
1002
996
  web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
1003
997
  ],
1004
998
  lookupTables: [],
@@ -1008,6 +1002,54 @@ class SymmetryCore {
1008
1002
  return txPayloadBatchSequence;
1009
1003
  });
1010
1004
  }
1005
+ claimBasketFeesTx(params) {
1006
+ return __awaiter(this, void 0, void 0, function* () {
1007
+ let claimer = new web3_js_1.PublicKey(params.claimer);
1008
+ let basket = yield this.fetchBasket(params.basket);
1009
+ let globalConfig = yield this.fetchGlobalConfig();
1010
+ let ixs = [];
1011
+ if (claimer.equals(globalConfig.symmetryFeeCollector))
1012
+ ixs.push((0, claimFees_1.claimFeesIx)({
1013
+ claimer: claimer,
1014
+ basketTokenMint: basket.mint,
1015
+ feeType: 0,
1016
+ managers: [],
1017
+ }));
1018
+ if (claimer.equals(basket.settings.creator))
1019
+ ixs.push((0, claimFees_1.claimFeesIx)({
1020
+ claimer: claimer,
1021
+ basketTokenMint: basket.mint,
1022
+ feeType: 1,
1023
+ managers: [],
1024
+ }));
1025
+ if (claimer.equals(basket.settings.host))
1026
+ ixs.push((0, claimFees_1.claimFeesIx)({
1027
+ claimer: claimer,
1028
+ basketTokenMint: basket.mint,
1029
+ feeType: 2,
1030
+ managers: [],
1031
+ }));
1032
+ if (basket.settings.managers.managers.find(manager => manager.equals(claimer)))
1033
+ ixs.push((0, claimFees_1.claimFeesIx)({
1034
+ claimer: claimer,
1035
+ basketTokenMint: basket.mint,
1036
+ feeType: 3,
1037
+ managers: basket.settings.managers.managers,
1038
+ }));
1039
+ let txBatchData = { batches: [[{
1040
+ payer: claimer,
1041
+ instructions: [
1042
+ ...ixs,
1043
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: constants_1.COMPUTE_UNITS }),
1044
+ web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.sdkParams.priorityFee }),
1045
+ ],
1046
+ lookupTables: [],
1047
+ }]] };
1048
+ let versionedTxs = yield (0, txUtils_1.prepareVersionedTxs)(this.sdkParams.connection, txBatchData);
1049
+ let txPayloadBatchSequence = (0, txUtils_1.prepareTxPayloadBatchSequence)(txBatchData, versionedTxs);
1050
+ return txPayloadBatchSequence;
1051
+ });
1052
+ }
1011
1053
  signAndSendVersionedTxs(params) {
1012
1054
  return __awaiter(this, void 0, void 0, function* () {
1013
1055
  let { versionedTxs, wallet } = params;
@@ -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
- const { claimer, basketTokenMint, feeType, managers } = params;
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.indexOf(addTokenData.oracles[i].oracle_type),
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 = (_a = updateWeightsData.token_mints_hash) !== null && _a !== void 0 ? _a : (0, basket_1.computeTokenMintsHash)(basket.composition.slice(0, basket.numTokens)
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
+ }>;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.processJupInstruction = processJupInstruction;
13
+ exports.getJupQuote = getJupQuote;
14
+ exports.getJupSwapInstructions = getJupSwapInstructions;
15
+ exports.getJupTokenLedgerAndSwapInstructions = getJupTokenLedgerAndSwapInstructions;
16
+ const web3_js_1 = require("@solana/web3.js");
17
+ function processJupInstruction(instruction) {
18
+ return {
19
+ programId: new web3_js_1.PublicKey(instruction.programId),
20
+ keys: instruction.accounts.map((a) => (Object.assign(Object.assign({}, a), { pubkey: new web3_js_1.PublicKey(a.pubkey) }))),
21
+ data: Buffer.from(instruction.data, "base64")
22
+ };
23
+ }
24
+ function getJupQuote(params) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ let options = { method: 'GET', headers: { 'x-api-key': params.apiKey } };
27
+ let reqUrl = 'https://api.jup.ag/swap/v1/quote' +
28
+ '?inputMint=' + params.basketMintOut.toBase58() +
29
+ '&outputMint=' + params.basketMintIn.toBase58() +
30
+ '&amount=' + (params.swapMode == "exact_in" ? params.basketAmountIn : params.basketAmountOut) +
31
+ '&swapMode=' + (params.swapMode == "exact_in" ? "ExactOut" : "ExactIn") +
32
+ '&maxAccounts=' + params.maxJupAccounts;
33
+ let res = yield fetch(reqUrl, options).then(res => res.json());
34
+ return res;
35
+ });
36
+ }
37
+ function getJupSwapInstructions(params) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ let reqUrl = 'https://api.jup.ag/swap/v1/swap-instructions';
40
+ let body = {
41
+ userPublicKey: params.keeper.toBase58(),
42
+ quoteResponse: params.quoteResponse,
43
+ wrapAndUnwrapSol: false,
44
+ useTokenLedger: true,
45
+ };
46
+ let options = {
47
+ method: 'POST',
48
+ headers: {
49
+ 'Content-Type': 'application/json',
50
+ 'x-api-key': params.apiKey
51
+ },
52
+ body: JSON.stringify(body),
53
+ };
54
+ let res = yield fetch(reqUrl, options).then(res => res.json());
55
+ return res;
56
+ });
57
+ }
58
+ function getJupTokenLedgerAndSwapInstructions(params) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ let quoteResponse = yield getJupQuote(params);
61
+ let swapInstructions = yield getJupSwapInstructions(Object.assign(Object.assign({}, params), { quoteResponse }));
62
+ return {
63
+ tokenLedgerInstruction: processJupInstruction(swapInstructions.tokenLedgerInstruction),
64
+ swapInstruction: processJupInstruction(swapInstructions.swapInstruction),
65
+ addressLookupTableAddresses: swapInstructions.addressLookupTableAddresses.map((a) => new web3_js_1.PublicKey(a)),
66
+ quoteResponse: quoteResponse,
67
+ };
68
+ });
69
+ }
@@ -5,6 +5,8 @@ import { OraclePrice } from '../states/oracles/oracle';
5
5
  import Decimal from 'decimal.js';
6
6
  import { BasketSettings } from './config';
7
7
  import { EditAddTokenSettings, EditAutomationSettings, EditCreatorSettings, EditCustomRebalanceSettings, EditDepositsSettings, EditFeeSettings, EditForceRebalanceSettings, EditLpSettings, EditMakeDirectSwapSettings, EditManagerSettings, EditMetadataSettings, EditScheduleSettings, EditUpdateWeightsSettings, OracleInput } from './intents/intent';
8
+ export type FormattedBasketType = "private" | "public";
9
+ export declare const BASKET_TYPES_STRINGS: Map<number, FormattedBasketType>;
8
10
  export interface FormattedAccumulatedFees {
9
11
  symmetry_fees: number;
10
12
  creator_fees: number;
@@ -97,7 +99,7 @@ export interface FormattedBasket {
97
99
  supply_outstanding: number;
98
100
  creator: string;
99
101
  host: string;
100
- basket_type: string;
102
+ basket_type: FormattedBasketType;
101
103
  bounty_mint: string;
102
104
  bounty_balance: number;
103
105
  start_price: number;
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BasketLayout = exports.AssetLayout = exports.LookupTablesLayout = exports.BasketFeesLayout = void 0;
3
+ exports.BasketLayout = exports.AssetLayout = exports.LookupTablesLayout = exports.BasketFeesLayout = exports.BASKET_TYPES_STRINGS = void 0;
4
4
  const borsh_1 = require("@coral-xyz/borsh");
5
5
  const oracle_1 = require("./oracle");
6
6
  const config_1 = require("./config");
7
7
  const constants_1 = require("../constants");
8
+ exports.BASKET_TYPES_STRINGS = new Map([
9
+ [0, "private"],
10
+ [1, "public"],
11
+ ]);
8
12
  ;
9
13
  exports.BasketFeesLayout = (0, borsh_1.struct)([
10
14
  (0, borsh_1.u64)("symmetryFees"),
@@ -7,3 +7,14 @@ export interface Fraction {
7
7
  export declare const FractionLayout: any;
8
8
  export declare function fractionToDecimal(fraction: Fraction): Decimal;
9
9
  export declare function decimalToFraction(decimal: Decimal): Fraction;
10
+ export declare function fractionAdd(a: Fraction, b: Fraction): Fraction;
11
+ export declare function fractionSub(a: Fraction, b: Fraction): Fraction;
12
+ export declare function fractionMul(a: Fraction, b: Fraction): Fraction;
13
+ export declare function fractionDiv(a: Fraction, b: Fraction): Fraction;
14
+ export declare function fractionLt(a: Fraction, b: Fraction): boolean;
15
+ export declare function fractionLte(a: Fraction, b: Fraction): boolean;
16
+ export declare function fractionGt(a: Fraction, b: Fraction): boolean;
17
+ export declare function fractionGte(a: Fraction, b: Fraction): boolean;
18
+ export declare function fractionEq(a: Fraction, b: Fraction): boolean;
19
+ export declare function fractionRoundDown(fraction: Fraction): BN;
20
+ export declare function fractionRoundUp(fraction: Fraction): BN;