@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,53 @@
|
|
|
1
|
+
import { BN, Wallet } from '@coral-xyz/anchor';
|
|
2
|
+
import { Connection, PublicKey, TransactionSignature } from '@solana/web3.js';
|
|
3
|
+
import { Basket } from './layouts/basket';
|
|
4
|
+
import { Fraction } from './layouts/fraction';
|
|
5
|
+
import { EditData, HostFees, Intent, MetadataParams, TaskType } from './layouts/intents/intent';
|
|
6
|
+
import { RebalanceIntent } from './layouts/intents/rebalanceIntent';
|
|
7
|
+
import { VersionedTxs } from './txUtils';
|
|
8
|
+
export declare const COMPUTE_UNITS = 1000000;
|
|
9
|
+
export declare const PRIORITY_FEE = 100000;
|
|
10
|
+
export declare const JUPITER_API_KEY = "https://quote-api.jup.ag/v6/";
|
|
11
|
+
export declare const MAX_JUPITER_ACCOUNTS = 35;
|
|
12
|
+
export declare class BasketsSdk {
|
|
13
|
+
private sdkParams;
|
|
14
|
+
constructor(params: {
|
|
15
|
+
connection: Connection;
|
|
16
|
+
payer?: PublicKey;
|
|
17
|
+
priorityFee?: number;
|
|
18
|
+
jupiterApiKey?: string;
|
|
19
|
+
maxAllowedAccounts?: number;
|
|
20
|
+
});
|
|
21
|
+
setPayer(payer: PublicKey): Promise<void>;
|
|
22
|
+
getBasket(params: {
|
|
23
|
+
basket: PublicKey;
|
|
24
|
+
}): Promise<Basket>;
|
|
25
|
+
fetchAllBaskets(): Promise<Basket[]>;
|
|
26
|
+
fetchAllIntents(): Promise<Intent[]>;
|
|
27
|
+
fetchAllRebalanceIntents(): Promise<RebalanceIntent[]>;
|
|
28
|
+
createBasketTx(params: {
|
|
29
|
+
creator: PublicKey;
|
|
30
|
+
host: PublicKey;
|
|
31
|
+
startPrice: Fraction;
|
|
32
|
+
hostFees: HostFees;
|
|
33
|
+
metadataParams: MetadataParams;
|
|
34
|
+
metadataModificationDelay: BN;
|
|
35
|
+
}): Promise<VersionedTxs>;
|
|
36
|
+
createEditBasketIntentTx(params: {
|
|
37
|
+
manager: PublicKey;
|
|
38
|
+
basket: Basket;
|
|
39
|
+
editType: TaskType;
|
|
40
|
+
editData: EditData;
|
|
41
|
+
useBounty: number;
|
|
42
|
+
}): Promise<VersionedTxs>;
|
|
43
|
+
createEditBasketTx(params: {
|
|
44
|
+
keeper: PublicKey;
|
|
45
|
+
basket: PublicKey;
|
|
46
|
+
manager: PublicKey;
|
|
47
|
+
editType: TaskType;
|
|
48
|
+
}): Promise<VersionedTxs>;
|
|
49
|
+
signAndSendVersionedTxs(params: {
|
|
50
|
+
vtxs: VersionedTxs;
|
|
51
|
+
wallet: Wallet;
|
|
52
|
+
}): Promise<TransactionSignature[]>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BasketsSdk = exports.MAX_JUPITER_ACCOUNTS = exports.JUPITER_API_KEY = exports.PRIORITY_FEE = exports.COMPUTE_UNITS = void 0;
|
|
13
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
14
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
15
|
+
const constants_1 = require("./constants");
|
|
16
|
+
const createBasket_1 = require("./instructions/management/createBasket");
|
|
17
|
+
const edit_1 = require("./instructions/management/edit");
|
|
18
|
+
const pda_1 = require("./instructions/pda");
|
|
19
|
+
const basket_1 = require("./states/basket");
|
|
20
|
+
const intent_1 = require("./states/intents/intent");
|
|
21
|
+
const rebalanceIntent_1 = require("./states/intents/rebalanceIntent");
|
|
22
|
+
const txUtils_1 = require("./txUtils");
|
|
23
|
+
exports.COMPUTE_UNITS = 1000000;
|
|
24
|
+
exports.PRIORITY_FEE = 100000;
|
|
25
|
+
exports.JUPITER_API_KEY = "https://quote-api.jup.ag/v6/";
|
|
26
|
+
exports.MAX_JUPITER_ACCOUNTS = 35;
|
|
27
|
+
class BasketsSdk {
|
|
28
|
+
constructor(params) {
|
|
29
|
+
var _a, _b, _c, _d;
|
|
30
|
+
this.sdkParams = {
|
|
31
|
+
connection: params.connection,
|
|
32
|
+
payer: (_a = params.payer) !== null && _a !== void 0 ? _a : web3_js_1.Keypair.generate().publicKey,
|
|
33
|
+
priorityFee: (_b = params.priorityFee) !== null && _b !== void 0 ? _b : exports.PRIORITY_FEE,
|
|
34
|
+
jupiterApiKey: (_c = params.jupiterApiKey) !== null && _c !== void 0 ? _c : exports.JUPITER_API_KEY,
|
|
35
|
+
maxAllowedAccounts: (_d = params.maxAllowedAccounts) !== null && _d !== void 0 ? _d : exports.MAX_JUPITER_ACCOUNTS,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
setPayer(payer) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
this.sdkParams.payer = payer;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getBasket(params) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const basketState = yield (0, basket_1.fetchBasket)(this.sdkParams.connection, params.basket);
|
|
46
|
+
return basketState;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
fetchAllBaskets() {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const baskets = yield (0, basket_1.fetchBaskets)(this.sdkParams.connection, []);
|
|
52
|
+
return baskets;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
fetchAllIntents() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const intents = yield (0, intent_1.fetchIntents)(this.sdkParams.connection, []);
|
|
58
|
+
return intents;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
fetchAllRebalanceIntents() {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const rebalanceIntents = yield (0, rebalanceIntent_1.fetchRebalanceIntents)(this.sdkParams.connection, []);
|
|
64
|
+
return rebalanceIntents;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
createBasketTx(params) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
var _a;
|
|
70
|
+
const { creator, host, startPrice, hostFees, metadataParams, metadataModificationDelay } = params;
|
|
71
|
+
// generate random seed
|
|
72
|
+
const basketSeeds = (0, pda_1.getRandomSeed)();
|
|
73
|
+
let basket = (0, pda_1.getBasketState)(basketSeeds);
|
|
74
|
+
const slot = yield this.sdkParams.connection.getSlot();
|
|
75
|
+
let ix = (0, createBasket_1.createBasketIx)({
|
|
76
|
+
basket,
|
|
77
|
+
seed: basketSeeds,
|
|
78
|
+
slot,
|
|
79
|
+
creator,
|
|
80
|
+
host,
|
|
81
|
+
startPrice,
|
|
82
|
+
hostFees,
|
|
83
|
+
metadataParams,
|
|
84
|
+
metadataModificationDelay
|
|
85
|
+
});
|
|
86
|
+
let preIx = (0, createBasket_1.createBasketStateAccountIx)({
|
|
87
|
+
creator,
|
|
88
|
+
seed: basketSeeds,
|
|
89
|
+
basket
|
|
90
|
+
});
|
|
91
|
+
let preIx2 = (0, createBasket_1.resizeBasketStateIx)({
|
|
92
|
+
basket
|
|
93
|
+
});
|
|
94
|
+
let vtxs = yield (0, txUtils_1.prepareV0Transactions)({
|
|
95
|
+
connection: this.sdkParams.connection,
|
|
96
|
+
payer: creator,
|
|
97
|
+
priorityFee: (_a = this.sdkParams.priorityFee) !== null && _a !== void 0 ? _a : 1000000,
|
|
98
|
+
multipleIxs: [[preIx, preIx2, preIx2, ix]],
|
|
99
|
+
multipleLookupTableAddresses: [],
|
|
100
|
+
signers: [[]],
|
|
101
|
+
batches: [1],
|
|
102
|
+
});
|
|
103
|
+
return vtxs;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
createEditBasketIntentTx(params) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const { manager, basket, editType, editData, useBounty } = params;
|
|
109
|
+
let ix = (0, edit_1.createEditBasketIntentIx)({
|
|
110
|
+
manager,
|
|
111
|
+
basket: basket.ownAddress,
|
|
112
|
+
bountyMint: constants_1.BOUNTY_MINT,
|
|
113
|
+
editType,
|
|
114
|
+
editData,
|
|
115
|
+
useBounty
|
|
116
|
+
});
|
|
117
|
+
let ix2 = null;
|
|
118
|
+
let modificationDelay;
|
|
119
|
+
switch (editType) {
|
|
120
|
+
case 1: modificationDelay = basket.settings.schedule.modificationDelay;
|
|
121
|
+
case 2: modificationDelay = basket.settings.feeSettings.modificationDelay;
|
|
122
|
+
case 3: modificationDelay = basket.settings.managerSettings.modificationDelay;
|
|
123
|
+
case 4: modificationDelay = basket.settings.automationSettings.modificationDelay;
|
|
124
|
+
case 5: modificationDelay = basket.settings.lpSettings.modificationDelay;
|
|
125
|
+
case 6: modificationDelay = basket.settings.metadataSettings.modificationDelay;
|
|
126
|
+
case 7: modificationDelay = basket.settings.addTokenDelay;
|
|
127
|
+
case 8: modificationDelay = basket.settings.updateWeightsDelay;
|
|
128
|
+
case 9: modificationDelay = basket.settings.addTokenDelay;
|
|
129
|
+
case 10: modificationDelay = basket.settings.updateWeightsDelay;
|
|
130
|
+
case 11: modificationDelay = basket.settings.makeDirectSwapDelay;
|
|
131
|
+
}
|
|
132
|
+
if (modificationDelay.eq(new anchor_1.BN(0))) {
|
|
133
|
+
let intent = (0, pda_1.getIntentPda)(basket.ownAddress, manager, editType);
|
|
134
|
+
let basketTokenMint = (0, pda_1.getBasketTokenMintPda)(basket.ownAddress);
|
|
135
|
+
let metadataAccount = (0, pda_1.getMetadataAccount)(basketTokenMint);
|
|
136
|
+
ix2 = (0, edit_1.editBasketIx)({
|
|
137
|
+
keeper: manager,
|
|
138
|
+
basket: basket.ownAddress,
|
|
139
|
+
intent,
|
|
140
|
+
bountyMint: constants_1.BOUNTY_MINT,
|
|
141
|
+
manager,
|
|
142
|
+
editType,
|
|
143
|
+
metadataAccount
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
let ixs = [];
|
|
147
|
+
if (ix2 === null)
|
|
148
|
+
ixs = [[ix]];
|
|
149
|
+
else
|
|
150
|
+
ixs = [[ix, ix2]];
|
|
151
|
+
const signers = ixs.map(() => []);
|
|
152
|
+
let vtxs = yield (0, txUtils_1.prepareV0Transactions)({
|
|
153
|
+
connection: this.sdkParams.connection,
|
|
154
|
+
payer: manager,
|
|
155
|
+
priorityFee: this.sdkParams.priorityFee,
|
|
156
|
+
multipleIxs: ixs,
|
|
157
|
+
multipleLookupTableAddresses: [],
|
|
158
|
+
signers,
|
|
159
|
+
batches: [1],
|
|
160
|
+
});
|
|
161
|
+
return vtxs;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
createEditBasketTx(params) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
const { keeper, basket, manager, editType } = params;
|
|
167
|
+
let intent = (0, pda_1.getIntentPda)(basket, manager, editType);
|
|
168
|
+
let basketTokenMint = (0, pda_1.getBasketTokenMintPda)(basket);
|
|
169
|
+
let metadataAccount = (0, pda_1.getMetadataAccount)(basketTokenMint);
|
|
170
|
+
let ix = (0, edit_1.editBasketIx)({
|
|
171
|
+
keeper,
|
|
172
|
+
basket,
|
|
173
|
+
intent,
|
|
174
|
+
bountyMint: constants_1.BOUNTY_MINT,
|
|
175
|
+
manager,
|
|
176
|
+
editType,
|
|
177
|
+
metadataAccount
|
|
178
|
+
});
|
|
179
|
+
let vtxs = yield (0, txUtils_1.prepareV0Transactions)({
|
|
180
|
+
connection: this.sdkParams.connection,
|
|
181
|
+
payer: manager,
|
|
182
|
+
priorityFee: this.sdkParams.priorityFee,
|
|
183
|
+
multipleIxs: [[ix]],
|
|
184
|
+
multipleLookupTableAddresses: [],
|
|
185
|
+
signers: [[]],
|
|
186
|
+
batches: [1],
|
|
187
|
+
});
|
|
188
|
+
return vtxs;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
signAndSendVersionedTxs(params) {
|
|
192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
const { vtxs, wallet } = params;
|
|
194
|
+
vtxs.versionedTxs = yield wallet.signAllTransactions(vtxs.versionedTxs);
|
|
195
|
+
return yield (0, txUtils_1.sendV0Transactions)(this.sdkParams.connection, vtxs, false);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.BasketsSdk = BasketsSdk;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
export declare const BASKETS_V3_PROGRAM_ID: PublicKey;
|
|
3
|
+
export declare const GLOBAL_CONFIG_SEED: Buffer;
|
|
4
|
+
export declare const BASKET_FEES_SEED: Buffer;
|
|
5
|
+
export declare const MINT_SEED: Buffer;
|
|
6
|
+
export declare const RENT_PAYER_SEED: Buffer;
|
|
7
|
+
export declare const BOUNTY_VAULT_SEED: Buffer;
|
|
8
|
+
export declare const REBALANCE_INTENT_SEED: Buffer;
|
|
9
|
+
export declare const WSOL_MINT: PublicKey;
|
|
10
|
+
export declare const USDC_MINT: PublicKey;
|
|
11
|
+
export declare const PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT: PublicKey;
|
|
12
|
+
export declare const PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT: PublicKey;
|
|
13
|
+
export declare const METADATA_PROGRAM_ID: PublicKey;
|
|
14
|
+
export declare function serializeString(input: string): Uint8Array;
|
|
15
|
+
export declare function getRandomSeed(): number[];
|
|
16
|
+
export declare function getBasketState(seeds: number[]): PublicKey;
|
|
17
|
+
export declare function getBountyVaultPda(): PublicKey;
|
|
18
|
+
export declare function getBasketTokenMintPda(basket: PublicKey): PublicKey;
|
|
19
|
+
export declare function getBasketFeesPda(basket: PublicKey): PublicKey;
|
|
20
|
+
export declare function getGlobalConfigPda(): PublicKey;
|
|
21
|
+
export declare function getIntentPda(basket: PublicKey, manager: PublicKey, editType: number): PublicKey;
|
|
22
|
+
export declare function getRebalanceIntentPda(basket: PublicKey, buyer: PublicKey): PublicKey;
|
|
23
|
+
export declare function getMetadataAccount(tokenMint: PublicKey): PublicKey;
|
|
24
|
+
export declare function getLookupTableAccount(creator: PublicKey, slot: number): PublicKey;
|
|
25
|
+
export declare function getLookupTableInfoAccount(lookupTable: PublicKey): PublicKey;
|
|
26
|
+
export declare function getAta(wallet: PublicKey, tokenMint: PublicKey): PublicKey;
|
|
27
|
+
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 = exports.BASKETS_V3_PROGRAM_ID = 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
|
+
exports.BASKETS_V3_PROGRAM_ID = new web3_js_1.PublicKey("BASKT7aKd8n7ibpUbwLP3Wiyxyi3yoiXsxBk4Hpumate");
|
|
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)], exports.BASKETS_V3_PROGRAM_ID)[0];
|
|
53
|
+
}
|
|
54
|
+
function getBountyVaultPda() {
|
|
55
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
56
|
+
exports.BOUNTY_VAULT_SEED,
|
|
57
|
+
], exports.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
|
+
], exports.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
|
+
], exports.BASKETS_V3_PROGRAM_ID)[0];
|
|
70
|
+
}
|
|
71
|
+
function getGlobalConfigPda() {
|
|
72
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
73
|
+
exports.GLOBAL_CONFIG_SEED
|
|
74
|
+
], exports.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
|
+
], exports.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
|
+
], exports.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()], exports.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], exports.BASKETS_V3_PROGRAM_ID)[0];
|
|
110
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
export declare const CREATE_AUCTION_DISCRIMINATOR: Buffer;
|
|
3
|
+
export declare function createAuctionIx(params: {
|
|
4
|
+
keeper: PublicKey;
|
|
5
|
+
basket: PublicKey;
|
|
6
|
+
bountyMint: PublicKey;
|
|
7
|
+
}): TransactionInstruction;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CREATE_AUCTION_DISCRIMINATOR = void 0;
|
|
4
|
+
exports.createAuctionIx = createAuctionIx;
|
|
5
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
6
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const web3_js_2 = require("@solana/web3.js");
|
|
9
|
+
exports.CREATE_AUCTION_DISCRIMINATOR = Buffer.from([50, 37, 7, 103, 80, 100, 162, 13]);
|
|
10
|
+
function createAuctionIx(params) {
|
|
11
|
+
const [bountyVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("bounty_vault")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
12
|
+
const bountyVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(params.bountyMint, bountyVault, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
13
|
+
const [rebalanceIntent] = web3_js_1.PublicKey.findProgramAddressSync([
|
|
14
|
+
Buffer.from("rebalance_intent"),
|
|
15
|
+
params.basket.toBuffer(),
|
|
16
|
+
params.basket.toBuffer(),
|
|
17
|
+
], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
18
|
+
const [rentPayerPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("rent_payer")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
19
|
+
const [globalConfig] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("global_config")], constants_1.BASKETS_V3_PROGRAM_ID);
|
|
20
|
+
const keeperBountyATA = (0, spl_token_1.getAssociatedTokenAddressSync)(params.bountyMint, params.keeper);
|
|
21
|
+
const data = exports.CREATE_AUCTION_DISCRIMINATOR;
|
|
22
|
+
const keys = [
|
|
23
|
+
{ pubkey: params.keeper, isWritable: true, isSigner: true },
|
|
24
|
+
{ pubkey: params.basket, isWritable: true, isSigner: false },
|
|
25
|
+
{ pubkey: rebalanceIntent, isWritable: true, isSigner: false },
|
|
26
|
+
{ pubkey: rentPayerPda, isWritable: true, isSigner: false },
|
|
27
|
+
{ pubkey: globalConfig, isWritable: false, isSigner: false },
|
|
28
|
+
{ pubkey: params.bountyMint, isWritable: false, isSigner: false },
|
|
29
|
+
{ pubkey: keeperBountyATA, isWritable: true, isSigner: false },
|
|
30
|
+
{ pubkey: bountyVault, isWritable: true, isSigner: false },
|
|
31
|
+
{ pubkey: bountyVaultAta, isWritable: true, isSigner: false },
|
|
32
|
+
{ pubkey: web3_js_2.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
33
|
+
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
34
|
+
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
35
|
+
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
36
|
+
{ pubkey: rebalanceIntent, isWritable: true, isSigner: false }
|
|
37
|
+
];
|
|
38
|
+
return new web3_js_1.TransactionInstruction({
|
|
39
|
+
keys,
|
|
40
|
+
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
41
|
+
data,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAuctionIx = createAuctionIx;
|
|
4
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
7
|
+
const web3_js_2 = require("@solana/web3.js");
|
|
8
|
+
const pda_1 = require("../pda");
|
|
9
|
+
const CREATE_AUCTION_DISCRIMINATOR = Buffer.from([50, 37, 7, 103, 80, 100, 162, 13]);
|
|
10
|
+
function createAuctionIx(params) {
|
|
11
|
+
const { keeper, basket, bountyMint } = params;
|
|
12
|
+
let bountyVault = (0, pda_1.getBountyVaultPda)();
|
|
13
|
+
let bountyVaultAta = (0, pda_1.getAta)(bountyMint, bountyVault);
|
|
14
|
+
let rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket, basket);
|
|
15
|
+
let rentPayerPda = (0, pda_1.getRentPayerPda)();
|
|
16
|
+
let globalConfig = (0, pda_1.getGlobalConfigPda)();
|
|
17
|
+
let keeperBountyATA = (0, pda_1.getAta)(keeper, bountyMint);
|
|
18
|
+
const data = CREATE_AUCTION_DISCRIMINATOR;
|
|
19
|
+
const keys = [
|
|
20
|
+
{ pubkey: keeper, isWritable: true, isSigner: true },
|
|
21
|
+
{ pubkey: basket, isWritable: true, isSigner: false },
|
|
22
|
+
{ pubkey: rebalanceIntent, isWritable: true, isSigner: false },
|
|
23
|
+
{ pubkey: rentPayerPda, isWritable: true, isSigner: false },
|
|
24
|
+
{ pubkey: globalConfig, isWritable: false, isSigner: false },
|
|
25
|
+
{ pubkey: bountyMint, isWritable: false, isSigner: false },
|
|
26
|
+
{ pubkey: keeperBountyATA, isWritable: true, isSigner: false },
|
|
27
|
+
{ pubkey: bountyVault, isWritable: true, isSigner: false },
|
|
28
|
+
{ pubkey: bountyVaultAta, isWritable: true, isSigner: false },
|
|
29
|
+
{ pubkey: web3_js_2.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
30
|
+
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
31
|
+
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
32
|
+
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
33
|
+
{ pubkey: rebalanceIntent, isWritable: true, isSigner: false }
|
|
34
|
+
];
|
|
35
|
+
return new web3_js_1.TransactionInstruction({
|
|
36
|
+
keys,
|
|
37
|
+
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
38
|
+
data,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
|
3
|
+
export declare const CLAIM_BOUNTY_HANDLER_DISCRIMINATOR: Buffer;
|
|
4
|
+
export declare function claimBountyIx(params: {
|
|
5
|
+
keeper: PublicKey;
|
|
6
|
+
basket: PublicKey;
|
|
7
|
+
intent: PublicKey;
|
|
8
|
+
bountyMint: PublicKey;
|
|
9
|
+
bountyDepositor: PublicKey;
|
|
10
|
+
rentPayer: PublicKey;
|
|
11
|
+
keepers: PublicKey[];
|
|
12
|
+
}): TransactionInstruction;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLAIM_BOUNTY_HANDLER_DISCRIMINATOR = void 0;
|
|
4
|
+
exports.claimBountyIx = claimBountyIx;
|
|
5
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
6
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
7
|
+
const pda_1 = require("../pda");
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
9
|
+
exports.CLAIM_BOUNTY_HANDLER_DISCRIMINATOR = Buffer.from([13, 252, 98, 119, 169, 40, 250, 254]);
|
|
10
|
+
function claimBountyIx(params) {
|
|
11
|
+
const { keeper, basket, intent, bountyMint, bountyDepositor, rentPayer, keepers } = params;
|
|
12
|
+
let bountyVault = (0, pda_1.getBountyVaultPda)();
|
|
13
|
+
let globalConfig = (0, pda_1.getGlobalConfigPda)();
|
|
14
|
+
let keeperBountyAta = (0, pda_1.getAta)(keeper, bountyMint);
|
|
15
|
+
let basketBountyAta = (0, pda_1.getAta)(basket, bountyMint);
|
|
16
|
+
let bountyVaultAta = (0, pda_1.getAta)(bountyVault, bountyMint);
|
|
17
|
+
let bountyDepositorAta = (0, pda_1.getAta)(bountyDepositor, bountyMint);
|
|
18
|
+
const data = exports.CLAIM_BOUNTY_HANDLER_DISCRIMINATOR;
|
|
19
|
+
const keys = [
|
|
20
|
+
{ pubkey: keeper, isSigner: true, isWritable: true },
|
|
21
|
+
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
22
|
+
{ pubkey: intent, isSigner: false, isWritable: true },
|
|
23
|
+
{ pubkey: bountyMint, isSigner: false, isWritable: false },
|
|
24
|
+
{ pubkey: keeperBountyAta, isSigner: false, isWritable: true },
|
|
25
|
+
{ pubkey: basketBountyAta, isSigner: false, isWritable: true },
|
|
26
|
+
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
27
|
+
{ pubkey: bountyVaultAta, isSigner: false, isWritable: true },
|
|
28
|
+
{ pubkey: bountyDepositorAta, isSigner: false, isWritable: true },
|
|
29
|
+
{ pubkey: rentPayer, isSigner: false, isWritable: true },
|
|
30
|
+
{ pubkey: globalConfig, isSigner: false, isWritable: false },
|
|
31
|
+
{ pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
32
|
+
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
33
|
+
];
|
|
34
|
+
keepers.forEach((keeperPubkey) => {
|
|
35
|
+
keys.push({ pubkey: keeperPubkey, isWritable: true, isSigner: false });
|
|
36
|
+
const remKeeperATA = (0, pda_1.getAta)(keeperPubkey, bountyMint);
|
|
37
|
+
keys.push({ pubkey: remKeeperATA, isWritable: true, isSigner: false });
|
|
38
|
+
});
|
|
39
|
+
return new web3_js_1.TransactionInstruction({
|
|
40
|
+
keys,
|
|
41
|
+
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
42
|
+
data,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
export declare function startPriceUpdatesIx(params: {
|
|
3
|
+
keeper: PublicKey;
|
|
4
|
+
basket: PublicKey;
|
|
5
|
+
rebalanceIntent: PublicKey;
|
|
6
|
+
}): TransactionInstruction;
|
|
7
|
+
export declare function updateTokenPricesIx(params: {
|
|
8
|
+
keeper: PublicKey;
|
|
9
|
+
basket: PublicKey;
|
|
10
|
+
rebalanceIntent: PublicKey;
|
|
11
|
+
lookupTable0: PublicKey;
|
|
12
|
+
lookupTable1: PublicKey;
|
|
13
|
+
tokenIndices: number[];
|
|
14
|
+
additionalOracleAccounts: PublicKey[];
|
|
15
|
+
}): TransactionInstruction;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startPriceUpdatesIx = startPriceUpdatesIx;
|
|
4
|
+
exports.updateTokenPricesIx = updateTokenPricesIx;
|
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
7
|
+
const pda_1 = require("../pda");
|
|
8
|
+
const START_PRICE_UPDATES_DISCRIMINATOR = Buffer.from([240, 67, 241, 88, 0, 32, 224, 184]);
|
|
9
|
+
const UPDATE_TOKEN_PRICES_DISCRIMINATOR = Buffer.from([147, 87, 140, 33, 214, 189, 181, 242]);
|
|
10
|
+
function startPriceUpdatesIx(params) {
|
|
11
|
+
const keys = [
|
|
12
|
+
{ pubkey: params.keeper, isSigner: true, isWritable: true },
|
|
13
|
+
{ pubkey: params.basket, isSigner: false, isWritable: false },
|
|
14
|
+
{ pubkey: params.rebalanceIntent, isSigner: false, isWritable: true },
|
|
15
|
+
];
|
|
16
|
+
const data = START_PRICE_UPDATES_DISCRIMINATOR;
|
|
17
|
+
return new web3_js_1.TransactionInstruction({
|
|
18
|
+
keys,
|
|
19
|
+
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
20
|
+
data,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
;
|
|
24
|
+
function updateTokenPricesIx(params) {
|
|
25
|
+
let globalConfig = (0, pda_1.getGlobalConfigPda)();
|
|
26
|
+
const data = Buffer.concat([
|
|
27
|
+
Buffer.from(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: globalConfig, 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,10 @@
|
|
|
1
|
+
import { TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
|
3
|
+
export declare function rebalanceSwapIx(params: {
|
|
4
|
+
keeper: PublicKey;
|
|
5
|
+
basket: PublicKey;
|
|
6
|
+
mintFrom: PublicKey;
|
|
7
|
+
mintTo: PublicKey;
|
|
8
|
+
amount: number;
|
|
9
|
+
side: number;
|
|
10
|
+
}): TransactionInstruction;
|