@gearbox-protocol/sdk 3.0.0-vfour.3 → 3.0.0-vfour.5
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/index.cjs +1370 -401
- package/dist/cjs/index.d.ts +216 -140
- package/dist/esm/index.d.mts +216 -140
- package/dist/esm/index.mjs +1309 -355
- package/package.json +2 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,266 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var sdkGov = require('@gearbox-protocol/sdk-gov');
|
|
4
3
|
var viem = require('viem');
|
|
5
4
|
var utils = require('viem/utils');
|
|
5
|
+
var dateFns = require('date-fns');
|
|
6
6
|
var chains$1 = require('viem/chains');
|
|
7
|
+
var actions = require('viem/actions');
|
|
7
8
|
var eventemitter3 = require('eventemitter3');
|
|
8
9
|
var evmConnector = require('@redstone-finance/evm-connector');
|
|
9
10
|
var redstoneProtocol = require('redstone-protocol');
|
|
11
|
+
var sdkGov = require('@gearbox-protocol/sdk-gov');
|
|
10
12
|
var aura = require('@gearbox-protocol/sdk-gov/lib/tokens/aura');
|
|
11
13
|
|
|
12
|
-
// src/
|
|
13
|
-
|
|
14
|
-
// src/constants/addresses.ts
|
|
15
|
-
var ADDRESS_0X0 = "0x0000000000000000000000000000000000000000";
|
|
16
|
-
var NOT_DEPLOYED = "0xNOT DEPLOYED";
|
|
17
|
-
|
|
18
|
-
// src/constants/address-provider.ts
|
|
19
|
-
var NO_VERSION = 0;
|
|
20
|
-
var AP_ACL = "ACL";
|
|
21
|
-
var AP_CONTRACTS_REGISTER = "CONTRACTS_REGISTER";
|
|
22
|
-
var AP_PRICE_ORACLE = "PRICE_ORACLE";
|
|
23
|
-
var AP_ACCOUNT_FACTORY = "ACCOUNT_FACTORY";
|
|
24
|
-
var AP_DATA_COMPRESSOR = "DATA_COMPRESSOR";
|
|
25
|
-
var AP_MARKET_COMPRESSOR = "MARKET_COMPRESSOR";
|
|
26
|
-
var AP_CREDIT_ACCOUNT_COMPRESSOR = "CREDIT_ACCOUNT_COMPRESSOR";
|
|
27
|
-
var AP_TREASURY = "TREASURY";
|
|
28
|
-
var AP_GEAR_TOKEN = "GEAR_TOKEN";
|
|
29
|
-
var AP_WETH_TOKEN = "WETH_TOKEN";
|
|
30
|
-
var AP_WETH_GATEWAY = "WETH_GATEWAY";
|
|
31
|
-
var AP_ROUTER = "ROUTER";
|
|
32
|
-
var AP_BOT_LIST = "BOT_LIST";
|
|
33
|
-
var AP_GEAR_STAKING = "GEAR_STAKING";
|
|
34
|
-
var AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
|
|
35
|
-
var AP_CONTROLLER_TIMELOCK = "CONTROLLER_TIMELOCK";
|
|
36
|
-
var AP_DEGEN_NFT = "DEGEN_NFT";
|
|
37
|
-
var AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
|
|
38
|
-
var AP_DEGEN_DISTRIBUTOR = "DEGEN_DISTRIBUTOR";
|
|
39
|
-
var AP_MULTI_PAUSE = "MULTI_PAUSE";
|
|
40
|
-
var AP_INFLATION_ATTACK_BLOCKER = "INFLATION_ATTACK_BLOCKER";
|
|
41
|
-
var AP_INSOLVENCY_CHECKER = "INSOLVENCY_CHECKER";
|
|
42
|
-
var AP_PARTIAL_LIQUIDATION_BOT = "PARTIAL_LIQUIDATION_BOT";
|
|
43
|
-
var AP_DELEVERAGE_BOT_PEGGED = "DELEVERAGE_BOT_PEGGED";
|
|
44
|
-
var AP_DELEVERAGE_BOT_LV = "DELEVERAGE_BOT_LV";
|
|
45
|
-
var AP_DELEVERAGE_BOT_HV = "DELEVERAGE_BOT_HV";
|
|
46
|
-
var ADDRESS_PROVIDER = {
|
|
47
|
-
Mainnet: "0x9ea7b04Da02a5373317D745c1571c84aaD03321D",
|
|
48
|
-
Arbitrum: "0x7d04eCdb892Ae074f03B5D0aBA03796F90F3F2af",
|
|
49
|
-
Optimism: "0x3761ca4BFAcFCFFc1B8034e69F19116dD6756726",
|
|
50
|
-
Base: NOT_DEPLOYED
|
|
51
|
-
};
|
|
52
|
-
var AddressMap = class {
|
|
53
|
-
#map;
|
|
54
|
-
#frozen = false;
|
|
55
|
-
constructor(entries) {
|
|
56
|
-
this.#map = /* @__PURE__ */ new Map();
|
|
57
|
-
if (entries) {
|
|
58
|
-
for (const [address, value] of entries) {
|
|
59
|
-
const key = address.toLowerCase();
|
|
60
|
-
if (!viem.isAddress(key)) {
|
|
61
|
-
throw new Error(`value "${address}" is not an address`);
|
|
62
|
-
}
|
|
63
|
-
this.#map.set(key, value);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Adds or updates value
|
|
69
|
-
* @param address
|
|
70
|
-
* @param value
|
|
71
|
-
*/
|
|
72
|
-
upsert(address, value) {
|
|
73
|
-
if (this.#frozen) {
|
|
74
|
-
throw new Error(`AddressMap is frozen`);
|
|
75
|
-
}
|
|
76
|
-
const key = address.toLowerCase();
|
|
77
|
-
if (!viem.isAddress(key)) {
|
|
78
|
-
throw new Error(`value "${address}" is not an address`);
|
|
79
|
-
}
|
|
80
|
-
this.#map.set(key, value);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Adds value, throws if this address is already used
|
|
84
|
-
* @param address
|
|
85
|
-
* @param value
|
|
86
|
-
*/
|
|
87
|
-
insert(address, value) {
|
|
88
|
-
if (this.#frozen) {
|
|
89
|
-
throw new Error(`AddressMap is frozen`);
|
|
90
|
-
}
|
|
91
|
-
const key = address.toLowerCase();
|
|
92
|
-
if (!viem.isAddress(key)) {
|
|
93
|
-
throw new Error(`value "${address}" is not an address`);
|
|
94
|
-
}
|
|
95
|
-
if (this.#map.has(key)) {
|
|
96
|
-
throw new Error(`address ${address} already exists`);
|
|
97
|
-
}
|
|
98
|
-
this.#map.set(key, value);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Checks if address is present in map
|
|
102
|
-
* @param address
|
|
103
|
-
* @returns
|
|
104
|
-
*/
|
|
105
|
-
has(address) {
|
|
106
|
-
const key = address.toLowerCase();
|
|
107
|
-
if (!viem.isAddress(key)) {
|
|
108
|
-
throw new Error(`value "${address}" is not an address`);
|
|
109
|
-
}
|
|
110
|
-
return this.#map.has(key);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Returns value, or undefined if the address is not in map
|
|
114
|
-
* @param address
|
|
115
|
-
* @returns
|
|
116
|
-
*/
|
|
117
|
-
get(address) {
|
|
118
|
-
const key = address.toLowerCase();
|
|
119
|
-
if (!viem.isAddress(key)) {
|
|
120
|
-
throw new Error(`value "${address}" is not an address`);
|
|
121
|
-
}
|
|
122
|
-
return this.#map.get(key);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Gets address from map, throws if not found
|
|
126
|
-
* @param address
|
|
127
|
-
* @returns
|
|
128
|
-
*/
|
|
129
|
-
mustGet(address) {
|
|
130
|
-
const v = this.get(address);
|
|
131
|
-
if (!v) {
|
|
132
|
-
throw new Error(`address ${address} not found in map`);
|
|
133
|
-
}
|
|
134
|
-
return v;
|
|
135
|
-
}
|
|
136
|
-
entries() {
|
|
137
|
-
return this.#map.entries();
|
|
138
|
-
}
|
|
139
|
-
values() {
|
|
140
|
-
return this.#map.values();
|
|
141
|
-
}
|
|
142
|
-
asRecord() {
|
|
143
|
-
return Object.fromEntries(this.#map.entries());
|
|
144
|
-
}
|
|
145
|
-
freeze() {
|
|
146
|
-
this.#frozen = true;
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
function bytes32ToString(bytes) {
|
|
150
|
-
return viem.bytesToString(viem.toBytes(bytes)).replaceAll("\0", "");
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// src/utils/childLogger.ts
|
|
154
|
-
function childLogger(module, logger) {
|
|
155
|
-
return logger?.child?.({ module }) ?? logger;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// src/utils/json.ts
|
|
159
|
-
function replacer(_key, value) {
|
|
160
|
-
if (typeof value === "bigint") {
|
|
161
|
-
return {
|
|
162
|
-
__type: "bigint",
|
|
163
|
-
__value: value.toString()
|
|
164
|
-
};
|
|
165
|
-
} else {
|
|
166
|
-
return value;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function reviver(_key, value) {
|
|
170
|
-
if (value && value.__type === "bigint") {
|
|
171
|
-
return BigInt(value.__value);
|
|
172
|
-
}
|
|
173
|
-
return value;
|
|
174
|
-
}
|
|
175
|
-
var json_stringify = (obj, space = 2) => {
|
|
176
|
-
return JSON.stringify(obj, replacer, space);
|
|
177
|
-
};
|
|
178
|
-
var json_parse = (s) => {
|
|
179
|
-
return JSON.parse(s, reviver);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
// src/utils/createRawTx.ts
|
|
183
|
-
function createRawTx(to, parameters, description) {
|
|
184
|
-
const { args } = parameters;
|
|
185
|
-
const fname = parameters.functionName;
|
|
186
|
-
const { abi: abi2, functionName } = (() => {
|
|
187
|
-
if (parameters.abi.length === 1 && parameters.functionName?.startsWith("0x"))
|
|
188
|
-
return parameters;
|
|
189
|
-
return viem.prepareEncodeFunctionData(parameters);
|
|
190
|
-
})();
|
|
191
|
-
const abiItem = abi2[0];
|
|
192
|
-
const signature = functionName;
|
|
193
|
-
const data = "inputs" in abiItem && abiItem.inputs ? viem.encodeAbiParameters(abiItem.inputs, args ?? []) : void 0;
|
|
194
|
-
const functionEncodedData = viem.concatHex([signature, data ?? "0x"]);
|
|
195
|
-
const inputs = "inputs" in abiItem && abiItem.inputs ? [...abiItem.inputs] : [];
|
|
196
|
-
const payable = "payble" in abiItem ? abiItem.payble === true : false;
|
|
197
|
-
const contractInputsValues = {};
|
|
198
|
-
if (inputs.length > 0 && args && args.length !== 0) {
|
|
199
|
-
args.forEach((arg, i) => {
|
|
200
|
-
const methodName = inputs[i].name;
|
|
201
|
-
let stringifiedArg = arg instanceof BigInt ? arg.toString() : arg;
|
|
202
|
-
contractInputsValues[methodName] = Array.isArray(stringifiedArg) ? json_stringify(stringifiedArg) : stringifiedArg;
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
to,
|
|
207
|
-
value: "0",
|
|
208
|
-
contractMethod: {
|
|
209
|
-
inputs,
|
|
210
|
-
name: fname,
|
|
211
|
-
payable
|
|
212
|
-
},
|
|
213
|
-
signature: utils.formatAbiItem(abiItem),
|
|
214
|
-
callData: functionEncodedData,
|
|
215
|
-
contractInputsValues,
|
|
216
|
-
description
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// src/base/AddressLabeller.ts
|
|
221
|
-
var AddressLabeller = class {
|
|
222
|
-
#labels = new AddressMap();
|
|
223
|
-
set(address, label) {
|
|
224
|
-
if (address === NOT_DEPLOYED) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
if (typeof label === "string") {
|
|
228
|
-
this.#labels.upsert(address, label);
|
|
229
|
-
} else {
|
|
230
|
-
this.#labels.upsert(address, label(this.#labels.get(address)));
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
get(address) {
|
|
234
|
-
const label = this.#labels.get(address);
|
|
235
|
-
return label ? `${address} [${label}]` : address;
|
|
236
|
-
}
|
|
237
|
-
get all() {
|
|
238
|
-
return this.#labels.asRecord();
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
function initLegacyLabels(labeller, network) {
|
|
242
|
-
Object.entries(sdkGov.tokenDataByNetwork[network]).forEach(([label, address]) => {
|
|
243
|
-
labeller.set(address, label);
|
|
244
|
-
});
|
|
245
|
-
Object.entries(sdkGov.tickerTokensByNetwork[network]).forEach(([label, address]) => {
|
|
246
|
-
labeller.set(address, label);
|
|
247
|
-
});
|
|
248
|
-
Object.entries(sdkGov.contractsByNetwork[network]).forEach(([label, address]) => {
|
|
249
|
-
labeller.set(address, label);
|
|
250
|
-
});
|
|
251
|
-
const multisigs = [
|
|
252
|
-
{ safe: sdkGov.MULTISIG, label: "Multisig" },
|
|
253
|
-
{ safe: sdkGov.ROUTER_MULTISIG_ADDRESS, label: "RouterMultisig" },
|
|
254
|
-
{ safe: sdkGov.VETO_ADMIN, label: "VetoAdmin" },
|
|
255
|
-
{ safe: sdkGov.TREASURY, label: "Treasury" }
|
|
256
|
-
];
|
|
257
|
-
multisigs.forEach(({ safe, label }) => {
|
|
258
|
-
labeller.set(safe[network], label);
|
|
259
|
-
});
|
|
260
|
-
sdkGov.emergencyLiquidators.forEach((address) => {
|
|
261
|
-
labeller.set(address, "EmergencyLiquidator");
|
|
262
|
-
});
|
|
263
|
-
}
|
|
14
|
+
// src/accounts/CreditAccountsService.ts
|
|
264
15
|
|
|
265
16
|
// src/abi/compressors.ts
|
|
266
17
|
var iAddressProviderV3_1Abi = [
|
|
@@ -458,27 +209,410 @@ var iAddressProviderV3_1Abi = [
|
|
|
458
209
|
indexed: true
|
|
459
210
|
}
|
|
460
211
|
],
|
|
461
|
-
name: "RemoveMarketConfigurator"
|
|
212
|
+
name: "RemoveMarketConfigurator"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
type: "event",
|
|
216
|
+
anonymous: false,
|
|
217
|
+
inputs: [
|
|
218
|
+
{ name: "key", internalType: "string", type: "string", indexed: false },
|
|
219
|
+
{
|
|
220
|
+
name: "value",
|
|
221
|
+
internalType: "address",
|
|
222
|
+
type: "address",
|
|
223
|
+
indexed: true
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: "version",
|
|
227
|
+
internalType: "uint256",
|
|
228
|
+
type: "uint256",
|
|
229
|
+
indexed: false
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
name: "SetAddress"
|
|
233
|
+
}
|
|
234
|
+
];
|
|
235
|
+
var iCreditAccountCompressorAbi = [
|
|
236
|
+
{
|
|
237
|
+
type: "function",
|
|
238
|
+
inputs: [],
|
|
239
|
+
name: "contractType",
|
|
240
|
+
outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
|
|
241
|
+
stateMutability: "view"
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
type: "function",
|
|
245
|
+
inputs: [
|
|
246
|
+
{ name: "creditManager", internalType: "address", type: "address" },
|
|
247
|
+
{
|
|
248
|
+
name: "caFilter",
|
|
249
|
+
internalType: "struct CreditAccountFilter",
|
|
250
|
+
type: "tuple",
|
|
251
|
+
components: [
|
|
252
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
253
|
+
{ name: "includeZeroDebt", internalType: "bool", type: "bool" },
|
|
254
|
+
{ name: "minHealthFactor", internalType: "uint16", type: "uint16" },
|
|
255
|
+
{ name: "maxHealthFactor", internalType: "uint16", type: "uint16" },
|
|
256
|
+
{ name: "reverting", internalType: "bool", type: "bool" }
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
name: "countCreditAccounts",
|
|
261
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
262
|
+
stateMutability: "view"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
type: "function",
|
|
266
|
+
inputs: [
|
|
267
|
+
{
|
|
268
|
+
name: "cmFilter",
|
|
269
|
+
internalType: "struct MarketFilter",
|
|
270
|
+
type: "tuple",
|
|
271
|
+
components: [
|
|
272
|
+
{ name: "curators", internalType: "address[]", type: "address[]" },
|
|
273
|
+
{ name: "pools", internalType: "address[]", type: "address[]" },
|
|
274
|
+
{ name: "underlying", internalType: "address", type: "address" }
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: "caFilter",
|
|
279
|
+
internalType: "struct CreditAccountFilter",
|
|
280
|
+
type: "tuple",
|
|
281
|
+
components: [
|
|
282
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
283
|
+
{ name: "includeZeroDebt", internalType: "bool", type: "bool" },
|
|
284
|
+
{ name: "minHealthFactor", internalType: "uint16", type: "uint16" },
|
|
285
|
+
{ name: "maxHealthFactor", internalType: "uint16", type: "uint16" },
|
|
286
|
+
{ name: "reverting", internalType: "bool", type: "bool" }
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
],
|
|
290
|
+
name: "countCreditAccounts",
|
|
291
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
292
|
+
stateMutability: "view"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
type: "function",
|
|
296
|
+
inputs: [
|
|
297
|
+
{ name: "creditAccount", internalType: "address", type: "address" }
|
|
298
|
+
],
|
|
299
|
+
name: "getCreditAccountData",
|
|
300
|
+
outputs: [
|
|
301
|
+
{
|
|
302
|
+
name: "",
|
|
303
|
+
internalType: "struct CreditAccountData",
|
|
304
|
+
type: "tuple",
|
|
305
|
+
components: [
|
|
306
|
+
{ name: "creditAccount", internalType: "address", type: "address" },
|
|
307
|
+
{ name: "creditManager", internalType: "address", type: "address" },
|
|
308
|
+
{ name: "creditFacade", internalType: "address", type: "address" },
|
|
309
|
+
{ name: "underlying", internalType: "address", type: "address" },
|
|
310
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
311
|
+
{
|
|
312
|
+
name: "enabledTokensMask",
|
|
313
|
+
internalType: "uint256",
|
|
314
|
+
type: "uint256"
|
|
315
|
+
},
|
|
316
|
+
{ name: "debt", internalType: "uint256", type: "uint256" },
|
|
317
|
+
{ name: "accruedInterest", internalType: "uint256", type: "uint256" },
|
|
318
|
+
{ name: "accruedFees", internalType: "uint256", type: "uint256" },
|
|
319
|
+
{ name: "totalDebtUSD", internalType: "uint256", type: "uint256" },
|
|
320
|
+
{ name: "totalValueUSD", internalType: "uint256", type: "uint256" },
|
|
321
|
+
{ name: "twvUSD", internalType: "uint256", type: "uint256" },
|
|
322
|
+
{ name: "totalValue", internalType: "uint256", type: "uint256" },
|
|
323
|
+
{ name: "healthFactor", internalType: "uint16", type: "uint16" },
|
|
324
|
+
{ name: "success", internalType: "bool", type: "bool" },
|
|
325
|
+
{
|
|
326
|
+
name: "tokens",
|
|
327
|
+
internalType: "struct TokenInfo[]",
|
|
328
|
+
type: "tuple[]",
|
|
329
|
+
components: [
|
|
330
|
+
{ name: "token", internalType: "address", type: "address" },
|
|
331
|
+
{ name: "mask", internalType: "uint256", type: "uint256" },
|
|
332
|
+
{ name: "balance", internalType: "uint256", type: "uint256" },
|
|
333
|
+
{ name: "quota", internalType: "uint256", type: "uint256" },
|
|
334
|
+
{ name: "success", internalType: "bool", type: "bool" }
|
|
335
|
+
]
|
|
336
|
+
}
|
|
337
|
+
]
|
|
338
|
+
}
|
|
339
|
+
],
|
|
340
|
+
stateMutability: "view"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
type: "function",
|
|
344
|
+
inputs: [
|
|
345
|
+
{
|
|
346
|
+
name: "cmFilter",
|
|
347
|
+
internalType: "struct MarketFilter",
|
|
348
|
+
type: "tuple",
|
|
349
|
+
components: [
|
|
350
|
+
{ name: "curators", internalType: "address[]", type: "address[]" },
|
|
351
|
+
{ name: "pools", internalType: "address[]", type: "address[]" },
|
|
352
|
+
{ name: "underlying", internalType: "address", type: "address" }
|
|
353
|
+
]
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: "caFilter",
|
|
357
|
+
internalType: "struct CreditAccountFilter",
|
|
358
|
+
type: "tuple",
|
|
359
|
+
components: [
|
|
360
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
361
|
+
{ name: "includeZeroDebt", internalType: "bool", type: "bool" },
|
|
362
|
+
{ name: "minHealthFactor", internalType: "uint16", type: "uint16" },
|
|
363
|
+
{ name: "maxHealthFactor", internalType: "uint16", type: "uint16" },
|
|
364
|
+
{ name: "reverting", internalType: "bool", type: "bool" }
|
|
365
|
+
]
|
|
366
|
+
},
|
|
367
|
+
{ name: "offset", internalType: "uint256", type: "uint256" }
|
|
368
|
+
],
|
|
369
|
+
name: "getCreditAccounts",
|
|
370
|
+
outputs: [
|
|
371
|
+
{
|
|
372
|
+
name: "data",
|
|
373
|
+
internalType: "struct CreditAccountData[]",
|
|
374
|
+
type: "tuple[]",
|
|
375
|
+
components: [
|
|
376
|
+
{ name: "creditAccount", internalType: "address", type: "address" },
|
|
377
|
+
{ name: "creditManager", internalType: "address", type: "address" },
|
|
378
|
+
{ name: "creditFacade", internalType: "address", type: "address" },
|
|
379
|
+
{ name: "underlying", internalType: "address", type: "address" },
|
|
380
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
381
|
+
{
|
|
382
|
+
name: "enabledTokensMask",
|
|
383
|
+
internalType: "uint256",
|
|
384
|
+
type: "uint256"
|
|
385
|
+
},
|
|
386
|
+
{ name: "debt", internalType: "uint256", type: "uint256" },
|
|
387
|
+
{ name: "accruedInterest", internalType: "uint256", type: "uint256" },
|
|
388
|
+
{ name: "accruedFees", internalType: "uint256", type: "uint256" },
|
|
389
|
+
{ name: "totalDebtUSD", internalType: "uint256", type: "uint256" },
|
|
390
|
+
{ name: "totalValueUSD", internalType: "uint256", type: "uint256" },
|
|
391
|
+
{ name: "twvUSD", internalType: "uint256", type: "uint256" },
|
|
392
|
+
{ name: "totalValue", internalType: "uint256", type: "uint256" },
|
|
393
|
+
{ name: "healthFactor", internalType: "uint16", type: "uint16" },
|
|
394
|
+
{ name: "success", internalType: "bool", type: "bool" },
|
|
395
|
+
{
|
|
396
|
+
name: "tokens",
|
|
397
|
+
internalType: "struct TokenInfo[]",
|
|
398
|
+
type: "tuple[]",
|
|
399
|
+
components: [
|
|
400
|
+
{ name: "token", internalType: "address", type: "address" },
|
|
401
|
+
{ name: "mask", internalType: "uint256", type: "uint256" },
|
|
402
|
+
{ name: "balance", internalType: "uint256", type: "uint256" },
|
|
403
|
+
{ name: "quota", internalType: "uint256", type: "uint256" },
|
|
404
|
+
{ name: "success", internalType: "bool", type: "bool" }
|
|
405
|
+
]
|
|
406
|
+
}
|
|
407
|
+
]
|
|
408
|
+
},
|
|
409
|
+
{ name: "nextOffset", internalType: "uint256", type: "uint256" }
|
|
410
|
+
],
|
|
411
|
+
stateMutability: "view"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
type: "function",
|
|
415
|
+
inputs: [
|
|
416
|
+
{ name: "creditManager", internalType: "address", type: "address" },
|
|
417
|
+
{
|
|
418
|
+
name: "caFilter",
|
|
419
|
+
internalType: "struct CreditAccountFilter",
|
|
420
|
+
type: "tuple",
|
|
421
|
+
components: [
|
|
422
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
423
|
+
{ name: "includeZeroDebt", internalType: "bool", type: "bool" },
|
|
424
|
+
{ name: "minHealthFactor", internalType: "uint16", type: "uint16" },
|
|
425
|
+
{ name: "maxHealthFactor", internalType: "uint16", type: "uint16" },
|
|
426
|
+
{ name: "reverting", internalType: "bool", type: "bool" }
|
|
427
|
+
]
|
|
428
|
+
},
|
|
429
|
+
{ name: "offset", internalType: "uint256", type: "uint256" }
|
|
430
|
+
],
|
|
431
|
+
name: "getCreditAccounts",
|
|
432
|
+
outputs: [
|
|
433
|
+
{
|
|
434
|
+
name: "data",
|
|
435
|
+
internalType: "struct CreditAccountData[]",
|
|
436
|
+
type: "tuple[]",
|
|
437
|
+
components: [
|
|
438
|
+
{ name: "creditAccount", internalType: "address", type: "address" },
|
|
439
|
+
{ name: "creditManager", internalType: "address", type: "address" },
|
|
440
|
+
{ name: "creditFacade", internalType: "address", type: "address" },
|
|
441
|
+
{ name: "underlying", internalType: "address", type: "address" },
|
|
442
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
443
|
+
{
|
|
444
|
+
name: "enabledTokensMask",
|
|
445
|
+
internalType: "uint256",
|
|
446
|
+
type: "uint256"
|
|
447
|
+
},
|
|
448
|
+
{ name: "debt", internalType: "uint256", type: "uint256" },
|
|
449
|
+
{ name: "accruedInterest", internalType: "uint256", type: "uint256" },
|
|
450
|
+
{ name: "accruedFees", internalType: "uint256", type: "uint256" },
|
|
451
|
+
{ name: "totalDebtUSD", internalType: "uint256", type: "uint256" },
|
|
452
|
+
{ name: "totalValueUSD", internalType: "uint256", type: "uint256" },
|
|
453
|
+
{ name: "twvUSD", internalType: "uint256", type: "uint256" },
|
|
454
|
+
{ name: "totalValue", internalType: "uint256", type: "uint256" },
|
|
455
|
+
{ name: "healthFactor", internalType: "uint16", type: "uint16" },
|
|
456
|
+
{ name: "success", internalType: "bool", type: "bool" },
|
|
457
|
+
{
|
|
458
|
+
name: "tokens",
|
|
459
|
+
internalType: "struct TokenInfo[]",
|
|
460
|
+
type: "tuple[]",
|
|
461
|
+
components: [
|
|
462
|
+
{ name: "token", internalType: "address", type: "address" },
|
|
463
|
+
{ name: "mask", internalType: "uint256", type: "uint256" },
|
|
464
|
+
{ name: "balance", internalType: "uint256", type: "uint256" },
|
|
465
|
+
{ name: "quota", internalType: "uint256", type: "uint256" },
|
|
466
|
+
{ name: "success", internalType: "bool", type: "bool" }
|
|
467
|
+
]
|
|
468
|
+
}
|
|
469
|
+
]
|
|
470
|
+
},
|
|
471
|
+
{ name: "nextOffset", internalType: "uint256", type: "uint256" }
|
|
472
|
+
],
|
|
473
|
+
stateMutability: "view"
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
type: "function",
|
|
477
|
+
inputs: [
|
|
478
|
+
{ name: "creditManager", internalType: "address", type: "address" },
|
|
479
|
+
{
|
|
480
|
+
name: "caFilter",
|
|
481
|
+
internalType: "struct CreditAccountFilter",
|
|
482
|
+
type: "tuple",
|
|
483
|
+
components: [
|
|
484
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
485
|
+
{ name: "includeZeroDebt", internalType: "bool", type: "bool" },
|
|
486
|
+
{ name: "minHealthFactor", internalType: "uint16", type: "uint16" },
|
|
487
|
+
{ name: "maxHealthFactor", internalType: "uint16", type: "uint16" },
|
|
488
|
+
{ name: "reverting", internalType: "bool", type: "bool" }
|
|
489
|
+
]
|
|
490
|
+
},
|
|
491
|
+
{ name: "offset", internalType: "uint256", type: "uint256" },
|
|
492
|
+
{ name: "limit", internalType: "uint256", type: "uint256" }
|
|
493
|
+
],
|
|
494
|
+
name: "getCreditAccounts",
|
|
495
|
+
outputs: [
|
|
496
|
+
{
|
|
497
|
+
name: "data",
|
|
498
|
+
internalType: "struct CreditAccountData[]",
|
|
499
|
+
type: "tuple[]",
|
|
500
|
+
components: [
|
|
501
|
+
{ name: "creditAccount", internalType: "address", type: "address" },
|
|
502
|
+
{ name: "creditManager", internalType: "address", type: "address" },
|
|
503
|
+
{ name: "creditFacade", internalType: "address", type: "address" },
|
|
504
|
+
{ name: "underlying", internalType: "address", type: "address" },
|
|
505
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
506
|
+
{
|
|
507
|
+
name: "enabledTokensMask",
|
|
508
|
+
internalType: "uint256",
|
|
509
|
+
type: "uint256"
|
|
510
|
+
},
|
|
511
|
+
{ name: "debt", internalType: "uint256", type: "uint256" },
|
|
512
|
+
{ name: "accruedInterest", internalType: "uint256", type: "uint256" },
|
|
513
|
+
{ name: "accruedFees", internalType: "uint256", type: "uint256" },
|
|
514
|
+
{ name: "totalDebtUSD", internalType: "uint256", type: "uint256" },
|
|
515
|
+
{ name: "totalValueUSD", internalType: "uint256", type: "uint256" },
|
|
516
|
+
{ name: "twvUSD", internalType: "uint256", type: "uint256" },
|
|
517
|
+
{ name: "totalValue", internalType: "uint256", type: "uint256" },
|
|
518
|
+
{ name: "healthFactor", internalType: "uint16", type: "uint16" },
|
|
519
|
+
{ name: "success", internalType: "bool", type: "bool" },
|
|
520
|
+
{
|
|
521
|
+
name: "tokens",
|
|
522
|
+
internalType: "struct TokenInfo[]",
|
|
523
|
+
type: "tuple[]",
|
|
524
|
+
components: [
|
|
525
|
+
{ name: "token", internalType: "address", type: "address" },
|
|
526
|
+
{ name: "mask", internalType: "uint256", type: "uint256" },
|
|
527
|
+
{ name: "balance", internalType: "uint256", type: "uint256" },
|
|
528
|
+
{ name: "quota", internalType: "uint256", type: "uint256" },
|
|
529
|
+
{ name: "success", internalType: "bool", type: "bool" }
|
|
530
|
+
]
|
|
531
|
+
}
|
|
532
|
+
]
|
|
533
|
+
},
|
|
534
|
+
{ name: "nextOffset", internalType: "uint256", type: "uint256" }
|
|
535
|
+
],
|
|
536
|
+
stateMutability: "view"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
type: "function",
|
|
540
|
+
inputs: [
|
|
541
|
+
{
|
|
542
|
+
name: "cmFilter",
|
|
543
|
+
internalType: "struct MarketFilter",
|
|
544
|
+
type: "tuple",
|
|
545
|
+
components: [
|
|
546
|
+
{ name: "curators", internalType: "address[]", type: "address[]" },
|
|
547
|
+
{ name: "pools", internalType: "address[]", type: "address[]" },
|
|
548
|
+
{ name: "underlying", internalType: "address", type: "address" }
|
|
549
|
+
]
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
name: "caFilter",
|
|
553
|
+
internalType: "struct CreditAccountFilter",
|
|
554
|
+
type: "tuple",
|
|
555
|
+
components: [
|
|
556
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
557
|
+
{ name: "includeZeroDebt", internalType: "bool", type: "bool" },
|
|
558
|
+
{ name: "minHealthFactor", internalType: "uint16", type: "uint16" },
|
|
559
|
+
{ name: "maxHealthFactor", internalType: "uint16", type: "uint16" },
|
|
560
|
+
{ name: "reverting", internalType: "bool", type: "bool" }
|
|
561
|
+
]
|
|
562
|
+
},
|
|
563
|
+
{ name: "offset", internalType: "uint256", type: "uint256" },
|
|
564
|
+
{ name: "limit", internalType: "uint256", type: "uint256" }
|
|
565
|
+
],
|
|
566
|
+
name: "getCreditAccounts",
|
|
567
|
+
outputs: [
|
|
568
|
+
{
|
|
569
|
+
name: "data",
|
|
570
|
+
internalType: "struct CreditAccountData[]",
|
|
571
|
+
type: "tuple[]",
|
|
572
|
+
components: [
|
|
573
|
+
{ name: "creditAccount", internalType: "address", type: "address" },
|
|
574
|
+
{ name: "creditManager", internalType: "address", type: "address" },
|
|
575
|
+
{ name: "creditFacade", internalType: "address", type: "address" },
|
|
576
|
+
{ name: "underlying", internalType: "address", type: "address" },
|
|
577
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
578
|
+
{
|
|
579
|
+
name: "enabledTokensMask",
|
|
580
|
+
internalType: "uint256",
|
|
581
|
+
type: "uint256"
|
|
582
|
+
},
|
|
583
|
+
{ name: "debt", internalType: "uint256", type: "uint256" },
|
|
584
|
+
{ name: "accruedInterest", internalType: "uint256", type: "uint256" },
|
|
585
|
+
{ name: "accruedFees", internalType: "uint256", type: "uint256" },
|
|
586
|
+
{ name: "totalDebtUSD", internalType: "uint256", type: "uint256" },
|
|
587
|
+
{ name: "totalValueUSD", internalType: "uint256", type: "uint256" },
|
|
588
|
+
{ name: "twvUSD", internalType: "uint256", type: "uint256" },
|
|
589
|
+
{ name: "totalValue", internalType: "uint256", type: "uint256" },
|
|
590
|
+
{ name: "healthFactor", internalType: "uint16", type: "uint16" },
|
|
591
|
+
{ name: "success", internalType: "bool", type: "bool" },
|
|
592
|
+
{
|
|
593
|
+
name: "tokens",
|
|
594
|
+
internalType: "struct TokenInfo[]",
|
|
595
|
+
type: "tuple[]",
|
|
596
|
+
components: [
|
|
597
|
+
{ name: "token", internalType: "address", type: "address" },
|
|
598
|
+
{ name: "mask", internalType: "uint256", type: "uint256" },
|
|
599
|
+
{ name: "balance", internalType: "uint256", type: "uint256" },
|
|
600
|
+
{ name: "quota", internalType: "uint256", type: "uint256" },
|
|
601
|
+
{ name: "success", internalType: "bool", type: "bool" }
|
|
602
|
+
]
|
|
603
|
+
}
|
|
604
|
+
]
|
|
605
|
+
},
|
|
606
|
+
{ name: "nextOffset", internalType: "uint256", type: "uint256" }
|
|
607
|
+
],
|
|
608
|
+
stateMutability: "view"
|
|
462
609
|
},
|
|
463
610
|
{
|
|
464
|
-
type: "
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
name: "value",
|
|
470
|
-
internalType: "address",
|
|
471
|
-
type: "address",
|
|
472
|
-
indexed: true
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
name: "version",
|
|
476
|
-
internalType: "uint256",
|
|
477
|
-
type: "uint256",
|
|
478
|
-
indexed: false
|
|
479
|
-
}
|
|
480
|
-
],
|
|
481
|
-
name: "SetAddress"
|
|
611
|
+
type: "function",
|
|
612
|
+
inputs: [],
|
|
613
|
+
name: "version",
|
|
614
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
615
|
+
stateMutability: "view"
|
|
482
616
|
}
|
|
483
617
|
];
|
|
484
618
|
var iMarketCompressorAbi = [
|
|
@@ -12275,7 +12409,364 @@ var routerV3Abi = [
|
|
|
12275
12409
|
inputs: [{ name: "", internalType: "address", type: "address" }],
|
|
12276
12410
|
name: "UnsupportedRouterComponent"
|
|
12277
12411
|
}
|
|
12278
|
-
];
|
|
12412
|
+
];
|
|
12413
|
+
|
|
12414
|
+
// src/constants/addresses.ts
|
|
12415
|
+
var ADDRESS_0X0 = "0x0000000000000000000000000000000000000000";
|
|
12416
|
+
var NOT_DEPLOYED = "0xNOT DEPLOYED";
|
|
12417
|
+
var USDC = {
|
|
12418
|
+
Mainnet: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
12419
|
+
Arbitrum: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
12420
|
+
Optimism: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
12421
|
+
Base: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
12422
|
+
};
|
|
12423
|
+
var TIMELOCK = {
|
|
12424
|
+
Mainnet: "0xa133C9A92Fb8dDB962Af1cbae58b2723A0bdf23b",
|
|
12425
|
+
Arbitrum: "0x148DD932eCe1155c11006F5650c6Ff428f8D374A",
|
|
12426
|
+
Optimism: "0x148DD932eCe1155c11006F5650c6Ff428f8D374A",
|
|
12427
|
+
Base: NOT_DEPLOYED
|
|
12428
|
+
};
|
|
12429
|
+
|
|
12430
|
+
// src/constants/address-provider.ts
|
|
12431
|
+
var NO_VERSION = 0;
|
|
12432
|
+
var AP_ACL = "ACL";
|
|
12433
|
+
var AP_CONTRACTS_REGISTER = "CONTRACTS_REGISTER";
|
|
12434
|
+
var AP_PRICE_ORACLE = "PRICE_ORACLE";
|
|
12435
|
+
var AP_ACCOUNT_FACTORY = "ACCOUNT_FACTORY";
|
|
12436
|
+
var AP_DATA_COMPRESSOR = "DATA_COMPRESSOR";
|
|
12437
|
+
var AP_MARKET_COMPRESSOR = "MARKET_COMPRESSOR";
|
|
12438
|
+
var AP_CREDIT_ACCOUNT_COMPRESSOR = "CREDIT_ACCOUNT_COMPRESSOR";
|
|
12439
|
+
var AP_TREASURY = "TREASURY";
|
|
12440
|
+
var AP_GEAR_TOKEN = "GEAR_TOKEN";
|
|
12441
|
+
var AP_WETH_TOKEN = "WETH_TOKEN";
|
|
12442
|
+
var AP_WETH_GATEWAY = "WETH_GATEWAY";
|
|
12443
|
+
var AP_ROUTER = "ROUTER";
|
|
12444
|
+
var AP_BOT_LIST = "BOT_LIST";
|
|
12445
|
+
var AP_GEAR_STAKING = "GEAR_STAKING";
|
|
12446
|
+
var AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
|
|
12447
|
+
var AP_CONTROLLER_TIMELOCK = "CONTROLLER_TIMELOCK";
|
|
12448
|
+
var AP_DEGEN_NFT = "DEGEN_NFT";
|
|
12449
|
+
var AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
|
|
12450
|
+
var AP_DEGEN_DISTRIBUTOR = "DEGEN_DISTRIBUTOR";
|
|
12451
|
+
var AP_MULTI_PAUSE = "MULTI_PAUSE";
|
|
12452
|
+
var AP_INFLATION_ATTACK_BLOCKER = "INFLATION_ATTACK_BLOCKER";
|
|
12453
|
+
var AP_INSOLVENCY_CHECKER = "INSOLVENCY_CHECKER";
|
|
12454
|
+
var AP_PARTIAL_LIQUIDATION_BOT = "PARTIAL_LIQUIDATION_BOT";
|
|
12455
|
+
var AP_DELEVERAGE_BOT_PEGGED = "DELEVERAGE_BOT_PEGGED";
|
|
12456
|
+
var AP_DELEVERAGE_BOT_LV = "DELEVERAGE_BOT_LV";
|
|
12457
|
+
var AP_DELEVERAGE_BOT_HV = "DELEVERAGE_BOT_HV";
|
|
12458
|
+
var ADDRESS_PROVIDER = {
|
|
12459
|
+
Mainnet: "0x9ea7b04Da02a5373317D745c1571c84aaD03321D",
|
|
12460
|
+
Arbitrum: "0x7d04eCdb892Ae074f03B5D0aBA03796F90F3F2af",
|
|
12461
|
+
Optimism: "0x3761ca4BFAcFCFFc1B8034e69F19116dD6756726",
|
|
12462
|
+
Base: NOT_DEPLOYED
|
|
12463
|
+
};
|
|
12464
|
+
|
|
12465
|
+
// src/constants/bot-permissions.ts
|
|
12466
|
+
var BotPermissions = /* @__PURE__ */ ((BotPermissions2) => {
|
|
12467
|
+
BotPermissions2[BotPermissions2["ADD_COLLATERAL"] = 1] = "ADD_COLLATERAL";
|
|
12468
|
+
BotPermissions2[BotPermissions2["INCREASE_DEBT"] = 2] = "INCREASE_DEBT";
|
|
12469
|
+
BotPermissions2[BotPermissions2["DECREASE_DEBT"] = 4] = "DECREASE_DEBT";
|
|
12470
|
+
BotPermissions2[BotPermissions2["ENABLE_TOKEN"] = 8] = "ENABLE_TOKEN";
|
|
12471
|
+
BotPermissions2[BotPermissions2["DISABLE_TOKEN"] = 16] = "DISABLE_TOKEN";
|
|
12472
|
+
BotPermissions2[BotPermissions2["WITHDRAW_COLLATERAL"] = 32] = "WITHDRAW_COLLATERAL";
|
|
12473
|
+
BotPermissions2[BotPermissions2["UPDATE_QUOTA"] = 64] = "UPDATE_QUOTA";
|
|
12474
|
+
BotPermissions2[BotPermissions2["REVOKE_ALLOWANCES"] = 128] = "REVOKE_ALLOWANCES";
|
|
12475
|
+
BotPermissions2[BotPermissions2["EXTERNAL_CALLS"] = 65536] = "EXTERNAL_CALLS";
|
|
12476
|
+
BotPermissions2[BotPermissions2["ALL_CREDIT_FACADE_CALLS"] = 255] = "ALL_CREDIT_FACADE_CALLS";
|
|
12477
|
+
BotPermissions2[BotPermissions2["ALLS"] = 65791] = "ALLS";
|
|
12478
|
+
return BotPermissions2;
|
|
12479
|
+
})(BotPermissions || {});
|
|
12480
|
+
function botPermissionsToString(value) {
|
|
12481
|
+
let result = "";
|
|
12482
|
+
for (let i = 0; i < 16; i++) {
|
|
12483
|
+
if ((value & 1n << BigInt(i)) !== 0n) {
|
|
12484
|
+
if (result.length > 0) {
|
|
12485
|
+
result += " | ";
|
|
12486
|
+
}
|
|
12487
|
+
result += BotPermissions[1 << i];
|
|
12488
|
+
}
|
|
12489
|
+
}
|
|
12490
|
+
return result;
|
|
12491
|
+
}
|
|
12492
|
+
|
|
12493
|
+
// src/constants/math.ts
|
|
12494
|
+
var MIN_INT96 = -39614081257132168796771975168n;
|
|
12495
|
+
var MAX_UINT256 = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;
|
|
12496
|
+
var AddressMap = class {
|
|
12497
|
+
#map;
|
|
12498
|
+
#frozen = false;
|
|
12499
|
+
constructor(entries) {
|
|
12500
|
+
this.#map = /* @__PURE__ */ new Map();
|
|
12501
|
+
if (entries) {
|
|
12502
|
+
for (const [address, value] of entries) {
|
|
12503
|
+
const key = address.toLowerCase();
|
|
12504
|
+
if (!viem.isAddress(key)) {
|
|
12505
|
+
throw new Error(`value "${address}" is not an address`);
|
|
12506
|
+
}
|
|
12507
|
+
this.#map.set(key, value);
|
|
12508
|
+
}
|
|
12509
|
+
}
|
|
12510
|
+
}
|
|
12511
|
+
/**
|
|
12512
|
+
* Adds or updates value
|
|
12513
|
+
* @param address
|
|
12514
|
+
* @param value
|
|
12515
|
+
*/
|
|
12516
|
+
upsert(address, value) {
|
|
12517
|
+
if (this.#frozen) {
|
|
12518
|
+
throw new Error(`AddressMap is frozen`);
|
|
12519
|
+
}
|
|
12520
|
+
const key = address.toLowerCase();
|
|
12521
|
+
if (!viem.isAddress(key)) {
|
|
12522
|
+
throw new Error(`value "${address}" is not an address`);
|
|
12523
|
+
}
|
|
12524
|
+
this.#map.set(key, value);
|
|
12525
|
+
}
|
|
12526
|
+
/**
|
|
12527
|
+
* Adds value, throws if this address is already used
|
|
12528
|
+
* @param address
|
|
12529
|
+
* @param value
|
|
12530
|
+
*/
|
|
12531
|
+
insert(address, value) {
|
|
12532
|
+
if (this.#frozen) {
|
|
12533
|
+
throw new Error(`AddressMap is frozen`);
|
|
12534
|
+
}
|
|
12535
|
+
const key = address.toLowerCase();
|
|
12536
|
+
if (!viem.isAddress(key)) {
|
|
12537
|
+
throw new Error(`value "${address}" is not an address`);
|
|
12538
|
+
}
|
|
12539
|
+
if (this.#map.has(key)) {
|
|
12540
|
+
throw new Error(`address ${address} already exists`);
|
|
12541
|
+
}
|
|
12542
|
+
this.#map.set(key, value);
|
|
12543
|
+
}
|
|
12544
|
+
/**
|
|
12545
|
+
* Checks if address is present in map
|
|
12546
|
+
* @param address
|
|
12547
|
+
* @returns
|
|
12548
|
+
*/
|
|
12549
|
+
has(address) {
|
|
12550
|
+
const key = address.toLowerCase();
|
|
12551
|
+
if (!viem.isAddress(key)) {
|
|
12552
|
+
throw new Error(`value "${address}" is not an address`);
|
|
12553
|
+
}
|
|
12554
|
+
return this.#map.has(key);
|
|
12555
|
+
}
|
|
12556
|
+
/**
|
|
12557
|
+
* Returns value, or undefined if the address is not in map
|
|
12558
|
+
* @param address
|
|
12559
|
+
* @returns
|
|
12560
|
+
*/
|
|
12561
|
+
get(address) {
|
|
12562
|
+
const key = address.toLowerCase();
|
|
12563
|
+
if (!viem.isAddress(key)) {
|
|
12564
|
+
throw new Error(`value "${address}" is not an address`);
|
|
12565
|
+
}
|
|
12566
|
+
return this.#map.get(key);
|
|
12567
|
+
}
|
|
12568
|
+
/**
|
|
12569
|
+
* Gets address from map, throws if not found
|
|
12570
|
+
* @param address
|
|
12571
|
+
* @returns
|
|
12572
|
+
*/
|
|
12573
|
+
mustGet(address) {
|
|
12574
|
+
const v = this.get(address);
|
|
12575
|
+
if (!v) {
|
|
12576
|
+
throw new Error(`address ${address} not found in map`);
|
|
12577
|
+
}
|
|
12578
|
+
return v;
|
|
12579
|
+
}
|
|
12580
|
+
entries() {
|
|
12581
|
+
return this.#map.entries();
|
|
12582
|
+
}
|
|
12583
|
+
values() {
|
|
12584
|
+
return this.#map.values();
|
|
12585
|
+
}
|
|
12586
|
+
asRecord() {
|
|
12587
|
+
return Object.fromEntries(this.#map.entries());
|
|
12588
|
+
}
|
|
12589
|
+
freeze() {
|
|
12590
|
+
this.#frozen = true;
|
|
12591
|
+
}
|
|
12592
|
+
};
|
|
12593
|
+
function bytes32ToString(bytes) {
|
|
12594
|
+
return viem.bytesToString(viem.toBytes(bytes)).replaceAll("\0", "");
|
|
12595
|
+
}
|
|
12596
|
+
|
|
12597
|
+
// src/utils/childLogger.ts
|
|
12598
|
+
function childLogger(module, logger) {
|
|
12599
|
+
return logger?.child?.({ module }) ?? logger;
|
|
12600
|
+
}
|
|
12601
|
+
|
|
12602
|
+
// src/utils/json.ts
|
|
12603
|
+
function replacer(_key, value) {
|
|
12604
|
+
if (typeof value === "bigint") {
|
|
12605
|
+
return {
|
|
12606
|
+
__type: "bigint",
|
|
12607
|
+
__value: value.toString()
|
|
12608
|
+
};
|
|
12609
|
+
} else {
|
|
12610
|
+
return value;
|
|
12611
|
+
}
|
|
12612
|
+
}
|
|
12613
|
+
function reviver(_key, value) {
|
|
12614
|
+
if (value && value.__type === "bigint") {
|
|
12615
|
+
return BigInt(value.__value);
|
|
12616
|
+
}
|
|
12617
|
+
return value;
|
|
12618
|
+
}
|
|
12619
|
+
var json_stringify = (obj, space = 2) => {
|
|
12620
|
+
return JSON.stringify(obj, replacer, space);
|
|
12621
|
+
};
|
|
12622
|
+
var json_parse = (s) => {
|
|
12623
|
+
return JSON.parse(s, reviver);
|
|
12624
|
+
};
|
|
12625
|
+
|
|
12626
|
+
// src/utils/createRawTx.ts
|
|
12627
|
+
function createRawTx(to, parameters, description) {
|
|
12628
|
+
const { args } = parameters;
|
|
12629
|
+
const fname = parameters.functionName;
|
|
12630
|
+
const { abi: abi2, functionName } = (() => {
|
|
12631
|
+
if (parameters.abi.length === 1 && parameters.functionName?.startsWith("0x"))
|
|
12632
|
+
return parameters;
|
|
12633
|
+
return viem.prepareEncodeFunctionData(parameters);
|
|
12634
|
+
})();
|
|
12635
|
+
const abiItem = abi2[0];
|
|
12636
|
+
const signature = functionName;
|
|
12637
|
+
const data = "inputs" in abiItem && abiItem.inputs ? viem.encodeAbiParameters(abiItem.inputs, args ?? []) : void 0;
|
|
12638
|
+
const functionEncodedData = viem.concatHex([signature, data ?? "0x"]);
|
|
12639
|
+
const inputs = "inputs" in abiItem && abiItem.inputs ? [...abiItem.inputs] : [];
|
|
12640
|
+
const payable = "payble" in abiItem ? abiItem.payble === true : false;
|
|
12641
|
+
const contractInputsValues = {};
|
|
12642
|
+
if (inputs.length > 0 && args && args.length !== 0) {
|
|
12643
|
+
args.forEach((arg, i) => {
|
|
12644
|
+
const methodName = inputs[i].name;
|
|
12645
|
+
let stringifiedArg = arg instanceof BigInt ? arg.toString() : arg;
|
|
12646
|
+
contractInputsValues[methodName] = Array.isArray(stringifiedArg) ? json_stringify(stringifiedArg) : stringifiedArg;
|
|
12647
|
+
});
|
|
12648
|
+
}
|
|
12649
|
+
return {
|
|
12650
|
+
to,
|
|
12651
|
+
value: "0",
|
|
12652
|
+
contractMethod: {
|
|
12653
|
+
inputs,
|
|
12654
|
+
name: fname,
|
|
12655
|
+
payable
|
|
12656
|
+
},
|
|
12657
|
+
signature: utils.formatAbiItem(abiItem),
|
|
12658
|
+
callData: functionEncodedData,
|
|
12659
|
+
contractInputsValues,
|
|
12660
|
+
description
|
|
12661
|
+
};
|
|
12662
|
+
}
|
|
12663
|
+
var percentFmt = (v, raw = true) => `${(Number(v) / 100).toFixed(2)}%` + (raw ? ` [${v}]` : "");
|
|
12664
|
+
function formatBNvalue(num, decimals2, precision, raw = true) {
|
|
12665
|
+
return `${formatBN(num, decimals2, precision)}` + (raw ? ` [ ${num} ]` : "");
|
|
12666
|
+
}
|
|
12667
|
+
function formatBN(num, decimals2, precision) {
|
|
12668
|
+
if (num === void 0) {
|
|
12669
|
+
return "-";
|
|
12670
|
+
}
|
|
12671
|
+
const numBInt = BigInt(num);
|
|
12672
|
+
const limitedNum = limitNum(numBInt, decimals2);
|
|
12673
|
+
const limitedPrecision = limitPrecision(limitedNum, precision);
|
|
12674
|
+
return toHumanFormat(limitedNum, limitedPrecision);
|
|
12675
|
+
}
|
|
12676
|
+
var limitPrecision = (n, p) => {
|
|
12677
|
+
const notZero = n !== 0n;
|
|
12678
|
+
if (n <= 10n && notZero) {
|
|
12679
|
+
return 6;
|
|
12680
|
+
}
|
|
12681
|
+
if (n <= 100n && notZero) {
|
|
12682
|
+
return 5;
|
|
12683
|
+
}
|
|
12684
|
+
if (n <= 1000n && notZero) {
|
|
12685
|
+
return 4;
|
|
12686
|
+
}
|
|
12687
|
+
if (n <= 10000n && notZero) {
|
|
12688
|
+
return 3;
|
|
12689
|
+
}
|
|
12690
|
+
if (p === void 0 && n > 10n ** 21n) {
|
|
12691
|
+
return 2;
|
|
12692
|
+
}
|
|
12693
|
+
if (p === void 0 && n > 10n ** 24n) {
|
|
12694
|
+
return 0;
|
|
12695
|
+
}
|
|
12696
|
+
return p;
|
|
12697
|
+
};
|
|
12698
|
+
var limitNum = (n, d = 18) => {
|
|
12699
|
+
let limited = n <= 2n ? 0n : n;
|
|
12700
|
+
if (d <= 6) {
|
|
12701
|
+
return limited * 10n ** BigInt(6 - d);
|
|
12702
|
+
} else {
|
|
12703
|
+
return limited / 10n ** BigInt(d - 6);
|
|
12704
|
+
}
|
|
12705
|
+
};
|
|
12706
|
+
function toHumanFormat(num, precision = 2) {
|
|
12707
|
+
if (num >= BigInt(1e15)) {
|
|
12708
|
+
return `${formatBn4dig(num / BigInt(1e9), precision)}Bn`;
|
|
12709
|
+
}
|
|
12710
|
+
if (num >= BigInt(1e12)) {
|
|
12711
|
+
return `${formatBn4dig(num / BigInt(1e6), precision)}M`;
|
|
12712
|
+
}
|
|
12713
|
+
if (num >= BigInt(1e9)) {
|
|
12714
|
+
return `${formatBn4dig(num / BigInt(1e3), precision)}K`;
|
|
12715
|
+
}
|
|
12716
|
+
return formatBn4dig(num, precision);
|
|
12717
|
+
}
|
|
12718
|
+
function formatBn4dig(num, precision = 2) {
|
|
12719
|
+
if (precision > 6) {
|
|
12720
|
+
throw new Error("Precision is too high, try <= 6");
|
|
12721
|
+
}
|
|
12722
|
+
const numStr = num.toString();
|
|
12723
|
+
if (numStr.length <= 6) {
|
|
12724
|
+
const completed = "0".repeat(6 - numStr.length) + numStr;
|
|
12725
|
+
return `0.${completed.slice(0, precision)}`;
|
|
12726
|
+
}
|
|
12727
|
+
return `${numStr.slice(0, numStr.length - 6)}.${numStr.slice(
|
|
12728
|
+
numStr.length - 6,
|
|
12729
|
+
numStr.length - 6 + precision
|
|
12730
|
+
)}`;
|
|
12731
|
+
}
|
|
12732
|
+
function fmtBinaryMask(mask) {
|
|
12733
|
+
return mask.toString(2).padStart(64, "0");
|
|
12734
|
+
}
|
|
12735
|
+
function numberWithCommas(x) {
|
|
12736
|
+
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
12737
|
+
}
|
|
12738
|
+
function formatDuration(seconds, raw = true) {
|
|
12739
|
+
const now = Math.floor(Date.now() / 1e3) * 1e3;
|
|
12740
|
+
const start = new Date(now);
|
|
12741
|
+
const end = new Date(now + seconds * 1e3);
|
|
12742
|
+
const duration = dateFns.intervalToDuration({ start, end });
|
|
12743
|
+
return `${dateFns.formatDuration(duration)}` + (raw ? `[${seconds.toString()}]` : "");
|
|
12744
|
+
}
|
|
12745
|
+
function formatNumberToString_(value) {
|
|
12746
|
+
return value.toLocaleString("en-US", { minimumIntegerDigits: 1, useGrouping: true }).replaceAll(",", "_");
|
|
12747
|
+
}
|
|
12748
|
+
|
|
12749
|
+
// src/base/AddressLabeller.ts
|
|
12750
|
+
var AddressLabeller = class {
|
|
12751
|
+
#labels = new AddressMap();
|
|
12752
|
+
set(address, label) {
|
|
12753
|
+
if (address === NOT_DEPLOYED) {
|
|
12754
|
+
return;
|
|
12755
|
+
}
|
|
12756
|
+
if (typeof label === "string") {
|
|
12757
|
+
this.#labels.upsert(address, label);
|
|
12758
|
+
} else {
|
|
12759
|
+
this.#labels.upsert(address, label(this.#labels.get(address)));
|
|
12760
|
+
}
|
|
12761
|
+
}
|
|
12762
|
+
get(address) {
|
|
12763
|
+
const label = this.#labels.get(address);
|
|
12764
|
+
return label ? `${address} [${label}]` : address;
|
|
12765
|
+
}
|
|
12766
|
+
get all() {
|
|
12767
|
+
return this.#labels.asRecord();
|
|
12768
|
+
}
|
|
12769
|
+
};
|
|
12279
12770
|
|
|
12280
12771
|
// src/base/SDKConstruct.ts
|
|
12281
12772
|
var SDKConstruct = class {
|
|
@@ -12442,9 +12933,6 @@ var Provider = class {
|
|
|
12442
12933
|
chain;
|
|
12443
12934
|
networkType;
|
|
12444
12935
|
publicClient;
|
|
12445
|
-
/**
|
|
12446
|
-
* Note: use interface here to hide implementation that uses sdk-gov
|
|
12447
|
-
*/
|
|
12448
12936
|
addressLabels;
|
|
12449
12937
|
constructor(opts) {
|
|
12450
12938
|
const { chainId, networkType, rpcURL, timeout = 12e4 } = opts;
|
|
@@ -12462,6 +12950,504 @@ var Provider = class {
|
|
|
12462
12950
|
this.addressLabels = new AddressLabeller();
|
|
12463
12951
|
}
|
|
12464
12952
|
};
|
|
12953
|
+
|
|
12954
|
+
// src/utils/viem/detectNetwork.ts
|
|
12955
|
+
async function detectNetwork(client) {
|
|
12956
|
+
for (const chain of SUPPORTED_CHAINS) {
|
|
12957
|
+
try {
|
|
12958
|
+
await client.readContract({
|
|
12959
|
+
abi: ierc20MetadataAbi,
|
|
12960
|
+
address: USDC[chain],
|
|
12961
|
+
functionName: "symbol"
|
|
12962
|
+
});
|
|
12963
|
+
return chain;
|
|
12964
|
+
} catch {
|
|
12965
|
+
}
|
|
12966
|
+
}
|
|
12967
|
+
throw new Error("Unsupported network");
|
|
12968
|
+
}
|
|
12969
|
+
|
|
12970
|
+
// src/utils/viem/createAnvilClient.ts
|
|
12971
|
+
function createAnvilClient({
|
|
12972
|
+
chain,
|
|
12973
|
+
transport
|
|
12974
|
+
}) {
|
|
12975
|
+
return viem.createTestClient(
|
|
12976
|
+
{
|
|
12977
|
+
chain,
|
|
12978
|
+
mode: "anvil",
|
|
12979
|
+
transport,
|
|
12980
|
+
cacheTime: 0
|
|
12981
|
+
}
|
|
12982
|
+
).extend(viem.publicActions).extend(viem.walletActions).extend((client) => ({
|
|
12983
|
+
isAnvil: () => isAnvil(client),
|
|
12984
|
+
detectNetwork: () => detectNetwork(client)
|
|
12985
|
+
}));
|
|
12986
|
+
}
|
|
12987
|
+
async function isAnvil(client) {
|
|
12988
|
+
try {
|
|
12989
|
+
const resp = await client.request({
|
|
12990
|
+
method: "anvil_nodeInfo",
|
|
12991
|
+
params: []
|
|
12992
|
+
});
|
|
12993
|
+
return !!resp.currentBlockNumber;
|
|
12994
|
+
} catch {
|
|
12995
|
+
return false;
|
|
12996
|
+
}
|
|
12997
|
+
}
|
|
12998
|
+
async function simulateMulticall(client, parameters) {
|
|
12999
|
+
const {
|
|
13000
|
+
allowFailure = true,
|
|
13001
|
+
batchSize: batchSize_,
|
|
13002
|
+
blockNumber,
|
|
13003
|
+
blockTag,
|
|
13004
|
+
multicallAddress: multicallAddress_,
|
|
13005
|
+
stateOverride,
|
|
13006
|
+
gas
|
|
13007
|
+
} = parameters;
|
|
13008
|
+
const contracts = parameters.contracts;
|
|
13009
|
+
const batchSize = batchSize_ ?? (typeof client.batch?.multicall === "object" && client.batch.multicall.batchSize || 1024);
|
|
13010
|
+
let multicallAddress = multicallAddress_;
|
|
13011
|
+
if (!multicallAddress) {
|
|
13012
|
+
if (!client.chain)
|
|
13013
|
+
throw new Error(
|
|
13014
|
+
"client chain not configured. multicallAddress is required."
|
|
13015
|
+
);
|
|
13016
|
+
multicallAddress = viem.getChainContractAddress({
|
|
13017
|
+
blockNumber,
|
|
13018
|
+
chain: client.chain,
|
|
13019
|
+
contract: "multicall3"
|
|
13020
|
+
});
|
|
13021
|
+
}
|
|
13022
|
+
const chunkedCalls = [[]];
|
|
13023
|
+
let currentChunk = 0;
|
|
13024
|
+
let currentChunkSize = 0;
|
|
13025
|
+
for (const contract of contracts) {
|
|
13026
|
+
const { abi: abi2, address, args, functionName } = contract;
|
|
13027
|
+
try {
|
|
13028
|
+
const callData = viem.encodeFunctionData({ abi: abi2, args, functionName });
|
|
13029
|
+
currentChunkSize += (callData.length - 2) / 2;
|
|
13030
|
+
if (
|
|
13031
|
+
// Check if batching is enabled.
|
|
13032
|
+
batchSize > 0 && // Check if the current size of the batch exceeds the size limit.
|
|
13033
|
+
currentChunkSize > batchSize && // Check if the current chunk is not already empty.
|
|
13034
|
+
chunkedCalls[currentChunk].length > 0
|
|
13035
|
+
) {
|
|
13036
|
+
currentChunk++;
|
|
13037
|
+
currentChunkSize = (callData.length - 2) / 2;
|
|
13038
|
+
chunkedCalls[currentChunk] = [];
|
|
13039
|
+
}
|
|
13040
|
+
chunkedCalls[currentChunk] = [
|
|
13041
|
+
...chunkedCalls[currentChunk],
|
|
13042
|
+
{
|
|
13043
|
+
allowFailure: true,
|
|
13044
|
+
callData,
|
|
13045
|
+
target: address
|
|
13046
|
+
}
|
|
13047
|
+
];
|
|
13048
|
+
} catch (err) {
|
|
13049
|
+
const error = viem.getContractError(err, {
|
|
13050
|
+
abi: abi2,
|
|
13051
|
+
address,
|
|
13052
|
+
args,
|
|
13053
|
+
docsPath: "/docs/contract/multicall",
|
|
13054
|
+
functionName
|
|
13055
|
+
});
|
|
13056
|
+
if (!allowFailure) throw error;
|
|
13057
|
+
chunkedCalls[currentChunk] = [
|
|
13058
|
+
...chunkedCalls[currentChunk],
|
|
13059
|
+
{
|
|
13060
|
+
allowFailure: true,
|
|
13061
|
+
callData: "0x",
|
|
13062
|
+
target: address
|
|
13063
|
+
}
|
|
13064
|
+
];
|
|
13065
|
+
}
|
|
13066
|
+
}
|
|
13067
|
+
const aggregate3Results = await Promise.allSettled(
|
|
13068
|
+
chunkedCalls.map(
|
|
13069
|
+
(calls) => utils.getAction(
|
|
13070
|
+
client,
|
|
13071
|
+
actions.simulateContract,
|
|
13072
|
+
"simulateContract"
|
|
13073
|
+
)({
|
|
13074
|
+
abi: viem.multicall3Abi,
|
|
13075
|
+
address: multicallAddress,
|
|
13076
|
+
args: [calls],
|
|
13077
|
+
blockNumber,
|
|
13078
|
+
blockTag,
|
|
13079
|
+
// does not infer well that either blockNumber or blockTag must be present
|
|
13080
|
+
functionName: "aggregate3",
|
|
13081
|
+
stateOverride,
|
|
13082
|
+
gas
|
|
13083
|
+
})
|
|
13084
|
+
)
|
|
13085
|
+
);
|
|
13086
|
+
const results = [];
|
|
13087
|
+
for (let i = 0; i < aggregate3Results.length; i++) {
|
|
13088
|
+
const result = aggregate3Results[i];
|
|
13089
|
+
if (result.status === "rejected") {
|
|
13090
|
+
if (!allowFailure) {
|
|
13091
|
+
throw result.reason;
|
|
13092
|
+
}
|
|
13093
|
+
for (const _i of chunkedCalls[i]) {
|
|
13094
|
+
results.push({
|
|
13095
|
+
status: "failure",
|
|
13096
|
+
error: result.reason,
|
|
13097
|
+
result: void 0
|
|
13098
|
+
});
|
|
13099
|
+
}
|
|
13100
|
+
continue;
|
|
13101
|
+
}
|
|
13102
|
+
const aggregate3Result = result.value.result;
|
|
13103
|
+
for (let j = 0; j < aggregate3Result.length; j++) {
|
|
13104
|
+
const { returnData, success } = aggregate3Result[j];
|
|
13105
|
+
const { callData } = chunkedCalls[i][j];
|
|
13106
|
+
const { abi: abi2, address, functionName, args } = contracts[results.length];
|
|
13107
|
+
try {
|
|
13108
|
+
if (callData === "0x") throw new viem.AbiDecodingZeroDataError();
|
|
13109
|
+
if (!success) throw new viem.RawContractError({ data: returnData });
|
|
13110
|
+
const result2 = viem.decodeFunctionResult({
|
|
13111
|
+
abi: abi2,
|
|
13112
|
+
args,
|
|
13113
|
+
data: returnData,
|
|
13114
|
+
functionName
|
|
13115
|
+
});
|
|
13116
|
+
results.push(allowFailure ? { result: result2, status: "success" } : result2);
|
|
13117
|
+
} catch (err) {
|
|
13118
|
+
const error = viem.getContractError(err, {
|
|
13119
|
+
abi: abi2,
|
|
13120
|
+
address,
|
|
13121
|
+
args,
|
|
13122
|
+
docsPath: "/docs/contract/multicall",
|
|
13123
|
+
functionName
|
|
13124
|
+
});
|
|
13125
|
+
if (!allowFailure) throw error;
|
|
13126
|
+
results.push({ error, result: void 0, status: "failure" });
|
|
13127
|
+
}
|
|
13128
|
+
}
|
|
13129
|
+
}
|
|
13130
|
+
if (results.length !== contracts.length)
|
|
13131
|
+
throw new viem.BaseError("multicall results mismatch");
|
|
13132
|
+
return results;
|
|
13133
|
+
}
|
|
13134
|
+
|
|
13135
|
+
// src/accounts/CreditAccountsService.ts
|
|
13136
|
+
var CreditAccountsService = class extends SDKConstruct {
|
|
13137
|
+
#compressor;
|
|
13138
|
+
#wallet;
|
|
13139
|
+
constructor(sdk, wallet) {
|
|
13140
|
+
super(sdk);
|
|
13141
|
+
this.#compressor = sdk.addressProvider.getLatestVersion(
|
|
13142
|
+
AP_CREDIT_ACCOUNT_COMPRESSOR
|
|
13143
|
+
);
|
|
13144
|
+
this.#wallet = wallet;
|
|
13145
|
+
}
|
|
13146
|
+
/**
|
|
13147
|
+
* Returns single credit account data, or undefined if it's not found
|
|
13148
|
+
* Performs all necessary price feed updates under the hood
|
|
13149
|
+
* @param account
|
|
13150
|
+
* @returns
|
|
13151
|
+
*/
|
|
13152
|
+
async getCreditAccountData(account) {
|
|
13153
|
+
let raw;
|
|
13154
|
+
try {
|
|
13155
|
+
raw = await this.provider.publicClient.readContract({
|
|
13156
|
+
abi: iCreditAccountCompressorAbi,
|
|
13157
|
+
address: this.#compressor,
|
|
13158
|
+
functionName: "getCreditAccountData",
|
|
13159
|
+
args: [account]
|
|
13160
|
+
});
|
|
13161
|
+
} catch (e) {
|
|
13162
|
+
return void 0;
|
|
13163
|
+
}
|
|
13164
|
+
if (raw.success) {
|
|
13165
|
+
return raw;
|
|
13166
|
+
}
|
|
13167
|
+
const { txs: priceUpdateTxs, timestamp: _ } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
|
|
13168
|
+
const resp = await simulateMulticall(this.#wallet, {
|
|
13169
|
+
contracts: [
|
|
13170
|
+
...priceUpdateTxs.map(rawTxToMulticallPriceUpdate),
|
|
13171
|
+
{
|
|
13172
|
+
abi: iCreditAccountCompressorAbi,
|
|
13173
|
+
address: this.#compressor,
|
|
13174
|
+
functionName: "getCreditAccountData",
|
|
13175
|
+
args: [account]
|
|
13176
|
+
}
|
|
13177
|
+
],
|
|
13178
|
+
allowFailure: false,
|
|
13179
|
+
gas: 550000000n,
|
|
13180
|
+
batchSize: 0
|
|
13181
|
+
// we cannot have price updates and compressor request in different batches
|
|
13182
|
+
});
|
|
13183
|
+
const cad = resp.pop();
|
|
13184
|
+
return cad;
|
|
13185
|
+
}
|
|
13186
|
+
/**
|
|
13187
|
+
* Methods to get all credit accounts with some optional filtering
|
|
13188
|
+
* Performs all necessary price feed updates under the hood
|
|
13189
|
+
*
|
|
13190
|
+
* TODO: do we want to expose pagination?
|
|
13191
|
+
* TODO: do we want to expose "reverting"?
|
|
13192
|
+
* TODO: do we want to expose MarketFilter in any way? If so, we need to check that the MarketFilter is compatibled with attached markets?
|
|
13193
|
+
* @param args
|
|
13194
|
+
* @returns
|
|
13195
|
+
*/
|
|
13196
|
+
async getCreditAccounts(args) {
|
|
13197
|
+
const {
|
|
13198
|
+
creditManager,
|
|
13199
|
+
includeZeroDebt = false,
|
|
13200
|
+
maxHealthFactor = 65535,
|
|
13201
|
+
// TODO: this will change to bigint
|
|
13202
|
+
minHealthFactor = 0,
|
|
13203
|
+
owner = ADDRESS_0X0
|
|
13204
|
+
} = args ?? {};
|
|
13205
|
+
const arg0 = creditManager ?? {
|
|
13206
|
+
curators: [],
|
|
13207
|
+
pools: this.pools,
|
|
13208
|
+
underlying: ADDRESS_0X0
|
|
13209
|
+
};
|
|
13210
|
+
const caFilter = {
|
|
13211
|
+
owner,
|
|
13212
|
+
includeZeroDebt,
|
|
13213
|
+
minHealthFactor,
|
|
13214
|
+
maxHealthFactor
|
|
13215
|
+
};
|
|
13216
|
+
const { txs: priceUpdateTxs, timestamp: _ } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
|
|
13217
|
+
const allCAs = [];
|
|
13218
|
+
for (const reverting of [false, true]) {
|
|
13219
|
+
let offset = 0n;
|
|
13220
|
+
do {
|
|
13221
|
+
const [accounts, newOffset] = await this.#getCreditAccounts({
|
|
13222
|
+
priceUpdateTxs,
|
|
13223
|
+
args: [arg0, { ...caFilter, reverting }, offset]
|
|
13224
|
+
});
|
|
13225
|
+
allCAs.push(...accounts);
|
|
13226
|
+
offset = newOffset;
|
|
13227
|
+
} while (offset !== 0n);
|
|
13228
|
+
}
|
|
13229
|
+
return allCAs;
|
|
13230
|
+
}
|
|
13231
|
+
/**
|
|
13232
|
+
* Generates transaction to liquidate credit account
|
|
13233
|
+
* @param account
|
|
13234
|
+
* @param to Address to transfer underlying left after liquidation
|
|
13235
|
+
* @param slippage
|
|
13236
|
+
* @returns
|
|
13237
|
+
*/
|
|
13238
|
+
async fullyLiquidate(account, to, slippage = 50n) {
|
|
13239
|
+
const cm = this.sdk.marketRegister.findCreditManager(account.creditManager);
|
|
13240
|
+
const market = this.sdk.marketRegister.findByCreditManager(
|
|
13241
|
+
account.creditManager
|
|
13242
|
+
);
|
|
13243
|
+
const preview = await this.sdk.router.findBestClosePath(
|
|
13244
|
+
account,
|
|
13245
|
+
cm.creditManager,
|
|
13246
|
+
slippage
|
|
13247
|
+
);
|
|
13248
|
+
const priceUpdates = await this.#getUpdateForAccounts(account);
|
|
13249
|
+
const priceUpdateCalls = market.priceOracle.onDemandPriceUpdates(
|
|
13250
|
+
cm.creditFacade.address,
|
|
13251
|
+
priceUpdates
|
|
13252
|
+
);
|
|
13253
|
+
return cm.creditFacade.createRawTx({
|
|
13254
|
+
functionName: "liquidateCreditAccount",
|
|
13255
|
+
args: [
|
|
13256
|
+
account.creditAccount,
|
|
13257
|
+
to,
|
|
13258
|
+
[...priceUpdateCalls, ...preview.calls]
|
|
13259
|
+
]
|
|
13260
|
+
});
|
|
13261
|
+
}
|
|
13262
|
+
/**
|
|
13263
|
+
* Closes credit account or sets debt to zero (but keep account)
|
|
13264
|
+
* @param operation
|
|
13265
|
+
* @param ca
|
|
13266
|
+
* @param assetsToKeep Tokens to withdraw from credit account
|
|
13267
|
+
* @param to Address to withdraw underlying to
|
|
13268
|
+
* @param slippage
|
|
13269
|
+
* @returns
|
|
13270
|
+
*/
|
|
13271
|
+
async closeCreditAccount(operation, ca, assetsToKeep, to, slippage = 50n) {
|
|
13272
|
+
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
13273
|
+
const calls = await this.#prepareCloseCreditAccount(
|
|
13274
|
+
ca,
|
|
13275
|
+
cm,
|
|
13276
|
+
assetsToKeep,
|
|
13277
|
+
to,
|
|
13278
|
+
slippage
|
|
13279
|
+
);
|
|
13280
|
+
return cm.creditFacade.createRawTx({
|
|
13281
|
+
functionName: operation === "close" ? "closeCreditAccount" : "multicall",
|
|
13282
|
+
args: [ca.creditAccount, calls]
|
|
13283
|
+
});
|
|
13284
|
+
}
|
|
13285
|
+
/**
|
|
13286
|
+
* Internal wrapper for CreditAccountCompressor.getCreditAccounts + price updates wrapped into multicall
|
|
13287
|
+
* @param param0
|
|
13288
|
+
* @returns
|
|
13289
|
+
*/
|
|
13290
|
+
async #getCreditAccounts({
|
|
13291
|
+
args,
|
|
13292
|
+
priceUpdateTxs
|
|
13293
|
+
}) {
|
|
13294
|
+
if (priceUpdateTxs?.length) {
|
|
13295
|
+
const resp = await simulateMulticall(this.#wallet, {
|
|
13296
|
+
contracts: [
|
|
13297
|
+
...priceUpdateTxs.map(rawTxToMulticallPriceUpdate),
|
|
13298
|
+
{
|
|
13299
|
+
abi: iCreditAccountCompressorAbi,
|
|
13300
|
+
address: this.#compressor,
|
|
13301
|
+
functionName: "getCreditAccounts",
|
|
13302
|
+
args
|
|
13303
|
+
}
|
|
13304
|
+
],
|
|
13305
|
+
allowFailure: false,
|
|
13306
|
+
gas: 550000000n,
|
|
13307
|
+
batchSize: 0
|
|
13308
|
+
// we cannot have price updates and compressor request in different batches
|
|
13309
|
+
});
|
|
13310
|
+
const getCreditAccountsResp = resp.pop();
|
|
13311
|
+
return getCreditAccountsResp;
|
|
13312
|
+
}
|
|
13313
|
+
return this.provider.publicClient.readContract({
|
|
13314
|
+
abi: iCreditAccountCompressorAbi,
|
|
13315
|
+
address: this.#compressor,
|
|
13316
|
+
functionName: "getCreditAccounts",
|
|
13317
|
+
args
|
|
13318
|
+
});
|
|
13319
|
+
}
|
|
13320
|
+
/**
|
|
13321
|
+
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
13322
|
+
* @param accounts
|
|
13323
|
+
* @returns
|
|
13324
|
+
*/
|
|
13325
|
+
async #getUpdateForAccounts(...accounts) {
|
|
13326
|
+
const tokensByPool = /* @__PURE__ */ new Map();
|
|
13327
|
+
const oracleByPool = /* @__PURE__ */ new Map();
|
|
13328
|
+
for (const acc of accounts) {
|
|
13329
|
+
const market = this.sdk.marketRegister.findByCreditManager(
|
|
13330
|
+
acc.creditManager
|
|
13331
|
+
);
|
|
13332
|
+
const pool = market.state.pool.pool.address;
|
|
13333
|
+
oracleByPool.set(pool, market.priceOracle);
|
|
13334
|
+
for (const t of acc.tokens) {
|
|
13335
|
+
if (t.balance > 10n) {
|
|
13336
|
+
const tokens = tokensByPool.get(pool) ?? /* @__PURE__ */ new Set();
|
|
13337
|
+
tokens.add(t.token);
|
|
13338
|
+
tokensByPool.set(pool, tokens);
|
|
13339
|
+
}
|
|
13340
|
+
}
|
|
13341
|
+
}
|
|
13342
|
+
const priceFeeds = [];
|
|
13343
|
+
for (const [pool, priceFeedFactory] of oracleByPool.entries()) {
|
|
13344
|
+
const tokens = Array.from(tokensByPool.get(pool) ?? []);
|
|
13345
|
+
priceFeeds.push(...priceFeedFactory.priceFeedsForTokens(tokens));
|
|
13346
|
+
}
|
|
13347
|
+
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(priceFeeds);
|
|
13348
|
+
}
|
|
13349
|
+
async #prepareCloseCreditAccount(ca, cm, assetsToKeep, to, slippage = 50n) {
|
|
13350
|
+
const market = this.sdk.marketRegister.findByCreditManager(
|
|
13351
|
+
ca.creditManager
|
|
13352
|
+
);
|
|
13353
|
+
const closePath = await this.sdk.router.findBestClosePath(
|
|
13354
|
+
ca,
|
|
13355
|
+
cm.creditManager,
|
|
13356
|
+
slippage
|
|
13357
|
+
);
|
|
13358
|
+
const priceUpdates = await this.#getUpdateForAccounts(ca);
|
|
13359
|
+
const priceUpdateCalls = market.priceOracle.onDemandPriceUpdates(
|
|
13360
|
+
cm.creditFacade.address,
|
|
13361
|
+
priceUpdates
|
|
13362
|
+
);
|
|
13363
|
+
return [
|
|
13364
|
+
...priceUpdateCalls,
|
|
13365
|
+
...closePath.calls,
|
|
13366
|
+
...this.#prepareDisableQuotas(ca),
|
|
13367
|
+
...this.#prepareDecreaseDebt(ca),
|
|
13368
|
+
...this.#prepareDisableTokens(ca),
|
|
13369
|
+
...assetsToKeep.map(
|
|
13370
|
+
(t) => this.#prepareWithdrawToken(ca, t, MAX_UINT256, to)
|
|
13371
|
+
)
|
|
13372
|
+
];
|
|
13373
|
+
}
|
|
13374
|
+
#prepareDisableQuotas(ca) {
|
|
13375
|
+
const calls = [];
|
|
13376
|
+
for (const { token, quota } of ca.tokens) {
|
|
13377
|
+
if (quota > 0n) {
|
|
13378
|
+
calls.push({
|
|
13379
|
+
target: ca.creditFacade,
|
|
13380
|
+
callData: viem.encodeFunctionData({
|
|
13381
|
+
abi: iCreditFacadeV3MulticallAbi,
|
|
13382
|
+
functionName: "updateQuota",
|
|
13383
|
+
args: [token, MIN_INT96, 0n]
|
|
13384
|
+
})
|
|
13385
|
+
});
|
|
13386
|
+
}
|
|
13387
|
+
}
|
|
13388
|
+
return calls;
|
|
13389
|
+
}
|
|
13390
|
+
#prepareDecreaseDebt(ca) {
|
|
13391
|
+
if (ca.totalDebtUSD > 0n) {
|
|
13392
|
+
return [
|
|
13393
|
+
{
|
|
13394
|
+
target: ca.creditFacade,
|
|
13395
|
+
callData: viem.encodeFunctionData({
|
|
13396
|
+
abi: iCreditFacadeV3MulticallAbi,
|
|
13397
|
+
functionName: "decreaseDebt",
|
|
13398
|
+
args: [MAX_UINT256]
|
|
13399
|
+
})
|
|
13400
|
+
}
|
|
13401
|
+
];
|
|
13402
|
+
}
|
|
13403
|
+
return [];
|
|
13404
|
+
}
|
|
13405
|
+
#prepareDisableTokens(ca) {
|
|
13406
|
+
const calls = [];
|
|
13407
|
+
for (const t of ca.tokens) {
|
|
13408
|
+
if (t.token !== ca.underlying && (t.mask & ca.enabledTokensMask) !== 0n && t.quota === 0n) {
|
|
13409
|
+
calls.push({
|
|
13410
|
+
target: ca.creditFacade,
|
|
13411
|
+
callData: viem.encodeFunctionData({
|
|
13412
|
+
abi: iCreditFacadeV3MulticallAbi,
|
|
13413
|
+
functionName: "disableToken",
|
|
13414
|
+
args: [t.token]
|
|
13415
|
+
})
|
|
13416
|
+
});
|
|
13417
|
+
}
|
|
13418
|
+
}
|
|
13419
|
+
return calls;
|
|
13420
|
+
}
|
|
13421
|
+
#prepareWithdrawToken(ca, token, amount, to) {
|
|
13422
|
+
return {
|
|
13423
|
+
target: ca.creditFacade,
|
|
13424
|
+
callData: viem.encodeFunctionData({
|
|
13425
|
+
abi: iCreditFacadeV3MulticallAbi,
|
|
13426
|
+
functionName: "withdrawCollateral",
|
|
13427
|
+
args: [token, amount, to]
|
|
13428
|
+
})
|
|
13429
|
+
};
|
|
13430
|
+
}
|
|
13431
|
+
/**
|
|
13432
|
+
* Returns addresses of pools of attached markets
|
|
13433
|
+
*/
|
|
13434
|
+
get pools() {
|
|
13435
|
+
return this.sdk.marketRegister.poolState.map((p) => p.pool.address);
|
|
13436
|
+
}
|
|
13437
|
+
};
|
|
13438
|
+
function rawTxToMulticallPriceUpdate(tx) {
|
|
13439
|
+
const { to, callData } = tx;
|
|
13440
|
+
const { args, functionName } = viem.decodeFunctionData({
|
|
13441
|
+
abi: iUpdatablePriceFeedAbi,
|
|
13442
|
+
data: callData
|
|
13443
|
+
});
|
|
13444
|
+
return {
|
|
13445
|
+
abi: iUpdatablePriceFeedAbi,
|
|
13446
|
+
address: to,
|
|
13447
|
+
functionName,
|
|
13448
|
+
args
|
|
13449
|
+
};
|
|
13450
|
+
}
|
|
12465
13451
|
var AddressProviderContractV3_1 = class extends BaseContract {
|
|
12466
13452
|
#addresses = {};
|
|
12467
13453
|
versions = {};
|
|
@@ -12576,7 +13562,7 @@ var BotListContract = class extends BaseContract {
|
|
|
12576
13562
|
return [
|
|
12577
13563
|
this.addressLabels.get(bot),
|
|
12578
13564
|
this.addressLabels.get(creditManager),
|
|
12579
|
-
|
|
13565
|
+
botPermissionsToString(permissions)
|
|
12580
13566
|
];
|
|
12581
13567
|
}
|
|
12582
13568
|
default:
|
|
@@ -12607,7 +13593,7 @@ var BotListContract = class extends BaseContract {
|
|
|
12607
13593
|
break;
|
|
12608
13594
|
case "SetBotSpecialPermissions":
|
|
12609
13595
|
this.logger?.debug(
|
|
12610
|
-
`Bot ${parsedLog.args.bot} has been given permissions ${
|
|
13596
|
+
`Bot ${parsedLog.args.bot} has been given permissions ${botPermissionsToString(
|
|
12611
13597
|
parsedLog.args.permissions
|
|
12612
13598
|
)} for credit manager ${parsedLog.args.creditManager}`
|
|
12613
13599
|
);
|
|
@@ -12647,16 +13633,18 @@ var GearStakingContract = class extends BaseContract {
|
|
|
12647
13633
|
};
|
|
12648
13634
|
}
|
|
12649
13635
|
};
|
|
13636
|
+
|
|
13637
|
+
// src/market/CreditConfiguratorContract.ts
|
|
12650
13638
|
var CreditConfiguratorContract = class extends BaseContract {
|
|
12651
13639
|
adapters = [];
|
|
12652
13640
|
emergencyLiquidators = [];
|
|
12653
|
-
constructor(sdk, { creditConfigurator, creditManager },
|
|
13641
|
+
constructor(sdk, { creditConfigurator, creditManager }, emergencyLiquidators) {
|
|
12654
13642
|
super(sdk, {
|
|
12655
13643
|
...creditConfigurator.baseParams,
|
|
12656
13644
|
name: `CreditConfigurator(${creditManager.name})`,
|
|
12657
13645
|
abi: creditConfiguratorV3Abi
|
|
12658
13646
|
});
|
|
12659
|
-
this.emergencyLiquidators = [...
|
|
13647
|
+
this.emergencyLiquidators = [...emergencyLiquidators];
|
|
12660
13648
|
}
|
|
12661
13649
|
get state() {
|
|
12662
13650
|
return {
|
|
@@ -12669,7 +13657,7 @@ var CreditConfiguratorContract = class extends BaseContract {
|
|
|
12669
13657
|
case "addCollateralToken":
|
|
12670
13658
|
case "setLiquidationThreshold": {
|
|
12671
13659
|
const [token, lt] = params.args;
|
|
12672
|
-
return [this.addressLabels.get(token),
|
|
13660
|
+
return [this.addressLabels.get(token), percentFmt(lt)];
|
|
12673
13661
|
}
|
|
12674
13662
|
case "setExpirationDate": {
|
|
12675
13663
|
const [expirationDate] = params.args;
|
|
@@ -12684,11 +13672,11 @@ var CreditConfiguratorContract = class extends BaseContract {
|
|
|
12684
13672
|
liquidationPremiumExpired
|
|
12685
13673
|
] = params.args;
|
|
12686
13674
|
return [
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
-
|
|
13675
|
+
percentFmt(feeInterest),
|
|
13676
|
+
percentFmt(feeLiquidation),
|
|
13677
|
+
percentFmt(liquidationPremium),
|
|
13678
|
+
percentFmt(feeLiquidationExpired),
|
|
13679
|
+
percentFmt(liquidationPremiumExpired)
|
|
12692
13680
|
];
|
|
12693
13681
|
}
|
|
12694
13682
|
// case "setMinDebtLimit":
|
|
@@ -12704,9 +13692,9 @@ var CreditConfiguratorContract = class extends BaseContract {
|
|
|
12704
13692
|
const [token, liquidationThresholdFinal, rampStart, rampDuration] = params.args;
|
|
12705
13693
|
return [
|
|
12706
13694
|
this.addressLabels.get(token),
|
|
12707
|
-
|
|
13695
|
+
percentFmt(liquidationThresholdFinal),
|
|
12708
13696
|
`${rampStart}`,
|
|
12709
|
-
|
|
13697
|
+
formatDuration(rampDuration)
|
|
12710
13698
|
];
|
|
12711
13699
|
}
|
|
12712
13700
|
default:
|
|
@@ -12714,6 +13702,8 @@ var CreditConfiguratorContract = class extends BaseContract {
|
|
|
12714
13702
|
}
|
|
12715
13703
|
}
|
|
12716
13704
|
};
|
|
13705
|
+
|
|
13706
|
+
// src/market/CreditFacadeContract.ts
|
|
12717
13707
|
var CreditFacadeContract = class extends BaseContract {
|
|
12718
13708
|
state;
|
|
12719
13709
|
constructor(sdk, { creditFacade, creditManager }) {
|
|
@@ -12780,7 +13770,7 @@ var CreditFacadeContract = class extends BaseContract {
|
|
|
12780
13770
|
return [
|
|
12781
13771
|
this.addressLabels.get(creditAccount),
|
|
12782
13772
|
this.addressLabels.get(bot),
|
|
12783
|
-
|
|
13773
|
+
fmtBinaryMask(permissions)
|
|
12784
13774
|
];
|
|
12785
13775
|
}
|
|
12786
13776
|
default:
|
|
@@ -12792,7 +13782,7 @@ var CreditFacadeContract = class extends BaseContract {
|
|
|
12792
13782
|
// src/market/CreditManagerContract.ts
|
|
12793
13783
|
var CreditManagerContract = class extends BaseContract {
|
|
12794
13784
|
state;
|
|
12795
|
-
constructor(sdk, { creditManager, creditFacade }, pool) {
|
|
13785
|
+
constructor(sdk, { creditManager, creditFacade, adapters }, pool) {
|
|
12796
13786
|
super(sdk, {
|
|
12797
13787
|
...creditManager.baseParams,
|
|
12798
13788
|
name: `CreditManagerV3(${creditManager.name})`,
|
|
@@ -12817,14 +13807,9 @@ var CreditManagerContract = class extends BaseContract {
|
|
|
12817
13807
|
feeLiquidationExpired: creditManager.feeLiquidationExpired,
|
|
12818
13808
|
liquidationDiscountExpired: creditManager.liquidationDiscountExpired,
|
|
12819
13809
|
quotedTokensMask: 0n,
|
|
12820
|
-
contractsToAdapters:
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
// acc[adapter.targetContract as Address] = adapter.adapter as Address;
|
|
12824
|
-
// return acc;
|
|
12825
|
-
// },
|
|
12826
|
-
// {} as Record<Address, Address>,
|
|
12827
|
-
// ),
|
|
13810
|
+
contractsToAdapters: Object.fromEntries(
|
|
13811
|
+
adapters.map((a) => [a.targetContract, a.baseParams.addr])
|
|
13812
|
+
),
|
|
12828
13813
|
creditAccounts: [],
|
|
12829
13814
|
// [...result[5].result!],
|
|
12830
13815
|
name: creditManager.name
|
|
@@ -12850,7 +13835,7 @@ var CreditFactory = class {
|
|
|
12850
13835
|
// TODO:
|
|
12851
13836
|
// adapterFactory: AdapterFactory;
|
|
12852
13837
|
constructor(sdk, marketData, index) {
|
|
12853
|
-
const { creditManagers, pool, emergencyLiquidators
|
|
13838
|
+
const { creditManagers, pool, emergencyLiquidators } = marketData;
|
|
12854
13839
|
const creditManager = creditManagers[index];
|
|
12855
13840
|
const { name, collateralTokens, liquidationThresholds } = creditManager.creditManager;
|
|
12856
13841
|
this.name = name;
|
|
@@ -12864,7 +13849,7 @@ var CreditFactory = class {
|
|
|
12864
13849
|
this.creditConfigurator = new CreditConfiguratorContract(
|
|
12865
13850
|
sdk,
|
|
12866
13851
|
creditManager,
|
|
12867
|
-
|
|
13852
|
+
emergencyLiquidators
|
|
12868
13853
|
);
|
|
12869
13854
|
}
|
|
12870
13855
|
async tvl() {
|
|
@@ -12992,7 +13977,7 @@ var PoolContract = class extends BaseContract {
|
|
|
12992
13977
|
...this.contractData,
|
|
12993
13978
|
lastBaseInterestUpdate: data.lastBaseInterestUpdate,
|
|
12994
13979
|
underlying: data.underlying,
|
|
12995
|
-
decimals:
|
|
13980
|
+
decimals: sdk.marketRegister.tokensMeta.mustGet(data.underlying).decimals,
|
|
12996
13981
|
creditManagerDebtParams,
|
|
12997
13982
|
withdrawFee: Number(data.withdrawFee)
|
|
12998
13983
|
};
|
|
@@ -13019,7 +14004,7 @@ var PoolContract = class extends BaseContract {
|
|
|
13019
14004
|
case "deposit": {
|
|
13020
14005
|
const [amount, onBehalfOf] = params.args;
|
|
13021
14006
|
return [
|
|
13022
|
-
|
|
14007
|
+
formatBN(amount, this.state.decimals),
|
|
13023
14008
|
this.addressLabels.get(onBehalfOf)
|
|
13024
14009
|
];
|
|
13025
14010
|
}
|
|
@@ -13028,6 +14013,8 @@ var PoolContract = class extends BaseContract {
|
|
|
13028
14013
|
}
|
|
13029
14014
|
}
|
|
13030
14015
|
};
|
|
14016
|
+
|
|
14017
|
+
// src/market/PoolQuotaKeeperContract.ts
|
|
13031
14018
|
var PoolQuotaKeeperContract = class extends BaseContract {
|
|
13032
14019
|
decimals;
|
|
13033
14020
|
state;
|
|
@@ -13037,7 +14024,9 @@ var PoolQuotaKeeperContract = class extends BaseContract {
|
|
|
13037
14024
|
name: `PoolQuotaKeeper(${pool.name})`,
|
|
13038
14025
|
abi: poolQuotaKeeperV3Abi
|
|
13039
14026
|
});
|
|
13040
|
-
this.decimals =
|
|
14027
|
+
this.decimals = sdk.marketRegister.tokensMeta.mustGet(
|
|
14028
|
+
pool.underlying
|
|
14029
|
+
).decimals;
|
|
13041
14030
|
this.state = {
|
|
13042
14031
|
...this.contractData,
|
|
13043
14032
|
quotas: Object.fromEntries(
|
|
@@ -13413,7 +14402,7 @@ var Erc4626PriceFeedContract = class extends AbstractLPPriceFeedContract {
|
|
|
13413
14402
|
};
|
|
13414
14403
|
}
|
|
13415
14404
|
async getValue() {
|
|
13416
|
-
const
|
|
14405
|
+
const decimals2 = await this.sdk.provider.publicClient.readContract({
|
|
13417
14406
|
abi: erc20Abi,
|
|
13418
14407
|
address: this.lpContract,
|
|
13419
14408
|
functionName: "decimals"
|
|
@@ -13422,7 +14411,7 @@ var Erc4626PriceFeedContract = class extends AbstractLPPriceFeedContract {
|
|
|
13422
14411
|
abi: viem.erc4626Abi,
|
|
13423
14412
|
address: this.lpContract,
|
|
13424
14413
|
functionName: "convertToAssets",
|
|
13425
|
-
args: [10n ** BigInt(
|
|
14414
|
+
args: [10n ** BigInt(decimals2)]
|
|
13426
14415
|
});
|
|
13427
14416
|
return price;
|
|
13428
14417
|
}
|
|
@@ -13976,7 +14965,8 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
13976
14965
|
// }
|
|
13977
14966
|
#labelPriceFeed(address, usage, token) {
|
|
13978
14967
|
this.sdk.provider.addressLabels.set(address, (label) => {
|
|
13979
|
-
|
|
14968
|
+
const { symbol } = this.sdk.marketRegister.tokensMeta.mustGet(token);
|
|
14969
|
+
let pricefeedTag = `${symbol}.${usage}`;
|
|
13980
14970
|
if (label) {
|
|
13981
14971
|
pricefeedTag = `${label}, ${pricefeedTag}`;
|
|
13982
14972
|
}
|
|
@@ -14029,14 +15019,15 @@ var MarketFactory = class {
|
|
|
14029
15019
|
creditManagers = [];
|
|
14030
15020
|
constructor(sdk, marketData) {
|
|
14031
15021
|
this.riskCurator = marketData.owner;
|
|
15022
|
+
for (const t of marketData.tokens) {
|
|
15023
|
+
sdk.marketRegister.tokensMeta.upsert(t.addr, t);
|
|
15024
|
+
sdk.provider.addressLabels.set(t.addr, t.symbol);
|
|
15025
|
+
}
|
|
14032
15026
|
this.poolFactory = new PoolFactory(sdk, marketData);
|
|
14033
15027
|
for (let i = 0; i < marketData.creditManagers.length; i++) {
|
|
14034
15028
|
this.creditManagers.push(new CreditFactory(sdk, marketData, i));
|
|
14035
15029
|
}
|
|
14036
15030
|
this.priceOracle = new PriceOracleContract(sdk, marketData.priceOracleData);
|
|
14037
|
-
for (const t of marketData.tokens) {
|
|
14038
|
-
sdk.provider.addressLabels.set(t.addr, t.symbol);
|
|
14039
|
-
}
|
|
14040
15031
|
}
|
|
14041
15032
|
get state() {
|
|
14042
15033
|
return {
|
|
@@ -14197,7 +15188,7 @@ var PathOptionFactory = class _PathOptionFactory {
|
|
|
14197
15188
|
}
|
|
14198
15189
|
static getBalancerPools(balances) {
|
|
14199
15190
|
const nonZeroBalances = Object.entries(balances).filter(
|
|
14200
|
-
([, balance]) =>
|
|
15191
|
+
([, balance]) => balance.balance > 1
|
|
14201
15192
|
);
|
|
14202
15193
|
const balancerPools = nonZeroBalances.map(([token]) => sdkGov.getTokenSymbol(token)).filter((symbol) => sdkGov.isBalancerLPToken(symbol));
|
|
14203
15194
|
const balancerAuraTokens = Object.entries(aura.auraTokens).filter(([, data]) => sdkGov.isBalancerLPToken(data.underlying)).map(([token]) => token);
|
|
@@ -14420,8 +15411,8 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
14420
15411
|
const token = t;
|
|
14421
15412
|
const isEnabled = (mask & ca.enabledTokensMask) !== 0n;
|
|
14422
15413
|
expectedBalances[token] = { token, balance };
|
|
14423
|
-
const
|
|
14424
|
-
const minBalance = 10n ** BigInt(Math.max(8,
|
|
15414
|
+
const decimals2 = this.sdk.marketRegister.tokensMeta.mustGet(token).decimals;
|
|
15415
|
+
const minBalance = 10n ** BigInt(Math.max(8, decimals2) - 8);
|
|
14425
15416
|
if (balance < minBalance || !isEnabled) {
|
|
14426
15417
|
leftoverBalances[token] = { token, balance };
|
|
14427
15418
|
}
|
|
@@ -14459,49 +15450,6 @@ function compareRouterResults(a, b) {
|
|
|
14459
15450
|
function assetsMap(assets) {
|
|
14460
15451
|
return new AddressMap(assets.map(({ token, balance }) => [token, balance]));
|
|
14461
15452
|
}
|
|
14462
|
-
async function detectNetwork(client) {
|
|
14463
|
-
for (const chain of sdkGov.supportedChains) {
|
|
14464
|
-
try {
|
|
14465
|
-
await client.readContract({
|
|
14466
|
-
abi: ierc20MetadataAbi,
|
|
14467
|
-
address: sdkGov.tokenDataByNetwork[chain].USDC,
|
|
14468
|
-
functionName: "symbol"
|
|
14469
|
-
});
|
|
14470
|
-
return chain;
|
|
14471
|
-
} catch {
|
|
14472
|
-
}
|
|
14473
|
-
}
|
|
14474
|
-
throw new Error("Unsupported network");
|
|
14475
|
-
}
|
|
14476
|
-
|
|
14477
|
-
// src/utils/viem/createAnvilClient.ts
|
|
14478
|
-
function createAnvilClient({
|
|
14479
|
-
chain,
|
|
14480
|
-
transport
|
|
14481
|
-
}) {
|
|
14482
|
-
return viem.createTestClient(
|
|
14483
|
-
{
|
|
14484
|
-
chain,
|
|
14485
|
-
mode: "anvil",
|
|
14486
|
-
transport,
|
|
14487
|
-
cacheTime: 0
|
|
14488
|
-
}
|
|
14489
|
-
).extend(viem.publicActions).extend(viem.walletActions).extend((client) => ({
|
|
14490
|
-
isAnvil: () => isAnvil(client),
|
|
14491
|
-
detectNetwork: () => detectNetwork(client)
|
|
14492
|
-
}));
|
|
14493
|
-
}
|
|
14494
|
-
async function isAnvil(client) {
|
|
14495
|
-
try {
|
|
14496
|
-
const resp = await client.request({
|
|
14497
|
-
method: "anvil_nodeInfo",
|
|
14498
|
-
params: []
|
|
14499
|
-
});
|
|
14500
|
-
return !!resp.currentBlockNumber;
|
|
14501
|
-
} catch {
|
|
14502
|
-
return false;
|
|
14503
|
-
}
|
|
14504
|
-
}
|
|
14505
15453
|
|
|
14506
15454
|
// src/GearboxSDK.ts
|
|
14507
15455
|
var GearboxSDK = class _GearboxSDK extends eventemitter3.EventEmitter {
|
|
@@ -14591,7 +15539,9 @@ var GearboxSDK = class _GearboxSDK extends eventemitter3.EventEmitter {
|
|
|
14591
15539
|
gearStakingAddress
|
|
14592
15540
|
);
|
|
14593
15541
|
this.#marketRegister = new MarketRegister(this);
|
|
14594
|
-
await this.#marketRegister.loadMarkets([
|
|
15542
|
+
await this.#marketRegister.loadMarkets([
|
|
15543
|
+
TIMELOCK[this.provider.networkType]
|
|
15544
|
+
]);
|
|
14595
15545
|
try {
|
|
14596
15546
|
const router = this.#addressProvider.getLatestVersion(AP_ROUTER);
|
|
14597
15547
|
this.#router = new RouterV3Contract(this, router);
|
|
@@ -14652,7 +15602,7 @@ var GearboxSDK = class _GearboxSDK extends eventemitter3.EventEmitter {
|
|
|
14652
15602
|
async tvl() {
|
|
14653
15603
|
const { tvl, tvlUSD } = await this.marketRegister.tvl();
|
|
14654
15604
|
this.logger?.info(tvl);
|
|
14655
|
-
this.logger?.info(`Total TVL: ${
|
|
15605
|
+
this.logger?.info(`Total TVL: ${formatBN(tvlUSD, 8)}`);
|
|
14656
15606
|
}
|
|
14657
15607
|
async syncState(toBlock, timestamp) {
|
|
14658
15608
|
if (toBlock <= this.currentBlock) {
|
|
@@ -14719,7 +15669,7 @@ var GearboxSDK = class _GearboxSDK extends eventemitter3.EventEmitter {
|
|
|
14719
15669
|
return this.#router;
|
|
14720
15670
|
}
|
|
14721
15671
|
};
|
|
14722
|
-
function convertCreditFacadeStateToHuman(state,
|
|
15672
|
+
function convertCreditFacadeStateToHuman(state, decimals2, labelAddress, _raw = true) {
|
|
14723
15673
|
return {
|
|
14724
15674
|
...convertBaseContractState(state, labelAddress),
|
|
14725
15675
|
maxQuotaMultiplier: state.maxQuotaMultiplier,
|
|
@@ -14729,11 +15679,11 @@ function convertCreditFacadeStateToHuman(state, decimals4, labelAddress, _raw =
|
|
|
14729
15679
|
expirationDate: state.expirationDate,
|
|
14730
15680
|
maxDebtPerBlockMultiplier: state.maxDebtPerBlockMultiplier,
|
|
14731
15681
|
botList: labelAddress(state.botList),
|
|
14732
|
-
minDebt:
|
|
14733
|
-
maxDebt:
|
|
14734
|
-
currentCumulativeLoss:
|
|
14735
|
-
maxCumulativeLoss:
|
|
14736
|
-
forbiddenTokenMask:
|
|
15682
|
+
minDebt: formatBNvalue(state.minDebt, decimals2),
|
|
15683
|
+
maxDebt: formatBNvalue(state.maxDebt, decimals2),
|
|
15684
|
+
currentCumulativeLoss: formatBNvalue(state.currentCumulativeLoss, decimals2),
|
|
15685
|
+
maxCumulativeLoss: formatBNvalue(state.maxCumulativeLoss, decimals2),
|
|
15686
|
+
forbiddenTokenMask: fmtBinaryMask(state.forbiddenTokenMask),
|
|
14737
15687
|
isPaused: state.isPaused
|
|
14738
15688
|
};
|
|
14739
15689
|
}
|
|
@@ -14751,18 +15701,18 @@ function convertCreditManagerStateToHuman(state, labelAddress, raw = true) {
|
|
|
14751
15701
|
collateralTokens: Object.fromEntries(
|
|
14752
15702
|
Object.entries(state.collateralTokens).map(([k, v]) => [
|
|
14753
15703
|
labelAddress(k),
|
|
14754
|
-
|
|
15704
|
+
percentFmt(v, raw)
|
|
14755
15705
|
])
|
|
14756
15706
|
),
|
|
14757
|
-
feeInterest:
|
|
14758
|
-
feeLiquidation:
|
|
14759
|
-
liquidationDiscount:
|
|
14760
|
-
feeLiquidationExpired:
|
|
14761
|
-
liquidationDiscountExpired:
|
|
15707
|
+
feeInterest: percentFmt(state.feeInterest, raw),
|
|
15708
|
+
feeLiquidation: percentFmt(state.feeLiquidation, raw),
|
|
15709
|
+
liquidationDiscount: percentFmt(state.liquidationDiscount, raw),
|
|
15710
|
+
feeLiquidationExpired: percentFmt(state.feeLiquidationExpired, raw),
|
|
15711
|
+
liquidationDiscountExpired: percentFmt(
|
|
14762
15712
|
state.liquidationDiscountExpired,
|
|
14763
15713
|
raw
|
|
14764
15714
|
),
|
|
14765
|
-
quotedTokensMask:
|
|
15715
|
+
quotedTokensMask: fmtBinaryMask(state.quotedTokensMask),
|
|
14766
15716
|
contractsToAdapters: Object.fromEntries(
|
|
14767
15717
|
Object.entries(state.contractsToAdapters).map(([k, v]) => [
|
|
14768
15718
|
labelAddress(k),
|
|
@@ -14796,6 +15746,8 @@ function convertCreditFactoryStateToHuman(state, labelAddress, _raw = true) {
|
|
|
14796
15746
|
)
|
|
14797
15747
|
};
|
|
14798
15748
|
}
|
|
15749
|
+
|
|
15750
|
+
// src/state/poolStateHuman.ts
|
|
14799
15751
|
function convertPoolStateToHuman(state, labelAddress, raw = true) {
|
|
14800
15752
|
return {
|
|
14801
15753
|
...convertBaseContractState(state, labelAddress),
|
|
@@ -14803,27 +15755,27 @@ function convertPoolStateToHuman(state, labelAddress, raw = true) {
|
|
|
14803
15755
|
symbol: state.symbol,
|
|
14804
15756
|
name: state.name,
|
|
14805
15757
|
decimals: state.decimals,
|
|
14806
|
-
availableLiquidity:
|
|
15758
|
+
availableLiquidity: formatBNvalue(
|
|
14807
15759
|
state.availableLiquidity,
|
|
14808
15760
|
state.decimals,
|
|
14809
15761
|
2,
|
|
14810
15762
|
raw
|
|
14811
15763
|
),
|
|
14812
|
-
expectedLiquidity:
|
|
15764
|
+
expectedLiquidity: formatBNvalue(
|
|
14813
15765
|
state.expectedLiquidity,
|
|
14814
15766
|
state.decimals,
|
|
14815
15767
|
2,
|
|
14816
15768
|
raw
|
|
14817
15769
|
),
|
|
14818
|
-
totalBorrowed:
|
|
14819
|
-
totalDebtLimit:
|
|
15770
|
+
totalBorrowed: formatBNvalue(state.totalBorrowed, state.decimals, 2, raw),
|
|
15771
|
+
totalDebtLimit: formatBNvalue(state.totalDebtLimit, state.decimals, 2, raw),
|
|
14820
15772
|
creditManagerDebtParams: Object.fromEntries(
|
|
14821
15773
|
Object.entries(state.creditManagerDebtParams).map(([cm, params]) => [
|
|
14822
15774
|
labelAddress(cm),
|
|
14823
15775
|
{
|
|
14824
|
-
borrowed:
|
|
14825
|
-
limit:
|
|
14826
|
-
availableToBorrow:
|
|
15776
|
+
borrowed: formatBNvalue(params.borrowed, state.decimals, 2, raw),
|
|
15777
|
+
limit: formatBNvalue(params.limit, state.decimals, 2, raw),
|
|
15778
|
+
availableToBorrow: formatBNvalue(
|
|
14827
15779
|
params.availableToBorrow,
|
|
14828
15780
|
state.decimals,
|
|
14829
15781
|
2,
|
|
@@ -14832,28 +15784,28 @@ function convertPoolStateToHuman(state, labelAddress, raw = true) {
|
|
|
14832
15784
|
}
|
|
14833
15785
|
])
|
|
14834
15786
|
),
|
|
14835
|
-
totalAssets:
|
|
14836
|
-
totalSupply:
|
|
14837
|
-
supplyRate: `${
|
|
14838
|
-
baseInterestIndex: `${
|
|
14839
|
-
baseInterestRate: `${
|
|
14840
|
-
withdrawFee:
|
|
15787
|
+
totalAssets: formatBNvalue(state.totalAssets, state.decimals, 2, raw),
|
|
15788
|
+
totalSupply: formatBNvalue(state.totalSupply, state.decimals, 2, raw),
|
|
15789
|
+
supplyRate: `${formatBNvalue(state.supplyRate, 25, 2, raw)}%`,
|
|
15790
|
+
baseInterestIndex: `${formatBNvalue(state.totalSupply, 25, 2, raw)}%`,
|
|
15791
|
+
baseInterestRate: `${formatBNvalue(state.totalSupply, 25, 2, raw)}%`,
|
|
15792
|
+
withdrawFee: percentFmt(state.withdrawFee),
|
|
14841
15793
|
lastBaseInterestUpdate: state.lastBaseInterestUpdate.toString(),
|
|
14842
15794
|
baseInterestIndexLU: state.lastBaseInterestUpdate.toString(),
|
|
14843
15795
|
isPaused: state.isPaused
|
|
14844
15796
|
};
|
|
14845
15797
|
}
|
|
14846
|
-
function convertPoolQuotaKeeperStateToHuman(state,
|
|
15798
|
+
function convertPoolQuotaKeeperStateToHuman(state, decimals2, labelAddress, raw = true) {
|
|
14847
15799
|
return {
|
|
14848
15800
|
...convertBaseContractState(state, labelAddress),
|
|
14849
15801
|
quotas: Object.entries(state.quotas).reduce(
|
|
14850
15802
|
(acc, [address, params]) => ({
|
|
14851
15803
|
...acc,
|
|
14852
15804
|
[address]: {
|
|
14853
|
-
rate:
|
|
14854
|
-
quotaIncreaseFee:
|
|
14855
|
-
totalQuoted:
|
|
14856
|
-
limit:
|
|
15805
|
+
rate: percentFmt(params.rate, raw),
|
|
15806
|
+
quotaIncreaseFee: percentFmt(params.quotaIncreaseFee, raw),
|
|
15807
|
+
totalQuoted: formatBNvalue(params.totalQuoted, decimals2, 2, raw),
|
|
15808
|
+
limit: formatBNvalue(params.limit, decimals2, 2, raw),
|
|
14857
15809
|
isActive: params.isActive
|
|
14858
15810
|
}
|
|
14859
15811
|
}),
|
|
@@ -14864,12 +15816,12 @@ function convertPoolQuotaKeeperStateToHuman(state, decimals4, labelAddress, raw
|
|
|
14864
15816
|
function convertLinearModelStateToHuman(state, labelAddress, raw = true) {
|
|
14865
15817
|
return {
|
|
14866
15818
|
...convertBaseContractState(state, labelAddress),
|
|
14867
|
-
U1:
|
|
14868
|
-
U2:
|
|
14869
|
-
Rbase:
|
|
14870
|
-
Rslope1:
|
|
14871
|
-
Rslope2:
|
|
14872
|
-
Rslope3:
|
|
15819
|
+
U1: percentFmt(state.U1, raw),
|
|
15820
|
+
U2: percentFmt(state.U2, raw),
|
|
15821
|
+
Rbase: percentFmt(state.Rbase, raw),
|
|
15822
|
+
Rslope1: percentFmt(state.Rslope1, raw),
|
|
15823
|
+
Rslope2: percentFmt(state.Rslope2, raw),
|
|
15824
|
+
Rslope3: percentFmt(state.Rslope3, raw),
|
|
14873
15825
|
isBorrowingMoreU2Forbidden: state.isBorrowingMoreU2Forbidden
|
|
14874
15826
|
};
|
|
14875
15827
|
}
|
|
@@ -14882,11 +15834,11 @@ function convertGaugeStateToHuman(state, labelAddress, raw = true) {
|
|
|
14882
15834
|
(acc, [address, params]) => ({
|
|
14883
15835
|
...acc,
|
|
14884
15836
|
[address]: {
|
|
14885
|
-
minRate:
|
|
14886
|
-
maxRate:
|
|
15837
|
+
minRate: percentFmt(params.minRate, raw),
|
|
15838
|
+
maxRate: percentFmt(params.maxRate, raw),
|
|
14887
15839
|
totalVotesLpSide: params.totalVotesLpSide / 1e18,
|
|
14888
15840
|
totalVotesCaSide: params.totalVotesCaSide / 1e18,
|
|
14889
|
-
rate:
|
|
15841
|
+
rate: percentFmt(params.rate, raw)
|
|
14890
15842
|
}
|
|
14891
15843
|
}),
|
|
14892
15844
|
{}
|
|
@@ -14906,6 +15858,8 @@ function convertPoolFactoryStateToHuman(state, labelAddress, raw = true) {
|
|
|
14906
15858
|
gauge: convertGaugeStateToHuman(state.gauge, labelAddress, raw)
|
|
14907
15859
|
};
|
|
14908
15860
|
}
|
|
15861
|
+
|
|
15862
|
+
// src/state/priceFactoryStateHuman.ts
|
|
14909
15863
|
function convertPriceOracleStateToHuman(state, labelAddress, _raw = true) {
|
|
14910
15864
|
return {
|
|
14911
15865
|
priceOracleV3: {
|
|
@@ -14935,7 +15889,7 @@ function convertPriceFeedStateToHuman(state, labelAddress, raw = true) {
|
|
|
14935
15889
|
pricefeeds: state.pricefeeds.map(
|
|
14936
15890
|
(pf) => convertPriceFeedStateToHuman(pf, labelAddress)
|
|
14937
15891
|
),
|
|
14938
|
-
stalenessPeriod:
|
|
15892
|
+
stalenessPeriod: formatDuration(state.stalenessPeriod, raw)
|
|
14939
15893
|
};
|
|
14940
15894
|
}
|
|
14941
15895
|
case "PF_REDSTONE_ORACLE": {
|
|
@@ -14943,7 +15897,7 @@ function convertPriceFeedStateToHuman(state, labelAddress, raw = true) {
|
|
|
14943
15897
|
...state,
|
|
14944
15898
|
...convertBaseContractState(state, labelAddress),
|
|
14945
15899
|
contractType: "PF_REDSTONE_ORACLE",
|
|
14946
|
-
stalenessPeriod:
|
|
15900
|
+
stalenessPeriod: formatDuration(state.stalenessPeriod, raw)
|
|
14947
15901
|
};
|
|
14948
15902
|
}
|
|
14949
15903
|
default: {
|
|
@@ -14953,7 +15907,7 @@ function convertPriceFeedStateToHuman(state, labelAddress, raw = true) {
|
|
|
14953
15907
|
pricefeeds: state.pricefeeds.map(
|
|
14954
15908
|
(pf) => convertPriceFeedStateToHuman(pf, labelAddress)
|
|
14955
15909
|
),
|
|
14956
|
-
stalenessPeriod:
|
|
15910
|
+
stalenessPeriod: formatDuration(state.stalenessPeriod, raw)
|
|
14957
15911
|
};
|
|
14958
15912
|
}
|
|
14959
15913
|
}
|
|
@@ -15120,9 +16074,11 @@ exports.BalancerStablePriceFeedContract = BalancerStablePriceFeedContract;
|
|
|
15120
16074
|
exports.BalancerWeightedPriceFeedContract = BalancerWeightedPriceFeedContract;
|
|
15121
16075
|
exports.BaseContract = BaseContract;
|
|
15122
16076
|
exports.BotListContract = BotListContract;
|
|
16077
|
+
exports.BotPermissions = BotPermissions;
|
|
15123
16078
|
exports.BoundedPriceFeedContract = BoundedPriceFeedContract;
|
|
15124
16079
|
exports.ChainlinkPriceFeedContract = ChainlinkPriceFeedContract;
|
|
15125
16080
|
exports.CompositePriceFeedContract = CompositePriceFeedContract;
|
|
16081
|
+
exports.CreditAccountsService = CreditAccountsService;
|
|
15126
16082
|
exports.CreditConfiguratorContract = CreditConfiguratorContract;
|
|
15127
16083
|
exports.CreditFacadeContract = CreditFacadeContract;
|
|
15128
16084
|
exports.CreditFactory = CreditFactory;
|
|
@@ -15135,6 +16091,8 @@ exports.GaugeContract = GaugeContract;
|
|
|
15135
16091
|
exports.GearStakingContract = GearStakingContract;
|
|
15136
16092
|
exports.GearboxSDK = GearboxSDK;
|
|
15137
16093
|
exports.LinearModelContract = LinearModelContract;
|
|
16094
|
+
exports.MAX_UINT256 = MAX_UINT256;
|
|
16095
|
+
exports.MIN_INT96 = MIN_INT96;
|
|
15138
16096
|
exports.MarketFactory = MarketFactory;
|
|
15139
16097
|
exports.MarketRegister = MarketRegister;
|
|
15140
16098
|
exports.MellowLRTPriceFeedContract = MellowLRTPriceFeedContract;
|
|
@@ -15150,10 +16108,13 @@ exports.Provider = Provider;
|
|
|
15150
16108
|
exports.RedstonePriceFeedContract = RedstonePriceFeedContract;
|
|
15151
16109
|
exports.SDKConstruct = SDKConstruct;
|
|
15152
16110
|
exports.SUPPORTED_CHAINS = SUPPORTED_CHAINS;
|
|
16111
|
+
exports.TIMELOCK = TIMELOCK;
|
|
16112
|
+
exports.USDC = USDC;
|
|
15153
16113
|
exports.VotingContractStatus = VotingContractStatus;
|
|
15154
16114
|
exports.WstETHPriceFeedContract = WstETHPriceFeedContract;
|
|
15155
16115
|
exports.YearnPriceFeedContract = YearnPriceFeedContract;
|
|
15156
16116
|
exports.ZeroPriceFeedContract = ZeroPriceFeedContract;
|
|
16117
|
+
exports.botPermissionsToString = botPermissionsToString;
|
|
15157
16118
|
exports.bytes32ToString = bytes32ToString;
|
|
15158
16119
|
exports.chains = chains;
|
|
15159
16120
|
exports.childLogger = childLogger;
|
|
@@ -15174,6 +16135,14 @@ exports.convertRouterStateToHuman = convertRouterStateToHuman;
|
|
|
15174
16135
|
exports.convertRouterV3StateToHuman = convertRouterV3StateToHuman;
|
|
15175
16136
|
exports.convertZapperRegisterStateToHuman = convertZapperRegisterStateToHuman;
|
|
15176
16137
|
exports.createRawTx = createRawTx;
|
|
15177
|
-
exports.
|
|
16138
|
+
exports.fmtBinaryMask = fmtBinaryMask;
|
|
16139
|
+
exports.formatBN = formatBN;
|
|
16140
|
+
exports.formatBNvalue = formatBNvalue;
|
|
16141
|
+
exports.formatBn4dig = formatBn4dig;
|
|
16142
|
+
exports.formatDuration = formatDuration;
|
|
16143
|
+
exports.formatNumberToString_ = formatNumberToString_;
|
|
15178
16144
|
exports.json_parse = json_parse;
|
|
15179
16145
|
exports.json_stringify = json_stringify;
|
|
16146
|
+
exports.numberWithCommas = numberWithCommas;
|
|
16147
|
+
exports.percentFmt = percentFmt;
|
|
16148
|
+
exports.toHumanFormat = toHumanFormat;
|