@symmetry-hq/temp-v3-sdk 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +2 -2
- package/dist/src/states/oracles/pythOracle.d.ts +3 -3
- package/dist/src/txUtils.d.ts +13 -2
- package/dist/src/txUtils.js +5 -7
- package/package.json +3 -3
- package/src/index.ts +4 -4
- package/src/states/oracles/pythOracle.ts +3 -4
- package/src/txUtils.ts +18 -11
- package/dist/idl/idl.d.ts +0 -8
- package/dist/idl/idl.js +0 -4958
- package/dist/idl/types.d.ts +0 -4955
- package/dist/idl/types.js +0 -2
- package/dist/index.d.ts +0 -24
- package/dist/index.js +0 -60
- package/dist/layouts/basket.d.ts +0 -42
- package/dist/layouts/basket.js +0 -43
- package/dist/layouts/config.d.ts +0 -97
- package/dist/layouts/config.js +0 -102
- package/dist/layouts/fraction.d.ts +0 -6
- package/dist/layouts/fraction.js +0 -9
- package/dist/layouts/oracle.d.ts +0 -36
- package/dist/layouts/oracle.js +0 -37
- package/dist/src/idl/idl.d.ts +0 -8
- package/dist/src/idl/idl.js +0 -4958
- package/dist/src/idl/types.d.ts +0 -4955
- package/dist/src/idl/types.js +0 -2
- package/dist/src/instructions/accounts.d.ts +0 -27
- package/dist/src/instructions/accounts.js +0 -110
- package/dist/src/instructions/auction.d.ts +0 -7
- package/dist/src/instructions/auction.js +0 -43
- package/dist/src/instructions/basket.d.ts +0 -120
- package/dist/src/instructions/basket.js +0 -622
- package/dist/src/instructions/bounty.d.ts +0 -18
- package/dist/src/instructions/bounty.js +0 -81
- package/dist/src/instructions/fee.d.ts +0 -8
- package/dist/src/instructions/fee.js +0 -46
- package/dist/src/instructions/globalConfig.d.ts +0 -11
- package/dist/src/instructions/globalConfig.js +0 -43
- package/dist/src/instructions/luts.d.ts +0 -33
- package/dist/src/instructions/luts.js +0 -91
- package/dist/src/instructions/price.d.ts +0 -17
- package/dist/src/instructions/price.js +0 -47
- package/dist/src/states/oracles/clmm_oracle.d.ts +0 -178
- package/dist/src/states/oracles/clmm_oracle.js +0 -546
- package/dist/src/states/oracles/pyth_oracle.d.ts +0 -39
- package/dist/src/states/oracles/pyth_oracle.js +0 -202
- package/dist/src/states/oracles/raydium_cpmm_oracle.d.ts +0 -139
- package/dist/src/states/oracles/raydium_cpmm_oracle.js +0 -420
- package/dist/src/states/oracles/switchboard_oracle.d.ts +0 -0
- package/dist/src/states/oracles/switchboard_oracle.js +0 -1
- package/dist/states/basket.d.ts +0 -8
- package/dist/states/basket.js +0 -57
|
@@ -1,622 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RESIZE_REBALANCE_INTENT_HANDLER = exports.CREATE_USER_REBALANCE_INTENT_ACCOUNT = exports.RESIZE_BASKET_STATE_DISCRIMINATOR = exports.REDEEM_TOKENS_DISCRIMINATOR = exports.REBALANCE_SWAP_DISCRIMINATOR = exports.MINT_BASKET_DISCRIMINATOR = exports.LOCK_DEPOSITS_DISCRIMINATOR = exports.EDIT_PRIVATE_BASKET_SETTINGS_DISCRIMINATOR = exports.EDIT_BASKET_DISCRIMINATOR = exports.DEPOSIT_TOKENS_DISCRIMINATOR = exports.CREATE_WITHDRAW_STATE_DISCRIMINATOR = exports.EDIT_BASKET_INTENT_DISCRIMINATOR = exports.CREATE_BASKET_STATE_ACCOUNT_DISCRIMINATOR = exports.CREATE_BASKET_DISCRIMINATOR = void 0;
|
|
4
|
-
exports.createBasketIx = createBasketIx;
|
|
5
|
-
exports.createBasketStateAccountIx = createBasketStateAccountIx;
|
|
6
|
-
exports.depositStateIx = depositStateIx;
|
|
7
|
-
exports.createEditBasketIntentIx = createEditBasketIntentIx;
|
|
8
|
-
exports.createWithdrawStateIx = createWithdrawStateIx;
|
|
9
|
-
exports.depositTokensIx = depositTokensIx;
|
|
10
|
-
exports.editBasketIx = editBasketIx;
|
|
11
|
-
exports.editPrivateBasketSettingsIx = editPrivateBasketSettingsIx;
|
|
12
|
-
exports.lockDepositsIx = lockDepositsIx;
|
|
13
|
-
exports.mintBasketIx = mintBasketIx;
|
|
14
|
-
exports.rebalanceSwapIx = rebalanceSwapIx;
|
|
15
|
-
exports.redeemTokensIx = redeemTokensIx;
|
|
16
|
-
exports.resizeBasketStateIx = resizeBasketStateIx;
|
|
17
|
-
exports.createUserRebalanceIntentIx = createUserRebalanceIntentIx;
|
|
18
|
-
exports.resizeRebalanceIntentIx = resizeRebalanceIntentIx;
|
|
19
|
-
const anchor_1 = require("@coral-xyz/anchor");
|
|
20
|
-
const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
|
|
21
|
-
const spl_token_1 = require("@solana/spl-token");
|
|
22
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
23
|
-
const constants_1 = require("../constants");
|
|
24
|
-
const intent_1 = require("../layouts/intents/intent");
|
|
25
|
-
const config_1 = require("../layouts/config");
|
|
26
|
-
const intent_2 = require("../layouts/intents/intent");
|
|
27
|
-
// import {
|
|
28
|
-
// AddTokenDelayLayout, AddTokenLayout, AuthorityBitmasksLayout, AutomationSettingsLayout,
|
|
29
|
-
// EditDataManagerSettingsLayout, EditPrivateBasketLayout, FeeSettingsLayout, HostFeesLayout,
|
|
30
|
-
// LpSettingsLayout, ManagerSettingsLayout, MetadataParamsLayout, MetadataSettingsLayout,
|
|
31
|
-
// ScheduleSettingsLayout, UpdateWeightsDelayLayout, UpdateWeightsLayout
|
|
32
|
-
// } from '../layouts';
|
|
33
|
-
// import {
|
|
34
|
-
// AdditionalAccounts, AddToken, AddTokenDelay, AuthorityBitmasks, AutomationSettings, EditData,
|
|
35
|
-
// EditDataManagerSettings, FeeSettings, HostFees, LpSettings, ManagerSettings, MetadataParams,
|
|
36
|
-
// MetadataSettings, ScheduleSettings, Swap, TaskType, UpdateWeights, UpdateWeightsDelay
|
|
37
|
-
// } from '../types';
|
|
38
|
-
function serializeString(input) {
|
|
39
|
-
const utf8 = new TextEncoder().encode(input);
|
|
40
|
-
const length = utf8.length;
|
|
41
|
-
const out = new Uint8Array(4 + length);
|
|
42
|
-
// encode length as little-endian u32
|
|
43
|
-
out[0] = length & 0xff;
|
|
44
|
-
out[1] = (length >> 8) & 0xff;
|
|
45
|
-
out[2] = (length >> 16) & 0xff;
|
|
46
|
-
out[3] = (length >> 24) & 0xff;
|
|
47
|
-
// copy utf8 bytes after the 4-byte length
|
|
48
|
-
out.set(utf8, 4);
|
|
49
|
-
return out;
|
|
50
|
-
}
|
|
51
|
-
exports.CREATE_BASKET_DISCRIMINATOR = Buffer.from([175, 138, 181, 18, 46, 58, 146, 159]);
|
|
52
|
-
function createBasketIx(params) {
|
|
53
|
-
const discriminator = exports.CREATE_BASKET_DISCRIMINATOR;
|
|
54
|
-
const hostFeesBuffer = Buffer.alloc(intent_1.HostFeesLayout.span);
|
|
55
|
-
const feeSettingsLen = intent_1.HostFeesLayout.encode(params.hostFees, hostFeesBuffer);
|
|
56
|
-
if (feeSettingsLen > hostFeesBuffer.length)
|
|
57
|
-
throw new Error(`FeeSettings encoded ${feeSettingsLen} > buffer ${hostFeesBuffer.length}`);
|
|
58
|
-
const data = Buffer.concat([
|
|
59
|
-
discriminator,
|
|
60
|
-
Buffer.from(params.basketSeeds),
|
|
61
|
-
Buffer.from(params.slot.toArray("le", 8)),
|
|
62
|
-
params.host.toBuffer(),
|
|
63
|
-
Buffer.from(params.startPrice.numerator.toArray("le", 8)),
|
|
64
|
-
Buffer.from(params.startPrice.exponent.toArray("le", 8)),
|
|
65
|
-
hostFeesBuffer,
|
|
66
|
-
serializeString(params.metadataParams.name),
|
|
67
|
-
serializeString(params.metadataParams.symbol),
|
|
68
|
-
serializeString(params.metadataParams.uri),
|
|
69
|
-
Buffer.from(params.metadataModificationDelay.toArray("le", 8)),
|
|
70
|
-
]);
|
|
71
|
-
const [basket] = web3_js_1.PublicKey.findProgramAddressSync([params.basketSeeds], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
72
|
-
const wsolBasketTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.WSOL_MINT, basket, true);
|
|
73
|
-
const usdcBasketTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.USDC_MINT, basket, true);
|
|
74
|
-
const [basketTokenMint] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("mint"), basket.toBuffer()], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
75
|
-
const [lookupTableInfo0] = web3_js_1.PublicKey.findProgramAddressSync([params.lookupTable0.toBuffer()], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
76
|
-
const [lookupTableInfo1] = web3_js_1.PublicKey.findProgramAddressSync([params.lookupTable1.toBuffer()], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
77
|
-
const [rentPayerPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("rent_payer")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
78
|
-
const keys = [
|
|
79
|
-
{ pubkey: params.creator, isSigner: true, isWritable: true },
|
|
80
|
-
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
81
|
-
{ pubkey: basketTokenMint, isSigner: false, isWritable: true },
|
|
82
|
-
{ pubkey: params.metadataAccount, isSigner: false, isWritable: true },
|
|
83
|
-
{ pubkey: params.lookupTable0, isSigner: false, isWritable: true },
|
|
84
|
-
{ pubkey: params.lookupTable1, isSigner: false, isWritable: true },
|
|
85
|
-
{ pubkey: lookupTableInfo0, isSigner: false, isWritable: true },
|
|
86
|
-
{ pubkey: lookupTableInfo1, isSigner: false, isWritable: true },
|
|
87
|
-
{ pubkey: wsolBasketTokenAccount, isSigner: false, isWritable: true },
|
|
88
|
-
{ pubkey: constants_1.WSOL_MINT, isSigner: false, isWritable: true },
|
|
89
|
-
{ pubkey: constants_1.PYTH_SOL_ACCOUNT, isSigner: false, isWritable: true },
|
|
90
|
-
{ pubkey: usdcBasketTokenAccount, isSigner: false, isWritable: true },
|
|
91
|
-
{ pubkey: constants_1.USDC_MINT, isSigner: false, isWritable: true },
|
|
92
|
-
{ pubkey: constants_1.PYTH_USDC_ACCOUNT, isSigner: false, isWritable: true },
|
|
93
|
-
{ pubkey: rentPayerPda, isSigner: false, isWritable: true },
|
|
94
|
-
{ pubkey: constants_1.ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
95
|
-
{ pubkey: constants_1.METADATA_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
96
|
-
{ pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
|
|
97
|
-
{ pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
98
|
-
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
99
|
-
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
100
|
-
];
|
|
101
|
-
return new web3_js_1.TransactionInstruction({
|
|
102
|
-
keys,
|
|
103
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
104
|
-
data,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
exports.CREATE_BASKET_STATE_ACCOUNT_DISCRIMINATOR = Buffer.from([
|
|
108
|
-
119, 105, 241, 40, 193, 2, 32, 12,
|
|
109
|
-
]);
|
|
110
|
-
function createBasketStateAccountIx(params) {
|
|
111
|
-
if (params.basketSeeds.length !== 16) {
|
|
112
|
-
throw new Error("basketSeeds must be exactly 16 bytes");
|
|
113
|
-
}
|
|
114
|
-
const [basket] = web3_js_1.PublicKey.findProgramAddressSync([params.basketSeeds], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
115
|
-
const data = Buffer.concat([
|
|
116
|
-
exports.CREATE_BASKET_STATE_ACCOUNT_DISCRIMINATOR,
|
|
117
|
-
Buffer.from(params.basketSeeds),
|
|
118
|
-
]);
|
|
119
|
-
const [rentPayerPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("rent_payer")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
120
|
-
const keys = [
|
|
121
|
-
{ pubkey: params.creator, isSigner: true, isWritable: true },
|
|
122
|
-
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
123
|
-
{ pubkey: rentPayerPda, isSigner: false, isWritable: true },
|
|
124
|
-
{ pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
|
|
125
|
-
{ pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
126
|
-
];
|
|
127
|
-
return new web3_js_1.TransactionInstruction({
|
|
128
|
-
keys,
|
|
129
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
130
|
-
data,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
const DEPOSIT_STATE_DISCRIMINATOR = Buffer.from([66, 42, 217, 222, 49, 159, 36, 188]);
|
|
134
|
-
function depositStateIx(params) {
|
|
135
|
-
const { buyer, basket, bountyMint, rebalanceIntentRentPayer, rebalanceSlippageBps, executionStartTime, } = params;
|
|
136
|
-
const [rebalanceIntent] = web3_js_1.PublicKey.findProgramAddressSync([
|
|
137
|
-
Buffer.from("rebalance_intent"),
|
|
138
|
-
params.basket.toBuffer(),
|
|
139
|
-
params.buyer.toBuffer(),
|
|
140
|
-
], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
141
|
-
const [rentPayerPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("rent_payer")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
142
|
-
const [basketTokenMint] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("mint"), params.basket.toBuffer()], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
143
|
-
const [globalConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("global_config")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
144
|
-
const [bountyVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("bounty_vault")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
145
|
-
const buyerBountyAta = (0, spl_token_1.getAssociatedTokenAddressSync)(bountyMint, buyer, true);
|
|
146
|
-
const bountyVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(bountyMint, bountyVault, true);
|
|
147
|
-
const buyerBasketAta = (0, spl_token_1.getAssociatedTokenAddressSync)(basketTokenMint, buyer, true);
|
|
148
|
-
const discriminator = DEPOSIT_STATE_DISCRIMINATOR;
|
|
149
|
-
const rebalanceIntentRentPayerBuf = rebalanceIntentRentPayer.toBuffer();
|
|
150
|
-
const rebalanceSlippageBuf = Buffer.from(new anchor_1.BN(rebalanceSlippageBps).toArray("le", 2));
|
|
151
|
-
const executionStartBuf = Buffer.from(executionStartTime.toArray("le", 8));
|
|
152
|
-
const data = Buffer.concat([discriminator, rebalanceIntentRentPayerBuf, rebalanceSlippageBuf, executionStartBuf]);
|
|
153
|
-
const keys = [
|
|
154
|
-
{ pubkey: buyer, isSigner: true, isWritable: true },
|
|
155
|
-
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
156
|
-
{ pubkey: rebalanceIntent, isSigner: false, isWritable: true },
|
|
157
|
-
{ pubkey: rentPayerPda, isSigner: false, isWritable: true },
|
|
158
|
-
{ pubkey: basketTokenMint, isSigner: false, isWritable: false },
|
|
159
|
-
{ pubkey: buyerBasketAta, isSigner: false, isWritable: true },
|
|
160
|
-
{ pubkey: globalConfig, isSigner: false, isWritable: false },
|
|
161
|
-
{ pubkey: bountyMint, isSigner: false, isWritable: false },
|
|
162
|
-
{ pubkey: buyerBountyAta, isSigner: false, isWritable: true },
|
|
163
|
-
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
164
|
-
{ pubkey: bountyVaultAta, isSigner: false, isWritable: true },
|
|
165
|
-
{ pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
166
|
-
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
167
|
-
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
168
|
-
// { pubkey: rebalanceIntent, isSigner: false, isWritable: true } // remaining accounts
|
|
169
|
-
];
|
|
170
|
-
return new web3_js_1.TransactionInstruction({
|
|
171
|
-
keys,
|
|
172
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
173
|
-
data,
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
exports.EDIT_BASKET_INTENT_DISCRIMINATOR = Buffer.from([82, 150, 58, 227, 153, 129, 20, 30]);
|
|
177
|
-
function createEditBasketIntentIx(params) {
|
|
178
|
-
const { manager, basket, bountyMint, editType, editData, useBounty, } = params;
|
|
179
|
-
const [intent] = web3_js_1.PublicKey.findProgramAddressSync([
|
|
180
|
-
basket.toBuffer(),
|
|
181
|
-
manager.toBuffer(),
|
|
182
|
-
Buffer.from([editType]),
|
|
183
|
-
], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
184
|
-
const [globalConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("global_config")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
185
|
-
const [bountyVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("bounty_vault")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
186
|
-
const managerBountyATA = (0, spl_token_1.getAssociatedTokenAddressSync)(bountyMint, manager, true);
|
|
187
|
-
const bountyVaultATA = (0, spl_token_1.getAssociatedTokenAddressSync)(bountyMint, bountyVault, true);
|
|
188
|
-
const discriminator = exports.EDIT_BASKET_INTENT_DISCRIMINATOR;
|
|
189
|
-
const editTypeBuf = Buffer.from([editType]);
|
|
190
|
-
const keys = [
|
|
191
|
-
{ pubkey: manager, isSigner: true, isWritable: true },
|
|
192
|
-
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
193
|
-
{ pubkey: intent, isSigner: false, isWritable: true },
|
|
194
|
-
{ pubkey: globalConfig, isSigner: false, isWritable: false },
|
|
195
|
-
{ pubkey: bountyMint, isSigner: false, isWritable: false },
|
|
196
|
-
{ pubkey: managerBountyATA, isSigner: false, isWritable: true },
|
|
197
|
-
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
198
|
-
{ pubkey: bountyVaultATA, isSigner: false, isWritable: true },
|
|
199
|
-
{ pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
200
|
-
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
201
|
-
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
202
|
-
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
203
|
-
];
|
|
204
|
-
const editDataBuf = Buffer.alloc(260);
|
|
205
|
-
switch (editType) {
|
|
206
|
-
case intent_1.TaskType.EditSchedule: // 1
|
|
207
|
-
config_1.ScheduleSettingsLayout.encode(editData, editDataBuf);
|
|
208
|
-
break;
|
|
209
|
-
case intent_1.TaskType.EditFeeSettings: // 2
|
|
210
|
-
config_1.FeeSettingsLayout.encode(editData, editDataBuf);
|
|
211
|
-
break;
|
|
212
|
-
case intent_1.TaskType.EditManagerSettings: // 3
|
|
213
|
-
// TODO: ?????
|
|
214
|
-
intent_1.ManagerSettingsWithAuthorityBitmasksLayout.encode(editData, editDataBuf)(editData).managers.forEach((managerPubkey) => {
|
|
215
|
-
keys.push({ pubkey: managerPubkey, isWritable: true, isSigner: false });
|
|
216
|
-
});
|
|
217
|
-
break;
|
|
218
|
-
case intent_1.TaskType.EditAutomationSettings: // 4
|
|
219
|
-
config_1.AutomationSettingsLayout.encode(editData, editDataBuf);
|
|
220
|
-
break;
|
|
221
|
-
case intent_1.TaskType.EditLpSettings: // 5
|
|
222
|
-
config_1.LpSettingsLayout.encode(editData, editDataBuf);
|
|
223
|
-
break;
|
|
224
|
-
case intent_1.TaskType.EditMetadataSettings: // 6
|
|
225
|
-
config_1.MetadataSettingsLayout.encode(editData, editDataBuf);
|
|
226
|
-
break;
|
|
227
|
-
case intent_1.TaskType.EditAddTokenDelay: // 7
|
|
228
|
-
intent_2.AddTokenDelayLayout.encode(editData, editDataBuf);
|
|
229
|
-
break;
|
|
230
|
-
case intent_1.TaskType.EditUpdateWeightsDelay: // 8
|
|
231
|
-
intent_2.UpdateWeightsDelayLayout.encode(editData, editDataBuf);
|
|
232
|
-
break;
|
|
233
|
-
// case TaskType.AddToken: // 9
|
|
234
|
-
// AddTokenLayout.encode(editData as AddToken, editDataBuf);
|
|
235
|
-
// keys.push({pubkey: (editData as AddToken).tokenMint, isWritable: false, isSigner: false});
|
|
236
|
-
// const basketNewTokenAta = getAssociatedTokenAddressSync(
|
|
237
|
-
// (editData as AddToken).tokenMint,
|
|
238
|
-
// basket,
|
|
239
|
-
// true
|
|
240
|
-
// );
|
|
241
|
-
// keys.push({pubkey: basketNewTokenAta, isWritable: true, isSigner: false});
|
|
242
|
-
// additionalAccounts.lookupTables.forEach((lookupTablePubkey) => {
|
|
243
|
-
// keys.push({ pubkey: lookupTablePubkey, isWritable: true, isSigner: false });
|
|
244
|
-
// });
|
|
245
|
-
// additionalAccounts.additionalOracleAccounts.forEach((oraclePubkey) => {
|
|
246
|
-
// keys.push({ pubkey: oraclePubkey, isWritable: false, isSigner: false });
|
|
247
|
-
// });
|
|
248
|
-
// break;
|
|
249
|
-
case intent_1.TaskType.UpdateWeights: // 10
|
|
250
|
-
intent_1.UpdateWeightsLayout.encode(editData, editDataBuf);
|
|
251
|
-
break;
|
|
252
|
-
case intent_1.TaskType.Swap: // 11
|
|
253
|
-
break;
|
|
254
|
-
default:
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
const useBountyBuf = Buffer.from([useBounty]);
|
|
258
|
-
const data = Buffer.concat([
|
|
259
|
-
discriminator,
|
|
260
|
-
editTypeBuf,
|
|
261
|
-
editDataBuf,
|
|
262
|
-
useBountyBuf,
|
|
263
|
-
]);
|
|
264
|
-
if (editType === intent_1.TaskType.EditManagerSettings) {
|
|
265
|
-
}
|
|
266
|
-
return new web3_js_1.TransactionInstruction({
|
|
267
|
-
keys,
|
|
268
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
269
|
-
data,
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
exports.CREATE_WITHDRAW_STATE_DISCRIMINATOR = Buffer.from([161, 45, 253, 59, 110, 240, 65, 3]);
|
|
273
|
-
function createWithdrawStateIx(params) {
|
|
274
|
-
const { seller, basket, withdrawAmount, rebalanceSlippageBps, executionStartTime, bountyMint, } = params;
|
|
275
|
-
const [rebalanceIntent] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("rebalance_intent"), params.basket.toBuffer(), params.seller.toBuffer()], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
276
|
-
const [rentPayerPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("rent_payer")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
277
|
-
const [basketTokenMint] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("mint"), params.basket.toBuffer()], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
278
|
-
const [globalConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("global_config")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
279
|
-
const [bountyVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("bounty_vault")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
280
|
-
const sellerBasketAta = (0, spl_token_1.getAssociatedTokenAddressSync)(basketTokenMint, seller, true);
|
|
281
|
-
const sellerBountyAta = (0, spl_token_1.getAssociatedTokenAddressSync)(bountyMint, seller, true);
|
|
282
|
-
const bountyVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(bountyMint, bountyVault, true);
|
|
283
|
-
const [basketRebalanceIntent] = web3_js_1.PublicKey.findProgramAddressSync([
|
|
284
|
-
Buffer.from("rebalance_intent"),
|
|
285
|
-
params.basket.toBuffer(),
|
|
286
|
-
seller.toBuffer(),
|
|
287
|
-
], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
288
|
-
const discriminator = exports.CREATE_WITHDRAW_STATE_DISCRIMINATOR;
|
|
289
|
-
const data = Buffer.concat([
|
|
290
|
-
discriminator,
|
|
291
|
-
Buffer.from(withdrawAmount.toArray("le", 8)),
|
|
292
|
-
Buffer.from(new anchor_1.BN(rebalanceSlippageBps).toArray("le", 2)),
|
|
293
|
-
Buffer.from(executionStartTime.toArray("le", 8)),
|
|
294
|
-
]);
|
|
295
|
-
const keys = [
|
|
296
|
-
{ pubkey: seller, isSigner: true, isWritable: true },
|
|
297
|
-
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
298
|
-
{ pubkey: basketRebalanceIntent, isSigner: false, isWritable: true },
|
|
299
|
-
{ pubkey: rebalanceIntent, isSigner: false, isWritable: true },
|
|
300
|
-
{ pubkey: rentPayerPda, isSigner: false, isWritable: true },
|
|
301
|
-
{ pubkey: basketTokenMint, isSigner: false, isWritable: false },
|
|
302
|
-
{ pubkey: sellerBasketAta, isSigner: false, isWritable: true },
|
|
303
|
-
{ pubkey: globalConfig, isSigner: false, isWritable: false },
|
|
304
|
-
{ pubkey: bountyMint, isSigner: false, isWritable: false },
|
|
305
|
-
{ pubkey: sellerBountyAta, isSigner: false, isWritable: true },
|
|
306
|
-
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
307
|
-
{ pubkey: bountyVaultAta, isSigner: false, isWritable: true },
|
|
308
|
-
{ pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
309
|
-
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
310
|
-
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
311
|
-
{ pubkey: rebalanceIntent, isSigner: false, isWritable: false } // remaining accounts
|
|
312
|
-
];
|
|
313
|
-
return new web3_js_1.TransactionInstruction({
|
|
314
|
-
keys,
|
|
315
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
316
|
-
data,
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
exports.DEPOSIT_TOKENS_DISCRIMINATOR = Buffer.from([88, 92, 158, 219, 83, 71, 239, 164]);
|
|
320
|
-
function depositTokensIx(params) {
|
|
321
|
-
const { owner, basket, contributionAmounts, tokenMints } = params;
|
|
322
|
-
const [rebalanceIntentPda] = web3_js_1.PublicKey.findProgramAddressSync([
|
|
323
|
-
Buffer.from("rebalance_intent"),
|
|
324
|
-
basket.toBuffer(),
|
|
325
|
-
owner.toBuffer(),
|
|
326
|
-
], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
327
|
-
const discriminator = exports.DEPOSIT_TOKENS_DISCRIMINATOR;
|
|
328
|
-
const amountsBuffer = Buffer.concat(contributionAmounts.map((amt) => Buffer.from(amt.toArray("le", 8))));
|
|
329
|
-
const data = Buffer.concat([discriminator, amountsBuffer]);
|
|
330
|
-
const keys = [
|
|
331
|
-
{ pubkey: owner, isSigner: true, isWritable: true },
|
|
332
|
-
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
333
|
-
{ pubkey: rebalanceIntentPda, isSigner: false, isWritable: true },
|
|
334
|
-
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
335
|
-
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
336
|
-
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
337
|
-
{ pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
338
|
-
];
|
|
339
|
-
// remaining accounts
|
|
340
|
-
tokenMints.forEach((mint) => {
|
|
341
|
-
keys.push({ pubkey: mint, isSigner: false, isWritable: false });
|
|
342
|
-
const ownerAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mint, owner);
|
|
343
|
-
keys.push({ pubkey: ownerAta, isSigner: false, isWritable: true });
|
|
344
|
-
const basketAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mint, basket);
|
|
345
|
-
keys.push({ pubkey: basketAta, isSigner: false, isWritable: true });
|
|
346
|
-
});
|
|
347
|
-
return new web3_js_1.TransactionInstruction({
|
|
348
|
-
keys,
|
|
349
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
350
|
-
data,
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
exports.EDIT_BASKET_DISCRIMINATOR = Buffer.from([156, 31, 4, 39, 248, 29, 55, 220]);
|
|
354
|
-
function editBasketIx(params) {
|
|
355
|
-
const { keeper, basket, intent, bountyMint, manager } = params;
|
|
356
|
-
const [globalConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("global_config")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
357
|
-
const [bountyVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("bounty_vault")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
358
|
-
const keeperBountyATA = (0, spl_token_1.getAssociatedTokenAddressSync)(bountyMint, keeper);
|
|
359
|
-
const managerBountyATA = (0, spl_token_1.getAssociatedTokenAddressSync)(bountyMint, manager);
|
|
360
|
-
const bountyVaultATA = (0, spl_token_1.getAssociatedTokenAddressSync)(bountyMint, bountyVault);
|
|
361
|
-
// discriminator
|
|
362
|
-
const data = exports.EDIT_BASKET_DISCRIMINATOR;
|
|
363
|
-
// accounts
|
|
364
|
-
const keys = [
|
|
365
|
-
{ pubkey: keeper, isSigner: true, isWritable: true },
|
|
366
|
-
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
367
|
-
{ pubkey: intent, isSigner: false, isWritable: true },
|
|
368
|
-
{ pubkey: globalConfig, isSigner: false, isWritable: true },
|
|
369
|
-
{ pubkey: bountyMint, isSigner: false, isWritable: false },
|
|
370
|
-
{ pubkey: keeperBountyATA, isSigner: false, isWritable: true },
|
|
371
|
-
{ pubkey: manager, isSigner: false, isWritable: true },
|
|
372
|
-
{ pubkey: managerBountyATA, isSigner: false, isWritable: true },
|
|
373
|
-
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
374
|
-
{ pubkey: bountyVaultATA, isSigner: false, isWritable: true },
|
|
375
|
-
{ pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
376
|
-
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
377
|
-
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
378
|
-
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
379
|
-
];
|
|
380
|
-
// remaining accounts
|
|
381
|
-
if (params.editType === intent_1.TaskType.EditMetadataSettings) {
|
|
382
|
-
keys.push({ pubkey: params.basket, isSigner: true, isWritable: false });
|
|
383
|
-
keys.push({ pubkey: params.metadataAccount, isSigner: false, isWritable: true });
|
|
384
|
-
keys.push({ pubkey: constants_1.METADATA_PROGRAM_ID, isSigner: false, isWritable: false });
|
|
385
|
-
}
|
|
386
|
-
;
|
|
387
|
-
// if(params.editType === TaskType.AddToken){
|
|
388
|
-
// params.lookupTables.forEach((lookupTablePubkey) => {
|
|
389
|
-
// keys.push({ pubkey: lookupTablePubkey, isWritable: false, isSigner: false });
|
|
390
|
-
// });
|
|
391
|
-
// };
|
|
392
|
-
return new web3_js_1.TransactionInstruction({
|
|
393
|
-
keys,
|
|
394
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
395
|
-
data,
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
exports.EDIT_PRIVATE_BASKET_SETTINGS_DISCRIMINATOR = Buffer.from([202, 54, 138, 17, 3, 104, 128, 229]);
|
|
399
|
-
function editPrivateBasketSettingsIx(params) {
|
|
400
|
-
const [metadataAccount] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), params.basket.toBuffer()], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
401
|
-
const [globalConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("global_config")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
402
|
-
const discriminator = exports.EDIT_PRIVATE_BASKET_SETTINGS_DISCRIMINATOR;
|
|
403
|
-
const scheduleSettingsBuffer = Buffer.alloc(config_1.ScheduleSettingsLayout.span);
|
|
404
|
-
const scheduleBytesLen = config_1.ScheduleSettingsLayout.encode(params.scheduleBytes, scheduleSettingsBuffer);
|
|
405
|
-
const feeSettingsBuffer = Buffer.alloc(config_1.FeeSettingsLayout.span);
|
|
406
|
-
const feeSettingsBytesLen = config_1.FeeSettingsLayout.encode(params.feeSettingsBytes, feeSettingsBuffer);
|
|
407
|
-
const managerSettingsBuffer = Buffer.alloc(config_1.ManagerSettingsLayout.span);
|
|
408
|
-
const managerSettingsBytesLen = config_1.ManagerSettingsLayout.encode(params.managerSettingsBytes, managerSettingsBuffer);
|
|
409
|
-
const automationSettingsBuffer = Buffer.alloc(config_1.AutomationSettingsLayout.span);
|
|
410
|
-
const automationSettingsBytesLen = config_1.AutomationSettingsLayout.encode(params.automationSettingsBytes, automationSettingsBuffer);
|
|
411
|
-
const lpSettingsBuffer = Buffer.alloc(config_1.LpSettingsLayout.span);
|
|
412
|
-
const lpSettingsByteslen = config_1.LpSettingsLayout.encode(params.lpSettingsBytes, lpSettingsBuffer);
|
|
413
|
-
const authorityBitmasksBuffer = Buffer.alloc(intent_1.AuthorityBitmasksLayout.span);
|
|
414
|
-
const authorityBitmasksBytesLen = intent_1.AuthorityBitmasksLayout.encode(params.authorityBitmasks, authorityBitmasksBuffer);
|
|
415
|
-
const metadataParamsBuffer = Buffer.alloc(intent_1.MetadataParamsLayout.span);
|
|
416
|
-
const metadataParamsBytesLen = intent_1.MetadataParamsLayout.encode(params.metadataParams, metadataParamsBuffer);
|
|
417
|
-
const data = Buffer.concat([
|
|
418
|
-
discriminator,
|
|
419
|
-
Buffer.from([params.basketType]),
|
|
420
|
-
scheduleSettingsBuffer,
|
|
421
|
-
feeSettingsBuffer,
|
|
422
|
-
managerSettingsBuffer,
|
|
423
|
-
automationSettingsBuffer,
|
|
424
|
-
lpSettingsBuffer,
|
|
425
|
-
authorityBitmasksBuffer,
|
|
426
|
-
serializeString(params.metadataParams.name),
|
|
427
|
-
serializeString(params.metadataParams.symbol),
|
|
428
|
-
serializeString(params.metadataParams.uri),
|
|
429
|
-
Buffer.from(params.metadataModificationDelay.toArray("le", 8)),
|
|
430
|
-
]);
|
|
431
|
-
const keys = [
|
|
432
|
-
{ pubkey: params.creator, isSigner: true, isWritable: true },
|
|
433
|
-
{ pubkey: params.basket, isSigner: false, isWritable: true },
|
|
434
|
-
{ pubkey: metadataAccount, isSigner: false, isWritable: true },
|
|
435
|
-
{ pubkey: globalConfig, isSigner: false, isWritable: false },
|
|
436
|
-
{ pubkey: constants_1.METADATA_PROGRAM_ID, isSigner: false, isWritable: false }
|
|
437
|
-
];
|
|
438
|
-
return new web3_js_1.TransactionInstruction({
|
|
439
|
-
keys,
|
|
440
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
441
|
-
data
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
exports.LOCK_DEPOSITS_DISCRIMINATOR = Buffer.from([64, 238, 171, 198, 135, 253, 37, 9]);
|
|
445
|
-
function lockDepositsIx(params) {
|
|
446
|
-
const [rebalanceIntentPda] = web3_js_1.PublicKey.findProgramAddressSync([
|
|
447
|
-
Buffer.from("rebalance_intent"),
|
|
448
|
-
params.owner.toBuffer()
|
|
449
|
-
], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
450
|
-
const discriminator = exports.LOCK_DEPOSITS_DISCRIMINATOR;
|
|
451
|
-
const keys = [
|
|
452
|
-
{ pubkey: params.owner, isSigner: true, isWritable: true },
|
|
453
|
-
{ pubkey: rebalanceIntentPda, isSigner: false, isWritable: true },
|
|
454
|
-
];
|
|
455
|
-
return new web3_js_1.TransactionInstruction({
|
|
456
|
-
keys,
|
|
457
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
458
|
-
data: discriminator,
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
exports.MINT_BASKET_DISCRIMINATOR = Buffer.from([161, 207, 48, 45, 7, 156, 233, 143]);
|
|
462
|
-
function mintBasketIx(params) {
|
|
463
|
-
const [rebalanceIntentPda] = web3_js_1.PublicKey.findProgramAddressSync([
|
|
464
|
-
Buffer.from("rebalance_intent"),
|
|
465
|
-
params.basket.toBuffer(),
|
|
466
|
-
params.buyer.toBuffer(),
|
|
467
|
-
], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
468
|
-
const [basketTokenMintPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("mint"), params.basket.toBuffer()], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
469
|
-
const [basketFeesPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("basket_fees"), params.basket.toBuffer()], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
470
|
-
const [globalConfigPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("global_config")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
471
|
-
const buyerBasketATA = (0, spl_token_1.getAssociatedTokenAddressSync)(basketTokenMintPda, params.buyer);
|
|
472
|
-
// CHECK
|
|
473
|
-
const basketFeesATA = (0, spl_token_1.getAssociatedTokenAddressSync)(basketTokenMintPda, params.basket);
|
|
474
|
-
const keys = [
|
|
475
|
-
{ pubkey: params.keeper, isWritable: true, isSigner: true },
|
|
476
|
-
{ pubkey: params.basket, isWritable: true, isSigner: false },
|
|
477
|
-
{ pubkey: rebalanceIntentPda, isWritable: true, isSigner: false },
|
|
478
|
-
{ pubkey: basketTokenMintPda, isWritable: true, isSigner: false },
|
|
479
|
-
{ pubkey: params.buyer, isWritable: true, isSigner: false },
|
|
480
|
-
{ pubkey: buyerBasketATA, isWritable: true, isSigner: false },
|
|
481
|
-
{ pubkey: globalConfigPda, isWritable: false, isSigner: false },
|
|
482
|
-
{ pubkey: basketFeesPda, isWritable: true, isSigner: false },
|
|
483
|
-
{ pubkey: basketFeesATA, isWritable: true, isSigner: false },
|
|
484
|
-
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
485
|
-
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
486
|
-
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
487
|
-
{ pubkey: system_1.SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
488
|
-
];
|
|
489
|
-
const discriminator = exports.MINT_BASKET_DISCRIMINATOR;
|
|
490
|
-
return new web3_js_1.TransactionInstruction({
|
|
491
|
-
keys,
|
|
492
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
493
|
-
data: discriminator,
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
exports.REBALANCE_SWAP_DISCRIMINATOR = Buffer.from([101, 122, 61, 201, 21, 165, 177, 213]);
|
|
497
|
-
function rebalanceSwapIx(params) {
|
|
498
|
-
const [rebalanceIntent] = web3_js_1.PublicKey.findProgramAddressSync([
|
|
499
|
-
Buffer.from("rebalance_intent"),
|
|
500
|
-
params.basket.toBuffer(),
|
|
501
|
-
], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
502
|
-
const keeperFromATA = (0, spl_token_1.getAssociatedTokenAddressSync)(params.mintFrom, params.keeper);
|
|
503
|
-
const keeperToATA = (0, spl_token_1.getAssociatedTokenAddressSync)(params.mintTo, params.keeper);
|
|
504
|
-
const basketFromATA = (0, spl_token_1.getAssociatedTokenAddressSync)(params.mintFrom, params.basket);
|
|
505
|
-
const basketToATA = (0, spl_token_1.getAssociatedTokenAddressSync)(params.mintTo, params.basket);
|
|
506
|
-
const keys = [
|
|
507
|
-
{ pubkey: params.keeper, isWritable: true, isSigner: true },
|
|
508
|
-
{ pubkey: params.basket, isWritable: true, isSigner: false },
|
|
509
|
-
{ pubkey: rebalanceIntent, isWritable: true, isSigner: false },
|
|
510
|
-
{ pubkey: params.mintFrom, isWritable: false, isSigner: false },
|
|
511
|
-
{ pubkey: params.mintTo, isWritable: false, isSigner: false },
|
|
512
|
-
{ pubkey: keeperFromATA, isWritable: true, isSigner: false },
|
|
513
|
-
{ pubkey: keeperToATA, isWritable: true, isSigner: false },
|
|
514
|
-
{ pubkey: basketFromATA, isWritable: true, isSigner: false },
|
|
515
|
-
{ pubkey: basketToATA, isWritable: true, isSigner: false },
|
|
516
|
-
{ pubkey: system_1.SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
517
|
-
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
518
|
-
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
519
|
-
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
520
|
-
];
|
|
521
|
-
const discriminator = exports.REBALANCE_SWAP_DISCRIMINATOR;
|
|
522
|
-
const amountBuffer = Buffer.from(params.amount.toArray("le", 8));
|
|
523
|
-
const sideBuffer = Buffer.from([params.side]);
|
|
524
|
-
const data = Buffer.concat([discriminator, amountBuffer, sideBuffer]);
|
|
525
|
-
return new web3_js_1.TransactionInstruction({
|
|
526
|
-
keys,
|
|
527
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
528
|
-
data,
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
exports.REDEEM_TOKENS_DISCRIMINATOR = Buffer.from([83, 49, 112, 2, 105, 193, 106, 126]);
|
|
532
|
-
function redeemTokensIx(params) {
|
|
533
|
-
const { keeper, basket, owner, } = params;
|
|
534
|
-
const [rebalanceIntentPda] = web3_js_1.PublicKey.findProgramAddressSync([
|
|
535
|
-
Buffer.from("rebalance_intent"),
|
|
536
|
-
basket.toBuffer(),
|
|
537
|
-
owner.toBuffer(),
|
|
538
|
-
], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
539
|
-
const keys = [
|
|
540
|
-
{ pubkey: keeper, isSigner: true, isWritable: true },
|
|
541
|
-
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
542
|
-
{ pubkey: rebalanceIntentPda, isSigner: false, isWritable: true },
|
|
543
|
-
{ pubkey: owner, isSigner: false, isWritable: true },
|
|
544
|
-
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
545
|
-
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
546
|
-
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
547
|
-
{ pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
548
|
-
];
|
|
549
|
-
// remaining accounts
|
|
550
|
-
params.tokenMints.forEach((mint) => {
|
|
551
|
-
keys.push({ pubkey: mint, isWritable: false, isSigner: false });
|
|
552
|
-
const ownerAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mint, owner);
|
|
553
|
-
keys.push({ pubkey: ownerAta, isWritable: true, isSigner: false });
|
|
554
|
-
const basketAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mint, basket);
|
|
555
|
-
keys.push({ pubkey: basketAta, isWritable: true, isSigner: false });
|
|
556
|
-
});
|
|
557
|
-
const discriminator = exports.REDEEM_TOKENS_DISCRIMINATOR;
|
|
558
|
-
const data = discriminator;
|
|
559
|
-
return new web3_js_1.TransactionInstruction({
|
|
560
|
-
keys,
|
|
561
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
562
|
-
data,
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
exports.RESIZE_BASKET_STATE_DISCRIMINATOR = Uint8Array.from([103, 216, 111, 212, 45, 172, 125, 84]);
|
|
566
|
-
function resizeBasketStateIx(params) {
|
|
567
|
-
if (params.basketSeeds.length !== 16) {
|
|
568
|
-
throw new Error("basketSeeds must be 16 bytes");
|
|
569
|
-
}
|
|
570
|
-
const data = Buffer.concat([
|
|
571
|
-
exports.RESIZE_BASKET_STATE_DISCRIMINATOR,
|
|
572
|
-
Buffer.from(params.basketSeeds),
|
|
573
|
-
]);
|
|
574
|
-
const [basket] = web3_js_1.PublicKey.findProgramAddressSync([params.basketSeeds], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
575
|
-
const keys = [
|
|
576
|
-
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
577
|
-
];
|
|
578
|
-
return new web3_js_1.TransactionInstruction({
|
|
579
|
-
keys,
|
|
580
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
581
|
-
data,
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
exports.CREATE_USER_REBALANCE_INTENT_ACCOUNT = Buffer.from([212, 23, 1, 46, 192, 87, 74, 196]);
|
|
585
|
-
function createUserRebalanceIntentIx(params) {
|
|
586
|
-
const { user, basket } = params;
|
|
587
|
-
const [rebalanceIntent] = web3_js_1.PublicKey.findProgramAddressSync([
|
|
588
|
-
Buffer.from("rebalance_intent"),
|
|
589
|
-
basket.toBuffer(),
|
|
590
|
-
user.toBuffer(),
|
|
591
|
-
], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
592
|
-
const [rentPayerPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("rent_payer")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
593
|
-
const [globalConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("global_config")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
594
|
-
const keys = [
|
|
595
|
-
{ pubkey: user, isSigner: true, isWritable: true },
|
|
596
|
-
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
597
|
-
{ pubkey: rebalanceIntent, isSigner: false, isWritable: true },
|
|
598
|
-
{ pubkey: rentPayerPda, isSigner: false, isWritable: true },
|
|
599
|
-
{ pubkey: globalConfig, isSigner: false, isWritable: true },
|
|
600
|
-
{ pubkey: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false },
|
|
601
|
-
{ pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
|
|
602
|
-
{ pubkey: system_1.SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false }
|
|
603
|
-
];
|
|
604
|
-
const data = exports.CREATE_USER_REBALANCE_INTENT_ACCOUNT;
|
|
605
|
-
return new web3_js_1.TransactionInstruction({
|
|
606
|
-
keys,
|
|
607
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
608
|
-
data
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
exports.RESIZE_REBALANCE_INTENT_HANDLER = Buffer.from([71, 204, 243, 183, 209, 118, 111, 94]);
|
|
612
|
-
function resizeRebalanceIntentIx(rebalanceIntent) {
|
|
613
|
-
const data = exports.RESIZE_REBALANCE_INTENT_HANDLER;
|
|
614
|
-
const keys = [
|
|
615
|
-
{ pubkey: rebalanceIntent, isSigner: false, isWritable: true }
|
|
616
|
-
];
|
|
617
|
-
return new web3_js_1.TransactionInstruction({
|
|
618
|
-
keys,
|
|
619
|
-
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
620
|
-
data
|
|
621
|
-
});
|
|
622
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BN } from '@coral-xyz/anchor';
|
|
2
|
-
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
-
export declare const ADD_BOUNTY_DISCRIMINATOR: Buffer;
|
|
4
|
-
export declare function addBountyIx(params: {
|
|
5
|
-
keeper: PublicKey;
|
|
6
|
-
basket: PublicKey;
|
|
7
|
-
bountyMint: PublicKey;
|
|
8
|
-
amount: BN;
|
|
9
|
-
}): TransactionInstruction;
|
|
10
|
-
export declare const CLAIM_BOUNTY_HANDLER_DISCRIMINATOR: Buffer;
|
|
11
|
-
export declare function claimBountyIx(params: {
|
|
12
|
-
keeper: PublicKey;
|
|
13
|
-
basket: PublicKey;
|
|
14
|
-
bountyMint: PublicKey;
|
|
15
|
-
bountyDepositor: PublicKey;
|
|
16
|
-
rentPayer: PublicKey;
|
|
17
|
-
keepers: PublicKey[];
|
|
18
|
-
}): TransactionInstruction;
|