@symmetry-hq/temp-v3-sdk 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.js +0 -1
- package/dist/src/instructions/automation/priceUpdate.js +1 -1
- package/dist/src/instructions/management/edit.js +6 -1
- package/dist/src/layouts/basket.d.ts +1 -1
- package/dist/src/layouts/basket.js +1 -1
- package/dist/src/layouts/intents/intent.d.ts +2 -1
- package/dist/src/layouts/intents/intent.js +1 -0
- package/dist/src/layouts/intents/rebalanceIntent.d.ts +1 -1
- package/dist/src/states/basket.js +55 -4
- package/dist/src/states/oracles/oracle.d.ts +4 -4
- package/dist/src/states/oracles/oracle.js +36 -16
- package/dist/src/states/oracles/pythOracle.d.ts +142 -1
- package/dist/src/states/oracles/pythOracle.js +747 -15
- package/dist/src/states/oracles/raydiumClmmOracle.d.ts +151 -2
- package/dist/src/states/oracles/raydiumClmmOracle.js +346 -44
- package/dist/src/states/oracles/raydiumCpmmOracle.d.ts +92 -9
- package/dist/src/states/oracles/raydiumCpmmOracle.js +173 -78
- package/dist/test.js +29 -29
- package/package.json +2 -2
- package/src/index.ts +0 -1
- package/src/instructions/automation/priceUpdate.ts +1 -1
- package/src/instructions/management/createBasket.ts +1 -1
- package/src/instructions/management/edit.ts +7 -2
- package/src/layouts/basket.ts +2 -2
- package/src/layouts/intents/intent.ts +4 -2
- package/src/layouts/intents/rebalanceIntent.ts +1 -1
- package/src/states/basket.ts +72 -8
- package/src/states/oracles/oracle.ts +43 -18
- package/src/states/oracles/pythOracle.ts +970 -18
- package/src/states/oracles/raydiumClmmOracle.ts +434 -57
- package/src/states/oracles/raydiumCpmmOracle.ts +224 -94
- package/test.ts +31 -29
package/dist/src/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const UPDATE_TOKEN_PRICES_DISCRIMINATOR = Buffer.from([147, 87, 140, 33, 214, 18
|
|
|
10
10
|
function startPriceUpdatesIx(params) {
|
|
11
11
|
const keys = [
|
|
12
12
|
{ pubkey: params.keeper, isSigner: true, isWritable: true },
|
|
13
|
-
{ pubkey: params.basket, isSigner: false, isWritable:
|
|
13
|
+
{ pubkey: params.basket, isSigner: false, isWritable: true },
|
|
14
14
|
{ pubkey: params.rebalanceIntent, isSigner: false, isWritable: true },
|
|
15
15
|
];
|
|
16
16
|
const data = START_PRICE_UPDATES_DISCRIMINATOR;
|
|
@@ -162,7 +162,12 @@ function createEditBasketIntentIx(params) {
|
|
|
162
162
|
}
|
|
163
163
|
break;
|
|
164
164
|
case intent_1.TaskType.UpdateWeights: // 10
|
|
165
|
-
|
|
165
|
+
let updateWeightsData = editData;
|
|
166
|
+
while (updateWeightsData.tokenMintsHash.length < 32)
|
|
167
|
+
updateWeightsData.tokenMintsHash.push(0);
|
|
168
|
+
while (updateWeightsData.tokenWeights.length < constants_1.MAX_SUPPORTED_TOKENS_PER_BASKET)
|
|
169
|
+
updateWeightsData.tokenWeights.push(0);
|
|
170
|
+
intent_1.UpdateWeightsLayout.encode(updateWeightsData, editDataBuf);
|
|
166
171
|
break;
|
|
167
172
|
case intent_1.TaskType.Swap: // 11
|
|
168
173
|
break;
|
|
@@ -22,6 +22,7 @@ export interface Asset {
|
|
|
22
22
|
mint: PublicKey;
|
|
23
23
|
amount: BN;
|
|
24
24
|
weight: number;
|
|
25
|
+
active: number;
|
|
25
26
|
oracleAggregator: OracleAggregator;
|
|
26
27
|
price?: OraclePrice;
|
|
27
28
|
value?: Decimal;
|
|
@@ -43,7 +44,6 @@ export interface Basket {
|
|
|
43
44
|
settings: BasketSettings;
|
|
44
45
|
accumulatedFees: BasketFees;
|
|
45
46
|
lookupTables: LookupTables;
|
|
46
|
-
writeVersion: BN;
|
|
47
47
|
numTokens: number;
|
|
48
48
|
composition: Asset[];
|
|
49
49
|
lutPubkeys?: AddressLookupTableAccount[];
|
|
@@ -23,6 +23,7 @@ exports.AssetLayout = (0, borsh_1.struct)([
|
|
|
23
23
|
(0, borsh_1.publicKey)('mint'),
|
|
24
24
|
(0, borsh_1.u64)('amount'),
|
|
25
25
|
(0, borsh_1.u16)('weight'),
|
|
26
|
+
(0, borsh_1.u8)('active'),
|
|
26
27
|
oracle_1.OracleAggregatorLayout.replicate('oracleAggregator'),
|
|
27
28
|
]);
|
|
28
29
|
;
|
|
@@ -37,7 +38,6 @@ exports.BasketLayout = (0, borsh_1.struct)([
|
|
|
37
38
|
config_1.BasketSettingsLayout.replicate('settings'),
|
|
38
39
|
exports.BasketFeesLayout.replicate('accumulatedFees'),
|
|
39
40
|
exports.LookupTablesLayout.replicate('lookupTables'),
|
|
40
|
-
(0, borsh_1.u64)('writeVersion'),
|
|
41
41
|
(0, borsh_1.u8)('numTokens'),
|
|
42
42
|
(0, borsh_1.array)(exports.AssetLayout, exports.MAX_SUPPORTED_TOKENS_PER_BASKET, 'composition'),
|
|
43
43
|
]);
|
|
@@ -24,6 +24,7 @@ export interface Intent {
|
|
|
24
24
|
export declare const IntentLayout: any;
|
|
25
25
|
export interface HostFees {
|
|
26
26
|
hostDepositFeeBps: number;
|
|
27
|
+
hostWithdrawalFeeBps: number;
|
|
27
28
|
hostManagementFeeBps: number;
|
|
28
29
|
hostPerformanceFeeBps: number;
|
|
29
30
|
}
|
|
@@ -83,7 +84,7 @@ export interface AddToken {
|
|
|
83
84
|
export declare const AddTokenLayout: any;
|
|
84
85
|
export interface UpdateWeights {
|
|
85
86
|
tokenWeights: number[];
|
|
86
|
-
|
|
87
|
+
tokenMintsHash: number[];
|
|
87
88
|
}
|
|
88
89
|
export declare const UpdateWeightsLayout: any;
|
|
89
90
|
export interface Swap {
|
|
@@ -27,6 +27,7 @@ exports.IntentLayout = (0, borsh_1.struct)([
|
|
|
27
27
|
]);
|
|
28
28
|
exports.HostFeesLayout = (0, borsh_1.struct)([
|
|
29
29
|
(0, borsh_1.u16)('hostDepositFeeBps'),
|
|
30
|
+
(0, borsh_1.u16)('hostWithdrawalFeeBps'),
|
|
30
31
|
(0, borsh_1.u16)('hostManagementFeeBps'),
|
|
31
32
|
(0, borsh_1.u16)('hostPerformanceFeeBps'),
|
|
32
33
|
]);
|
|
@@ -47,7 +47,7 @@ export interface RebalanceIntent {
|
|
|
47
47
|
perTradeRebalanceThresholdSlippageBps: number;
|
|
48
48
|
initialTvl: Fraction;
|
|
49
49
|
auctionUpdateTimestamp: BN;
|
|
50
|
-
auctions: AuctionTimestamps;
|
|
50
|
+
auctions: AuctionTimestamps[];
|
|
51
51
|
tokens: TokenAuction[];
|
|
52
52
|
lastActionTimestamp: BN;
|
|
53
53
|
bounty: Bounty;
|
|
@@ -22,9 +22,10 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
22
22
|
const constants_1 = require("../constants");
|
|
23
23
|
const basket_1 = require("../layouts/basket");
|
|
24
24
|
const oracle_1 = require("../layouts/oracle");
|
|
25
|
-
const oracle_2 = require("./oracles/oracle");
|
|
26
25
|
const txUtils_1 = require("../txUtils");
|
|
26
|
+
const oracle_2 = require("./oracles/oracle");
|
|
27
27
|
const pythOracle_1 = require("./oracles/pythOracle");
|
|
28
|
+
const raydiumClmmOracle_1 = require("./oracles/raydiumClmmOracle");
|
|
28
29
|
function decodeBasket(dataWithoutDiscriminator) {
|
|
29
30
|
let basket = basket_1.BasketLayout.decode(dataWithoutDiscriminator);
|
|
30
31
|
let metadataSettings = basket.settings.metadataSettings;
|
|
@@ -102,6 +103,28 @@ function fetchBaskets(connection, filters) {
|
|
|
102
103
|
return baskets;
|
|
103
104
|
});
|
|
104
105
|
}
|
|
106
|
+
// export async function getBasketOracleAccountInfos(
|
|
107
|
+
// connection: Connection,
|
|
108
|
+
// basket: Basket,
|
|
109
|
+
// ): Promise<Map<string, AccountInfo<Buffer> | null>> {
|
|
110
|
+
// let allKeys: PublicKey[] = [];
|
|
111
|
+
// for (let i = 0; i < basket.numTokens; i++) {
|
|
112
|
+
// let agg = basket.composition[i].oracleAggregator;
|
|
113
|
+
// for (let j = 0; j < agg.numOracles; j++) {
|
|
114
|
+
// const oracleData = agg.oracles[j];
|
|
115
|
+
// for (let k = 0; k < oracleData.oracleSettings.numRequiredAccounts; k++) {
|
|
116
|
+
// const lutId = oracleData.accountsToLoadLutIds[k];
|
|
117
|
+
// const lutIdx = oracleData.accountsToLoadLutIndices[k];
|
|
118
|
+
// if (lutId === 0 && lutIdx === 0) continue;
|
|
119
|
+
// if (!basket.lutPubkeys) continue;
|
|
120
|
+
// allKeys.push(basket.lutPubkeys[lutId].state.addresses[lutIdx]);
|
|
121
|
+
// }
|
|
122
|
+
// }
|
|
123
|
+
// }
|
|
124
|
+
// allKeys.push(PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT);
|
|
125
|
+
// allKeys.push(PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT);
|
|
126
|
+
// return await getMultipleAccountsInfoBatched(connection, allKeys);
|
|
127
|
+
// }
|
|
105
128
|
function getBasketOracleAccountInfos(connection, basket) {
|
|
106
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
130
|
let allKeys = [];
|
|
@@ -122,7 +145,35 @@ function getBasketOracleAccountInfos(connection, basket) {
|
|
|
122
145
|
}
|
|
123
146
|
allKeys.push(constants_1.PYTHNET_CUSTODY_PRICE_WSOL_ACCOUNT);
|
|
124
147
|
allKeys.push(constants_1.PYTHNET_CUSTODY_PRICE_USDC_ACCOUNT);
|
|
125
|
-
|
|
148
|
+
// load known accounts
|
|
149
|
+
const baseInfos = yield (0, txUtils_1.getMultipleAccountsInfoBatched)(connection, allKeys);
|
|
150
|
+
// derive and bind tick array PDAs for Raydium CLMM, then batch load them
|
|
151
|
+
const derivedTickArrayKeys = [];
|
|
152
|
+
for (let i = 0; i < basket.numTokens; i++) {
|
|
153
|
+
const agg = basket.composition[i].oracleAggregator;
|
|
154
|
+
for (let j = 0; j < agg.numOracles; j++) {
|
|
155
|
+
const oracleData = agg.oracles[j];
|
|
156
|
+
if (oracleData.oracleSettings.oracleType !== oracle_1.OracleType.RaydiumClmm)
|
|
157
|
+
continue;
|
|
158
|
+
const lutId = oracleData.accountsToLoadLutIds[0];
|
|
159
|
+
const lutIdx = oracleData.accountsToLoadLutIndices[0];
|
|
160
|
+
if (!basket.lutPubkeys)
|
|
161
|
+
continue;
|
|
162
|
+
const poolPk = basket.lutPubkeys[lutId].state.addresses[lutIdx];
|
|
163
|
+
const poolAi = baseInfos.get(poolPk.toBase58());
|
|
164
|
+
if (!poolAi)
|
|
165
|
+
continue;
|
|
166
|
+
const [poolState] = raydiumClmmOracle_1.PoolState.decode(poolAi.data, 8);
|
|
167
|
+
const currStart = (0, raydiumClmmOracle_1.getTickArrayStartIndexByTick)(poolState.tickCurrent, poolState.tickSpacing);
|
|
168
|
+
const prevStart = (0, raydiumClmmOracle_1.getNextTickArrayStartIndex)(currStart, poolState.tickSpacing, true);
|
|
169
|
+
const nextStart = (0, raydiumClmmOracle_1.getNextTickArrayStartIndex)(currStart, poolState.tickSpacing, false);
|
|
170
|
+
[prevStart, currStart, nextStart].forEach(start => derivedTickArrayKeys.push((0, raydiumClmmOracle_1.getPdaTickArrayAddress)(poolPk, start)));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
let derivedInfos = new Map();
|
|
174
|
+
derivedInfos = yield (0, txUtils_1.getMultipleAccountsInfoBatched)(connection, derivedTickArrayKeys);
|
|
175
|
+
derivedInfos.forEach((v, k) => baseInfos.set(k, v));
|
|
176
|
+
return baseInfos;
|
|
126
177
|
});
|
|
127
178
|
}
|
|
128
179
|
function loadBasketPrice(basket, connection) {
|
|
@@ -136,14 +187,14 @@ function loadBasketPrice(basket, connection) {
|
|
|
136
187
|
for (let i = 0; i < basket.numTokens; i++) {
|
|
137
188
|
const oraclePrice = oracle_2.PriceAggregator.fetch(basket.composition[i].oracleAggregator, //@ts-ignore
|
|
138
189
|
basket.lutPubkeys, oracleAccountInfos, usdcPrice, solPrice);
|
|
139
|
-
let amount = new decimal_js_1.default(
|
|
190
|
+
let amount = new decimal_js_1.default(basket.composition[i].amount.toString());
|
|
140
191
|
const value = oraclePrice.price.mul(amount);
|
|
141
192
|
basket.composition[i].price = oraclePrice;
|
|
142
193
|
basket.composition[i].value = value;
|
|
143
194
|
totalValue = totalValue.add(value);
|
|
144
195
|
}
|
|
145
196
|
basket.tvl = totalValue;
|
|
146
|
-
let supplyOutstanding = new decimal_js_1.default(
|
|
197
|
+
let supplyOutstanding = new decimal_js_1.default(basket.supplyOutstanding.toString());
|
|
147
198
|
if (supplyOutstanding.gt(new decimal_js_1.default(0)))
|
|
148
199
|
basket.price = totalValue.div(supplyOutstanding);
|
|
149
200
|
return basket;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
|
+
import { AccountInfo, AddressLookupTableAccount } from '@solana/web3.js';
|
|
3
|
+
import { Fraction } from '../../layouts/fraction';
|
|
4
|
+
import { OracleAggregator, OracleData } from '../../layouts/oracle';
|
|
5
5
|
export declare class OraclePrice {
|
|
6
6
|
price: Decimal;
|
|
7
7
|
conf: Decimal;
|
|
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PriceAggregator = exports.OraclePrice = void 0;
|
|
7
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
9
|
+
const constants_1 = require("../../constants");
|
|
7
10
|
const fraction_1 = require("../../layouts/fraction");
|
|
8
11
|
const oracle_1 = require("../../layouts/oracle");
|
|
9
|
-
const
|
|
10
|
-
const anchor_1 = require("@coral-xyz/anchor");
|
|
11
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
12
|
-
const raydiumCpmmOracle_1 = require("./raydiumCpmmOracle");
|
|
12
|
+
const constants_2 = require("./constants");
|
|
13
13
|
const pythOracle_1 = require("./pythOracle");
|
|
14
14
|
const raydiumClmmOracle_1 = require("./raydiumClmmOracle");
|
|
15
|
-
const
|
|
15
|
+
const raydiumCpmmOracle_1 = require("./raydiumCpmmOracle");
|
|
16
16
|
class OraclePrice {
|
|
17
17
|
constructor(price, conf, updateTime) {
|
|
18
18
|
this.price = price;
|
|
@@ -51,8 +51,8 @@ class PriceAggregator {
|
|
|
51
51
|
throw new Error(`Minimum confidence must be between 0 and 10000`);
|
|
52
52
|
if (!(0 <= this.confThreshBps && this.confThreshBps < 10000))
|
|
53
53
|
throw new Error(`Confidence threshold must be between 0 and 10000`);
|
|
54
|
-
if (!(0 <= this.minOraclesThresh && this.minOraclesThresh <=
|
|
55
|
-
throw new Error(`Minimum number of oracles must be between 0 and ${
|
|
54
|
+
if (!(0 <= this.minOraclesThresh && this.minOraclesThresh <= constants_2.U32_MAX))
|
|
55
|
+
throw new Error(`Minimum number of oracles must be between 0 and ${constants_2.U32_MAX}`);
|
|
56
56
|
}
|
|
57
57
|
static fetch(oracleAggregator, lutAccounts, accountInfoMap, solPrice, usdPrice) {
|
|
58
58
|
const agg = oracleAggregator;
|
|
@@ -60,17 +60,35 @@ class PriceAggregator {
|
|
|
60
60
|
for (let i = 0; i < agg.numOracles; i++) {
|
|
61
61
|
const oracleData = agg.oracles[i];
|
|
62
62
|
const settings = oracleData.oracleSettings;
|
|
63
|
-
|
|
64
|
-
for (let j = 0; j <
|
|
63
|
+
let loadedAccounts = [];
|
|
64
|
+
for (let j = 0; j < settings.numRequiredAccounts; j++) {
|
|
65
65
|
const lutId = oracleData.accountsToLoadLutIds[j];
|
|
66
66
|
const lutIdx = oracleData.accountsToLoadLutIndices[j];
|
|
67
67
|
if (lutId === 0 && lutIdx === 0)
|
|
68
68
|
continue;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
const pubkey = lutAccounts[lutId].state.addresses[lutIdx];
|
|
70
|
+
const account = accountInfoMap.get(pubkey.toBase58());
|
|
71
|
+
// @ts-ignore
|
|
72
72
|
loadedAccounts.push(account);
|
|
73
73
|
}
|
|
74
|
+
if (settings.oracleType === oracle_1.OracleType.RaydiumClmm) {
|
|
75
|
+
// ensure tick arrays are appended in order: prev, current, next
|
|
76
|
+
const poolPubkey = lutAccounts[oracleData.accountsToLoadLutIds[0]].state.addresses[oracleData.accountsToLoadLutIndices[0]];
|
|
77
|
+
const poolAi = accountInfoMap.get(poolPubkey.toBase58());
|
|
78
|
+
if (poolAi) {
|
|
79
|
+
const [poolState] = raydiumClmmOracle_1.PoolState.decode(poolAi.data, 8);
|
|
80
|
+
const currStart = (0, raydiumClmmOracle_1.getTickArrayStartIndexByTick)(poolState.tickCurrent, poolState.tickSpacing);
|
|
81
|
+
const prevStart = (0, raydiumClmmOracle_1.getNextTickArrayStartIndex)(currStart, poolState.tickSpacing, true);
|
|
82
|
+
const nextStart = (0, raydiumClmmOracle_1.getNextTickArrayStartIndex)(currStart, poolState.tickSpacing, false);
|
|
83
|
+
const poolId = poolPubkey;
|
|
84
|
+
[prevStart, currStart, nextStart].forEach(start => {
|
|
85
|
+
const pk = (0, raydiumClmmOracle_1.getPdaTickArrayAddress)(poolId, start);
|
|
86
|
+
const ai = accountInfoMap.get(pk.toBase58());
|
|
87
|
+
if (ai)
|
|
88
|
+
loadedAccounts.push(ai);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
74
92
|
let result = (() => {
|
|
75
93
|
switch (settings.oracleType) {
|
|
76
94
|
case oracle_1.OracleType.Pyth:
|
|
@@ -91,6 +109,7 @@ class PriceAggregator {
|
|
|
91
109
|
}
|
|
92
110
|
oracleResults.push(result);
|
|
93
111
|
}
|
|
112
|
+
// check this
|
|
94
113
|
if (oracleResults.length < agg.minOraclesThresh)
|
|
95
114
|
return new OraclePrice(new decimal_js_1.default(0), new decimal_js_1.default(0), new anchor_1.BN(0));
|
|
96
115
|
let prices = [];
|
|
@@ -107,11 +126,12 @@ class PriceAggregator {
|
|
|
107
126
|
let first = medianPrice.sub(p25Price);
|
|
108
127
|
let second = p75Price.sub(medianPrice);
|
|
109
128
|
let conf = first.gte(second) ? first : second;
|
|
110
|
-
|
|
129
|
+
// confidence should be strictly less than median price
|
|
130
|
+
conf = conf.lt(medianPrice) ? conf : medianPrice;
|
|
111
131
|
conf = conf.mul((0, fraction_1.fractionToDecimal)(agg.confMultiplier));
|
|
112
|
-
if (conf.div(medianPrice).mul(new decimal_js_1.default(
|
|
113
|
-
conf = medianPrice.mul(new decimal_js_1.default(agg.minConfBps)).div(new decimal_js_1.default(
|
|
114
|
-
if (conf.div(medianPrice).mul(new decimal_js_1.default(
|
|
132
|
+
if (conf.div(medianPrice).mul(new decimal_js_1.default(constants_1.HUNDRED_PERCENT_BPS)).lt(new decimal_js_1.default(agg.minConfBps)))
|
|
133
|
+
conf = medianPrice.mul(new decimal_js_1.default(agg.minConfBps)).div(new decimal_js_1.default(constants_1.HUNDRED_PERCENT_BPS));
|
|
134
|
+
if (conf.div(medianPrice).mul(new decimal_js_1.default(constants_1.HUNDRED_PERCENT_BPS)).gt(new decimal_js_1.default(agg.confThreshBps)))
|
|
115
135
|
return new OraclePrice(new decimal_js_1.default(0), new decimal_js_1.default(0), 0);
|
|
116
136
|
const oldest = Math.min(...oracleResults.map(p => p.updateTime));
|
|
117
137
|
return new OraclePrice(medianPrice, conf, oldest);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BN } from '@coral-xyz/anchor';
|
|
2
|
-
import {
|
|
2
|
+
import { HermesClient } from '@pythnetwork/hermes-client';
|
|
3
|
+
import { AccountInfo, Connection, Keypair, PublicKey, Signer, Transaction, TransactionInstruction, VersionedTransaction } from '@solana/web3.js';
|
|
3
4
|
import { OracleSettings } from '../../layouts/oracle';
|
|
4
5
|
import { OraclePrice } from './oracle';
|
|
5
6
|
export type VerificationLevel = {
|
|
@@ -12,6 +13,146 @@ export declare function parseVerificationLevel(buf: Buffer, offset: number): {
|
|
|
12
13
|
level: VerificationLevel;
|
|
13
14
|
size: number;
|
|
14
15
|
};
|
|
16
|
+
export declare const TIP_ACCOUNTS: string[];
|
|
17
|
+
export declare function getRandomTipAccount(): PublicKey;
|
|
18
|
+
export declare function buildJitoTipInstruction(payer: PublicKey, lamports: number): TransactionInstruction;
|
|
19
|
+
/**
|
|
20
|
+
* Derives the Pyth price feed account address
|
|
21
|
+
*/
|
|
22
|
+
export declare function getPythPriceFeedAccountAddress(shardId: number, priceFeedId: string | Buffer, pushOracleProgramId?: PublicKey): PublicKey;
|
|
23
|
+
export interface InstructionWithSigners {
|
|
24
|
+
instruction: TransactionInstruction;
|
|
25
|
+
signers: Keypair[];
|
|
26
|
+
computeUnits?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface PythUpdateResult {
|
|
29
|
+
postInstructions: InstructionWithSigners[];
|
|
30
|
+
closeInstructions: InstructionWithSigners[];
|
|
31
|
+
signers: Keypair[];
|
|
32
|
+
priceFeedAccounts: Map<string, PublicKey>;
|
|
33
|
+
}
|
|
34
|
+
export declare function parsePriceFeedMessage(message: Buffer): {
|
|
35
|
+
feedId: Buffer;
|
|
36
|
+
price: Buffer;
|
|
37
|
+
confidence: Buffer;
|
|
38
|
+
exponent: number;
|
|
39
|
+
publishTime: Buffer;
|
|
40
|
+
prevPublishTime: Buffer;
|
|
41
|
+
emaPrice: Buffer;
|
|
42
|
+
emaConf: Buffer;
|
|
43
|
+
};
|
|
44
|
+
/** parsing of accumulator update data (VAA + updates) */
|
|
45
|
+
export declare function parseAccumulatorUpdateData(data: Buffer): {
|
|
46
|
+
vaa: Buffer;
|
|
47
|
+
updates: {
|
|
48
|
+
message: Buffer;
|
|
49
|
+
proof: number[][];
|
|
50
|
+
}[];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Build instructions to update Pyth price feed accounts (full verification)
|
|
54
|
+
*/
|
|
55
|
+
export declare function buildPythPriceFeedUpdateInstructions(connection: Connection, payer: PublicKey, priceFeedIds: string[], shardId?: number, hermesClient?: HermesClient): Promise<PythUpdateResult>;
|
|
56
|
+
export declare const DEFAULT_COMPUTE_BUDGET_UNITS = 200000;
|
|
57
|
+
/**
|
|
58
|
+
* The maximum size of a Solana transaction, leaving some room for the compute budget instructions.
|
|
59
|
+
*/
|
|
60
|
+
export declare const PACKET_DATA_SIZE_WITH_ROOM_FOR_COMPUTE_BUDGET: number;
|
|
61
|
+
/**
|
|
62
|
+
* The maximum number of transactions in a Jito bundle.
|
|
63
|
+
*/
|
|
64
|
+
export declare const JITO_BUNDLE_SIZE = 5;
|
|
65
|
+
export declare const DEFAULT_PRIORITY_FEE_CONFIG: {
|
|
66
|
+
computeUnitPriceMicroLamports: number;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Get the size of a transaction that would contain the provided array of instructions
|
|
70
|
+
*/
|
|
71
|
+
export declare function getSizeOfTransaction(instructions: TransactionInstruction[], versionedTransaction?: boolean, addressLookupTable?: {
|
|
72
|
+
state: {
|
|
73
|
+
addresses: PublicKey[];
|
|
74
|
+
};
|
|
75
|
+
}): number;
|
|
76
|
+
/** Get the size of n in bytes when serialized as a CompressedU16 */
|
|
77
|
+
export declare function getSizeOfCompressedU16(n: number): number;
|
|
78
|
+
/**
|
|
79
|
+
* This class batches instructions into transactions efficiently.
|
|
80
|
+
*/
|
|
81
|
+
export declare class TransactionBuilder {
|
|
82
|
+
private payer;
|
|
83
|
+
private connection;
|
|
84
|
+
private addressLookupTable?;
|
|
85
|
+
private transactionInstructions;
|
|
86
|
+
constructor(payer: PublicKey, connection: Connection, addressLookupTable?: {
|
|
87
|
+
state: {
|
|
88
|
+
addresses: PublicKey[];
|
|
89
|
+
};
|
|
90
|
+
} | undefined);
|
|
91
|
+
addInstruction(args: {
|
|
92
|
+
instruction: TransactionInstruction;
|
|
93
|
+
signers: Signer[];
|
|
94
|
+
computeUnits?: number;
|
|
95
|
+
}): void;
|
|
96
|
+
addInstructions(instructions: {
|
|
97
|
+
instruction: TransactionInstruction;
|
|
98
|
+
signers: Signer[];
|
|
99
|
+
computeUnits?: number;
|
|
100
|
+
}[]): void;
|
|
101
|
+
buildVersionedTransactions(args: {
|
|
102
|
+
computeUnitPriceMicroLamports?: number;
|
|
103
|
+
tightComputeBudget?: boolean;
|
|
104
|
+
jitoTipLamports?: number;
|
|
105
|
+
}): Promise<{
|
|
106
|
+
tx: VersionedTransaction;
|
|
107
|
+
signers: Signer[];
|
|
108
|
+
}[]>;
|
|
109
|
+
buildLegacyTransactions(args: {
|
|
110
|
+
computeUnitPriceMicroLamports?: number;
|
|
111
|
+
tightComputeBudget?: boolean;
|
|
112
|
+
jitoTipLamports?: number;
|
|
113
|
+
}): {
|
|
114
|
+
tx: Transaction;
|
|
115
|
+
signers: Signer[];
|
|
116
|
+
}[];
|
|
117
|
+
static batchIntoLegacyTransactions(instructions: TransactionInstruction[], priorityFeeConfig: {
|
|
118
|
+
computeUnitPriceMicroLamports?: number;
|
|
119
|
+
tightComputeBudget?: boolean;
|
|
120
|
+
jitoTipLamports?: number;
|
|
121
|
+
}): Transaction[];
|
|
122
|
+
static batchIntoVersionedTransactions(payer: PublicKey, connection: Connection, instructions: {
|
|
123
|
+
instruction: TransactionInstruction;
|
|
124
|
+
signers: Signer[];
|
|
125
|
+
computeUnits?: number;
|
|
126
|
+
}[], priorityFeeConfig: {
|
|
127
|
+
computeUnitPriceMicroLamports?: number;
|
|
128
|
+
tightComputeBudget?: boolean;
|
|
129
|
+
jitoTipLamports?: number;
|
|
130
|
+
}, addressLookupTable?: {
|
|
131
|
+
state: {
|
|
132
|
+
addresses: PublicKey[];
|
|
133
|
+
};
|
|
134
|
+
}): Promise<{
|
|
135
|
+
tx: VersionedTransaction;
|
|
136
|
+
signers: Signer[];
|
|
137
|
+
}[]>;
|
|
138
|
+
static addPriorityFee(transaction: Transaction, priorityFeeConfig: {
|
|
139
|
+
computeUnitPriceMicroLamports?: number;
|
|
140
|
+
tightComputeBudget?: boolean;
|
|
141
|
+
jitoTipLamports?: number;
|
|
142
|
+
}): void;
|
|
143
|
+
}
|
|
144
|
+
export declare const isVersionedTransaction: (tx: Transaction | VersionedTransaction) => tx is VersionedTransaction;
|
|
145
|
+
/**
|
|
146
|
+
* Send a set of transactions to the network (with retries), using a plain Signer for the payer
|
|
147
|
+
*/
|
|
148
|
+
export declare function sendTransactions(transactions: {
|
|
149
|
+
tx: Transaction | VersionedTransaction;
|
|
150
|
+
signers?: Signer[];
|
|
151
|
+
}[], connection: Connection, payer: Signer, maxRetries?: number): Promise<string[]>;
|
|
152
|
+
export declare function buildPythPriceFeedUpdateTxs(connection: Connection, payer: PublicKey, priceFeedIds: string[], shardId?: number, computeUnitPriceMicroLamports?: number, hermesClient?: HermesClient): Promise<{
|
|
153
|
+
tx: VersionedTransaction;
|
|
154
|
+
signers: Signer[];
|
|
155
|
+
}[]>;
|
|
15
156
|
export declare class PriceFeedMessage {
|
|
16
157
|
feedId: Buffer;
|
|
17
158
|
price: BN;
|