@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.
- package/dist/idl/idl.d.ts +8 -0
- package/dist/idl/idl.js +4958 -0
- package/dist/idl/types.d.ts +4955 -0
- package/dist/idl/types.js +2 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +60 -0
- package/dist/layouts/basket.d.ts +42 -0
- package/dist/layouts/basket.js +43 -0
- package/dist/layouts/config.d.ts +97 -0
- package/dist/layouts/config.js +102 -0
- package/dist/layouts/fraction.d.ts +6 -0
- package/dist/layouts/fraction.js +9 -0
- package/dist/layouts/oracle.d.ts +36 -0
- package/dist/layouts/oracle.js +37 -0
- package/dist/src/constants.d.ts +15 -0
- package/dist/src/constants.js +19 -0
- package/dist/src/idl/idl.d.ts +8 -0
- package/dist/src/idl/idl.js +4958 -0
- package/dist/src/idl/types.d.ts +4955 -0
- package/dist/src/idl/types.js +2 -0
- package/dist/src/index.d.ts +53 -0
- package/dist/src/index.js +199 -0
- package/dist/src/instructions/accounts.d.ts +27 -0
- package/dist/src/instructions/accounts.js +110 -0
- package/dist/src/instructions/auction.d.ts +7 -0
- package/dist/src/instructions/auction.js +43 -0
- package/dist/src/instructions/automation/auction.d.ts +6 -0
- package/dist/src/instructions/automation/auction.js +40 -0
- package/dist/src/instructions/automation/claimBounty.d.ts +12 -0
- package/dist/src/instructions/automation/claimBounty.js +44 -0
- package/dist/src/instructions/automation/priceUpdate.d.ts +15 -0
- package/dist/src/instructions/automation/priceUpdate.js +47 -0
- package/dist/src/instructions/automation/rebalanceSwap.d.ts +10 -0
- package/dist/src/instructions/automation/rebalanceSwap.js +42 -0
- package/dist/src/instructions/basket.d.ts +120 -0
- package/dist/src/instructions/basket.js +622 -0
- package/dist/src/instructions/bounty.d.ts +18 -0
- package/dist/src/instructions/bounty.js +81 -0
- package/dist/src/instructions/fee.d.ts +8 -0
- package/dist/src/instructions/fee.js +46 -0
- package/dist/src/instructions/globalConfig.d.ts +11 -0
- package/dist/src/instructions/globalConfig.js +43 -0
- package/dist/src/instructions/luts.d.ts +33 -0
- package/dist/src/instructions/luts.js +91 -0
- package/dist/src/instructions/management/addBounty.d.ts +7 -0
- package/dist/src/instructions/management/addBounty.js +39 -0
- package/dist/src/instructions/management/admin.d.ts +9 -0
- package/dist/src/instructions/management/admin.js +43 -0
- package/dist/src/instructions/management/claimFees.d.ts +7 -0
- package/dist/src/instructions/management/claimFees.js +47 -0
- package/dist/src/instructions/management/createBasket.d.ts +22 -0
- package/dist/src/instructions/management/createBasket.js +101 -0
- package/dist/src/instructions/management/edit.d.ts +34 -0
- package/dist/src/instructions/management/edit.js +192 -0
- package/dist/src/instructions/management/luts.d.ts +29 -0
- package/dist/src/instructions/management/luts.js +88 -0
- package/dist/src/instructions/pda.d.ts +26 -0
- package/dist/src/instructions/pda.js +110 -0
- package/dist/src/instructions/price.d.ts +17 -0
- package/dist/src/instructions/price.js +47 -0
- package/dist/src/instructions/user/deposit.d.ts +32 -0
- package/dist/src/instructions/user/deposit.js +168 -0
- package/dist/src/instructions/user/withdraw.d.ts +16 -0
- package/dist/src/instructions/user/withdraw.js +82 -0
- package/dist/src/layouts/basket.d.ts +41 -0
- package/dist/src/layouts/basket.js +43 -0
- package/dist/src/layouts/config.d.ts +133 -0
- package/dist/src/layouts/config.js +137 -0
- package/dist/src/layouts/fraction.d.ts +6 -0
- package/dist/src/layouts/fraction.js +9 -0
- package/dist/src/layouts/intents/bounty.d.ts +18 -0
- package/dist/src/layouts/intents/bounty.js +19 -0
- package/dist/src/layouts/intents/intent.d.ts +101 -0
- package/dist/src/layouts/intents/intent.js +113 -0
- package/dist/src/layouts/intents/rebalanceIntent.d.ts +56 -0
- package/dist/src/layouts/intents/rebalanceIntent.js +63 -0
- package/dist/src/layouts/lookupTable.d.ts +7 -0
- package/dist/src/layouts/lookupTable.js +10 -0
- package/dist/src/layouts/oracle.d.ts +42 -0
- package/dist/src/layouts/oracle.js +43 -0
- package/dist/src/states/basket.d.ts +8 -0
- package/dist/src/states/basket.js +54 -0
- package/dist/src/states/intents/intent.d.ts +14 -0
- package/dist/src/states/intents/intent.js +90 -0
- package/dist/src/states/intents/rebalanceIntent.d.ts +8 -0
- package/dist/src/states/intents/rebalanceIntent.js +54 -0
- package/dist/src/states/oracles/clmm_oracle.d.ts +178 -0
- package/dist/src/states/oracles/clmm_oracle.js +546 -0
- package/dist/src/states/oracles/constants.d.ts +8 -0
- package/dist/src/states/oracles/constants.js +12 -0
- package/dist/src/states/oracles/oracle.d.ts +60 -0
- package/dist/src/states/oracles/oracle.js +237 -0
- package/dist/src/states/oracles/pythOracle.d.ts +39 -0
- package/dist/src/states/oracles/pythOracle.js +202 -0
- package/dist/src/states/oracles/pyth_oracle.d.ts +39 -0
- package/dist/src/states/oracles/pyth_oracle.js +202 -0
- package/dist/src/states/oracles/raydiumClmmOracle.d.ts +178 -0
- package/dist/src/states/oracles/raydiumClmmOracle.js +546 -0
- package/dist/src/states/oracles/raydiumCpmmOracle.d.ts +139 -0
- package/dist/src/states/oracles/raydiumCpmmOracle.js +420 -0
- package/dist/src/states/oracles/raydium_cpmm_oracle.d.ts +139 -0
- package/dist/src/states/oracles/raydium_cpmm_oracle.js +420 -0
- package/dist/src/states/oracles/switchboardOracle.d.ts +0 -0
- package/dist/src/states/oracles/switchboardOracle.js +1 -0
- package/dist/src/states/oracles/switchboard_oracle.d.ts +0 -0
- package/dist/src/states/oracles/switchboard_oracle.js +1 -0
- package/dist/src/txUtils.d.ts +26 -0
- package/dist/src/txUtils.js +183 -0
- package/dist/states/basket.d.ts +8 -0
- package/dist/states/basket.js +57 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +39 -0
- package/package.json +30 -0
- package/src/constants.ts +24 -0
- package/src/index.ts +260 -0
- package/src/instructions/automation/auction.ts +55 -0
- package/src/instructions/automation/claimBounty.ts +69 -0
- package/src/instructions/automation/priceUpdate.ts +73 -0
- package/src/instructions/automation/rebalanceSwap.ts +60 -0
- package/src/instructions/management/addBounty.ts +56 -0
- package/src/instructions/management/admin.ts +65 -0
- package/src/instructions/management/claimFees.ts +59 -0
- package/src/instructions/management/createBasket.ts +148 -0
- package/src/instructions/management/edit.ts +255 -0
- package/src/instructions/management/luts.ts +134 -0
- package/src/instructions/pda.ts +160 -0
- package/src/instructions/user/deposit.ts +237 -0
- package/src/instructions/user/withdraw.ts +130 -0
- package/src/layouts/basket.ts +82 -0
- package/src/layouts/config.ts +301 -0
- package/src/layouts/fraction.ts +12 -0
- package/src/layouts/intents/bounty.ts +35 -0
- package/src/layouts/intents/intent.ts +204 -0
- package/src/layouts/intents/rebalanceIntent.ts +111 -0
- package/src/layouts/lookupTable.ts +14 -0
- package/src/layouts/oracle.ts +96 -0
- package/src/states/basket.ts +56 -0
- package/src/states/intents/intent.ts +107 -0
- package/src/states/intents/rebalanceIntent.ts +57 -0
- package/src/states/oracles/constants.ts +13 -0
- package/src/states/oracles/oracle.ts +260 -0
- package/src/states/oracles/pythOracle.ts +270 -0
- package/src/states/oracles/raydiumClmmOracle.ts +812 -0
- package/src/states/oracles/raydiumCpmmOracle.ts +614 -0
- package/src/states/oracles/switchboardOracle.ts +0 -0
- package/src/txUtils.ts +250 -0
- package/test.ts +30 -0
- package/tsconfig.json +101 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { BN, Program } from '@coral-xyz/anchor';
|
|
2
|
+
import { SYSTEM_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/native/system';
|
|
3
|
+
import { PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js';
|
|
4
|
+
import { ADDRESS_LOOKUP_TABLE_PROGRAM_ID, BASKETS_V3_PROGRAM_ID } from '../../constants';
|
|
5
|
+
import { getLookupTableInfoAccount } from '../pda';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const CREATE_BASKET_LOOKUP_TABLES_DISCRIMINATOR = Buffer.from([227,98,152,128,87,46,244,99]);
|
|
9
|
+
const EXTEND_BASKET_LOOKUP_TABLES_DISCRIMINATOR = Buffer.from([98, 129, 153, 127, 181, 160, 117, 74]);
|
|
10
|
+
const OVERWRITE_BASKET_LOOKUP_TABLES_DISCRIMINATOR = Buffer.from([197, 116, 189, 147, 222, 188, 6, 165]);
|
|
11
|
+
const CLOSE_DEACTIVATED_LOOKUP_TABLE_DISCRIMINATOR = Buffer.from([19, 4, 214, 20, 26, 43, 71, 233]);
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export function createBasketLookupTablesInstruction(params: {
|
|
15
|
+
signer: PublicKey;
|
|
16
|
+
basket: PublicKey;
|
|
17
|
+
oldTempLookupTable0: PublicKey;
|
|
18
|
+
oldTempLookupTable1: PublicKey;
|
|
19
|
+
newTempLookupTable0: PublicKey;
|
|
20
|
+
newTempLookupTable1: PublicKey;
|
|
21
|
+
slot: number;
|
|
22
|
+
}): TransactionInstruction {
|
|
23
|
+
const {
|
|
24
|
+
signer,
|
|
25
|
+
basket,
|
|
26
|
+
oldTempLookupTable0,
|
|
27
|
+
oldTempLookupTable1,
|
|
28
|
+
newTempLookupTable0,
|
|
29
|
+
newTempLookupTable1,
|
|
30
|
+
slot,
|
|
31
|
+
} = params;
|
|
32
|
+
|
|
33
|
+
let newTempLookupTableInfo0 = getLookupTableInfoAccount(newTempLookupTable0);
|
|
34
|
+
let newTempLookupTableInfo1 = getLookupTableInfoAccount(newTempLookupTable1);
|
|
35
|
+
|
|
36
|
+
const data = Buffer.concat([
|
|
37
|
+
CREATE_BASKET_LOOKUP_TABLES_DISCRIMINATOR,
|
|
38
|
+
new BN(slot).toArray("le", 8),
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
const keys = [
|
|
42
|
+
{ pubkey: signer, isSigner: true, isWritable: true },
|
|
43
|
+
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
44
|
+
{ pubkey: oldTempLookupTable0, isSigner: false, isWritable: true },
|
|
45
|
+
{ pubkey: oldTempLookupTable1, isSigner: false, isWritable: true },
|
|
46
|
+
{ pubkey: newTempLookupTable0, isSigner: false, isWritable: true },
|
|
47
|
+
{ pubkey: newTempLookupTable1, isSigner: false, isWritable: true },
|
|
48
|
+
{ pubkey: newTempLookupTableInfo0, isSigner: false, isWritable: true },
|
|
49
|
+
{ pubkey: newTempLookupTableInfo1, isSigner: false, isWritable: true },
|
|
50
|
+
{ pubkey: ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
51
|
+
{ pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
return new TransactionInstruction({
|
|
55
|
+
keys,
|
|
56
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
57
|
+
data,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function extendBasketLookupTablesIx(
|
|
62
|
+
params: {
|
|
63
|
+
signer: PublicKey;
|
|
64
|
+
basket: PublicKey;
|
|
65
|
+
tempLookupTable0: PublicKey;
|
|
66
|
+
tempLookupTable1: PublicKey;
|
|
67
|
+
}): TransactionInstruction {
|
|
68
|
+
|
|
69
|
+
const keys = [
|
|
70
|
+
{ pubkey: params.signer, isWritable: true, isSigner: true },
|
|
71
|
+
{ pubkey: params.basket, isWritable: true, isSigner: false },
|
|
72
|
+
{ pubkey: params.tempLookupTable0, isWritable: true, isSigner: false },
|
|
73
|
+
{ pubkey: params.tempLookupTable1, isWritable: true, isSigner: false },
|
|
74
|
+
{ pubkey: ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
75
|
+
{ pubkey: SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
return new TransactionInstruction({
|
|
79
|
+
keys,
|
|
80
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
81
|
+
data: EXTEND_BASKET_LOOKUP_TABLES_DISCRIMINATOR,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function overwriteBasketLookupTablesIx(
|
|
86
|
+
params: {
|
|
87
|
+
signer: PublicKey;
|
|
88
|
+
basket: PublicKey;
|
|
89
|
+
tempLookupTable0: PublicKey;
|
|
90
|
+
tempLookupTable1: PublicKey;
|
|
91
|
+
activeLookupTable0: PublicKey;
|
|
92
|
+
activeLookupTable1: PublicKey;
|
|
93
|
+
|
|
94
|
+
}): TransactionInstruction {
|
|
95
|
+
|
|
96
|
+
const keys = [
|
|
97
|
+
{ pubkey: params.signer, isWritable: true, isSigner: true },
|
|
98
|
+
{ pubkey: params.basket, isWritable: true, isSigner: false },
|
|
99
|
+
{ pubkey: params.tempLookupTable0, isWritable: true, isSigner: false },
|
|
100
|
+
{ pubkey: params.tempLookupTable1, isWritable: true, isSigner: false },
|
|
101
|
+
{ pubkey: params.activeLookupTable0, isWritable: true, isSigner: false },
|
|
102
|
+
{ pubkey: params.activeLookupTable1, isWritable: true, isSigner: false },
|
|
103
|
+
{ pubkey: SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
return new TransactionInstruction({
|
|
107
|
+
keys,
|
|
108
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
109
|
+
data: OVERWRITE_BASKET_LOOKUP_TABLES_DISCRIMINATOR,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function closeDeactivatedLookupTableIx(params: {
|
|
114
|
+
rentPayer: PublicKey,
|
|
115
|
+
basket: PublicKey,
|
|
116
|
+
lookupTable: PublicKey
|
|
117
|
+
}): TransactionInstruction {
|
|
118
|
+
let lookupTableInfo = getLookupTableInfoAccount(params.lookupTable);
|
|
119
|
+
|
|
120
|
+
const keys = [
|
|
121
|
+
{ pubkey: params.rentPayer, isWritable: true, isSigner: false },
|
|
122
|
+
{ pubkey: params.basket, isWritable: true, isSigner: false },
|
|
123
|
+
{ pubkey: params.lookupTable, isWritable: true, isSigner: false },
|
|
124
|
+
{ pubkey: lookupTableInfo, isWritable: true, isSigner: false },
|
|
125
|
+
{ pubkey: ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
126
|
+
{ pubkey: SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
return new TransactionInstruction({
|
|
130
|
+
keys,
|
|
131
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
132
|
+
data: CLOSE_DEACTIVATED_LOOKUP_TABLE_DISCRIMINATOR,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { AddressLookupTableProgram, Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { Metaplex } from "@metaplex-foundation/js";
|
|
3
|
+
import { getAssociatedTokenAddressSync } from "@solana/spl-token";
|
|
4
|
+
import { parse, v4 } from "uuid";
|
|
5
|
+
import { BASKETS_V3_PROGRAM_ID } from "../constants";
|
|
6
|
+
|
|
7
|
+
export const GLOBAL_CONFIG_SEED = Buffer.from("global_config");
|
|
8
|
+
export const BASKET_FEES_SEED = Buffer.from("basket_fees");
|
|
9
|
+
export const MINT_SEED = Buffer.from("mint");
|
|
10
|
+
export const RENT_PAYER_SEED = Buffer.from("rent_payer");
|
|
11
|
+
export const BOUNTY_VAULT_SEED = Buffer.from("bounty_vault");
|
|
12
|
+
export const REBALANCE_INTENT_SEED = Buffer.from("rebalance_intent");
|
|
13
|
+
|
|
14
|
+
export const WSOL_MINT = new PublicKey("So11111111111111111111111111111111111111112");
|
|
15
|
+
/// TODO: Devnet
|
|
16
|
+
export const USDC_MINT = new PublicKey("USDCoctVLVnvTXBEuP9s8hntucdJokbo17RwHuNXemT");
|
|
17
|
+
|
|
18
|
+
export const PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT = new PublicKey("Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX");
|
|
19
|
+
export const PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT = new PublicKey("7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE");
|
|
20
|
+
|
|
21
|
+
export const METADATA_PROGRAM_ID = new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export function serializeString(input: string): Uint8Array {
|
|
25
|
+
const utf8 = new TextEncoder().encode(input);
|
|
26
|
+
const length = utf8.length;
|
|
27
|
+
|
|
28
|
+
const out = new Uint8Array(4 + length);
|
|
29
|
+
|
|
30
|
+
// encode length as little-endian u32
|
|
31
|
+
out[0] = length & 0xff;
|
|
32
|
+
out[1] = (length >> 8) & 0xff;
|
|
33
|
+
out[2] = (length >> 16) & 0xff;
|
|
34
|
+
out[3] = (length >> 24) & 0xff;
|
|
35
|
+
|
|
36
|
+
// copy utf8 bytes after the 4-byte length
|
|
37
|
+
out.set(utf8, 4);
|
|
38
|
+
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getRandomSeed(): number[] {
|
|
43
|
+
return Array.from(parse(v4()));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getBasketState(seeds: number[]) {
|
|
47
|
+
return PublicKey.findProgramAddressSync(
|
|
48
|
+
[Uint8Array.from(seeds)],
|
|
49
|
+
BASKETS_V3_PROGRAM_ID
|
|
50
|
+
)[0];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function getBountyVaultPda() {
|
|
54
|
+
return PublicKey.findProgramAddressSync(
|
|
55
|
+
[
|
|
56
|
+
BOUNTY_VAULT_SEED,
|
|
57
|
+
],
|
|
58
|
+
BASKETS_V3_PROGRAM_ID
|
|
59
|
+
)[0];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function getBasketTokenMintPda(basket: PublicKey) {
|
|
63
|
+
return PublicKey.findProgramAddressSync(
|
|
64
|
+
[
|
|
65
|
+
MINT_SEED,
|
|
66
|
+
basket.toBuffer()
|
|
67
|
+
],
|
|
68
|
+
BASKETS_V3_PROGRAM_ID
|
|
69
|
+
)[0];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function getBasketFeesPda(basket: PublicKey) {
|
|
73
|
+
return PublicKey.findProgramAddressSync(
|
|
74
|
+
[
|
|
75
|
+
BASKET_FEES_SEED,
|
|
76
|
+
basket.toBuffer()
|
|
77
|
+
],
|
|
78
|
+
BASKETS_V3_PROGRAM_ID
|
|
79
|
+
)[0];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function getGlobalConfigPda() {
|
|
83
|
+
return PublicKey.findProgramAddressSync(
|
|
84
|
+
[
|
|
85
|
+
GLOBAL_CONFIG_SEED
|
|
86
|
+
],
|
|
87
|
+
BASKETS_V3_PROGRAM_ID
|
|
88
|
+
)[0];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function getIntentPda(
|
|
92
|
+
basket: PublicKey,
|
|
93
|
+
manager: PublicKey,
|
|
94
|
+
editType: number,
|
|
95
|
+
) {
|
|
96
|
+
return PublicKey.findProgramAddressSync(
|
|
97
|
+
[
|
|
98
|
+
basket.toBuffer(),
|
|
99
|
+
manager.toBuffer(),
|
|
100
|
+
Uint8Array.from([editType]),
|
|
101
|
+
],
|
|
102
|
+
BASKETS_V3_PROGRAM_ID
|
|
103
|
+
)[0];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function getRebalanceIntentPda(
|
|
107
|
+
basket: PublicKey,
|
|
108
|
+
buyer: PublicKey,
|
|
109
|
+
) {
|
|
110
|
+
return PublicKey.findProgramAddressSync(
|
|
111
|
+
[
|
|
112
|
+
REBALANCE_INTENT_SEED,
|
|
113
|
+
basket.toBuffer(),
|
|
114
|
+
buyer.toBuffer(),
|
|
115
|
+
],
|
|
116
|
+
BASKETS_V3_PROGRAM_ID
|
|
117
|
+
)[0];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function getMetadataAccount(
|
|
121
|
+
tokenMint: PublicKey
|
|
122
|
+
): PublicKey {
|
|
123
|
+
const metaplex = Metaplex.make(new Connection("https://api.devnet.solana.com"));
|
|
124
|
+
return metaplex.nfts().pdas().metadata({ mint: tokenMint });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function getLookupTableAccount(
|
|
128
|
+
creator: PublicKey,
|
|
129
|
+
slot: number,
|
|
130
|
+
): PublicKey {
|
|
131
|
+
const ixAndPubkey = AddressLookupTableProgram.createLookupTable({
|
|
132
|
+
authority: creator,
|
|
133
|
+
recentSlot: slot,
|
|
134
|
+
payer: creator,
|
|
135
|
+
});
|
|
136
|
+
return ixAndPubkey[1];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function getLookupTableInfoAccount(
|
|
140
|
+
lookupTable: PublicKey,
|
|
141
|
+
): PublicKey {
|
|
142
|
+
return PublicKey.findProgramAddressSync(
|
|
143
|
+
[lookupTable.toBuffer()],
|
|
144
|
+
BASKETS_V3_PROGRAM_ID,
|
|
145
|
+
)[0];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function getAta(
|
|
149
|
+
wallet: PublicKey,
|
|
150
|
+
tokenMint: PublicKey,
|
|
151
|
+
): PublicKey {
|
|
152
|
+
return getAssociatedTokenAddressSync(tokenMint, wallet, true);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function getRentPayerPda() {
|
|
156
|
+
return PublicKey.findProgramAddressSync(
|
|
157
|
+
[RENT_PAYER_SEED],
|
|
158
|
+
BASKETS_V3_PROGRAM_ID
|
|
159
|
+
)[0];
|
|
160
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RENT_PUBKEY } from "@solana/web3.js";
|
|
2
|
+
import { BN } from "@coral-xyz/anchor";
|
|
3
|
+
import { BASKETS_V3_PROGRAM_ID } from "../../constants";
|
|
4
|
+
import { getAta, getBasketFeesPda, getBasketTokenMintPda, getBountyVaultPda, getGlobalConfigPda, getRebalanceIntentPda, getRentPayerPda } from "../pda";
|
|
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
|
+
import { TransactionInstruction } from "@solana/web3.js";
|
|
8
|
+
|
|
9
|
+
const CREATE_USER_REBALANCE_INTENT_ACCOUNT = Buffer.from([212, 23, 1, 46, 192, 87, 74, 196]);
|
|
10
|
+
const RESIZE_REBALANCE_INTENT_HANDLER = Buffer.from([71, 204, 243, 183, 209, 118, 111, 94]);
|
|
11
|
+
const CREATE_DEPOSIT_STATE_DISCRIMINATOR = Buffer.from([66, 42, 217, 222, 49, 159, 36, 188]);
|
|
12
|
+
const DEPOSIT_TOKENS_DISCRIMINATOR = Buffer.from([88, 92, 158, 219, 83, 71, 239, 164]);
|
|
13
|
+
const LOCK_DEPOSITS_DISCRIMINATOR = Buffer.from([64, 238, 171, 198, 135, 253, 37, 9]);
|
|
14
|
+
const MINT_BASKET_DISCRIMINATOR = Buffer.from([161, 207, 48, 45, 7, 156, 233, 143]);
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export function createUserRebalanceIntentIx(params: {
|
|
18
|
+
user: PublicKey,
|
|
19
|
+
basket: PublicKey,
|
|
20
|
+
}): TransactionInstruction {
|
|
21
|
+
|
|
22
|
+
const {user, basket } = params
|
|
23
|
+
|
|
24
|
+
let rebalanceIntent = getRebalanceIntentPda(basket, user);
|
|
25
|
+
let rentPayerPda = getRentPayerPda();
|
|
26
|
+
let globalConfig = getGlobalConfigPda();
|
|
27
|
+
|
|
28
|
+
const keys = [
|
|
29
|
+
{ pubkey: user, isSigner: true, isWritable: true },
|
|
30
|
+
{ pubkey: basket, isSigner: false, isWritable: true},
|
|
31
|
+
{ pubkey: rebalanceIntent, isSigner: false, isWritable: true},
|
|
32
|
+
{ pubkey: rentPayerPda, isSigner: false, isWritable: true },
|
|
33
|
+
{ pubkey: globalConfig, isSigner: false, isWritable: true},
|
|
34
|
+
{ pubkey: SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false},
|
|
35
|
+
{ pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false},
|
|
36
|
+
{ pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false}
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const data = CREATE_USER_REBALANCE_INTENT_ACCOUNT;
|
|
40
|
+
|
|
41
|
+
return new TransactionInstruction({
|
|
42
|
+
keys,
|
|
43
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
44
|
+
data
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function resizeRebalanceIntentIx(
|
|
49
|
+
rebalanceIntent: PublicKey
|
|
50
|
+
): TransactionInstruction {
|
|
51
|
+
|
|
52
|
+
const data = RESIZE_REBALANCE_INTENT_HANDLER;
|
|
53
|
+
|
|
54
|
+
const keys = [
|
|
55
|
+
{ pubkey: rebalanceIntent, isSigner: false, isWritable: true}
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
return new TransactionInstruction({
|
|
59
|
+
keys,
|
|
60
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
61
|
+
data
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function depositStateIx(
|
|
66
|
+
params: {
|
|
67
|
+
buyer: PublicKey,
|
|
68
|
+
basket: PublicKey,
|
|
69
|
+
bountyMint: PublicKey,
|
|
70
|
+
rebalanceIntentRentPayer: PublicKey,
|
|
71
|
+
rebalanceSlippageBps: number, // u16
|
|
72
|
+
executionStartTime: number // u64
|
|
73
|
+
}
|
|
74
|
+
){
|
|
75
|
+
const {
|
|
76
|
+
buyer,
|
|
77
|
+
basket,
|
|
78
|
+
bountyMint,
|
|
79
|
+
rebalanceIntentRentPayer,
|
|
80
|
+
rebalanceSlippageBps,
|
|
81
|
+
executionStartTime,
|
|
82
|
+
} = params;
|
|
83
|
+
|
|
84
|
+
let rebalanceIntent = getRebalanceIntentPda(basket, buyer);
|
|
85
|
+
let basketTokenMint = getBasketTokenMintPda(basket);
|
|
86
|
+
let globalConfig = getGlobalConfigPda();
|
|
87
|
+
let rentPayerPda = getRentPayerPda();
|
|
88
|
+
let bountyVault = getBountyVaultPda();
|
|
89
|
+
let bountyVaultAta = getAta(bountyVault, bountyMint);
|
|
90
|
+
let buyerBountyAta = getAta(buyer, bountyMint);
|
|
91
|
+
let buyerBasketAta = getAta(buyer, basketTokenMint);
|
|
92
|
+
|
|
93
|
+
const rebalanceIntentRentPayerBuf = rebalanceIntentRentPayer.toBuffer();
|
|
94
|
+
const rebalanceSlippageBuf = Buffer.from(new BN(rebalanceSlippageBps).toArray("le", 2));
|
|
95
|
+
const executionStartBuf = Buffer.from(new BN(executionStartTime).toArray("le", 8));
|
|
96
|
+
|
|
97
|
+
const data = Buffer.concat([
|
|
98
|
+
CREATE_DEPOSIT_STATE_DISCRIMINATOR,
|
|
99
|
+
rebalanceIntentRentPayerBuf,
|
|
100
|
+
rebalanceSlippageBuf,
|
|
101
|
+
executionStartBuf
|
|
102
|
+
]);
|
|
103
|
+
const keys = [
|
|
104
|
+
{ pubkey: buyer, isSigner: true, isWritable: true },
|
|
105
|
+
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
106
|
+
{ pubkey: rebalanceIntent, isSigner: false, isWritable: true },
|
|
107
|
+
{ pubkey: rentPayerPda, isSigner: false, isWritable: true },
|
|
108
|
+
{ pubkey: basketTokenMint, isSigner: false, isWritable: false },
|
|
109
|
+
{ pubkey: buyerBasketAta, isSigner: false, isWritable: true },
|
|
110
|
+
{ pubkey: globalConfig, isSigner: false, isWritable: false },
|
|
111
|
+
{ pubkey: bountyMint, isSigner: false, isWritable: false },
|
|
112
|
+
{ pubkey: buyerBountyAta, isSigner: false, isWritable: true },
|
|
113
|
+
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
114
|
+
{ pubkey: bountyVaultAta, isSigner: false, isWritable: true },
|
|
115
|
+
{ pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
116
|
+
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
117
|
+
{ pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
118
|
+
// { pubkey: rebalanceIntent, isSigner: false, isWritable: true } // remaining accounts
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
return new TransactionInstruction({
|
|
122
|
+
keys,
|
|
123
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
124
|
+
data,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
export function depositTokensIx(params: {
|
|
130
|
+
owner: PublicKey;
|
|
131
|
+
basket: PublicKey;
|
|
132
|
+
contributions: {mint: PublicKey, amount: number}[]; // length 10
|
|
133
|
+
}): TransactionInstruction{
|
|
134
|
+
|
|
135
|
+
const { owner, basket, contributions } = params;
|
|
136
|
+
|
|
137
|
+
let rebalanceIntent = getRebalanceIntentPda(basket, owner);
|
|
138
|
+
|
|
139
|
+
const discriminator = DEPOSIT_TOKENS_DISCRIMINATOR;
|
|
140
|
+
const amountsBuffer = Buffer.concat(
|
|
141
|
+
contributions.map((contribution) => Buffer.from(new BN(contribution.amount).toArray("le", 8)))
|
|
142
|
+
);
|
|
143
|
+
const data = Buffer.concat([discriminator, amountsBuffer]);
|
|
144
|
+
|
|
145
|
+
const keys = [
|
|
146
|
+
{ pubkey: owner, isSigner: true, isWritable: true },
|
|
147
|
+
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
148
|
+
{ pubkey: rebalanceIntent, isSigner: false, isWritable: true },
|
|
149
|
+
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
150
|
+
{ pubkey: TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
151
|
+
{ pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
152
|
+
{ pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
// remaining accounts
|
|
156
|
+
contributions.forEach((contribution) => {
|
|
157
|
+
let mint = contribution.mint;
|
|
158
|
+
let ownerAta = getAta(owner, mint);
|
|
159
|
+
let basketAta = getAta(basket, mint);
|
|
160
|
+
keys.push({ pubkey: mint, isSigner: false, isWritable: false });
|
|
161
|
+
keys.push({ pubkey: ownerAta, isSigner: false, isWritable: true });
|
|
162
|
+
keys.push({ pubkey: basketAta, isSigner: false, isWritable: true });
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
return new TransactionInstruction({
|
|
167
|
+
keys,
|
|
168
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
169
|
+
data,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
export function lockDepositsIx(params: {
|
|
176
|
+
owner: PublicKey;
|
|
177
|
+
basket: PublicKey;
|
|
178
|
+
}): TransactionInstruction {
|
|
179
|
+
const { owner, basket } = params;
|
|
180
|
+
let rebalanceIntent = getRebalanceIntentPda(basket, owner);
|
|
181
|
+
|
|
182
|
+
const keys = [
|
|
183
|
+
{ pubkey: params.owner, isSigner: true , isWritable: true},
|
|
184
|
+
{ pubkey: rebalanceIntent, isSigner: false, isWritable: true },
|
|
185
|
+
];
|
|
186
|
+
|
|
187
|
+
return new TransactionInstruction({
|
|
188
|
+
keys,
|
|
189
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
190
|
+
data: LOCK_DEPOSITS_DISCRIMINATOR,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
export function mintBasketIx(params: {
|
|
196
|
+
keeper: PublicKey;
|
|
197
|
+
basket: PublicKey;
|
|
198
|
+
buyer: PublicKey;
|
|
199
|
+
}): TransactionInstruction {
|
|
200
|
+
|
|
201
|
+
const { keeper, basket, buyer } = params;
|
|
202
|
+
let rebalanceIntent = getRebalanceIntentPda(basket, buyer);
|
|
203
|
+
|
|
204
|
+
let basketTokenMint = getBasketTokenMintPda(basket);
|
|
205
|
+
|
|
206
|
+
let basketFees = getBasketFeesPda(basket);
|
|
207
|
+
|
|
208
|
+
let globalConfig = getGlobalConfigPda();
|
|
209
|
+
|
|
210
|
+
let buyerBasketATA = getAta(buyer, basketTokenMint);
|
|
211
|
+
let basketFeesAta = getAta(basketFees, basketTokenMint);
|
|
212
|
+
|
|
213
|
+
const keys = [
|
|
214
|
+
{ pubkey: keeper, isWritable: true, isSigner: true },
|
|
215
|
+
{ pubkey: basket, isWritable: true, isSigner: false },
|
|
216
|
+
{ pubkey: rebalanceIntent, isWritable: true, isSigner: false },
|
|
217
|
+
{ pubkey: basketTokenMint, isWritable: true, isSigner: false },
|
|
218
|
+
{ pubkey: buyer, isWritable: true, isSigner: false },
|
|
219
|
+
{ pubkey: buyerBasketATA, isWritable: true, isSigner: false },
|
|
220
|
+
{ pubkey: globalConfig, isWritable: false, isSigner: false },
|
|
221
|
+
{ pubkey: basketFees, isWritable: true, isSigner: false },
|
|
222
|
+
{ pubkey: basketFeesAta, isWritable: true, isSigner: false },
|
|
223
|
+
{ pubkey: TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
224
|
+
{ pubkey: TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
225
|
+
{ pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
226
|
+
{ pubkey: SYSTEM_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
227
|
+
];
|
|
228
|
+
|
|
229
|
+
return new TransactionInstruction({
|
|
230
|
+
keys,
|
|
231
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
232
|
+
data: MINT_BASKET_DISCRIMINATOR,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { BASKETS_V3_PROGRAM_ID } from "../../constants";
|
|
3
|
+
import { ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
|
4
|
+
import { BN } from "@coral-xyz/anchor";
|
|
5
|
+
import { getAta, getBasketTokenMintPda, getBountyVaultPda, getGlobalConfigPda, getRebalanceIntentPda, getRentPayerPda } from "../pda";
|
|
6
|
+
import { SYSTEM_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/native/system";
|
|
7
|
+
import { TransactionInstruction } from "@solana/web3.js";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const CREATE_WITHDRAW_STATE_DISCRIMINATOR = Buffer.from([161, 45, 253, 59, 110, 240, 65, 3]);
|
|
11
|
+
const REDEEM_TOKENS_DISCRIMINATOR = Buffer.from([83, 49, 112, 2, 105, 193, 106, 126]);
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export function createWithdrawStateIx(params: {
|
|
15
|
+
seller: PublicKey;
|
|
16
|
+
basket: PublicKey;
|
|
17
|
+
withdrawAmount: number;
|
|
18
|
+
rebalanceSlippageBps: number;
|
|
19
|
+
executionStartTime: number;
|
|
20
|
+
bountyMint: PublicKey;
|
|
21
|
+
}){
|
|
22
|
+
const {
|
|
23
|
+
seller,
|
|
24
|
+
basket,
|
|
25
|
+
withdrawAmount,
|
|
26
|
+
rebalanceSlippageBps,
|
|
27
|
+
executionStartTime,
|
|
28
|
+
bountyMint,
|
|
29
|
+
} = params;
|
|
30
|
+
|
|
31
|
+
let rebalanceIntent = getRebalanceIntentPda(basket, seller);
|
|
32
|
+
let rentPayerPda = getRentPayerPda();
|
|
33
|
+
let basketTokenMint = getBasketTokenMintPda(basket);
|
|
34
|
+
let globalConfig = getGlobalConfigPda();
|
|
35
|
+
let bountyVault = getBountyVaultPda();
|
|
36
|
+
|
|
37
|
+
let sellerBasketAta = getAta(seller, basketTokenMint);
|
|
38
|
+
let sellerBountyAta = getAta(seller, bountyMint);
|
|
39
|
+
let bountyVaultAta = getAta(bountyVault, bountyMint);
|
|
40
|
+
|
|
41
|
+
let basketRebalanceIntent = getRebalanceIntentPda(basket, basket);
|
|
42
|
+
|
|
43
|
+
const data = Buffer.concat([
|
|
44
|
+
CREATE_WITHDRAW_STATE_DISCRIMINATOR,
|
|
45
|
+
Buffer.from(new BN(withdrawAmount).toArray("le", 8)),
|
|
46
|
+
Buffer.from(new BN(rebalanceSlippageBps).toArray("le", 2)),
|
|
47
|
+
Buffer.from(new BN(executionStartTime).toArray("le", 8)),
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
const keys = [
|
|
52
|
+
{ pubkey: seller, isSigner: true, isWritable: true },
|
|
53
|
+
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
54
|
+
{ pubkey: basketRebalanceIntent, isSigner: false, isWritable: true },
|
|
55
|
+
{ pubkey: rebalanceIntent, isSigner: false, isWritable: true },
|
|
56
|
+
{ pubkey: rentPayerPda, isSigner: false, isWritable: true },
|
|
57
|
+
{ pubkey: basketTokenMint, isSigner: false, isWritable: false },
|
|
58
|
+
{ pubkey: sellerBasketAta, isSigner: false, isWritable: true },
|
|
59
|
+
{ pubkey: globalConfig, isSigner: false, isWritable: false },
|
|
60
|
+
{ pubkey: bountyMint, isSigner: false, isWritable: false },
|
|
61
|
+
{ pubkey: sellerBountyAta, isSigner: false, isWritable: true },
|
|
62
|
+
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
63
|
+
{ pubkey: bountyVaultAta, isSigner: false, isWritable: true },
|
|
64
|
+
{ pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
65
|
+
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
66
|
+
{ pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
67
|
+
{ pubkey: rebalanceIntent, isSigner: false, isWritable: false } // remaining accounts
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
return new TransactionInstruction({
|
|
71
|
+
keys,
|
|
72
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
73
|
+
data,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
export function redeemTokensIx(
|
|
80
|
+
params: {
|
|
81
|
+
keeper: PublicKey;
|
|
82
|
+
basket: PublicKey;
|
|
83
|
+
owner: PublicKey;
|
|
84
|
+
tokenMints: PublicKey[];
|
|
85
|
+
},
|
|
86
|
+
): TransactionInstruction {
|
|
87
|
+
const {
|
|
88
|
+
keeper,
|
|
89
|
+
basket,
|
|
90
|
+
owner,
|
|
91
|
+
} = params;
|
|
92
|
+
|
|
93
|
+
let rebalanceIntent = getRebalanceIntentPda(basket, owner);
|
|
94
|
+
|
|
95
|
+
const keys = [
|
|
96
|
+
{ pubkey: keeper, isSigner: true, isWritable: true },
|
|
97
|
+
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
98
|
+
{ pubkey: rebalanceIntent, isSigner: false, isWritable: true },
|
|
99
|
+
{ pubkey: owner, isSigner: false, isWritable: true },
|
|
100
|
+
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
101
|
+
{ pubkey: TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
102
|
+
{ pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
103
|
+
{ pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
// remaining accounts
|
|
107
|
+
params.tokenMints.forEach((mint) => {
|
|
108
|
+
keys.push({ pubkey: mint, isWritable: false, isSigner: false });
|
|
109
|
+
const ownerAta = getAssociatedTokenAddressSync(
|
|
110
|
+
mint,
|
|
111
|
+
owner
|
|
112
|
+
);
|
|
113
|
+
keys.push({ pubkey: ownerAta, isWritable: true, isSigner: false });
|
|
114
|
+
const basketAta = getAssociatedTokenAddressSync(
|
|
115
|
+
mint,
|
|
116
|
+
basket
|
|
117
|
+
);
|
|
118
|
+
keys.push({ pubkey: basketAta, isWritable: true, isSigner: false });
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const discriminator = REDEEM_TOKENS_DISCRIMINATOR;
|
|
122
|
+
|
|
123
|
+
const data = discriminator;
|
|
124
|
+
|
|
125
|
+
return new TransactionInstruction({
|
|
126
|
+
keys,
|
|
127
|
+
programId: BASKETS_V3_PROGRAM_ID,
|
|
128
|
+
data,
|
|
129
|
+
});
|
|
130
|
+
}
|