@gearbox-protocol/sdk 9.3.1 → 9.5.0
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/cjs/dev/AccountOpener.js +42 -6
- package/dist/cjs/sdk/base/TokensMeta.js +4 -2
- package/dist/cjs/sdk/constants/address-provider.js +3 -0
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +19 -0
- package/dist/esm/dev/AccountOpener.js +42 -6
- package/dist/esm/sdk/base/TokensMeta.js +4 -2
- package/dist/esm/sdk/constants/address-provider.js +2 -0
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +26 -1
- package/dist/types/dev/AccountOpener.d.ts +28 -3
- package/dist/types/sdk/base/TokensMeta.d.ts +6 -2
- package/dist/types/sdk/constants/address-provider.d.ts +1 -0
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +13 -2
- package/package.json +1 -1
|
@@ -162,28 +162,39 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
162
162
|
});
|
|
163
163
|
logger?.debug(`opening account #${index}/${total}`);
|
|
164
164
|
const borrower = await this.#getBorrower();
|
|
165
|
-
const
|
|
165
|
+
const preview = await this.prepareOpen(input);
|
|
166
|
+
const humanizedInput = this.#humanizePreview(input, preview);
|
|
166
167
|
let hash;
|
|
167
168
|
try {
|
|
168
169
|
hash = await (0, import_sdk.sendRawTx)(this.#anvil, {
|
|
169
|
-
tx,
|
|
170
|
+
tx: preview.tx,
|
|
170
171
|
account: borrower
|
|
171
172
|
});
|
|
172
173
|
logger?.debug(`send transaction ${hash}`);
|
|
173
174
|
} catch (e) {
|
|
174
175
|
return {
|
|
175
176
|
input,
|
|
177
|
+
humanizedInput,
|
|
176
178
|
error: e,
|
|
177
|
-
rawTx:
|
|
179
|
+
rawTx: {
|
|
180
|
+
to: preview.tx.to,
|
|
181
|
+
callData: preview.tx.callData,
|
|
182
|
+
value: preview.tx.value
|
|
183
|
+
}
|
|
178
184
|
};
|
|
179
185
|
}
|
|
180
186
|
const receipt = await this.#anvil.waitForTransactionReceipt({ hash });
|
|
181
187
|
if (receipt.status === "reverted") {
|
|
182
188
|
return {
|
|
183
189
|
input,
|
|
190
|
+
humanizedInput,
|
|
184
191
|
error: new OpenTxRevertedError(hash),
|
|
185
192
|
txHash: hash,
|
|
186
|
-
rawTx:
|
|
193
|
+
rawTx: {
|
|
194
|
+
to: preview.tx.to,
|
|
195
|
+
callData: preview.tx.callData,
|
|
196
|
+
value: preview.tx.value
|
|
197
|
+
}
|
|
187
198
|
};
|
|
188
199
|
}
|
|
189
200
|
logger?.info(`opened credit account ${index}/${total}`);
|
|
@@ -208,8 +219,13 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
208
219
|
}
|
|
209
220
|
return {
|
|
210
221
|
input,
|
|
222
|
+
humanizedInput,
|
|
211
223
|
txHash: hash,
|
|
212
|
-
rawTx:
|
|
224
|
+
rawTx: {
|
|
225
|
+
to: preview.tx.to,
|
|
226
|
+
callData: preview.tx.callData,
|
|
227
|
+
value: preview.tx.value
|
|
228
|
+
},
|
|
213
229
|
account
|
|
214
230
|
};
|
|
215
231
|
}
|
|
@@ -318,7 +334,14 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
318
334
|
);
|
|
319
335
|
}
|
|
320
336
|
logger?.debug("prepared open account transaction");
|
|
321
|
-
return
|
|
337
|
+
return {
|
|
338
|
+
tx,
|
|
339
|
+
leverage,
|
|
340
|
+
collateral: { token: underlying, balance: minDebt },
|
|
341
|
+
minQuota,
|
|
342
|
+
averageQuota,
|
|
343
|
+
slippage
|
|
344
|
+
};
|
|
322
345
|
}
|
|
323
346
|
async getOpenedAccounts() {
|
|
324
347
|
return await this.#service.getCreditAccounts({
|
|
@@ -838,6 +861,19 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
838
861
|
result = BigInt(Math.floor(Number(result) / 1e3) * 1e3);
|
|
839
862
|
return result;
|
|
840
863
|
}
|
|
864
|
+
#humanizePreview(input, preview) {
|
|
865
|
+
return {
|
|
866
|
+
creditManager: this.sdk.labelAddress(input.creditManager),
|
|
867
|
+
target: this.sdk.labelAddress(input.target),
|
|
868
|
+
leverage: Number(preview.leverage),
|
|
869
|
+
slippage: preview.slippage,
|
|
870
|
+
collateral: this.sdk.tokensMeta.formatBN(preview.collateral, {
|
|
871
|
+
symbol: true
|
|
872
|
+
}),
|
|
873
|
+
minQuota: preview.minQuota.filter((q) => q.balance > 10n).map((q) => this.sdk.tokensMeta.formatBN(q, { symbol: true })),
|
|
874
|
+
averageQuota: preview.averageQuota.filter((q) => q.balance > 10n).map((q) => this.sdk.tokensMeta.formatBN(q, { symbol: true }))
|
|
875
|
+
};
|
|
876
|
+
}
|
|
841
877
|
get faucet() {
|
|
842
878
|
if (!this.#faucet) {
|
|
843
879
|
throw new Error("faucet not found");
|
|
@@ -32,8 +32,10 @@ class TokensMeta extends import_utils.AddressMap {
|
|
|
32
32
|
formatBN(arg0, arg1, arg2) {
|
|
33
33
|
const token = typeof arg0 === "object" ? arg0.token : arg0;
|
|
34
34
|
const amount = typeof arg0 === "object" ? arg0.balance : arg1;
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const options = typeof arg0 === "object" ? arg1 : arg2;
|
|
36
|
+
const { precision, symbol } = options ?? {};
|
|
37
|
+
const asStr = (0, import_utils.formatBN)(amount, this.decimals(token), precision);
|
|
38
|
+
return symbol ? `${asStr} ${this.symbol(token)}` : asStr;
|
|
37
39
|
}
|
|
38
40
|
findBySymbol(symbol) {
|
|
39
41
|
return this.values().find((v) => v.symbol === symbol);
|
|
@@ -42,6 +42,7 @@ __export(address_provider_exports, {
|
|
|
42
42
|
AP_PARTIAL_LIQUIDATION_BOT: () => AP_PARTIAL_LIQUIDATION_BOT,
|
|
43
43
|
AP_PERIPHERY_COMPRESSOR: () => AP_PERIPHERY_COMPRESSOR,
|
|
44
44
|
AP_PRICE_FEED_COMPRESSOR: () => AP_PRICE_FEED_COMPRESSOR,
|
|
45
|
+
AP_PRICE_FEED_STORE: () => AP_PRICE_FEED_STORE,
|
|
45
46
|
AP_PRICE_ORACLE: () => AP_PRICE_ORACLE,
|
|
46
47
|
AP_REWARDS_COMPRESSOR: () => AP_REWARDS_COMPRESSOR,
|
|
47
48
|
AP_ROUTER: () => AP_ROUTER,
|
|
@@ -78,6 +79,7 @@ const AP_MARKET_CONFIGURATOR = "MARKET_CONFIGURATOR";
|
|
|
78
79
|
const AP_PARTIAL_LIQUIDATION_BOT = "PARTIAL_LIQUIDATION_BOT";
|
|
79
80
|
const AP_PERIPHERY_COMPRESSOR = "GLOBAL::PERIPHERY_COMPRESSOR";
|
|
80
81
|
const AP_PRICE_FEED_COMPRESSOR = "GLOBAL::PRICE_FEED_COMPRESSOR";
|
|
82
|
+
const AP_PRICE_FEED_STORE = "PRICE_FEED_STORE";
|
|
81
83
|
const AP_PRICE_ORACLE = "PRICE_ORACLE";
|
|
82
84
|
const AP_REWARDS_COMPRESSOR = "GLOBAL::REWARDS_COMPRESSOR";
|
|
83
85
|
const AP_ROUTER = "GLOBAL::ROUTER";
|
|
@@ -131,6 +133,7 @@ const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
|
|
|
131
133
|
AP_PARTIAL_LIQUIDATION_BOT,
|
|
132
134
|
AP_PERIPHERY_COMPRESSOR,
|
|
133
135
|
AP_PRICE_FEED_COMPRESSOR,
|
|
136
|
+
AP_PRICE_FEED_STORE,
|
|
134
137
|
AP_PRICE_ORACLE,
|
|
135
138
|
AP_REWARDS_COMPRESSOR,
|
|
136
139
|
AP_ROUTER,
|
|
@@ -21,6 +21,7 @@ __export(PriceFeedsRegister_exports, {
|
|
|
21
21
|
PriceFeedRegister: () => PriceFeedRegister
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(PriceFeedsRegister_exports);
|
|
24
|
+
var import_viem = require("viem");
|
|
24
25
|
var import_compressors = require("../../../abi/compressors.js");
|
|
25
26
|
var import_base = require("../../base/index.js");
|
|
26
27
|
var import_constants = require("../../constants/index.js");
|
|
@@ -127,6 +128,24 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
127
128
|
);
|
|
128
129
|
return (0, import_getRawPriceUpdates.getRawPriceUpdates)(updates);
|
|
129
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Similar to {@link generatePriceFeedsUpdates}, but returns raw transaction to PriceFeedStore.updatePrices
|
|
133
|
+
* @param priceFeeds
|
|
134
|
+
* @param logContext
|
|
135
|
+
* @returns
|
|
136
|
+
*/
|
|
137
|
+
async getPriceFeedStoreUpdateTx(priceFeeds, logContext = {}) {
|
|
138
|
+
const pfs = this.sdk.addressProvider.getAddress(import_constants.AP_PRICE_FEED_STORE);
|
|
139
|
+
const updates = await this.generatePriceFeedsUpdates(
|
|
140
|
+
priceFeeds,
|
|
141
|
+
logContext
|
|
142
|
+
);
|
|
143
|
+
return (0, import_utils.createRawTx)(pfs, {
|
|
144
|
+
abi: (0, import_viem.parseAbi)(["function updatePrices((address,bytes)[])"]),
|
|
145
|
+
functionName: "updatePrices",
|
|
146
|
+
args: [updates.map((u) => [u.priceFeed, u.data])]
|
|
147
|
+
});
|
|
148
|
+
}
|
|
130
149
|
/**
|
|
131
150
|
* Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds
|
|
132
151
|
* This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
|
|
@@ -155,28 +155,39 @@ class AccountOpener extends SDKConstruct {
|
|
|
155
155
|
});
|
|
156
156
|
logger?.debug(`opening account #${index}/${total}`);
|
|
157
157
|
const borrower = await this.#getBorrower();
|
|
158
|
-
const
|
|
158
|
+
const preview = await this.prepareOpen(input);
|
|
159
|
+
const humanizedInput = this.#humanizePreview(input, preview);
|
|
159
160
|
let hash;
|
|
160
161
|
try {
|
|
161
162
|
hash = await sendRawTx(this.#anvil, {
|
|
162
|
-
tx,
|
|
163
|
+
tx: preview.tx,
|
|
163
164
|
account: borrower
|
|
164
165
|
});
|
|
165
166
|
logger?.debug(`send transaction ${hash}`);
|
|
166
167
|
} catch (e) {
|
|
167
168
|
return {
|
|
168
169
|
input,
|
|
170
|
+
humanizedInput,
|
|
169
171
|
error: e,
|
|
170
|
-
rawTx:
|
|
172
|
+
rawTx: {
|
|
173
|
+
to: preview.tx.to,
|
|
174
|
+
callData: preview.tx.callData,
|
|
175
|
+
value: preview.tx.value
|
|
176
|
+
}
|
|
171
177
|
};
|
|
172
178
|
}
|
|
173
179
|
const receipt = await this.#anvil.waitForTransactionReceipt({ hash });
|
|
174
180
|
if (receipt.status === "reverted") {
|
|
175
181
|
return {
|
|
176
182
|
input,
|
|
183
|
+
humanizedInput,
|
|
177
184
|
error: new OpenTxRevertedError(hash),
|
|
178
185
|
txHash: hash,
|
|
179
|
-
rawTx:
|
|
186
|
+
rawTx: {
|
|
187
|
+
to: preview.tx.to,
|
|
188
|
+
callData: preview.tx.callData,
|
|
189
|
+
value: preview.tx.value
|
|
190
|
+
}
|
|
180
191
|
};
|
|
181
192
|
}
|
|
182
193
|
logger?.info(`opened credit account ${index}/${total}`);
|
|
@@ -201,8 +212,13 @@ class AccountOpener extends SDKConstruct {
|
|
|
201
212
|
}
|
|
202
213
|
return {
|
|
203
214
|
input,
|
|
215
|
+
humanizedInput,
|
|
204
216
|
txHash: hash,
|
|
205
|
-
rawTx:
|
|
217
|
+
rawTx: {
|
|
218
|
+
to: preview.tx.to,
|
|
219
|
+
callData: preview.tx.callData,
|
|
220
|
+
value: preview.tx.value
|
|
221
|
+
},
|
|
206
222
|
account
|
|
207
223
|
};
|
|
208
224
|
}
|
|
@@ -311,7 +327,14 @@ class AccountOpener extends SDKConstruct {
|
|
|
311
327
|
);
|
|
312
328
|
}
|
|
313
329
|
logger?.debug("prepared open account transaction");
|
|
314
|
-
return
|
|
330
|
+
return {
|
|
331
|
+
tx,
|
|
332
|
+
leverage,
|
|
333
|
+
collateral: { token: underlying, balance: minDebt },
|
|
334
|
+
minQuota,
|
|
335
|
+
averageQuota,
|
|
336
|
+
slippage
|
|
337
|
+
};
|
|
315
338
|
}
|
|
316
339
|
async getOpenedAccounts() {
|
|
317
340
|
return await this.#service.getCreditAccounts({
|
|
@@ -831,6 +854,19 @@ class AccountOpener extends SDKConstruct {
|
|
|
831
854
|
result = BigInt(Math.floor(Number(result) / 1e3) * 1e3);
|
|
832
855
|
return result;
|
|
833
856
|
}
|
|
857
|
+
#humanizePreview(input, preview) {
|
|
858
|
+
return {
|
|
859
|
+
creditManager: this.sdk.labelAddress(input.creditManager),
|
|
860
|
+
target: this.sdk.labelAddress(input.target),
|
|
861
|
+
leverage: Number(preview.leverage),
|
|
862
|
+
slippage: preview.slippage,
|
|
863
|
+
collateral: this.sdk.tokensMeta.formatBN(preview.collateral, {
|
|
864
|
+
symbol: true
|
|
865
|
+
}),
|
|
866
|
+
minQuota: preview.minQuota.filter((q) => q.balance > 10n).map((q) => this.sdk.tokensMeta.formatBN(q, { symbol: true })),
|
|
867
|
+
averageQuota: preview.averageQuota.filter((q) => q.balance > 10n).map((q) => this.sdk.tokensMeta.formatBN(q, { symbol: true }))
|
|
868
|
+
};
|
|
869
|
+
}
|
|
834
870
|
get faucet() {
|
|
835
871
|
if (!this.#faucet) {
|
|
836
872
|
throw new Error("faucet not found");
|
|
@@ -9,8 +9,10 @@ class TokensMeta extends AddressMap {
|
|
|
9
9
|
formatBN(arg0, arg1, arg2) {
|
|
10
10
|
const token = typeof arg0 === "object" ? arg0.token : arg0;
|
|
11
11
|
const amount = typeof arg0 === "object" ? arg0.balance : arg1;
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const options = typeof arg0 === "object" ? arg1 : arg2;
|
|
13
|
+
const { precision, symbol } = options ?? {};
|
|
14
|
+
const asStr = formatBN(amount, this.decimals(token), precision);
|
|
15
|
+
return symbol ? `${asStr} ${this.symbol(token)}` : asStr;
|
|
14
16
|
}
|
|
15
17
|
findBySymbol(symbol) {
|
|
16
18
|
return this.values().find((v) => v.symbol === symbol);
|
|
@@ -22,6 +22,7 @@ const AP_MARKET_CONFIGURATOR = "MARKET_CONFIGURATOR";
|
|
|
22
22
|
const AP_PARTIAL_LIQUIDATION_BOT = "PARTIAL_LIQUIDATION_BOT";
|
|
23
23
|
const AP_PERIPHERY_COMPRESSOR = "GLOBAL::PERIPHERY_COMPRESSOR";
|
|
24
24
|
const AP_PRICE_FEED_COMPRESSOR = "GLOBAL::PRICE_FEED_COMPRESSOR";
|
|
25
|
+
const AP_PRICE_FEED_STORE = "PRICE_FEED_STORE";
|
|
25
26
|
const AP_PRICE_ORACLE = "PRICE_ORACLE";
|
|
26
27
|
const AP_REWARDS_COMPRESSOR = "GLOBAL::REWARDS_COMPRESSOR";
|
|
27
28
|
const AP_ROUTER = "GLOBAL::ROUTER";
|
|
@@ -74,6 +75,7 @@ export {
|
|
|
74
75
|
AP_PARTIAL_LIQUIDATION_BOT,
|
|
75
76
|
AP_PERIPHERY_COMPRESSOR,
|
|
76
77
|
AP_PRICE_FEED_COMPRESSOR,
|
|
78
|
+
AP_PRICE_FEED_STORE,
|
|
77
79
|
AP_PRICE_ORACLE,
|
|
78
80
|
AP_REWARDS_COMPRESSOR,
|
|
79
81
|
AP_ROUTER,
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { parseAbi } from "viem";
|
|
1
2
|
import { iPriceFeedCompressorAbi } from "../../../abi/compressors.js";
|
|
2
3
|
import { SDKConstruct } from "../../base/index.js";
|
|
3
4
|
import {
|
|
4
5
|
ADDRESS_0X0,
|
|
5
6
|
AP_PRICE_FEED_COMPRESSOR,
|
|
7
|
+
AP_PRICE_FEED_STORE,
|
|
6
8
|
VERSION_RANGE_310
|
|
7
9
|
} from "../../constants/index.js";
|
|
8
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
AddressMap,
|
|
12
|
+
bytes32ToString,
|
|
13
|
+
childLogger,
|
|
14
|
+
createRawTx
|
|
15
|
+
} from "../../utils/index.js";
|
|
9
16
|
import { Hooks } from "../../utils/internal/index.js";
|
|
10
17
|
import {
|
|
11
18
|
PartialPriceFeedInitError
|
|
@@ -110,6 +117,24 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
110
117
|
);
|
|
111
118
|
return getRawPriceUpdates(updates);
|
|
112
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Similar to {@link generatePriceFeedsUpdates}, but returns raw transaction to PriceFeedStore.updatePrices
|
|
122
|
+
* @param priceFeeds
|
|
123
|
+
* @param logContext
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
async getPriceFeedStoreUpdateTx(priceFeeds, logContext = {}) {
|
|
127
|
+
const pfs = this.sdk.addressProvider.getAddress(AP_PRICE_FEED_STORE);
|
|
128
|
+
const updates = await this.generatePriceFeedsUpdates(
|
|
129
|
+
priceFeeds,
|
|
130
|
+
logContext
|
|
131
|
+
);
|
|
132
|
+
return createRawTx(pfs, {
|
|
133
|
+
abi: parseAbi(["function updatePrices((address,bytes)[])"]),
|
|
134
|
+
functionName: "updatePrices",
|
|
135
|
+
args: [updates.map((u) => [u.priceFeed, u.data])]
|
|
136
|
+
});
|
|
137
|
+
}
|
|
113
138
|
/**
|
|
114
139
|
* Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds
|
|
115
140
|
* This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address, Hash, Hex, PrivateKeyAccount } from "viem";
|
|
2
2
|
import { BaseError } from "viem";
|
|
3
|
-
import type { CreditAccountData, ICreditAccountsService, RawTx } from "../sdk/index.js";
|
|
3
|
+
import type { Asset, CreditAccountData, ICreditAccountsService, RawTx } from "../sdk/index.js";
|
|
4
4
|
import { SDKConstruct } from "../sdk/index.js";
|
|
5
5
|
export declare class OpenTxRevertedError extends BaseError {
|
|
6
6
|
readonly txHash: Hash;
|
|
@@ -42,11 +42,35 @@ export interface TargetAccount {
|
|
|
42
42
|
*/
|
|
43
43
|
slippage?: number;
|
|
44
44
|
}
|
|
45
|
+
interface OpenAccountPreview {
|
|
46
|
+
tx: RawTx;
|
|
47
|
+
/**
|
|
48
|
+
* Actual leverage, with percentage factor
|
|
49
|
+
*/
|
|
50
|
+
leverage: bigint;
|
|
51
|
+
/**
|
|
52
|
+
* What user adds as collateral
|
|
53
|
+
*/
|
|
54
|
+
collateral: Asset;
|
|
55
|
+
minQuota: Asset[];
|
|
56
|
+
averageQuota: Asset[];
|
|
57
|
+
slippage: number;
|
|
58
|
+
}
|
|
59
|
+
export interface OpenAccountHumanizedPreview {
|
|
60
|
+
creditManager: string;
|
|
61
|
+
target: string;
|
|
62
|
+
collateral: string;
|
|
63
|
+
leverage: number;
|
|
64
|
+
slippage: number;
|
|
65
|
+
minQuota: string[];
|
|
66
|
+
averageQuota: string[];
|
|
67
|
+
}
|
|
45
68
|
export interface OpenAccountResult {
|
|
46
69
|
input: TargetAccount;
|
|
70
|
+
humanizedInput?: OpenAccountHumanizedPreview;
|
|
47
71
|
error?: Error;
|
|
48
72
|
txHash?: string;
|
|
49
|
-
rawTx?: RawTx
|
|
73
|
+
rawTx?: Pick<RawTx, "to" | "callData" | "value">;
|
|
50
74
|
account?: CreditAccountData;
|
|
51
75
|
}
|
|
52
76
|
export type PoolDepositResult = {
|
|
@@ -76,7 +100,8 @@ export declare class AccountOpener extends SDKConstruct {
|
|
|
76
100
|
* Tries to open account with underlying only in each CM
|
|
77
101
|
*/
|
|
78
102
|
openCreditAccounts(targets: TargetAccount[], depositIntoPools?: boolean, claimFromFaucet?: boolean): Promise<OpenAccountsResult>;
|
|
79
|
-
prepareOpen(input: TargetAccount): Promise<
|
|
103
|
+
prepareOpen(input: TargetAccount): Promise<OpenAccountPreview>;
|
|
80
104
|
getOpenedAccounts(): Promise<CreditAccountData[]>;
|
|
81
105
|
get faucet(): Address;
|
|
82
106
|
}
|
|
107
|
+
export {};
|
|
@@ -2,11 +2,15 @@ import type { Address } from "viem";
|
|
|
2
2
|
import type { Asset } from "../router/index.js";
|
|
3
3
|
import { AddressMap } from "../utils/index.js";
|
|
4
4
|
import type { TokenMetaData } from "./types.js";
|
|
5
|
+
export interface FormatBNOptions {
|
|
6
|
+
precision?: number;
|
|
7
|
+
symbol?: boolean;
|
|
8
|
+
}
|
|
5
9
|
export declare class TokensMeta extends AddressMap<TokenMetaData> {
|
|
6
10
|
symbol(token: Address): string;
|
|
7
11
|
decimals(token: Address): number;
|
|
8
|
-
formatBN(asset: Asset,
|
|
9
|
-
formatBN(token: Address, amount: number | bigint | string | undefined,
|
|
12
|
+
formatBN(asset: Asset, options?: FormatBNOptions): string;
|
|
13
|
+
formatBN(token: Address, amount: number | bigint | string | undefined, options?: FormatBNOptions): string;
|
|
10
14
|
findBySymbol(symbol: string): TokenMetaData | undefined;
|
|
11
15
|
mustFindBySymbol(symbol: string): TokenMetaData;
|
|
12
16
|
}
|
|
@@ -23,6 +23,7 @@ export declare const AP_MARKET_CONFIGURATOR = "MARKET_CONFIGURATOR";
|
|
|
23
23
|
export declare const AP_PARTIAL_LIQUIDATION_BOT = "PARTIAL_LIQUIDATION_BOT";
|
|
24
24
|
export declare const AP_PERIPHERY_COMPRESSOR = "GLOBAL::PERIPHERY_COMPRESSOR";
|
|
25
25
|
export declare const AP_PRICE_FEED_COMPRESSOR = "GLOBAL::PRICE_FEED_COMPRESSOR";
|
|
26
|
+
export declare const AP_PRICE_FEED_STORE = "PRICE_FEED_STORE";
|
|
26
27
|
export declare const AP_PRICE_ORACLE = "PRICE_ORACLE";
|
|
27
28
|
export declare const AP_REWARDS_COMPRESSOR = "GLOBAL::REWARDS_COMPRESSOR";
|
|
28
29
|
export declare const AP_ROUTER = "GLOBAL::ROUTER";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Address, type BlockTag } from "viem";
|
|
2
2
|
import type { PriceFeedTreeNode } from "../../base/index.js";
|
|
3
3
|
import { SDKConstruct } from "../../base/index.js";
|
|
4
4
|
import type { GearboxSDK } from "../../GearboxSDK.js";
|
|
5
|
-
import type { ILogger } from "../../types/index.js";
|
|
5
|
+
import type { ILogger, RawTx } from "../../types/index.js";
|
|
6
6
|
import type { IHooks } from "../../utils/internal/index.js";
|
|
7
7
|
import { type PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
|
|
8
8
|
import type { IPriceFeedContract, PriceUpdateV310, UpdatePriceFeedsResult } from "./types.js";
|
|
@@ -57,6 +57,17 @@ export declare class PriceFeedRegister extends SDKConstruct implements IHooks<Pr
|
|
|
57
57
|
} | {
|
|
58
58
|
reserve: true;
|
|
59
59
|
}, logContext?: Record<string, any>): Promise<PriceUpdateV310[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Similar to {@link generatePriceFeedsUpdates}, but returns raw transaction to PriceFeedStore.updatePrices
|
|
62
|
+
* @param priceFeeds
|
|
63
|
+
* @param logContext
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
getPriceFeedStoreUpdateTx(priceFeeds?: IPriceFeedContract[] | {
|
|
67
|
+
main: true;
|
|
68
|
+
} | {
|
|
69
|
+
reserve: true;
|
|
70
|
+
}, logContext?: Record<string, any>): Promise<RawTx>;
|
|
60
71
|
/**
|
|
61
72
|
* Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds
|
|
62
73
|
* This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
|