@symmetry-hq/temp-v3-sdk 0.0.4 → 0.0.6
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/constants.d.ts +7 -2
- package/dist/src/constants.js +12 -4
- package/dist/src/index.d.ts +21 -7
- package/dist/src/index.js +158 -66
- package/dist/src/instructions/automation/priceUpdate.js +2 -2
- package/dist/src/instructions/management/createBasket.js +2 -2
- package/dist/src/instructions/management/edit.d.ts +3 -6
- package/dist/src/instructions/management/edit.js +60 -34
- package/dist/src/instructions/pda.d.ts +0 -5
- package/dist/src/instructions/pda.js +1 -7
- package/dist/src/instructions/user/deposit.d.ts +1 -1
- package/dist/src/instructions/user/deposit.js +34 -25
- package/dist/src/layouts/basket.d.ts +8 -1
- package/dist/src/layouts/config.js +1 -1
- package/dist/src/layouts/fraction.d.ts +3 -0
- package/dist/src/layouts/fraction.js +20 -0
- package/dist/src/layouts/intents/intent.d.ts +3 -2
- package/dist/src/layouts/intents/intent.js +1 -0
- package/dist/src/layouts/intents/rebalanceIntent.d.ts +3 -1
- package/dist/src/layouts/intents/rebalanceIntent.js +1 -1
- package/dist/src/layouts/oracle.d.ts +6 -3
- package/dist/src/layouts/oracle.js +22 -2
- package/dist/src/states/basket.d.ts +3 -1
- package/dist/src/states/basket.js +80 -2
- package/dist/src/states/intents/intent.js +0 -5
- package/dist/src/states/intents/rebalanceIntent.js +10 -6
- package/dist/src/states/oracles/oracle.d.ts +12 -49
- package/dist/src/states/oracles/oracle.js +86 -184
- package/dist/src/states/oracles/pythOracle.d.ts +33 -34
- package/dist/src/states/oracles/pythOracle.js +103 -185
- package/dist/src/states/oracles/raydiumClmmOracle.d.ts +15 -158
- package/dist/src/states/oracles/raydiumClmmOracle.js +92 -97
- package/dist/src/states/oracles/raydiumCpmmOracle.d.ts +13 -117
- package/dist/src/states/oracles/raydiumCpmmOracle.js +154 -136
- package/dist/src/txUtils.d.ts +3 -1
- package/dist/src/txUtils.js +46 -13
- package/dist/test.js +121 -24
- package/package.json +1 -1
- package/src/constants.ts +9 -3
- package/src/index.ts +179 -87
- package/src/instructions/automation/priceUpdate.ts +3 -3
- package/src/instructions/management/createBasket.ts +4 -4
- package/src/instructions/management/edit.ts +69 -47
- package/src/instructions/pda.ts +0 -10
- package/src/instructions/user/deposit.ts +43 -31
- package/src/layouts/basket.ts +9 -2
- package/src/layouts/config.ts +1 -1
- package/src/layouts/fraction.ts +17 -1
- package/src/layouts/intents/intent.ts +4 -3
- package/src/layouts/intents/rebalanceIntent.ts +4 -2
- package/src/layouts/oracle.ts +34 -4
- package/src/states/basket.ts +96 -8
- package/src/states/intents/intent.ts +0 -5
- package/src/states/intents/rebalanceIntent.ts +14 -7
- package/src/states/oracles/oracle.ts +110 -192
- package/src/states/oracles/pythOracle.ts +218 -245
- package/src/states/oracles/raydiumClmmOracle.ts +139 -133
- package/src/states/oracles/raydiumCpmmOracle.ts +211 -180
- package/src/txUtils.ts +55 -31
- package/test.ts +132 -26
package/dist/src/constants.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import Decimal from 'decimal.js';
|
|
2
3
|
export declare const BASKETS_V3_PROGRAM_ID: PublicKey;
|
|
3
4
|
export declare const METADATA_PROGRAM_ID: PublicKey;
|
|
4
5
|
export declare const ADDRESS_LOOKUP_TABLE_PROGRAM_ID: PublicKey;
|
|
5
6
|
export declare const RENT_SYSVAR_ID: PublicKey;
|
|
6
7
|
export declare const WSOL_MINT: PublicKey;
|
|
7
8
|
export declare const USDC_MINT: PublicKey;
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT: PublicKey;
|
|
10
|
+
export declare const PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT: PublicKey;
|
|
10
11
|
export declare const BOUNTY_MINT: PublicKey;
|
|
11
12
|
export declare const INTENT_TASK_DATA_SIZE = 600;
|
|
12
13
|
export declare const MAX_MANAGERS_PER_BASKET = 10;
|
|
14
|
+
export declare const X64: Decimal;
|
|
15
|
+
export declare const HUNDRED_PERCENT_BPS = 10000;
|
|
16
|
+
export declare const WSOL_DECIMALS = 9;
|
|
17
|
+
export declare const USDC_DECIMALS = 6;
|
|
13
18
|
export declare const MAX_SUPPORTED_TOKENS_PER_BASKET: number;
|
|
14
19
|
export declare const MAX_ORACLES_PER_TOKEN: number;
|
|
15
20
|
export declare const MAX_EXTRA_DATA_PER_ORACLE: number;
|
package/dist/src/constants.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_EXTRA_DATA_PER_ORACLE = exports.MAX_ORACLES_PER_TOKEN = exports.MAX_SUPPORTED_TOKENS_PER_BASKET = exports.MAX_MANAGERS_PER_BASKET = exports.INTENT_TASK_DATA_SIZE = exports.BOUNTY_MINT = exports.
|
|
6
|
+
exports.MAX_EXTRA_DATA_PER_ORACLE = exports.MAX_ORACLES_PER_TOKEN = exports.MAX_SUPPORTED_TOKENS_PER_BASKET = exports.USDC_DECIMALS = exports.WSOL_DECIMALS = exports.HUNDRED_PERCENT_BPS = exports.X64 = exports.MAX_MANAGERS_PER_BASKET = exports.INTENT_TASK_DATA_SIZE = exports.BOUNTY_MINT = exports.PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT = exports.PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT = exports.USDC_MINT = exports.WSOL_MINT = exports.RENT_SYSVAR_ID = exports.ADDRESS_LOOKUP_TABLE_PROGRAM_ID = exports.METADATA_PROGRAM_ID = exports.BASKETS_V3_PROGRAM_ID = void 0;
|
|
4
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
8
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
5
9
|
exports.BASKETS_V3_PROGRAM_ID = new web3_js_1.PublicKey("BASKT7aKd8n7ibpUbwLP3Wiyxyi3yoiXsxBk4Hpumate");
|
|
6
10
|
exports.METADATA_PROGRAM_ID = new web3_js_1.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
|
|
7
11
|
exports.ADDRESS_LOOKUP_TABLE_PROGRAM_ID = new web3_js_1.PublicKey("AddressLookupTab1e1111111111111111111111111");
|
|
@@ -9,11 +13,15 @@ exports.RENT_SYSVAR_ID = new web3_js_1.PublicKey("SysvarRent11111111111111111111
|
|
|
9
13
|
exports.WSOL_MINT = new web3_js_1.PublicKey("So11111111111111111111111111111111111111112");
|
|
10
14
|
// export const USDC_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
11
15
|
exports.USDC_MINT = new web3_js_1.PublicKey("USDCoctVLVnvTXBEuP9s8hntucdJokbo17RwHuNXemT");
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.BOUNTY_MINT = new web3_js_1.PublicKey("
|
|
16
|
+
exports.PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT = new web3_js_1.PublicKey("7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE");
|
|
17
|
+
exports.PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT = new web3_js_1.PublicKey("Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX");
|
|
18
|
+
exports.BOUNTY_MINT = new web3_js_1.PublicKey("So11111111111111111111111111111111111111112");
|
|
15
19
|
exports.INTENT_TASK_DATA_SIZE = 600;
|
|
16
20
|
exports.MAX_MANAGERS_PER_BASKET = 10;
|
|
21
|
+
exports.X64 = new decimal_js_1.default(2).pow(new decimal_js_1.default(64));
|
|
22
|
+
exports.HUNDRED_PERCENT_BPS = 10000;
|
|
23
|
+
exports.WSOL_DECIMALS = 9;
|
|
24
|
+
exports.USDC_DECIMALS = 6;
|
|
17
25
|
exports.MAX_SUPPORTED_TOKENS_PER_BASKET = 100;
|
|
18
26
|
exports.MAX_ORACLES_PER_TOKEN = 4;
|
|
19
27
|
exports.MAX_EXTRA_DATA_PER_ORACLE = 4;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { BN } from '@coral-xyz/anchor';
|
|
2
1
|
import { Connection, PublicKey, TransactionSignature } from '@solana/web3.js';
|
|
3
2
|
import { Basket } from './layouts/basket';
|
|
4
|
-
import { Fraction } from './layouts/fraction';
|
|
5
3
|
import { EditData, HostFees, Intent, MetadataParams, TaskType } from './layouts/intents/intent';
|
|
6
4
|
import { RebalanceIntent } from './layouts/intents/rebalanceIntent';
|
|
7
5
|
import { BasketFilter } from './states/basket';
|
|
@@ -26,29 +24,45 @@ export declare class SymmetryCore {
|
|
|
26
24
|
basket: PublicKey;
|
|
27
25
|
}): Promise<Basket>;
|
|
28
26
|
fetchAllBaskets(filters: BasketFilter[]): Promise<Basket[]>;
|
|
27
|
+
loadBasketPrice(basket: Basket): Promise<Basket>;
|
|
29
28
|
fetchAllIntents(filters: IntentFilter[]): Promise<Intent[]>;
|
|
30
29
|
fetchAllRebalanceIntents(filters: RebalanceIntentFilter[]): Promise<RebalanceIntent[]>;
|
|
31
30
|
createBasketTx(params: {
|
|
32
31
|
creator: PublicKey;
|
|
33
32
|
host: PublicKey;
|
|
34
|
-
startPrice:
|
|
33
|
+
startPrice: number;
|
|
35
34
|
hostFees: HostFees;
|
|
36
35
|
metadataParams: MetadataParams;
|
|
37
|
-
metadataModificationDelay:
|
|
36
|
+
metadataModificationDelay: number;
|
|
38
37
|
}): Promise<VersionedTxs>;
|
|
39
38
|
createEditBasketIntentTx(params: {
|
|
40
|
-
manager: PublicKey;
|
|
41
39
|
basket: Basket;
|
|
40
|
+
manager: PublicKey;
|
|
42
41
|
editType: TaskType;
|
|
43
42
|
editData: EditData;
|
|
44
|
-
useBounty:
|
|
43
|
+
useBounty: boolean;
|
|
45
44
|
}): Promise<VersionedTxs>;
|
|
46
|
-
|
|
45
|
+
executeEditBasketIntentTx(params: {
|
|
47
46
|
keeper: PublicKey;
|
|
48
47
|
basket: PublicKey;
|
|
49
48
|
manager: PublicKey;
|
|
50
49
|
editType: TaskType;
|
|
51
50
|
}): Promise<VersionedTxs>;
|
|
51
|
+
depositTx(params: {
|
|
52
|
+
buyer: PublicKey;
|
|
53
|
+
basket: PublicKey;
|
|
54
|
+
contributions: {
|
|
55
|
+
mint: PublicKey;
|
|
56
|
+
amount: number;
|
|
57
|
+
}[];
|
|
58
|
+
rebalanceSlippageBps?: number;
|
|
59
|
+
executionStartTime?: number;
|
|
60
|
+
}): Promise<VersionedTxs>;
|
|
61
|
+
updateTokenPricesTx(params: {
|
|
62
|
+
keeper: PublicKey;
|
|
63
|
+
rebalanceIntent: RebalanceIntent;
|
|
64
|
+
basket: Basket;
|
|
65
|
+
}): Promise<VersionedTxs>;
|
|
52
66
|
signAndSendVersionedTxs(params: {
|
|
53
67
|
vtxs: VersionedTxs;
|
|
54
68
|
wallet: Wallet;
|
package/dist/src/index.js
CHANGED
|
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.SymmetryCore = exports.MAX_JUPITER_ACCOUNTS = exports.JUPITER_API_KEY = exports.PRIORITY_FEE = exports.COMPUTE_UNITS = void 0;
|
|
13
16
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
@@ -16,10 +19,15 @@ const constants_1 = require("./constants");
|
|
|
16
19
|
const createBasket_1 = require("./instructions/management/createBasket");
|
|
17
20
|
const edit_1 = require("./instructions/management/edit");
|
|
18
21
|
const pda_1 = require("./instructions/pda");
|
|
22
|
+
const fraction_1 = require("./layouts/fraction");
|
|
23
|
+
const intent_1 = require("./layouts/intents/intent");
|
|
19
24
|
const basket_1 = require("./states/basket");
|
|
20
|
-
const
|
|
25
|
+
const intent_2 = require("./states/intents/intent");
|
|
21
26
|
const rebalanceIntent_1 = require("./states/intents/rebalanceIntent");
|
|
22
27
|
const txUtils_1 = require("./txUtils");
|
|
28
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
29
|
+
const deposit_1 = require("./instructions/user/deposit");
|
|
30
|
+
const priceUpdate_1 = require("./instructions/automation/priceUpdate");
|
|
23
31
|
exports.COMPUTE_UNITS = 1000000;
|
|
24
32
|
exports.PRIORITY_FEE = 100000;
|
|
25
33
|
exports.JUPITER_API_KEY = "https://quote-api.jup.ag/v6/";
|
|
@@ -52,9 +60,14 @@ class SymmetryCore {
|
|
|
52
60
|
return baskets;
|
|
53
61
|
});
|
|
54
62
|
}
|
|
63
|
+
loadBasketPrice(basket) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
return yield (0, basket_1.loadBasketPrice)(basket, this.sdkParams.connection);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
55
68
|
fetchAllIntents(filters) {
|
|
56
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const intents = yield (0,
|
|
70
|
+
const intents = yield (0, intent_2.fetchIntents)(this.sdkParams.connection, filters);
|
|
58
71
|
return intents;
|
|
59
72
|
});
|
|
60
73
|
}
|
|
@@ -66,7 +79,6 @@ class SymmetryCore {
|
|
|
66
79
|
}
|
|
67
80
|
createBasketTx(params) {
|
|
68
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
var _a;
|
|
70
82
|
const { creator, host, startPrice, hostFees, metadataParams, metadataModificationDelay } = params;
|
|
71
83
|
// generate random seed
|
|
72
84
|
const basketSeeds = (0, pda_1.getRandomSeed)();
|
|
@@ -78,10 +90,10 @@ class SymmetryCore {
|
|
|
78
90
|
slot,
|
|
79
91
|
creator,
|
|
80
92
|
host,
|
|
81
|
-
startPrice,
|
|
93
|
+
startPrice: (0, fraction_1.decimalToFraction)(new decimal_js_1.default(startPrice)),
|
|
82
94
|
hostFees,
|
|
83
95
|
metadataParams,
|
|
84
|
-
metadataModificationDelay
|
|
96
|
+
metadataModificationDelay: new anchor_1.BN(metadataModificationDelay),
|
|
85
97
|
});
|
|
86
98
|
let preIx = (0, createBasket_1.createBasketStateAccountIx)({
|
|
87
99
|
creator,
|
|
@@ -94,7 +106,7 @@ class SymmetryCore {
|
|
|
94
106
|
let vtxs = yield (0, txUtils_1.prepareV0Transactions)({
|
|
95
107
|
connection: this.sdkParams.connection,
|
|
96
108
|
payer: creator,
|
|
97
|
-
priorityFee:
|
|
109
|
+
priorityFee: this.sdkParams.priorityFee,
|
|
98
110
|
multipleIxs: [[preIx, preIx2, preIx2, ix]],
|
|
99
111
|
multipleLookupTableAddresses: [],
|
|
100
112
|
signers: [[]],
|
|
@@ -105,80 +117,47 @@ class SymmetryCore {
|
|
|
105
117
|
}
|
|
106
118
|
createEditBasketIntentTx(params) {
|
|
107
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
|
|
109
|
-
let
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
editType
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
case 9: modificationDelay = basket.settings.addTokenDelay;
|
|
129
|
-
case 10: modificationDelay = basket.settings.updateWeightsDelay;
|
|
130
|
-
case 11: modificationDelay = basket.settings.makeDirectSwapDelay;
|
|
131
|
-
}
|
|
120
|
+
let { basket } = params;
|
|
121
|
+
let ixs = [
|
|
122
|
+
(0, edit_1.createEditBasketIntentIx)(params)
|
|
123
|
+
];
|
|
124
|
+
let modificationDelay = (() => {
|
|
125
|
+
switch (params.editType) {
|
|
126
|
+
case intent_1.TaskType.EditSchedule: return basket.settings.schedule.modificationDelay;
|
|
127
|
+
case intent_1.TaskType.EditFeeSettings: return basket.settings.feeSettings.modificationDelay;
|
|
128
|
+
case intent_1.TaskType.EditManagerSettings: return basket.settings.managerSettings.modificationDelay;
|
|
129
|
+
case intent_1.TaskType.EditAutomationSettings: return basket.settings.automationSettings.modificationDelay;
|
|
130
|
+
case intent_1.TaskType.EditLpSettings: return basket.settings.lpSettings.modificationDelay;
|
|
131
|
+
case intent_1.TaskType.EditMetadataSettings: return basket.settings.metadataSettings.modificationDelay;
|
|
132
|
+
case intent_1.TaskType.EditAddTokenDelay: return basket.settings.addTokenDelay;
|
|
133
|
+
case intent_1.TaskType.EditUpdateWeightsDelay: return basket.settings.updateWeightsDelay;
|
|
134
|
+
case intent_1.TaskType.AddToken: return basket.settings.addTokenDelay;
|
|
135
|
+
case intent_1.TaskType.UpdateWeights: return basket.settings.updateWeightsDelay;
|
|
136
|
+
case intent_1.TaskType.Swap: return basket.settings.makeDirectSwapDelay;
|
|
137
|
+
default: return new anchor_1.BN(0);
|
|
138
|
+
}
|
|
139
|
+
})();
|
|
132
140
|
if (modificationDelay.eq(new anchor_1.BN(0))) {
|
|
133
|
-
|
|
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
|
-
});
|
|
141
|
+
ixs.push((0, edit_1.editBasketIx)(Object.assign(Object.assign({}, params), { basket: basket.ownAddress, keeper: params.manager })));
|
|
145
142
|
}
|
|
146
|
-
let ixs = [];
|
|
147
|
-
if (ix2 === null)
|
|
148
|
-
ixs = [[ix]];
|
|
149
|
-
else
|
|
150
|
-
ixs = [[ix, ix2]];
|
|
151
|
-
const signers = ixs.map(() => []);
|
|
152
143
|
let vtxs = yield (0, txUtils_1.prepareV0Transactions)({
|
|
153
144
|
connection: this.sdkParams.connection,
|
|
154
|
-
payer: manager,
|
|
145
|
+
payer: params.manager,
|
|
155
146
|
priorityFee: this.sdkParams.priorityFee,
|
|
156
|
-
multipleIxs: ixs,
|
|
147
|
+
multipleIxs: [ixs],
|
|
157
148
|
multipleLookupTableAddresses: [],
|
|
158
|
-
signers,
|
|
149
|
+
signers: [[]],
|
|
159
150
|
batches: [1],
|
|
160
151
|
});
|
|
161
152
|
return vtxs;
|
|
162
153
|
});
|
|
163
154
|
}
|
|
164
|
-
|
|
155
|
+
executeEditBasketIntentTx(params) {
|
|
165
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
|
|
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
|
-
});
|
|
157
|
+
let ix = (0, edit_1.editBasketIx)(params);
|
|
179
158
|
let vtxs = yield (0, txUtils_1.prepareV0Transactions)({
|
|
180
159
|
connection: this.sdkParams.connection,
|
|
181
|
-
payer:
|
|
160
|
+
payer: params.keeper,
|
|
182
161
|
priorityFee: this.sdkParams.priorityFee,
|
|
183
162
|
multipleIxs: [[ix]],
|
|
184
163
|
multipleLookupTableAddresses: [],
|
|
@@ -188,6 +167,119 @@ class SymmetryCore {
|
|
|
188
167
|
return vtxs;
|
|
189
168
|
});
|
|
190
169
|
}
|
|
170
|
+
depositTx(params) {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
let { buyer, basket, contributions, rebalanceSlippageBps, executionStartTime } = params;
|
|
173
|
+
if (!rebalanceSlippageBps)
|
|
174
|
+
rebalanceSlippageBps = 100;
|
|
175
|
+
if (!executionStartTime)
|
|
176
|
+
executionStartTime = 0;
|
|
177
|
+
let rebalanceIntent = (0, pda_1.getRebalanceIntentPda)(basket, buyer);
|
|
178
|
+
let batchIxs = [
|
|
179
|
+
[
|
|
180
|
+
(0, deposit_1.createUserRebalanceIntentIx)({
|
|
181
|
+
user: params.buyer,
|
|
182
|
+
basket: params.basket,
|
|
183
|
+
}),
|
|
184
|
+
(0, deposit_1.resizeRebalanceIntentIx)(rebalanceIntent),
|
|
185
|
+
(0, deposit_1.depositStateIx)({
|
|
186
|
+
buyer,
|
|
187
|
+
basket,
|
|
188
|
+
bountyMint: constants_1.BOUNTY_MINT,
|
|
189
|
+
rebalanceIntentRentPayer: buyer,
|
|
190
|
+
rebalanceSlippageBps: rebalanceSlippageBps,
|
|
191
|
+
executionStartTime: executionStartTime,
|
|
192
|
+
}),
|
|
193
|
+
]
|
|
194
|
+
];
|
|
195
|
+
let depositTokensIxs = (0, deposit_1.depositTokensIx)({
|
|
196
|
+
owner: buyer,
|
|
197
|
+
basket: basket,
|
|
198
|
+
contributions: contributions,
|
|
199
|
+
});
|
|
200
|
+
depositTokensIxs.forEach((ix) => {
|
|
201
|
+
batchIxs.push([ix]);
|
|
202
|
+
});
|
|
203
|
+
batchIxs.push([
|
|
204
|
+
(0, deposit_1.lockDepositsIx)({
|
|
205
|
+
owner: buyer,
|
|
206
|
+
basket: basket,
|
|
207
|
+
}),
|
|
208
|
+
]);
|
|
209
|
+
let signers = [];
|
|
210
|
+
let multipleLookupTableAddresses = [];
|
|
211
|
+
for (let i = 0; i < batchIxs.length; i++) {
|
|
212
|
+
signers.push([]);
|
|
213
|
+
multipleLookupTableAddresses.push([]);
|
|
214
|
+
}
|
|
215
|
+
let vtxs = yield (0, txUtils_1.prepareV0Transactions)({
|
|
216
|
+
connection: this.sdkParams.connection,
|
|
217
|
+
payer: buyer,
|
|
218
|
+
priorityFee: this.sdkParams.priorityFee,
|
|
219
|
+
multipleIxs: batchIxs,
|
|
220
|
+
multipleLookupTableAddresses: multipleLookupTableAddresses,
|
|
221
|
+
signers: signers,
|
|
222
|
+
batches: [1, depositTokensIxs.length, 1],
|
|
223
|
+
});
|
|
224
|
+
return vtxs;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
updateTokenPricesTx(params) {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
229
|
+
let { keeper, rebalanceIntent, basket } = params;
|
|
230
|
+
let ixs = [];
|
|
231
|
+
let signers = [];
|
|
232
|
+
let multipleLookupTableAddresses = [];
|
|
233
|
+
let batches = [];
|
|
234
|
+
let batchSize = 5;
|
|
235
|
+
for (let batchStart = 0; batchStart < basket.numTokens; batchStart += batchSize) {
|
|
236
|
+
let allKeys = [];
|
|
237
|
+
let tokenIndices = [];
|
|
238
|
+
for (let i = batchStart; i < basket.numTokens && i < batchStart + batchSize; i++) {
|
|
239
|
+
tokenIndices.push(i);
|
|
240
|
+
let agg = basket.composition[i].oracleAggregator;
|
|
241
|
+
for (let i = 0; i < agg.numOracles; i++) {
|
|
242
|
+
const oracleData = agg.oracles[i];
|
|
243
|
+
for (let j = 0; j < oracleData.oracleSettings.numRequiredAccounts; j++) {
|
|
244
|
+
const lutId = oracleData.accountsToLoadLutIds[j];
|
|
245
|
+
const lutIdx = oracleData.accountsToLoadLutIndices[j];
|
|
246
|
+
if (lutId === 0 && lutIdx === 0)
|
|
247
|
+
continue;
|
|
248
|
+
if (!basket.lutPubkeys)
|
|
249
|
+
continue;
|
|
250
|
+
allKeys.push(basket.lutPubkeys[lutId].state.addresses[lutIdx]);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
while (tokenIndices.length < 20)
|
|
255
|
+
tokenIndices.push(0);
|
|
256
|
+
ixs.push([
|
|
257
|
+
(0, priceUpdate_1.updateTokenPricesIx)({
|
|
258
|
+
keeper: keeper,
|
|
259
|
+
basket: rebalanceIntent.basket, //@ts-ignore
|
|
260
|
+
rebalanceIntent: rebalanceIntent.ownAddress,
|
|
261
|
+
lookupTable0: basket.lookupTables.active[0],
|
|
262
|
+
lookupTable1: basket.lookupTables.active[1],
|
|
263
|
+
tokenIndices: tokenIndices,
|
|
264
|
+
additionalOracleAccounts: allKeys,
|
|
265
|
+
}),
|
|
266
|
+
]);
|
|
267
|
+
signers.push([]);
|
|
268
|
+
multipleLookupTableAddresses.push([]);
|
|
269
|
+
batches.push(1);
|
|
270
|
+
}
|
|
271
|
+
let vtxs = yield (0, txUtils_1.prepareV0Transactions)({
|
|
272
|
+
connection: this.sdkParams.connection,
|
|
273
|
+
payer: keeper,
|
|
274
|
+
priorityFee: this.sdkParams.priorityFee,
|
|
275
|
+
multipleIxs: ixs,
|
|
276
|
+
multipleLookupTableAddresses: multipleLookupTableAddresses,
|
|
277
|
+
signers: signers,
|
|
278
|
+
batches: batches,
|
|
279
|
+
});
|
|
280
|
+
return vtxs;
|
|
281
|
+
});
|
|
282
|
+
}
|
|
191
283
|
signAndSendVersionedTxs(params) {
|
|
192
284
|
return __awaiter(this, void 0, void 0, function* () {
|
|
193
285
|
let { vtxs, wallet } = params;
|
|
@@ -32,8 +32,8 @@ function updateTokenPricesIx(params) {
|
|
|
32
32
|
{ pubkey: params.basket, isSigner: false, isWritable: true },
|
|
33
33
|
{ pubkey: params.rebalanceIntent, isSigner: false, isWritable: true },
|
|
34
34
|
{ pubkey: globalConfig, isSigner: false, isWritable: false },
|
|
35
|
-
{ pubkey: constants_1.
|
|
36
|
-
{ pubkey: constants_1.
|
|
35
|
+
{ pubkey: constants_1.PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT, isSigner: false, isWritable: true },
|
|
36
|
+
{ pubkey: constants_1.PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT, isSigner: false, isWritable: true },
|
|
37
37
|
{ pubkey: params.lookupTable0, isSigner: false, isWritable: true },
|
|
38
38
|
{ pubkey: params.lookupTable1, isSigner: false, isWritable: true },
|
|
39
39
|
];
|
|
@@ -82,10 +82,10 @@ function createBasketIx(params) {
|
|
|
82
82
|
{ pubkey: lookupTableInfo1, isSigner: false, isWritable: true },
|
|
83
83
|
{ pubkey: wsolBasketTokenAccount, isSigner: false, isWritable: true },
|
|
84
84
|
{ pubkey: constants_1.WSOL_MINT, isSigner: false, isWritable: true },
|
|
85
|
-
{ pubkey: constants_1.
|
|
85
|
+
{ pubkey: constants_1.PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT, isSigner: false, isWritable: true },
|
|
86
86
|
{ pubkey: usdcBasketTokenAccount, isSigner: false, isWritable: true },
|
|
87
87
|
{ pubkey: constants_1.USDC_MINT, isSigner: false, isWritable: true },
|
|
88
|
-
{ pubkey: constants_1.
|
|
88
|
+
{ pubkey: constants_1.PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT, isSigner: false, isWritable: true },
|
|
89
89
|
{ pubkey: constants_1.ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
90
90
|
{ pubkey: constants_1.METADATA_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
91
91
|
{ pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
|
|
@@ -2,6 +2,7 @@ import { PublicKey } from "@solana/web3.js";
|
|
|
2
2
|
import { AuthorityBitmasks, EditData, MetadataParams, TaskType } from "../../layouts/intents/intent";
|
|
3
3
|
import { TransactionInstruction } from "@solana/web3.js";
|
|
4
4
|
import { AutomationSettings, FeeSettings, LpSettings, ManagerSettings, ScheduleSettings } from "../../layouts/config";
|
|
5
|
+
import { Basket } from "../../layouts/basket";
|
|
5
6
|
export declare function editPrivateBasketSettingsIx(params: {
|
|
6
7
|
creator: PublicKey;
|
|
7
8
|
basket: PublicKey;
|
|
@@ -16,19 +17,15 @@ export declare function editPrivateBasketSettingsIx(params: {
|
|
|
16
17
|
metadataModificationDelay: number;
|
|
17
18
|
}): TransactionInstruction;
|
|
18
19
|
export declare function createEditBasketIntentIx(params: {
|
|
20
|
+
basket: Basket;
|
|
19
21
|
manager: PublicKey;
|
|
20
|
-
basket: PublicKey;
|
|
21
|
-
bountyMint: PublicKey;
|
|
22
22
|
editType: TaskType;
|
|
23
23
|
editData: EditData;
|
|
24
|
-
useBounty:
|
|
24
|
+
useBounty: boolean;
|
|
25
25
|
}): TransactionInstruction;
|
|
26
26
|
export declare function editBasketIx(params: {
|
|
27
27
|
keeper: PublicKey;
|
|
28
28
|
basket: PublicKey;
|
|
29
|
-
intent: PublicKey;
|
|
30
|
-
bountyMint: PublicKey;
|
|
31
29
|
manager: PublicKey;
|
|
32
30
|
editType: TaskType;
|
|
33
|
-
metadataAccount: PublicKey;
|
|
34
31
|
}): TransactionInstruction;
|
|
@@ -11,6 +11,7 @@ const spl_token_1 = require("@solana/spl-token");
|
|
|
11
11
|
const config_1 = require("../../layouts/config");
|
|
12
12
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
13
13
|
const web3_js_2 = require("@solana/web3.js");
|
|
14
|
+
const oracle_1 = require("../../layouts/oracle");
|
|
14
15
|
const EDIT_PRIVATE_BASKET_SETTINGS_DISCRIMINATOR = Buffer.from([202, 54, 138, 17, 3, 104, 128, 229]);
|
|
15
16
|
const CREATE_EDIT_BASKET_INTENT_DISCRIMINATOR = Buffer.from([82, 150, 58, 227, 153, 129, 20, 30]);
|
|
16
17
|
const EDIT_BASKET_DISCRIMINATOR = Buffer.from([156, 31, 4, 39, 248, 29, 55, 220]);
|
|
@@ -50,7 +51,7 @@ function editPrivateBasketSettingsIx(params) {
|
|
|
50
51
|
{ pubkey: params.basket, isSigner: false, isWritable: true },
|
|
51
52
|
{ pubkey: metadataAccount, isSigner: false, isWritable: true },
|
|
52
53
|
{ pubkey: globalConfig, isSigner: false, isWritable: false },
|
|
53
|
-
{ pubkey:
|
|
54
|
+
{ pubkey: constants_1.METADATA_PROGRAM_ID, isSigner: false, isWritable: false }
|
|
54
55
|
];
|
|
55
56
|
return new web3_js_1.TransactionInstruction({
|
|
56
57
|
keys,
|
|
@@ -59,14 +60,16 @@ function editPrivateBasketSettingsIx(params) {
|
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
function createEditBasketIntentIx(params) {
|
|
62
|
-
const { manager, basket,
|
|
63
|
-
let intent = (0, pda_1.getIntentPda)(basket, manager, editType);
|
|
63
|
+
const { manager, basket, editType, editData, useBounty, } = params;
|
|
64
|
+
let intent = (0, pda_1.getIntentPda)(basket.ownAddress, manager, editType);
|
|
64
65
|
let globalConfig = (0, pda_1.getGlobalConfigPda)();
|
|
65
66
|
let bountyVault = (0, pda_1.getBountyVaultPda)();
|
|
67
|
+
let bountyMint = constants_1.BOUNTY_MINT;
|
|
66
68
|
let managerBountyATA = (0, pda_1.getAta)(manager, bountyMint);
|
|
67
69
|
let bountyVaultATA = (0, pda_1.getAta)(bountyVault, bountyMint);
|
|
68
70
|
const editTypeBuf = Buffer.from([editType]);
|
|
69
|
-
|
|
71
|
+
let editDataBuf = Buffer.alloc(260);
|
|
72
|
+
let additionalAccounts = [];
|
|
70
73
|
switch (editType) {
|
|
71
74
|
case intent_1.TaskType.EditSchedule: // 1
|
|
72
75
|
config_1.ScheduleSettingsLayout.encode(editData, editDataBuf);
|
|
@@ -75,10 +78,22 @@ function createEditBasketIntentIx(params) {
|
|
|
75
78
|
config_1.FeeSettingsLayout.encode(editData, editDataBuf);
|
|
76
79
|
break;
|
|
77
80
|
case intent_1.TaskType.EditManagerSettings: // 3
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
let startIndex = 0;
|
|
82
|
+
for (let i = 0; i < config_1.MAX_MANAGERS_PER_BASKET; i++) {
|
|
83
|
+
let managerWeight = editData.managerSettings.managersWeightBps[i];
|
|
84
|
+
editDataBuf.writeUInt16LE(managerWeight, startIndex);
|
|
85
|
+
additionalAccounts.push({
|
|
86
|
+
pubkey: editData.managerSettings.managers[i],
|
|
87
|
+
isWritable: true,
|
|
88
|
+
isSigner: false
|
|
89
|
+
});
|
|
90
|
+
startIndex += 2;
|
|
91
|
+
}
|
|
92
|
+
let authorityBitmasksBuffer = Buffer.alloc(intent_1.AuthorityBitmasksLayout.span);
|
|
93
|
+
intent_1.AuthorityBitmasksLayout.encode(editData.authorityBitmasks, authorityBitmasksBuffer);
|
|
94
|
+
editDataBuf.set(authorityBitmasksBuffer, startIndex);
|
|
95
|
+
startIndex += intent_1.AuthorityBitmasksLayout.span;
|
|
96
|
+
editDataBuf.writeBigUint64LE(editData.managerSettings.modificationDelay, startIndex);
|
|
82
97
|
break;
|
|
83
98
|
case intent_1.TaskType.EditAutomationSettings: // 4
|
|
84
99
|
config_1.AutomationSettingsLayout.encode(editData, editDataBuf);
|
|
@@ -95,22 +110,34 @@ function createEditBasketIntentIx(params) {
|
|
|
95
110
|
case intent_1.TaskType.EditUpdateWeightsDelay: // 8
|
|
96
111
|
intent_1.UpdateWeightsDelayLayout.encode(editData, editDataBuf);
|
|
97
112
|
break;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
case intent_1.TaskType.AddToken: // 9
|
|
114
|
+
oracle_1.OracleAggregatorLayout.encode(editData.oracleAggregator, editDataBuf);
|
|
115
|
+
additionalAccounts.push({
|
|
116
|
+
pubkey: editData.tokenMint,
|
|
117
|
+
isWritable: false,
|
|
118
|
+
isSigner: false
|
|
119
|
+
});
|
|
120
|
+
additionalAccounts.push({
|
|
121
|
+
pubkey: (0, pda_1.getAta)(basket.ownAddress, editData.tokenMint),
|
|
122
|
+
isWritable: true,
|
|
123
|
+
isSigner: false
|
|
124
|
+
});
|
|
125
|
+
additionalAccounts.push({
|
|
126
|
+
pubkey: basket.lookupTables.active[0],
|
|
127
|
+
isWritable: true,
|
|
128
|
+
isSigner: false
|
|
129
|
+
});
|
|
130
|
+
additionalAccounts.push({
|
|
131
|
+
pubkey: basket.lookupTables.active[1],
|
|
132
|
+
isWritable: true,
|
|
133
|
+
isSigner: false
|
|
134
|
+
});
|
|
135
|
+
additionalAccounts.push({
|
|
136
|
+
pubkey: editData.oracleAccount,
|
|
137
|
+
isWritable: false,
|
|
138
|
+
isSigner: false
|
|
139
|
+
});
|
|
140
|
+
break;
|
|
114
141
|
case intent_1.TaskType.UpdateWeights: // 10
|
|
115
142
|
intent_1.UpdateWeightsLayout.encode(editData, editDataBuf);
|
|
116
143
|
break;
|
|
@@ -119,7 +146,7 @@ function createEditBasketIntentIx(params) {
|
|
|
119
146
|
default:
|
|
120
147
|
break;
|
|
121
148
|
}
|
|
122
|
-
const useBountyBuf = Buffer.from([useBounty]);
|
|
149
|
+
const useBountyBuf = Buffer.from([useBounty ? 1 : 0]);
|
|
123
150
|
const data = Buffer.concat([
|
|
124
151
|
CREATE_EDIT_BASKET_INTENT_DISCRIMINATOR,
|
|
125
152
|
editTypeBuf,
|
|
@@ -128,7 +155,7 @@ function createEditBasketIntentIx(params) {
|
|
|
128
155
|
]);
|
|
129
156
|
const keys = [
|
|
130
157
|
{ pubkey: manager, isSigner: true, isWritable: true },
|
|
131
|
-
{ pubkey: basket, isSigner: false, isWritable: true },
|
|
158
|
+
{ pubkey: basket.ownAddress, isSigner: false, isWritable: true },
|
|
132
159
|
{ pubkey: intent, isSigner: false, isWritable: true },
|
|
133
160
|
{ pubkey: globalConfig, isSigner: false, isWritable: false },
|
|
134
161
|
{ pubkey: bountyMint, isSigner: false, isWritable: false },
|
|
@@ -140,6 +167,7 @@ function createEditBasketIntentIx(params) {
|
|
|
140
167
|
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
141
168
|
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
142
169
|
];
|
|
170
|
+
keys.push(...additionalAccounts);
|
|
143
171
|
return new web3_js_1.TransactionInstruction({
|
|
144
172
|
keys,
|
|
145
173
|
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
@@ -147,9 +175,12 @@ function createEditBasketIntentIx(params) {
|
|
|
147
175
|
});
|
|
148
176
|
}
|
|
149
177
|
function editBasketIx(params) {
|
|
150
|
-
const { keeper, basket,
|
|
178
|
+
const { keeper, basket, manager, editType, } = params;
|
|
179
|
+
let intent = (0, pda_1.getIntentPda)(basket, manager, editType);
|
|
180
|
+
let metadataAccount = (0, pda_1.getMetadataAccount)(basket);
|
|
151
181
|
let globalConfig = (0, pda_1.getGlobalConfigPda)();
|
|
152
182
|
let bountyVault = (0, pda_1.getBountyVaultPda)();
|
|
183
|
+
let bountyMint = constants_1.BOUNTY_MINT;
|
|
153
184
|
let keeperBountyATA = (0, pda_1.getAta)(keeper, bountyMint);
|
|
154
185
|
let managerBountyATA = (0, pda_1.getAta)(manager, bountyMint);
|
|
155
186
|
let bountyVaultATA = (0, pda_1.getAta)(bountyVault, bountyMint);
|
|
@@ -175,15 +206,10 @@ function editBasketIx(params) {
|
|
|
175
206
|
// remaining accounts
|
|
176
207
|
if (params.editType === intent_1.TaskType.EditMetadataSettings) {
|
|
177
208
|
keys.push({ pubkey: params.basket, isSigner: true, isWritable: false });
|
|
178
|
-
keys.push({ pubkey:
|
|
179
|
-
keys.push({ pubkey:
|
|
209
|
+
keys.push({ pubkey: metadataAccount, isSigner: false, isWritable: true });
|
|
210
|
+
keys.push({ pubkey: constants_1.METADATA_PROGRAM_ID, isSigner: false, isWritable: false });
|
|
180
211
|
}
|
|
181
212
|
;
|
|
182
|
-
// if(params.editType === TaskType.AddToken){
|
|
183
|
-
// params.lookupTables.forEach((lookupTablePubkey) => {
|
|
184
|
-
// keys.push({ pubkey: lookupTablePubkey, isWritable: false, isSigner: false });
|
|
185
|
-
// });
|
|
186
|
-
// };
|
|
187
213
|
return new web3_js_1.TransactionInstruction({
|
|
188
214
|
keys,
|
|
189
215
|
programId: constants_1.BASKETS_V3_PROGRAM_ID,
|
|
@@ -5,11 +5,6 @@ export declare const MINT_SEED: Buffer;
|
|
|
5
5
|
export declare const RENT_PAYER_SEED: Buffer;
|
|
6
6
|
export declare const BOUNTY_VAULT_SEED: Buffer;
|
|
7
7
|
export declare const REBALANCE_INTENT_SEED: Buffer;
|
|
8
|
-
export declare const WSOL_MINT: PublicKey;
|
|
9
|
-
export declare const USDC_MINT: PublicKey;
|
|
10
|
-
export declare const PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT: PublicKey;
|
|
11
|
-
export declare const PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT: PublicKey;
|
|
12
|
-
export declare const METADATA_PROGRAM_ID: PublicKey;
|
|
13
8
|
export declare function serializeString(input: string): Uint8Array;
|
|
14
9
|
export declare function getRandomSeed(): number[];
|
|
15
10
|
export declare function getBasketState(seeds: number[]): PublicKey;
|