@symmetry-hq/temp-v3-sdk 0.0.2 → 0.0.3

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.
@@ -4,6 +4,9 @@ import { Basket } from './layouts/basket';
4
4
  import { Fraction } from './layouts/fraction';
5
5
  import { EditData, HostFees, Intent, MetadataParams, TaskType } from './layouts/intents/intent';
6
6
  import { RebalanceIntent } from './layouts/intents/rebalanceIntent';
7
+ import { BasketFilter } from './states/basket';
8
+ import { IntentFilter } from './states/intents/intent';
9
+ import { RebalanceIntentFilter } from './states/intents/rebalanceIntent';
7
10
  import { VersionedTxs, Wallet } from './txUtils';
8
11
  export declare const COMPUTE_UNITS = 1000000;
9
12
  export declare const PRIORITY_FEE = 100000;
@@ -22,9 +25,9 @@ export declare class BasketsSdk {
22
25
  getBasket(params: {
23
26
  basket: PublicKey;
24
27
  }): Promise<Basket>;
25
- fetchAllBaskets(): Promise<Basket[]>;
26
- fetchAllIntents(): Promise<Intent[]>;
27
- fetchAllRebalanceIntents(): Promise<RebalanceIntent[]>;
28
+ fetchAllBaskets(filters: BasketFilter[]): Promise<Basket[]>;
29
+ fetchAllIntents(filters: IntentFilter[]): Promise<Intent[]>;
30
+ fetchAllRebalanceIntents(filters: RebalanceIntentFilter[]): Promise<RebalanceIntent[]>;
28
31
  createBasketTx(params: {
29
32
  creator: PublicKey;
30
33
  host: PublicKey;
package/dist/src/index.js CHANGED
@@ -46,21 +46,21 @@ class BasketsSdk {
46
46
  return basketState;
47
47
  });
48
48
  }
49
- fetchAllBaskets() {
49
+ fetchAllBaskets(filters) {
50
50
  return __awaiter(this, void 0, void 0, function* () {
51
- const baskets = yield (0, basket_1.fetchBaskets)(this.sdkParams.connection, []);
51
+ const baskets = yield (0, basket_1.fetchBaskets)(this.sdkParams.connection, filters);
52
52
  return baskets;
53
53
  });
54
54
  }
55
- fetchAllIntents() {
55
+ fetchAllIntents(filters) {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
- const intents = yield (0, intent_1.fetchIntents)(this.sdkParams.connection, []);
57
+ const intents = yield (0, intent_1.fetchIntents)(this.sdkParams.connection, filters);
58
58
  return intents;
59
59
  });
60
60
  }
61
- fetchAllRebalanceIntents() {
61
+ fetchAllRebalanceIntents(filters) {
62
62
  return __awaiter(this, void 0, void 0, function* () {
63
- const rebalanceIntents = yield (0, rebalanceIntent_1.fetchRebalanceIntents)(this.sdkParams.connection, []);
63
+ const rebalanceIntents = yield (0, rebalanceIntent_1.fetchRebalanceIntents)(this.sdkParams.connection, filters);
64
64
  return rebalanceIntents;
65
65
  });
66
66
  }
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rebalanceSwapIx = rebalanceSwapIx;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const pda_1 = require("../pda");
6
- const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
7
6
  const spl_token_1 = require("@solana/spl-token");
8
7
  const anchor_1 = require("@coral-xyz/anchor");
9
8
  const constants_1 = require("../../constants");
9
+ const web3_js_2 = require("@solana/web3.js");
10
10
  const REBALANCE_SWAP_DISCRIMINATOR = Buffer.from([101, 122, 61, 201, 21, 165, 177, 213]);
11
11
  function rebalanceSwapIx(params) {
12
12
  const { keeper, basket, mintFrom, mintTo, amount, side } = params;
@@ -25,7 +25,7 @@ function rebalanceSwapIx(params) {
25
25
  { pubkey: keeperToATA, isWritable: true, isSigner: false },
26
26
  { pubkey: basketFromATA, isWritable: true, isSigner: false },
27
27
  { pubkey: basketToATA, isWritable: true, isSigner: false },
28
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
28
+ { pubkey: web3_js_2.SystemProgram.programId, isWritable: false, isSigner: false },
29
29
  { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
30
30
  { pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
31
31
  { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addBountyIx = addBountyIx;
4
4
  const anchor_1 = require("@coral-xyz/anchor");
5
- const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
6
5
  const spl_token_1 = require("@solana/spl-token");
7
6
  const web3_js_1 = require("@solana/web3.js");
8
7
  const constants_1 = require("../../constants");
@@ -26,7 +25,7 @@ function addBountyIx(params) {
26
25
  { pubkey: bountyVault, isSigner: false, isWritable: true },
27
26
  { pubkey: bountyVaultAta, isSigner: false, isWritable: true },
28
27
  { pubkey: globalConfig, isSigner: false, isWritable: false },
29
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
28
+ { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
30
29
  { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
31
30
  { pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
32
31
  { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createGlobalConfigIx = createGlobalConfigIx;
4
4
  exports.editGlobalConfigIx = editGlobalConfigIx;
5
- const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
6
5
  const web3_js_1 = require("@solana/web3.js");
7
6
  const constants_1 = require("../../constants");
8
7
  const config_1 = require("../../layouts/config");
@@ -16,7 +15,7 @@ function createGlobalConfigIx(params) {
16
15
  const keys = [
17
16
  { pubkey: admin, isSigner: true, isWritable: true },
18
17
  { pubkey: globalConfig, isSigner: false, isWritable: true },
19
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
18
+ { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
20
19
  { pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
21
20
  ];
22
21
  return new web3_js_1.TransactionInstruction({
@@ -8,9 +8,9 @@ const web3_js_1 = require("@solana/web3.js");
8
8
  const constants_1 = require("../../constants");
9
9
  const pda_1 = require("../pda");
10
10
  const spl_token_1 = require("@solana/spl-token");
11
- const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
12
11
  const config_1 = require("../../layouts/config");
13
12
  const anchor_1 = require("@coral-xyz/anchor");
13
+ const web3_js_2 = require("@solana/web3.js");
14
14
  const EDIT_PRIVATE_BASKET_SETTINGS_DISCRIMINATOR = Buffer.from([202, 54, 138, 17, 3, 104, 128, 229]);
15
15
  const CREATE_EDIT_BASKET_INTENT_DISCRIMINATOR = Buffer.from([82, 150, 58, 227, 153, 129, 20, 30]);
16
16
  const EDIT_BASKET_DISCRIMINATOR = Buffer.from([156, 31, 4, 39, 248, 29, 55, 220]);
@@ -135,7 +135,7 @@ function createEditBasketIntentIx(params) {
135
135
  { pubkey: managerBountyATA, isSigner: false, isWritable: true },
136
136
  { pubkey: bountyVault, isSigner: false, isWritable: true },
137
137
  { pubkey: bountyVaultATA, isSigner: false, isWritable: true },
138
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
138
+ { pubkey: web3_js_2.SystemProgram.programId, isSigner: false, isWritable: false },
139
139
  { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
140
140
  { pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
141
141
  { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
@@ -167,7 +167,7 @@ function editBasketIx(params) {
167
167
  { pubkey: managerBountyATA, isSigner: false, isWritable: true },
168
168
  { pubkey: bountyVault, isSigner: false, isWritable: true },
169
169
  { pubkey: bountyVaultATA, isSigner: false, isWritable: true },
170
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
170
+ { pubkey: web3_js_2.SystemProgram.programId, isSigner: false, isWritable: false },
171
171
  { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
172
172
  { pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
173
173
  { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
@@ -5,7 +5,6 @@ exports.extendBasketLookupTablesIx = extendBasketLookupTablesIx;
5
5
  exports.overwriteBasketLookupTablesIx = overwriteBasketLookupTablesIx;
6
6
  exports.closeDeactivatedLookupTableIx = closeDeactivatedLookupTableIx;
7
7
  const anchor_1 = require("@coral-xyz/anchor");
8
- const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
9
8
  const web3_js_1 = require("@solana/web3.js");
10
9
  const constants_1 = require("../../constants");
11
10
  const pda_1 = require("../pda");
@@ -31,7 +30,7 @@ function createBasketLookupTablesInstruction(params) {
31
30
  { pubkey: newTempLookupTableInfo0, isSigner: false, isWritable: true },
32
31
  { pubkey: newTempLookupTableInfo1, isSigner: false, isWritable: true },
33
32
  { pubkey: constants_1.ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isSigner: false, isWritable: false },
34
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
33
+ { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
35
34
  ];
36
35
  return new web3_js_1.TransactionInstruction({
37
36
  keys,
@@ -46,7 +45,7 @@ function extendBasketLookupTablesIx(params) {
46
45
  { pubkey: params.tempLookupTable0, isWritable: true, isSigner: false },
47
46
  { pubkey: params.tempLookupTable1, isWritable: true, isSigner: false },
48
47
  { pubkey: constants_1.ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isWritable: false, isSigner: false },
49
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
48
+ { pubkey: web3_js_1.SystemProgram.programId, isWritable: false, isSigner: false },
50
49
  ];
51
50
  return new web3_js_1.TransactionInstruction({
52
51
  keys,
@@ -62,7 +61,7 @@ function overwriteBasketLookupTablesIx(params) {
62
61
  { pubkey: params.tempLookupTable1, isWritable: true, isSigner: false },
63
62
  { pubkey: params.activeLookupTable0, isWritable: true, isSigner: false },
64
63
  { pubkey: params.activeLookupTable1, isWritable: true, isSigner: false },
65
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
64
+ { pubkey: web3_js_1.SystemProgram.programId, isWritable: false, isSigner: false },
66
65
  ];
67
66
  return new web3_js_1.TransactionInstruction({
68
67
  keys,
@@ -78,7 +77,7 @@ function closeDeactivatedLookupTableIx(params) {
78
77
  { pubkey: params.lookupTable, isWritable: true, isSigner: false },
79
78
  { pubkey: lookupTableInfo, isWritable: true, isSigner: false },
80
79
  { pubkey: constants_1.ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isWritable: false, isSigner: false },
81
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
80
+ { pubkey: web3_js_1.SystemProgram.programId, isWritable: false, isSigner: false },
82
81
  ];
83
82
  return new web3_js_1.TransactionInstruction({
84
83
  keys,
@@ -11,8 +11,8 @@ const anchor_1 = require("@coral-xyz/anchor");
11
11
  const constants_1 = require("../../constants");
12
12
  const pda_1 = require("../pda");
13
13
  const spl_token_1 = require("@solana/spl-token");
14
- const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
15
14
  const web3_js_2 = require("@solana/web3.js");
15
+ const web3_js_3 = require("@solana/web3.js");
16
16
  const CREATE_USER_REBALANCE_INTENT_ACCOUNT = Buffer.from([212, 23, 1, 46, 192, 87, 74, 196]);
17
17
  const RESIZE_REBALANCE_INTENT_HANDLER = Buffer.from([71, 204, 243, 183, 209, 118, 111, 94]);
18
18
  const CREATE_DEPOSIT_STATE_DISCRIMINATOR = Buffer.from([66, 42, 217, 222, 49, 159, 36, 188]);
@@ -32,7 +32,7 @@ function createUserRebalanceIntentIx(params) {
32
32
  { pubkey: globalConfig, isSigner: false, isWritable: true },
33
33
  { pubkey: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false },
34
34
  { pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
35
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false }
35
+ { pubkey: web3_js_3.SystemProgram.programId, isSigner: false, isWritable: false }
36
36
  ];
37
37
  const data = CREATE_USER_REBALANCE_INTENT_ACCOUNT;
38
38
  return new web3_js_2.TransactionInstruction({
@@ -83,7 +83,7 @@ function depositStateIx(params) {
83
83
  { pubkey: buyerBountyAta, isSigner: false, isWritable: true },
84
84
  { pubkey: bountyVault, isSigner: false, isWritable: true },
85
85
  { pubkey: bountyVaultAta, isSigner: false, isWritable: true },
86
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
86
+ { pubkey: web3_js_3.SystemProgram.programId, isSigner: false, isWritable: false },
87
87
  { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
88
88
  { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
89
89
  // { pubkey: rebalanceIntent, isSigner: false, isWritable: true } // remaining accounts
@@ -107,7 +107,7 @@ function depositTokensIx(params) {
107
107
  { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
108
108
  { pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
109
109
  { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
110
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
110
+ { pubkey: web3_js_3.SystemProgram.programId, isSigner: false, isWritable: false },
111
111
  ];
112
112
  // remaining accounts
113
113
  contributions.forEach((contribution) => {
@@ -158,7 +158,7 @@ function mintBasketIx(params) {
158
158
  { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
159
159
  { pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
160
160
  { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
161
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
161
+ { pubkey: web3_js_3.SystemProgram.programId, isWritable: false, isSigner: false },
162
162
  ];
163
163
  return new web3_js_2.TransactionInstruction({
164
164
  keys,
@@ -6,8 +6,8 @@ const constants_1 = require("../../constants");
6
6
  const spl_token_1 = require("@solana/spl-token");
7
7
  const anchor_1 = require("@coral-xyz/anchor");
8
8
  const pda_1 = require("../pda");
9
- const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
10
9
  const web3_js_1 = require("@solana/web3.js");
10
+ const web3_js_2 = require("@solana/web3.js");
11
11
  const CREATE_WITHDRAW_STATE_DISCRIMINATOR = Buffer.from([161, 45, 253, 59, 110, 240, 65, 3]);
12
12
  const REDEEM_TOKENS_DISCRIMINATOR = Buffer.from([83, 49, 112, 2, 105, 193, 106, 126]);
13
13
  function createWithdrawStateIx(params) {
@@ -40,7 +40,7 @@ function createWithdrawStateIx(params) {
40
40
  { pubkey: sellerBountyAta, isSigner: false, isWritable: true },
41
41
  { pubkey: bountyVault, isSigner: false, isWritable: true },
42
42
  { pubkey: bountyVaultAta, isSigner: false, isWritable: true },
43
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
43
+ { pubkey: web3_js_2.SystemProgram.programId, isSigner: false, isWritable: false },
44
44
  { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
45
45
  { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
46
46
  { pubkey: rebalanceIntent, isSigner: false, isWritable: false } // remaining accounts
@@ -62,7 +62,7 @@ function redeemTokensIx(params) {
62
62
  { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
63
63
  { pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
64
64
  { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
65
- { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
65
+ { pubkey: web3_js_2.SystemProgram.programId, isSigner: false, isWritable: false },
66
66
  ];
67
67
  // remaining accounts
68
68
  params.tokenMints.forEach((mint) => {
@@ -1,5 +1,6 @@
1
1
  import { Connection, PublicKey } from "@solana/web3.js";
2
2
  import { Basket } from "../layouts/basket";
3
+ export declare function decodeBasket(dataWithoutDiscriminator: Buffer): Basket;
3
4
  export declare function fetchBasket(connection: Connection, basketAddress: PublicKey): Promise<Basket>;
4
5
  export interface BasketFilter {
5
6
  filterType: "host" | "creator";
@@ -9,17 +9,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.decodeBasket = decodeBasket;
12
13
  exports.fetchBasket = fetchBasket;
13
14
  exports.fetchBaskets = fetchBaskets;
14
15
  const basket_1 = require("../layouts/basket");
15
16
  const constants_1 = require("../constants");
17
+ function decodeBasket(dataWithoutDiscriminator) {
18
+ let basket = basket_1.BasketLayout.decode(dataWithoutDiscriminator);
19
+ return basket;
20
+ }
16
21
  function fetchBasket(connection, basketAddress) {
17
22
  return __awaiter(this, void 0, void 0, function* () {
18
23
  const basketAi = yield connection.getAccountInfo(basketAddress);
19
24
  if (!basketAi) {
20
25
  throw new Error("Basket not found");
21
26
  }
22
- return basket_1.BasketLayout.decode(basketAi.data.slice(8));
27
+ return decodeBasket(basketAi.data.slice(8));
23
28
  });
24
29
  }
25
30
  function fetchBaskets(connection, filters) {
@@ -48,7 +53,7 @@ function fetchBaskets(connection, filters) {
48
53
  filters: accountFilters,
49
54
  encoding: 'base64'
50
55
  });
51
- const baskets = accounts.map(account => basket_1.BasketLayout.decode(account.account.data.slice(8)));
56
+ const baskets = accounts.map(account => decodeBasket(account.account.data.slice(8)));
52
57
  return baskets;
53
58
  });
54
59
  }
package/dist/test.js CHANGED
@@ -28,11 +28,11 @@ function testStates() {
28
28
  metadataModificationDelay: new anchor_1.BN(0),
29
29
  });
30
30
  console.log(x);
31
- let baskets = yield sdk.fetchAllBaskets();
31
+ let baskets = yield sdk.fetchAllBaskets([]);
32
32
  console.log(baskets.map(basket => basket.ownAddress.toBase58()));
33
- let intents = yield sdk.fetchAllIntents();
33
+ let intents = yield sdk.fetchAllIntents([]);
34
34
  console.log(intents.map(intent => intent.manager.toBase58()));
35
- let rebalanceIntents = yield sdk.fetchAllRebalanceIntents();
35
+ let rebalanceIntents = yield sdk.fetchAllRebalanceIntents([]);
36
36
  console.log(rebalanceIntents.map(rebalanceIntent => rebalanceIntent.owner.toBase58()));
37
37
  });
38
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symmetry-hq/temp-v3-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Symmetry Baskets V3 SDK",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
package/src/index.ts CHANGED
@@ -14,9 +14,9 @@ import { Basket } from './layouts/basket';
14
14
  import { Fraction } from './layouts/fraction';
15
15
  import { EditData, HostFees, Intent, MetadataParams, TaskType } from './layouts/intents/intent';
16
16
  import { RebalanceIntent } from './layouts/intents/rebalanceIntent';
17
- import { fetchBasket, fetchBaskets } from './states/basket';
18
- import { fetchIntents } from './states/intents/intent';
19
- import { fetchRebalanceIntents } from './states/intents/rebalanceIntent';
17
+ import { BasketFilter, fetchBasket, fetchBaskets } from './states/basket';
18
+ import { fetchIntents, IntentFilter } from './states/intents/intent';
19
+ import { fetchRebalanceIntents, RebalanceIntentFilter } from './states/intents/rebalanceIntent';
20
20
  import { prepareV0Transactions, sendV0Transactions, signedVersionedTxs, VersionedTxs, Wallet } from './txUtils';
21
21
 
22
22
  export const COMPUTE_UNITS = 1_000_000;
@@ -62,18 +62,24 @@ export class BasketsSdk {
62
62
  return basketState;
63
63
  }
64
64
 
65
- async fetchAllBaskets(): Promise<Basket[]> {
66
- const baskets = await fetchBaskets(this.sdkParams.connection, []);
65
+ async fetchAllBaskets(
66
+ filters: BasketFilter[],
67
+ ): Promise<Basket[]> {
68
+ const baskets = await fetchBaskets(this.sdkParams.connection, filters);
67
69
  return baskets;
68
70
  }
69
71
 
70
- async fetchAllIntents(): Promise<Intent[]> {
71
- const intents = await fetchIntents(this.sdkParams.connection, []);
72
+ async fetchAllIntents(
73
+ filters: IntentFilter[],
74
+ ): Promise<Intent[]> {
75
+ const intents = await fetchIntents(this.sdkParams.connection, filters);
72
76
  return intents;
73
77
  }
74
78
 
75
- async fetchAllRebalanceIntents(): Promise<RebalanceIntent[]> {
76
- const rebalanceIntents = await fetchRebalanceIntents(this.sdkParams.connection, []);
79
+ async fetchAllRebalanceIntents(
80
+ filters: RebalanceIntentFilter[],
81
+ ): Promise<RebalanceIntent[]> {
82
+ const rebalanceIntents = await fetchRebalanceIntents(this.sdkParams.connection, filters);
77
83
  return rebalanceIntents;
78
84
  }
79
85
 
@@ -1,10 +1,10 @@
1
1
  import { TransactionInstruction } from "@solana/web3.js";
2
2
  import { PublicKey } from "@solana/web3.js";
3
3
  import { getAta, getRebalanceIntentPda } from "../pda";
4
- import { SYSTEM_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/native/system";
5
4
  import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from "@solana/spl-token";
6
5
  import { BN } from "@coral-xyz/anchor";
7
6
  import { BASKETS_V3_PROGRAM_ID } from "../../constants";
7
+ import { SystemProgram } from "@solana/web3.js";
8
8
 
9
9
 
10
10
 
@@ -39,7 +39,7 @@ export function rebalanceSwapIx(
39
39
  { pubkey: keeperToATA, isWritable: true, isSigner: false },
40
40
  { pubkey: basketFromATA, isWritable: true, isSigner: false },
41
41
  { pubkey: basketToATA, isWritable: true, isSigner: false },
42
- { pubkey: SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
42
+ { pubkey: SystemProgram.programId, isWritable: false, isSigner: false },
43
43
  { pubkey: TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
44
44
  { pubkey: TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
45
45
  { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
@@ -1,5 +1,4 @@
1
1
  import { BN } from '@coral-xyz/anchor';
2
- import { SYSTEM_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/native/system';
3
2
  import {
4
3
  ASSOCIATED_TOKEN_PROGRAM_ID,
5
4
  TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID
@@ -42,7 +41,7 @@ export function addBountyIx(params: {
42
41
  { pubkey: bountyVault, isSigner: false, isWritable: true },
43
42
  { pubkey: bountyVaultAta, isSigner: false, isWritable: true },
44
43
  { pubkey: globalConfig, isSigner: false, isWritable: false },
45
- { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
44
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
46
45
  { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
47
46
  { pubkey: TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
48
47
  { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
@@ -1,5 +1,4 @@
1
1
  import { BN, Program } from '@coral-xyz/anchor';
2
- import { SYSTEM_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/native/system';
3
2
  import { array, publicKey, struct, u16, u64, u8 } from '@coral-xyz/borsh';
4
3
  import {
5
4
  PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY, TransactionInstruction
@@ -27,7 +26,7 @@ export function createGlobalConfigIx(params: {
27
26
  const keys = [
28
27
  { pubkey: admin, isSigner: true, isWritable: true },
29
28
  { pubkey: globalConfig, isSigner: false, isWritable: true },
30
- { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
29
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
31
30
  { pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
32
31
  ];
33
32
 
@@ -4,9 +4,9 @@ import { TransactionInstruction } from "@solana/web3.js";
4
4
  import { BASKETS_V3_PROGRAM_ID } from "../../constants";
5
5
  import { getAta, getBountyVaultPda, getGlobalConfigPda, getIntentPda, getMetadataAccount, METADATA_PROGRAM_ID, serializeString } from "../pda";
6
6
  import { ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from "@solana/spl-token";
7
- import { SYSTEM_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/native/system";
8
7
  import { AutomationSettings, AutomationSettingsLayout, FeeSettings, FeeSettingsLayout, LpSettings, LpSettingsLayout, ManagerSettings, ManagerSettingsLayout, MetadataSettings, MetadataSettingsLayout, ScheduleSettings, ScheduleSettingsLayout } from "../../layouts/config";
9
8
  import { BN } from "@coral-xyz/anchor";
9
+ import { SystemProgram } from "@solana/web3.js";
10
10
 
11
11
  const EDIT_PRIVATE_BASKET_SETTINGS_DISCRIMINATOR = Buffer.from([202,54,138,17,3,104,128,229]);
12
12
  const CREATE_EDIT_BASKET_INTENT_DISCRIMINATOR = Buffer.from([82, 150, 58, 227, 153, 129, 20, 30]);
@@ -177,7 +177,7 @@ export function createEditBasketIntentIx(params: {
177
177
  { pubkey: managerBountyATA, isSigner: false, isWritable: true },
178
178
  { pubkey: bountyVault, isSigner: false, isWritable: true },
179
179
  { pubkey: bountyVaultATA, isSigner: false, isWritable: true },
180
- { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
180
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
181
181
  { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
182
182
  { pubkey: TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
183
183
  { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
@@ -230,7 +230,7 @@ export function editBasketIx(params: {
230
230
  { pubkey: managerBountyATA, isSigner: false, isWritable: true },
231
231
  { pubkey: bountyVault, isSigner: false, isWritable: true },
232
232
  { pubkey: bountyVaultATA, isSigner: false, isWritable: true },
233
- { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
233
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
234
234
  { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
235
235
  { pubkey: TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
236
236
  { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
@@ -1,5 +1,4 @@
1
1
  import { BN, Program } from '@coral-xyz/anchor';
2
- import { SYSTEM_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/native/system';
3
2
  import { PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js';
4
3
  import { ADDRESS_LOOKUP_TABLE_PROGRAM_ID, BASKETS_V3_PROGRAM_ID } from '../../constants';
5
4
  import { getLookupTableInfoAccount } from '../pda';
@@ -48,7 +47,7 @@ export function createBasketLookupTablesInstruction(params: {
48
47
  { pubkey: newTempLookupTableInfo0, isSigner: false, isWritable: true },
49
48
  { pubkey: newTempLookupTableInfo1, isSigner: false, isWritable: true },
50
49
  { pubkey: ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isSigner: false, isWritable: false },
51
- { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
50
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
52
51
  ];
53
52
 
54
53
  return new TransactionInstruction({
@@ -72,7 +71,7 @@ export function extendBasketLookupTablesIx(
72
71
  { pubkey: params.tempLookupTable0, isWritable: true, isSigner: false },
73
72
  { pubkey: params.tempLookupTable1, isWritable: true, isSigner: false },
74
73
  { pubkey: ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isWritable: false, isSigner: false },
75
- { pubkey: SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
74
+ { pubkey: SystemProgram.programId, isWritable: false, isSigner: false },
76
75
  ];
77
76
 
78
77
  return new TransactionInstruction({
@@ -100,7 +99,7 @@ export function overwriteBasketLookupTablesIx(
100
99
  { pubkey: params.tempLookupTable1, isWritable: true, isSigner: false },
101
100
  { pubkey: params.activeLookupTable0, isWritable: true, isSigner: false },
102
101
  { pubkey: params.activeLookupTable1, isWritable: true, isSigner: false },
103
- { pubkey: SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
102
+ { pubkey: SystemProgram.programId, isWritable: false, isSigner: false },
104
103
  ];
105
104
 
106
105
  return new TransactionInstruction({
@@ -123,7 +122,7 @@ export function closeDeactivatedLookupTableIx(params: {
123
122
  { pubkey: params.lookupTable, isWritable: true, isSigner: false },
124
123
  { pubkey: lookupTableInfo, isWritable: true, isSigner: false },
125
124
  { pubkey: ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isWritable: false, isSigner: false },
126
- { pubkey: SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
125
+ { pubkey: SystemProgram.programId, isWritable: false, isSigner: false },
127
126
  ];
128
127
 
129
128
  return new TransactionInstruction({
@@ -3,8 +3,8 @@ import { BN } from "@coral-xyz/anchor";
3
3
  import { BASKETS_V3_PROGRAM_ID } from "../../constants";
4
4
  import { getAta, getBasketFeesPda, getBasketTokenMintPda, getBountyVaultPda, getGlobalConfigPda, getRebalanceIntentPda, getRentPayerPda } from "../pda";
5
5
  import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from "@solana/spl-token";
6
- import { SYSTEM_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/native/system";
7
6
  import { TransactionInstruction } from "@solana/web3.js";
7
+ import { SystemProgram } from "@solana/web3.js";
8
8
 
9
9
  const CREATE_USER_REBALANCE_INTENT_ACCOUNT = Buffer.from([212, 23, 1, 46, 192, 87, 74, 196]);
10
10
  const RESIZE_REBALANCE_INTENT_HANDLER = Buffer.from([71, 204, 243, 183, 209, 118, 111, 94]);
@@ -33,7 +33,7 @@ export function createUserRebalanceIntentIx(params: {
33
33
  { pubkey: globalConfig, isSigner: false, isWritable: true},
34
34
  { pubkey: SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false},
35
35
  { pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false},
36
- { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false}
36
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false}
37
37
  ];
38
38
 
39
39
  const data = CREATE_USER_REBALANCE_INTENT_ACCOUNT;
@@ -112,7 +112,7 @@ export function depositStateIx(
112
112
  { pubkey: buyerBountyAta, isSigner: false, isWritable: true },
113
113
  { pubkey: bountyVault, isSigner: false, isWritable: true },
114
114
  { pubkey: bountyVaultAta, isSigner: false, isWritable: true },
115
- { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
115
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
116
116
  { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
117
117
  { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
118
118
  // { pubkey: rebalanceIntent, isSigner: false, isWritable: true } // remaining accounts
@@ -149,7 +149,7 @@ export function depositTokensIx(params: {
149
149
  { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
150
150
  { pubkey: TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
151
151
  { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
152
- { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
152
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
153
153
  ];
154
154
 
155
155
  // remaining accounts
@@ -223,7 +223,7 @@ export function mintBasketIx(params: {
223
223
  { pubkey: TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
224
224
  { pubkey: TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
225
225
  { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
226
- { pubkey: SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
226
+ { pubkey: SystemProgram.programId, isWritable: false, isSigner: false },
227
227
  ];
228
228
 
229
229
  return new TransactionInstruction({
@@ -3,8 +3,8 @@ import { BASKETS_V3_PROGRAM_ID } from "../../constants";
3
3
  import { ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from "@solana/spl-token";
4
4
  import { BN } from "@coral-xyz/anchor";
5
5
  import { getAta, getBasketTokenMintPda, getBountyVaultPda, getGlobalConfigPda, getRebalanceIntentPda, getRentPayerPda } from "../pda";
6
- import { SYSTEM_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/native/system";
7
6
  import { TransactionInstruction } from "@solana/web3.js";
7
+ import { SystemProgram } from "@solana/web3.js";
8
8
 
9
9
 
10
10
  const CREATE_WITHDRAW_STATE_DISCRIMINATOR = Buffer.from([161, 45, 253, 59, 110, 240, 65, 3]);
@@ -61,7 +61,7 @@ export function createWithdrawStateIx(params: {
61
61
  { pubkey: sellerBountyAta, isSigner: false, isWritable: true },
62
62
  { pubkey: bountyVault, isSigner: false, isWritable: true },
63
63
  { pubkey: bountyVaultAta, isSigner: false, isWritable: true },
64
- { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
64
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
65
65
  { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
66
66
  { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
67
67
  { pubkey: rebalanceIntent, isSigner: false, isWritable: false } // remaining accounts
@@ -100,7 +100,7 @@ export function redeemTokensIx(
100
100
  { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
101
101
  { pubkey: TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
102
102
  { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
103
- { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
103
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
104
104
  ];
105
105
 
106
106
  // remaining accounts
@@ -3,6 +3,11 @@ import { AssetLayout, Basket, BasketLayout, LookupTablesLayout } from "../layout
3
3
  import { BASKETS_V3_PROGRAM_ID } from "../constants";
4
4
 
5
5
 
6
+ export function decodeBasket(dataWithoutDiscriminator: Buffer): Basket {
7
+ let basket = BasketLayout.decode(dataWithoutDiscriminator);
8
+ return basket;
9
+ }
10
+
6
11
  export async function fetchBasket(
7
12
  connection: Connection,
8
13
  basketAddress: PublicKey,
@@ -11,7 +16,7 @@ export async function fetchBasket(
11
16
  if (!basketAi) {
12
17
  throw new Error("Basket not found");
13
18
  }
14
- return BasketLayout.decode(basketAi.data.slice(8));
19
+ return decodeBasket(basketAi.data.slice(8));
15
20
  }
16
21
 
17
22
  export interface BasketFilter {
@@ -50,7 +55,7 @@ export async function fetchBaskets(
50
55
  }
51
56
  );
52
57
  const baskets: Basket[] = accounts.map(account =>
53
- BasketLayout.decode(account.account.data.slice(8))
58
+ decodeBasket(account.account.data.slice(8))
54
59
  );
55
60
  return baskets;
56
61
  }
package/test.ts CHANGED
@@ -19,11 +19,11 @@ async function testStates() {
19
19
  metadataModificationDelay: new BN(0),
20
20
  });
21
21
  console.log(x);
22
- let baskets = await sdk.fetchAllBaskets();
22
+ let baskets = await sdk.fetchAllBaskets([]);
23
23
  console.log(baskets.map(basket => basket.ownAddress.toBase58()));
24
- let intents = await sdk.fetchAllIntents();
24
+ let intents = await sdk.fetchAllIntents([]);
25
25
  console.log(intents.map(intent => intent.manager.toBase58()));
26
- let rebalanceIntents = await sdk.fetchAllRebalanceIntents();
26
+ let rebalanceIntents = await sdk.fetchAllRebalanceIntents([]);
27
27
  console.log(rebalanceIntents.map(rebalanceIntent => rebalanceIntent.owner.toBase58()));
28
28
  }
29
29