@symmetry-hq/temp-v3-sdk 0.0.1

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 (148) hide show
  1. package/dist/idl/idl.d.ts +8 -0
  2. package/dist/idl/idl.js +4958 -0
  3. package/dist/idl/types.d.ts +4955 -0
  4. package/dist/idl/types.js +2 -0
  5. package/dist/index.d.ts +24 -0
  6. package/dist/index.js +60 -0
  7. package/dist/layouts/basket.d.ts +42 -0
  8. package/dist/layouts/basket.js +43 -0
  9. package/dist/layouts/config.d.ts +97 -0
  10. package/dist/layouts/config.js +102 -0
  11. package/dist/layouts/fraction.d.ts +6 -0
  12. package/dist/layouts/fraction.js +9 -0
  13. package/dist/layouts/oracle.d.ts +36 -0
  14. package/dist/layouts/oracle.js +37 -0
  15. package/dist/src/constants.d.ts +15 -0
  16. package/dist/src/constants.js +19 -0
  17. package/dist/src/idl/idl.d.ts +8 -0
  18. package/dist/src/idl/idl.js +4958 -0
  19. package/dist/src/idl/types.d.ts +4955 -0
  20. package/dist/src/idl/types.js +2 -0
  21. package/dist/src/index.d.ts +53 -0
  22. package/dist/src/index.js +199 -0
  23. package/dist/src/instructions/accounts.d.ts +27 -0
  24. package/dist/src/instructions/accounts.js +110 -0
  25. package/dist/src/instructions/auction.d.ts +7 -0
  26. package/dist/src/instructions/auction.js +43 -0
  27. package/dist/src/instructions/automation/auction.d.ts +6 -0
  28. package/dist/src/instructions/automation/auction.js +40 -0
  29. package/dist/src/instructions/automation/claimBounty.d.ts +12 -0
  30. package/dist/src/instructions/automation/claimBounty.js +44 -0
  31. package/dist/src/instructions/automation/priceUpdate.d.ts +15 -0
  32. package/dist/src/instructions/automation/priceUpdate.js +47 -0
  33. package/dist/src/instructions/automation/rebalanceSwap.d.ts +10 -0
  34. package/dist/src/instructions/automation/rebalanceSwap.js +42 -0
  35. package/dist/src/instructions/basket.d.ts +120 -0
  36. package/dist/src/instructions/basket.js +622 -0
  37. package/dist/src/instructions/bounty.d.ts +18 -0
  38. package/dist/src/instructions/bounty.js +81 -0
  39. package/dist/src/instructions/fee.d.ts +8 -0
  40. package/dist/src/instructions/fee.js +46 -0
  41. package/dist/src/instructions/globalConfig.d.ts +11 -0
  42. package/dist/src/instructions/globalConfig.js +43 -0
  43. package/dist/src/instructions/luts.d.ts +33 -0
  44. package/dist/src/instructions/luts.js +91 -0
  45. package/dist/src/instructions/management/addBounty.d.ts +7 -0
  46. package/dist/src/instructions/management/addBounty.js +39 -0
  47. package/dist/src/instructions/management/admin.d.ts +9 -0
  48. package/dist/src/instructions/management/admin.js +43 -0
  49. package/dist/src/instructions/management/claimFees.d.ts +7 -0
  50. package/dist/src/instructions/management/claimFees.js +47 -0
  51. package/dist/src/instructions/management/createBasket.d.ts +22 -0
  52. package/dist/src/instructions/management/createBasket.js +101 -0
  53. package/dist/src/instructions/management/edit.d.ts +34 -0
  54. package/dist/src/instructions/management/edit.js +192 -0
  55. package/dist/src/instructions/management/luts.d.ts +29 -0
  56. package/dist/src/instructions/management/luts.js +88 -0
  57. package/dist/src/instructions/pda.d.ts +26 -0
  58. package/dist/src/instructions/pda.js +110 -0
  59. package/dist/src/instructions/price.d.ts +17 -0
  60. package/dist/src/instructions/price.js +47 -0
  61. package/dist/src/instructions/user/deposit.d.ts +32 -0
  62. package/dist/src/instructions/user/deposit.js +168 -0
  63. package/dist/src/instructions/user/withdraw.d.ts +16 -0
  64. package/dist/src/instructions/user/withdraw.js +82 -0
  65. package/dist/src/layouts/basket.d.ts +41 -0
  66. package/dist/src/layouts/basket.js +43 -0
  67. package/dist/src/layouts/config.d.ts +133 -0
  68. package/dist/src/layouts/config.js +137 -0
  69. package/dist/src/layouts/fraction.d.ts +6 -0
  70. package/dist/src/layouts/fraction.js +9 -0
  71. package/dist/src/layouts/intents/bounty.d.ts +18 -0
  72. package/dist/src/layouts/intents/bounty.js +19 -0
  73. package/dist/src/layouts/intents/intent.d.ts +101 -0
  74. package/dist/src/layouts/intents/intent.js +113 -0
  75. package/dist/src/layouts/intents/rebalanceIntent.d.ts +56 -0
  76. package/dist/src/layouts/intents/rebalanceIntent.js +63 -0
  77. package/dist/src/layouts/lookupTable.d.ts +7 -0
  78. package/dist/src/layouts/lookupTable.js +10 -0
  79. package/dist/src/layouts/oracle.d.ts +42 -0
  80. package/dist/src/layouts/oracle.js +43 -0
  81. package/dist/src/states/basket.d.ts +8 -0
  82. package/dist/src/states/basket.js +54 -0
  83. package/dist/src/states/intents/intent.d.ts +14 -0
  84. package/dist/src/states/intents/intent.js +90 -0
  85. package/dist/src/states/intents/rebalanceIntent.d.ts +8 -0
  86. package/dist/src/states/intents/rebalanceIntent.js +54 -0
  87. package/dist/src/states/oracles/clmm_oracle.d.ts +178 -0
  88. package/dist/src/states/oracles/clmm_oracle.js +546 -0
  89. package/dist/src/states/oracles/constants.d.ts +8 -0
  90. package/dist/src/states/oracles/constants.js +12 -0
  91. package/dist/src/states/oracles/oracle.d.ts +60 -0
  92. package/dist/src/states/oracles/oracle.js +237 -0
  93. package/dist/src/states/oracles/pythOracle.d.ts +39 -0
  94. package/dist/src/states/oracles/pythOracle.js +202 -0
  95. package/dist/src/states/oracles/pyth_oracle.d.ts +39 -0
  96. package/dist/src/states/oracles/pyth_oracle.js +202 -0
  97. package/dist/src/states/oracles/raydiumClmmOracle.d.ts +178 -0
  98. package/dist/src/states/oracles/raydiumClmmOracle.js +546 -0
  99. package/dist/src/states/oracles/raydiumCpmmOracle.d.ts +139 -0
  100. package/dist/src/states/oracles/raydiumCpmmOracle.js +420 -0
  101. package/dist/src/states/oracles/raydium_cpmm_oracle.d.ts +139 -0
  102. package/dist/src/states/oracles/raydium_cpmm_oracle.js +420 -0
  103. package/dist/src/states/oracles/switchboardOracle.d.ts +0 -0
  104. package/dist/src/states/oracles/switchboardOracle.js +1 -0
  105. package/dist/src/states/oracles/switchboard_oracle.d.ts +0 -0
  106. package/dist/src/states/oracles/switchboard_oracle.js +1 -0
  107. package/dist/src/txUtils.d.ts +26 -0
  108. package/dist/src/txUtils.js +183 -0
  109. package/dist/states/basket.d.ts +8 -0
  110. package/dist/states/basket.js +57 -0
  111. package/dist/test.d.ts +1 -0
  112. package/dist/test.js +39 -0
  113. package/package.json +30 -0
  114. package/src/constants.ts +24 -0
  115. package/src/index.ts +260 -0
  116. package/src/instructions/automation/auction.ts +55 -0
  117. package/src/instructions/automation/claimBounty.ts +69 -0
  118. package/src/instructions/automation/priceUpdate.ts +73 -0
  119. package/src/instructions/automation/rebalanceSwap.ts +60 -0
  120. package/src/instructions/management/addBounty.ts +56 -0
  121. package/src/instructions/management/admin.ts +65 -0
  122. package/src/instructions/management/claimFees.ts +59 -0
  123. package/src/instructions/management/createBasket.ts +148 -0
  124. package/src/instructions/management/edit.ts +255 -0
  125. package/src/instructions/management/luts.ts +134 -0
  126. package/src/instructions/pda.ts +160 -0
  127. package/src/instructions/user/deposit.ts +237 -0
  128. package/src/instructions/user/withdraw.ts +130 -0
  129. package/src/layouts/basket.ts +82 -0
  130. package/src/layouts/config.ts +301 -0
  131. package/src/layouts/fraction.ts +12 -0
  132. package/src/layouts/intents/bounty.ts +35 -0
  133. package/src/layouts/intents/intent.ts +204 -0
  134. package/src/layouts/intents/rebalanceIntent.ts +111 -0
  135. package/src/layouts/lookupTable.ts +14 -0
  136. package/src/layouts/oracle.ts +96 -0
  137. package/src/states/basket.ts +56 -0
  138. package/src/states/intents/intent.ts +107 -0
  139. package/src/states/intents/rebalanceIntent.ts +57 -0
  140. package/src/states/oracles/constants.ts +13 -0
  141. package/src/states/oracles/oracle.ts +260 -0
  142. package/src/states/oracles/pythOracle.ts +270 -0
  143. package/src/states/oracles/raydiumClmmOracle.ts +812 -0
  144. package/src/states/oracles/raydiumCpmmOracle.ts +614 -0
  145. package/src/states/oracles/switchboardOracle.ts +0 -0
  146. package/src/txUtils.ts +250 -0
  147. package/test.ts +30 -0
  148. package/tsconfig.json +101 -0
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.editPrivateBasketSettingsIx = editPrivateBasketSettingsIx;
4
+ exports.createEditBasketIntentIx = createEditBasketIntentIx;
5
+ exports.editBasketIx = editBasketIx;
6
+ const intent_1 = require("../../layouts/intents/intent");
7
+ const web3_js_1 = require("@solana/web3.js");
8
+ const constants_1 = require("../../constants");
9
+ const pda_1 = require("../pda");
10
+ const spl_token_1 = require("@solana/spl-token");
11
+ const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
12
+ const config_1 = require("../../layouts/config");
13
+ const anchor_1 = require("@coral-xyz/anchor");
14
+ const EDIT_PRIVATE_BASKET_SETTINGS_DISCRIMINATOR = Buffer.from([202, 54, 138, 17, 3, 104, 128, 229]);
15
+ const CREATE_EDIT_BASKET_INTENT_DISCRIMINATOR = Buffer.from([82, 150, 58, 227, 153, 129, 20, 30]);
16
+ const EDIT_BASKET_DISCRIMINATOR = Buffer.from([156, 31, 4, 39, 248, 29, 55, 220]);
17
+ function editPrivateBasketSettingsIx(params) {
18
+ let metadataAccount = (0, pda_1.getMetadataAccount)(params.basket);
19
+ let globalConfig = (0, pda_1.getGlobalConfigPda)();
20
+ const scheduleSettingsBuffer = Buffer.alloc(config_1.ScheduleSettingsLayout.span);
21
+ const scheduleBytesLen = config_1.ScheduleSettingsLayout.encode(params.scheduleBytes, scheduleSettingsBuffer);
22
+ const feeSettingsBuffer = Buffer.alloc(config_1.FeeSettingsLayout.span);
23
+ const feeSettingsBytesLen = config_1.FeeSettingsLayout.encode(params.feeSettingsBytes, feeSettingsBuffer);
24
+ const managerSettingsBuffer = Buffer.alloc(config_1.ManagerSettingsLayout.span);
25
+ const managerSettingsBytesLen = config_1.ManagerSettingsLayout.encode(params.managerSettingsBytes, managerSettingsBuffer);
26
+ const automationSettingsBuffer = Buffer.alloc(config_1.AutomationSettingsLayout.span);
27
+ const automationSettingsBytesLen = config_1.AutomationSettingsLayout.encode(params.automationSettingsBytes, automationSettingsBuffer);
28
+ const lpSettingsBuffer = Buffer.alloc(config_1.LpSettingsLayout.span);
29
+ const lpSettingsByteslen = config_1.LpSettingsLayout.encode(params.lpSettingsBytes, lpSettingsBuffer);
30
+ const authorityBitmasksBuffer = Buffer.alloc(intent_1.AuthorityBitmasksLayout.span);
31
+ const authorityBitmasksBytesLen = intent_1.AuthorityBitmasksLayout.encode(params.authorityBitmasks, authorityBitmasksBuffer);
32
+ const metadataParamsBuffer = Buffer.alloc(intent_1.MetadataParamsLayout.span);
33
+ const metadataParamsBytesLen = intent_1.MetadataParamsLayout.encode(params.metadataParams, metadataParamsBuffer);
34
+ const data = Buffer.concat([
35
+ EDIT_PRIVATE_BASKET_SETTINGS_DISCRIMINATOR,
36
+ Buffer.from([params.basketType]),
37
+ scheduleSettingsBuffer,
38
+ feeSettingsBuffer,
39
+ managerSettingsBuffer,
40
+ automationSettingsBuffer,
41
+ lpSettingsBuffer,
42
+ authorityBitmasksBuffer,
43
+ (0, pda_1.serializeString)(params.metadataParams.name),
44
+ (0, pda_1.serializeString)(params.metadataParams.symbol),
45
+ (0, pda_1.serializeString)(params.metadataParams.uri),
46
+ Buffer.from(new anchor_1.BN(params.metadataModificationDelay).toArray("le", 8)),
47
+ ]);
48
+ const keys = [
49
+ { pubkey: params.creator, isSigner: true, isWritable: true },
50
+ { pubkey: params.basket, isSigner: false, isWritable: true },
51
+ { pubkey: metadataAccount, isSigner: false, isWritable: true },
52
+ { pubkey: globalConfig, isSigner: false, isWritable: false },
53
+ { pubkey: pda_1.METADATA_PROGRAM_ID, isSigner: false, isWritable: false }
54
+ ];
55
+ return new web3_js_1.TransactionInstruction({
56
+ keys,
57
+ programId: constants_1.BASKETS_V3_PROGRAM_ID,
58
+ data
59
+ });
60
+ }
61
+ function createEditBasketIntentIx(params) {
62
+ const { manager, basket, bountyMint, editType, editData, useBounty, } = params;
63
+ let intent = (0, pda_1.getIntentPda)(basket, manager, editType);
64
+ let globalConfig = (0, pda_1.getGlobalConfigPda)();
65
+ let bountyVault = (0, pda_1.getBountyVaultPda)();
66
+ let managerBountyATA = (0, pda_1.getAta)(manager, bountyMint);
67
+ let bountyVaultATA = (0, pda_1.getAta)(bountyVault, bountyMint);
68
+ const editTypeBuf = Buffer.from([editType]);
69
+ const editDataBuf = Buffer.alloc(260);
70
+ switch (editType) {
71
+ case intent_1.TaskType.EditSchedule: // 1
72
+ config_1.ScheduleSettingsLayout.encode(editData, editDataBuf);
73
+ break;
74
+ case intent_1.TaskType.EditFeeSettings: // 2
75
+ config_1.FeeSettingsLayout.encode(editData, editDataBuf);
76
+ break;
77
+ case intent_1.TaskType.EditManagerSettings: // 3
78
+ // TODO: ?????
79
+ intent_1.ManagerSettingsWithAuthorityBitmasksLayout.encode(editData, editDataBuf)(editData).managers.forEach((managerPubkey) => {
80
+ keys.push({ pubkey: managerPubkey, isWritable: true, isSigner: false });
81
+ });
82
+ break;
83
+ case intent_1.TaskType.EditAutomationSettings: // 4
84
+ config_1.AutomationSettingsLayout.encode(editData, editDataBuf);
85
+ break;
86
+ case intent_1.TaskType.EditLpSettings: // 5
87
+ config_1.LpSettingsLayout.encode(editData, editDataBuf);
88
+ break;
89
+ case intent_1.TaskType.EditMetadataSettings: // 6
90
+ config_1.MetadataSettingsLayout.encode(editData, editDataBuf);
91
+ break;
92
+ case intent_1.TaskType.EditAddTokenDelay: // 7
93
+ intent_1.AddTokenDelayLayout.encode(editData, editDataBuf);
94
+ break;
95
+ case intent_1.TaskType.EditUpdateWeightsDelay: // 8
96
+ intent_1.UpdateWeightsDelayLayout.encode(editData, editDataBuf);
97
+ break;
98
+ // case TaskType.AddToken: // 9
99
+ // AddTokenLayout.encode(editData as AddToken, editDataBuf);
100
+ // keys.push({pubkey: (editData as AddToken).tokenMint, isWritable: false, isSigner: false});
101
+ // const basketNewTokenAta = getAssociatedTokenAddressSync(
102
+ // (editData as AddToken).tokenMint,
103
+ // basket,
104
+ // true
105
+ // );
106
+ // keys.push({pubkey: basketNewTokenAta, isWritable: true, isSigner: false});
107
+ // additionalAccounts.lookupTables.forEach((lookupTablePubkey) => {
108
+ // keys.push({ pubkey: lookupTablePubkey, isWritable: true, isSigner: false });
109
+ // });
110
+ // additionalAccounts.additionalOracleAccounts.forEach((oraclePubkey) => {
111
+ // keys.push({ pubkey: oraclePubkey, isWritable: false, isSigner: false });
112
+ // });
113
+ // break;
114
+ case intent_1.TaskType.UpdateWeights: // 10
115
+ intent_1.UpdateWeightsLayout.encode(editData, editDataBuf);
116
+ break;
117
+ case intent_1.TaskType.Swap: // 11
118
+ break;
119
+ default:
120
+ break;
121
+ }
122
+ const useBountyBuf = Buffer.from([useBounty]);
123
+ const data = Buffer.concat([
124
+ CREATE_EDIT_BASKET_INTENT_DISCRIMINATOR,
125
+ editTypeBuf,
126
+ editDataBuf,
127
+ useBountyBuf,
128
+ ]);
129
+ const keys = [
130
+ { pubkey: manager, isSigner: true, isWritable: true },
131
+ { pubkey: basket, isSigner: false, isWritable: true },
132
+ { pubkey: intent, isSigner: false, isWritable: true },
133
+ { pubkey: globalConfig, isSigner: false, isWritable: false },
134
+ { pubkey: bountyMint, isSigner: false, isWritable: false },
135
+ { pubkey: managerBountyATA, isSigner: false, isWritable: true },
136
+ { pubkey: bountyVault, isSigner: false, isWritable: true },
137
+ { pubkey: bountyVaultATA, isSigner: false, isWritable: true },
138
+ { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
139
+ { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
140
+ { pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
141
+ { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
142
+ ];
143
+ return new web3_js_1.TransactionInstruction({
144
+ keys,
145
+ programId: constants_1.BASKETS_V3_PROGRAM_ID,
146
+ data,
147
+ });
148
+ }
149
+ function editBasketIx(params) {
150
+ const { keeper, basket, intent, bountyMint, manager } = params;
151
+ let globalConfig = (0, pda_1.getGlobalConfigPda)();
152
+ let bountyVault = (0, pda_1.getBountyVaultPda)();
153
+ let keeperBountyATA = (0, pda_1.getAta)(keeper, bountyMint);
154
+ let managerBountyATA = (0, pda_1.getAta)(manager, bountyMint);
155
+ let bountyVaultATA = (0, pda_1.getAta)(bountyVault, bountyMint);
156
+ // discriminator
157
+ const data = EDIT_BASKET_DISCRIMINATOR;
158
+ // accounts
159
+ const keys = [
160
+ { pubkey: keeper, isSigner: true, isWritable: true },
161
+ { pubkey: basket, isSigner: false, isWritable: true },
162
+ { pubkey: intent, isSigner: false, isWritable: true },
163
+ { pubkey: globalConfig, isSigner: false, isWritable: true },
164
+ { pubkey: bountyMint, isSigner: false, isWritable: false },
165
+ { pubkey: keeperBountyATA, isSigner: false, isWritable: true },
166
+ { pubkey: manager, isSigner: false, isWritable: true },
167
+ { pubkey: managerBountyATA, isSigner: false, isWritable: true },
168
+ { pubkey: bountyVault, isSigner: false, isWritable: true },
169
+ { pubkey: bountyVaultATA, isSigner: false, isWritable: true },
170
+ { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
171
+ { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
172
+ { pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
173
+ { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
174
+ ];
175
+ // remaining accounts
176
+ if (params.editType === intent_1.TaskType.EditMetadataSettings) {
177
+ keys.push({ pubkey: params.basket, isSigner: true, isWritable: false });
178
+ keys.push({ pubkey: params.metadataAccount, isSigner: false, isWritable: true });
179
+ keys.push({ pubkey: pda_1.METADATA_PROGRAM_ID, isSigner: false, isWritable: false });
180
+ }
181
+ ;
182
+ // if(params.editType === TaskType.AddToken){
183
+ // params.lookupTables.forEach((lookupTablePubkey) => {
184
+ // keys.push({ pubkey: lookupTablePubkey, isWritable: false, isSigner: false });
185
+ // });
186
+ // };
187
+ return new web3_js_1.TransactionInstruction({
188
+ keys,
189
+ programId: constants_1.BASKETS_V3_PROGRAM_ID,
190
+ data,
191
+ });
192
+ }
@@ -0,0 +1,29 @@
1
+ import { PublicKey, TransactionInstruction } from '@solana/web3.js';
2
+ export declare function createBasketLookupTablesInstruction(params: {
3
+ signer: PublicKey;
4
+ basket: PublicKey;
5
+ oldTempLookupTable0: PublicKey;
6
+ oldTempLookupTable1: PublicKey;
7
+ newTempLookupTable0: PublicKey;
8
+ newTempLookupTable1: PublicKey;
9
+ slot: number;
10
+ }): TransactionInstruction;
11
+ export declare function extendBasketLookupTablesIx(params: {
12
+ signer: PublicKey;
13
+ basket: PublicKey;
14
+ tempLookupTable0: PublicKey;
15
+ tempLookupTable1: PublicKey;
16
+ }): TransactionInstruction;
17
+ export declare function overwriteBasketLookupTablesIx(params: {
18
+ signer: PublicKey;
19
+ basket: PublicKey;
20
+ tempLookupTable0: PublicKey;
21
+ tempLookupTable1: PublicKey;
22
+ activeLookupTable0: PublicKey;
23
+ activeLookupTable1: PublicKey;
24
+ }): TransactionInstruction;
25
+ export declare function closeDeactivatedLookupTableIx(params: {
26
+ rentPayer: PublicKey;
27
+ basket: PublicKey;
28
+ lookupTable: PublicKey;
29
+ }): TransactionInstruction;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBasketLookupTablesInstruction = createBasketLookupTablesInstruction;
4
+ exports.extendBasketLookupTablesIx = extendBasketLookupTablesIx;
5
+ exports.overwriteBasketLookupTablesIx = overwriteBasketLookupTablesIx;
6
+ exports.closeDeactivatedLookupTableIx = closeDeactivatedLookupTableIx;
7
+ const anchor_1 = require("@coral-xyz/anchor");
8
+ const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
9
+ const web3_js_1 = require("@solana/web3.js");
10
+ const constants_1 = require("../../constants");
11
+ const pda_1 = require("../pda");
12
+ const CREATE_BASKET_LOOKUP_TABLES_DISCRIMINATOR = Buffer.from([227, 98, 152, 128, 87, 46, 244, 99]);
13
+ const EXTEND_BASKET_LOOKUP_TABLES_DISCRIMINATOR = Buffer.from([98, 129, 153, 127, 181, 160, 117, 74]);
14
+ const OVERWRITE_BASKET_LOOKUP_TABLES_DISCRIMINATOR = Buffer.from([197, 116, 189, 147, 222, 188, 6, 165]);
15
+ const CLOSE_DEACTIVATED_LOOKUP_TABLE_DISCRIMINATOR = Buffer.from([19, 4, 214, 20, 26, 43, 71, 233]);
16
+ function createBasketLookupTablesInstruction(params) {
17
+ const { signer, basket, oldTempLookupTable0, oldTempLookupTable1, newTempLookupTable0, newTempLookupTable1, slot, } = params;
18
+ let newTempLookupTableInfo0 = (0, pda_1.getLookupTableInfoAccount)(newTempLookupTable0);
19
+ let newTempLookupTableInfo1 = (0, pda_1.getLookupTableInfoAccount)(newTempLookupTable1);
20
+ const data = Buffer.concat([
21
+ CREATE_BASKET_LOOKUP_TABLES_DISCRIMINATOR,
22
+ new anchor_1.BN(slot).toArray("le", 8),
23
+ ]);
24
+ const keys = [
25
+ { pubkey: signer, isSigner: true, isWritable: true },
26
+ { pubkey: basket, isSigner: false, isWritable: true },
27
+ { pubkey: oldTempLookupTable0, isSigner: false, isWritable: true },
28
+ { pubkey: oldTempLookupTable1, isSigner: false, isWritable: true },
29
+ { pubkey: newTempLookupTable0, isSigner: false, isWritable: true },
30
+ { pubkey: newTempLookupTable1, isSigner: false, isWritable: true },
31
+ { pubkey: newTempLookupTableInfo0, isSigner: false, isWritable: true },
32
+ { pubkey: newTempLookupTableInfo1, isSigner: false, isWritable: true },
33
+ { pubkey: constants_1.ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isSigner: false, isWritable: false },
34
+ { pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
35
+ ];
36
+ return new web3_js_1.TransactionInstruction({
37
+ keys,
38
+ programId: constants_1.BASKETS_V3_PROGRAM_ID,
39
+ data,
40
+ });
41
+ }
42
+ function extendBasketLookupTablesIx(params) {
43
+ const keys = [
44
+ { pubkey: params.signer, isWritable: true, isSigner: true },
45
+ { pubkey: params.basket, isWritable: true, isSigner: false },
46
+ { pubkey: params.tempLookupTable0, isWritable: true, isSigner: false },
47
+ { pubkey: params.tempLookupTable1, isWritable: true, isSigner: false },
48
+ { pubkey: constants_1.ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isWritable: false, isSigner: false },
49
+ { pubkey: system_1.SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
50
+ ];
51
+ return new web3_js_1.TransactionInstruction({
52
+ keys,
53
+ programId: constants_1.BASKETS_V3_PROGRAM_ID,
54
+ data: EXTEND_BASKET_LOOKUP_TABLES_DISCRIMINATOR,
55
+ });
56
+ }
57
+ function overwriteBasketLookupTablesIx(params) {
58
+ const keys = [
59
+ { pubkey: params.signer, isWritable: true, isSigner: true },
60
+ { pubkey: params.basket, isWritable: true, isSigner: false },
61
+ { pubkey: params.tempLookupTable0, isWritable: true, isSigner: false },
62
+ { pubkey: params.tempLookupTable1, isWritable: true, isSigner: false },
63
+ { pubkey: params.activeLookupTable0, isWritable: true, isSigner: false },
64
+ { pubkey: params.activeLookupTable1, isWritable: true, isSigner: false },
65
+ { pubkey: system_1.SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
66
+ ];
67
+ return new web3_js_1.TransactionInstruction({
68
+ keys,
69
+ programId: constants_1.BASKETS_V3_PROGRAM_ID,
70
+ data: OVERWRITE_BASKET_LOOKUP_TABLES_DISCRIMINATOR,
71
+ });
72
+ }
73
+ function closeDeactivatedLookupTableIx(params) {
74
+ let lookupTableInfo = (0, pda_1.getLookupTableInfoAccount)(params.lookupTable);
75
+ const keys = [
76
+ { pubkey: params.rentPayer, isWritable: true, isSigner: false },
77
+ { pubkey: params.basket, isWritable: true, isSigner: false },
78
+ { pubkey: params.lookupTable, isWritable: true, isSigner: false },
79
+ { pubkey: lookupTableInfo, isWritable: true, isSigner: false },
80
+ { pubkey: constants_1.ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isWritable: false, isSigner: false },
81
+ { pubkey: system_1.SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
82
+ ];
83
+ return new web3_js_1.TransactionInstruction({
84
+ keys,
85
+ programId: constants_1.BASKETS_V3_PROGRAM_ID,
86
+ data: CLOSE_DEACTIVATED_LOOKUP_TABLE_DISCRIMINATOR,
87
+ });
88
+ }
@@ -0,0 +1,26 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ export declare const GLOBAL_CONFIG_SEED: Buffer;
3
+ export declare const BASKET_FEES_SEED: Buffer;
4
+ export declare const MINT_SEED: Buffer;
5
+ export declare const RENT_PAYER_SEED: Buffer;
6
+ export declare const BOUNTY_VAULT_SEED: Buffer;
7
+ export declare const REBALANCE_INTENT_SEED: Buffer;
8
+ export declare const WSOL_MINT: PublicKey;
9
+ export declare const USDC_MINT: PublicKey;
10
+ export declare const PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT: PublicKey;
11
+ export declare const PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT: PublicKey;
12
+ export declare const METADATA_PROGRAM_ID: PublicKey;
13
+ export declare function serializeString(input: string): Uint8Array;
14
+ export declare function getRandomSeed(): number[];
15
+ export declare function getBasketState(seeds: number[]): PublicKey;
16
+ export declare function getBountyVaultPda(): PublicKey;
17
+ export declare function getBasketTokenMintPda(basket: PublicKey): PublicKey;
18
+ export declare function getBasketFeesPda(basket: PublicKey): PublicKey;
19
+ export declare function getGlobalConfigPda(): PublicKey;
20
+ export declare function getIntentPda(basket: PublicKey, manager: PublicKey, editType: number): PublicKey;
21
+ export declare function getRebalanceIntentPda(basket: PublicKey, buyer: PublicKey): PublicKey;
22
+ export declare function getMetadataAccount(tokenMint: PublicKey): PublicKey;
23
+ export declare function getLookupTableAccount(creator: PublicKey, slot: number): PublicKey;
24
+ export declare function getLookupTableInfoAccount(lookupTable: PublicKey): PublicKey;
25
+ export declare function getAta(wallet: PublicKey, tokenMint: PublicKey): PublicKey;
26
+ export declare function getRentPayerPda(): PublicKey;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.METADATA_PROGRAM_ID = exports.PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT = exports.PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT = exports.USDC_MINT = exports.WSOL_MINT = exports.REBALANCE_INTENT_SEED = exports.BOUNTY_VAULT_SEED = exports.RENT_PAYER_SEED = exports.MINT_SEED = exports.BASKET_FEES_SEED = exports.GLOBAL_CONFIG_SEED = void 0;
4
+ exports.serializeString = serializeString;
5
+ exports.getRandomSeed = getRandomSeed;
6
+ exports.getBasketState = getBasketState;
7
+ exports.getBountyVaultPda = getBountyVaultPda;
8
+ exports.getBasketTokenMintPda = getBasketTokenMintPda;
9
+ exports.getBasketFeesPda = getBasketFeesPda;
10
+ exports.getGlobalConfigPda = getGlobalConfigPda;
11
+ exports.getIntentPda = getIntentPda;
12
+ exports.getRebalanceIntentPda = getRebalanceIntentPda;
13
+ exports.getMetadataAccount = getMetadataAccount;
14
+ exports.getLookupTableAccount = getLookupTableAccount;
15
+ exports.getLookupTableInfoAccount = getLookupTableInfoAccount;
16
+ exports.getAta = getAta;
17
+ exports.getRentPayerPda = getRentPayerPda;
18
+ const web3_js_1 = require("@solana/web3.js");
19
+ const js_1 = require("@metaplex-foundation/js");
20
+ const spl_token_1 = require("@solana/spl-token");
21
+ const uuid_1 = require("uuid");
22
+ const constants_1 = require("../constants");
23
+ exports.GLOBAL_CONFIG_SEED = Buffer.from("global_config");
24
+ exports.BASKET_FEES_SEED = Buffer.from("basket_fees");
25
+ exports.MINT_SEED = Buffer.from("mint");
26
+ exports.RENT_PAYER_SEED = Buffer.from("rent_payer");
27
+ exports.BOUNTY_VAULT_SEED = Buffer.from("bounty_vault");
28
+ exports.REBALANCE_INTENT_SEED = Buffer.from("rebalance_intent");
29
+ exports.WSOL_MINT = new web3_js_1.PublicKey("So11111111111111111111111111111111111111112");
30
+ /// TODO: Devnet
31
+ exports.USDC_MINT = new web3_js_1.PublicKey("USDCoctVLVnvTXBEuP9s8hntucdJokbo17RwHuNXemT");
32
+ exports.PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT = new web3_js_1.PublicKey("Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX");
33
+ exports.PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT = new web3_js_1.PublicKey("7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE");
34
+ exports.METADATA_PROGRAM_ID = new web3_js_1.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
35
+ function serializeString(input) {
36
+ const utf8 = new TextEncoder().encode(input);
37
+ const length = utf8.length;
38
+ const out = new Uint8Array(4 + length);
39
+ // encode length as little-endian u32
40
+ out[0] = length & 0xff;
41
+ out[1] = (length >> 8) & 0xff;
42
+ out[2] = (length >> 16) & 0xff;
43
+ out[3] = (length >> 24) & 0xff;
44
+ // copy utf8 bytes after the 4-byte length
45
+ out.set(utf8, 4);
46
+ return out;
47
+ }
48
+ function getRandomSeed() {
49
+ return Array.from((0, uuid_1.parse)((0, uuid_1.v4)()));
50
+ }
51
+ function getBasketState(seeds) {
52
+ return web3_js_1.PublicKey.findProgramAddressSync([Uint8Array.from(seeds)], constants_1.BASKETS_V3_PROGRAM_ID)[0];
53
+ }
54
+ function getBountyVaultPda() {
55
+ return web3_js_1.PublicKey.findProgramAddressSync([
56
+ exports.BOUNTY_VAULT_SEED,
57
+ ], constants_1.BASKETS_V3_PROGRAM_ID)[0];
58
+ }
59
+ function getBasketTokenMintPda(basket) {
60
+ return web3_js_1.PublicKey.findProgramAddressSync([
61
+ exports.MINT_SEED,
62
+ basket.toBuffer()
63
+ ], constants_1.BASKETS_V3_PROGRAM_ID)[0];
64
+ }
65
+ function getBasketFeesPda(basket) {
66
+ return web3_js_1.PublicKey.findProgramAddressSync([
67
+ exports.BASKET_FEES_SEED,
68
+ basket.toBuffer()
69
+ ], constants_1.BASKETS_V3_PROGRAM_ID)[0];
70
+ }
71
+ function getGlobalConfigPda() {
72
+ return web3_js_1.PublicKey.findProgramAddressSync([
73
+ exports.GLOBAL_CONFIG_SEED
74
+ ], constants_1.BASKETS_V3_PROGRAM_ID)[0];
75
+ }
76
+ function getIntentPda(basket, manager, editType) {
77
+ return web3_js_1.PublicKey.findProgramAddressSync([
78
+ basket.toBuffer(),
79
+ manager.toBuffer(),
80
+ Uint8Array.from([editType]),
81
+ ], constants_1.BASKETS_V3_PROGRAM_ID)[0];
82
+ }
83
+ function getRebalanceIntentPda(basket, buyer) {
84
+ return web3_js_1.PublicKey.findProgramAddressSync([
85
+ exports.REBALANCE_INTENT_SEED,
86
+ basket.toBuffer(),
87
+ buyer.toBuffer(),
88
+ ], constants_1.BASKETS_V3_PROGRAM_ID)[0];
89
+ }
90
+ function getMetadataAccount(tokenMint) {
91
+ const metaplex = js_1.Metaplex.make(new web3_js_1.Connection("https://api.devnet.solana.com"));
92
+ return metaplex.nfts().pdas().metadata({ mint: tokenMint });
93
+ }
94
+ function getLookupTableAccount(creator, slot) {
95
+ const ixAndPubkey = web3_js_1.AddressLookupTableProgram.createLookupTable({
96
+ authority: creator,
97
+ recentSlot: slot,
98
+ payer: creator,
99
+ });
100
+ return ixAndPubkey[1];
101
+ }
102
+ function getLookupTableInfoAccount(lookupTable) {
103
+ return web3_js_1.PublicKey.findProgramAddressSync([lookupTable.toBuffer()], constants_1.BASKETS_V3_PROGRAM_ID)[0];
104
+ }
105
+ function getAta(wallet, tokenMint) {
106
+ return (0, spl_token_1.getAssociatedTokenAddressSync)(tokenMint, wallet, true);
107
+ }
108
+ function getRentPayerPda() {
109
+ return web3_js_1.PublicKey.findProgramAddressSync([exports.RENT_PAYER_SEED], constants_1.BASKETS_V3_PROGRAM_ID)[0];
110
+ }
@@ -0,0 +1,17 @@
1
+ import { PublicKey, TransactionInstruction } from '@solana/web3.js';
2
+ export declare const START_PRICE_UPDATES_DISCRIMINATOR: Buffer;
3
+ export declare function startPriceUpdatesIx(params: {
4
+ keeper: PublicKey;
5
+ basket: PublicKey;
6
+ rebalanceIntent: PublicKey;
7
+ }): TransactionInstruction;
8
+ export declare const UPDATE_TOKEN_PRICES_DISCRIMINATOR: Buffer;
9
+ export declare function updateTokenPricesIx(params: {
10
+ keeper: PublicKey;
11
+ basket: PublicKey;
12
+ rebalanceIntent: PublicKey;
13
+ lookupTable0: PublicKey;
14
+ lookupTable1: PublicKey;
15
+ tokenIndices: number[];
16
+ additionalOracleAccounts: PublicKey[];
17
+ }): TransactionInstruction;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UPDATE_TOKEN_PRICES_DISCRIMINATOR = exports.START_PRICE_UPDATES_DISCRIMINATOR = void 0;
4
+ exports.startPriceUpdatesIx = startPriceUpdatesIx;
5
+ exports.updateTokenPricesIx = updateTokenPricesIx;
6
+ const web3_js_1 = require("@solana/web3.js");
7
+ const constants_1 = require("../constants");
8
+ exports.START_PRICE_UPDATES_DISCRIMINATOR = Buffer.from([240, 67, 241, 88, 0, 32, 224, 184]);
9
+ function startPriceUpdatesIx(params) {
10
+ const keys = [
11
+ { pubkey: params.keeper, isSigner: true, isWritable: true },
12
+ { pubkey: params.basket, isSigner: false, isWritable: false },
13
+ { pubkey: params.rebalanceIntent, isSigner: false, isWritable: true },
14
+ ];
15
+ const data = exports.START_PRICE_UPDATES_DISCRIMINATOR;
16
+ return new web3_js_1.TransactionInstruction({
17
+ keys,
18
+ programId: constants_1.BASKETS_V3_PROGRAM_ID,
19
+ data,
20
+ });
21
+ }
22
+ ;
23
+ exports.UPDATE_TOKEN_PRICES_DISCRIMINATOR = Buffer.from([147, 87, 140, 33, 214, 189, 181, 242]);
24
+ function updateTokenPricesIx(params) {
25
+ const [globalConfigPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("global_config")], constants_1.BASKETS_V3_PROGRAM_ID);
26
+ const data = Buffer.concat([
27
+ Buffer.from(exports.UPDATE_TOKEN_PRICES_DISCRIMINATOR), // 8 bytes
28
+ Buffer.from(params.tokenIndices)
29
+ ]);
30
+ const keys = [
31
+ { pubkey: params.keeper, isSigner: true, isWritable: true },
32
+ { pubkey: params.basket, isSigner: false, isWritable: true },
33
+ { pubkey: params.rebalanceIntent, isSigner: false, isWritable: true },
34
+ { pubkey: globalConfigPda, isSigner: false, isWritable: false },
35
+ { pubkey: constants_1.PYTH_SOL_ACCOUNT, isSigner: false, isWritable: true },
36
+ { pubkey: constants_1.PYTH_USDC_ACCOUNT, isSigner: false, isWritable: true },
37
+ { pubkey: params.lookupTable0, isSigner: false, isWritable: true },
38
+ { pubkey: params.lookupTable1, isSigner: false, isWritable: true },
39
+ ];
40
+ // remaining accounts
41
+ keys.push(...params.additionalOracleAccounts.map((pubkey) => ({ pubkey, isSigner: false, isWritable: false })));
42
+ return new web3_js_1.TransactionInstruction({
43
+ keys,
44
+ programId: constants_1.BASKETS_V3_PROGRAM_ID,
45
+ data
46
+ });
47
+ }
@@ -0,0 +1,32 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import { TransactionInstruction } from "@solana/web3.js";
3
+ export declare function createUserRebalanceIntentIx(params: {
4
+ user: PublicKey;
5
+ basket: PublicKey;
6
+ }): TransactionInstruction;
7
+ export declare function resizeRebalanceIntentIx(rebalanceIntent: PublicKey): TransactionInstruction;
8
+ export declare function depositStateIx(params: {
9
+ buyer: PublicKey;
10
+ basket: PublicKey;
11
+ bountyMint: PublicKey;
12
+ rebalanceIntentRentPayer: PublicKey;
13
+ rebalanceSlippageBps: number;
14
+ executionStartTime: number;
15
+ }): TransactionInstruction;
16
+ export declare function depositTokensIx(params: {
17
+ owner: PublicKey;
18
+ basket: PublicKey;
19
+ contributions: {
20
+ mint: PublicKey;
21
+ amount: number;
22
+ }[];
23
+ }): TransactionInstruction;
24
+ export declare function lockDepositsIx(params: {
25
+ owner: PublicKey;
26
+ basket: PublicKey;
27
+ }): TransactionInstruction;
28
+ export declare function mintBasketIx(params: {
29
+ keeper: PublicKey;
30
+ basket: PublicKey;
31
+ buyer: PublicKey;
32
+ }): TransactionInstruction;