@gearbox-protocol/sdk 12.4.0-next.1 → 12.4.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/abi/errors.js +10 -1
- package/dist/cjs/dev/AccountOpener.js +2 -1
- package/dist/cjs/dev/RevolverTransport.js +4 -6
- package/dist/cjs/dev/ltUtils.js +2 -1
- package/dist/cjs/dev/migrateFaucet.js +2 -1
- package/dist/cjs/dev/providers.js +6 -2
- package/dist/cjs/dev/transports.js +3 -3
- package/dist/cjs/permissionless/bindings/compressors/token-compressor.js +7 -4
- package/dist/cjs/permissionless/bindings/governance/governor.js +3 -4
- package/dist/cjs/permissionless/bindings/market-configurator.js +4 -2
- package/dist/cjs/permissionless/bindings/price-feed-store.js +2 -1
- package/dist/cjs/permissionless/bindings/treasury-splitter.js +12 -1
- package/dist/cjs/permissionless/utils/format.js +0 -8
- package/dist/cjs/plugins/accounts-counter/AccountsCounterPlugin.js +2 -1
- package/dist/cjs/plugins/bots/BotsPlugin.js +4 -2
- package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +13 -7
- package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +2 -1
- package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +2 -1
- package/dist/cjs/plugins/zappers/ZappersPlugin.js +2 -1
- package/dist/cjs/sdk/GearboxSDK.js +9 -5
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +71 -38
- package/dist/cjs/sdk/base/TokensMeta.js +2 -1
- package/dist/cjs/sdk/core/address-provider/createAddressProvider.js +11 -5
- package/dist/cjs/sdk/gauges/GaugeStakingService.js +2 -1
- package/dist/cjs/sdk/index.js +2 -0
- package/dist/cjs/sdk/market/MarketConfiguratorContract.js +15 -0
- package/dist/cjs/sdk/market/credit/CreditFacadeV300Contract.js +1 -1
- package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +1 -1
- package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +6 -0
- package/dist/cjs/sdk/pools/AbstractPoolService.js +137 -0
- package/dist/cjs/sdk/pools/PoolServiceV300.js +30 -0
- package/dist/cjs/sdk/pools/PoolServiceV310.js +30 -0
- package/dist/cjs/sdk/pools/createPoolService.js +39 -0
- package/dist/cjs/sdk/pools/index.js +26 -0
- package/dist/cjs/sdk/pools/types.js +16 -0
- package/dist/cjs/sdk/sdk-legacy/core/endpoint.js +3 -9
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/api.js +2 -1
- package/dist/cjs/sdk/utils/formatter.js +8 -0
- package/dist/esm/abi/errors.js +9 -1
- package/dist/esm/dev/AccountOpener.js +2 -1
- package/dist/esm/dev/RevolverTransport.js +5 -7
- package/dist/esm/dev/ltUtils.js +2 -1
- package/dist/esm/dev/migrateFaucet.js +2 -1
- package/dist/esm/dev/providers.js +4 -1
- package/dist/esm/dev/transports.js +2 -2
- package/dist/esm/permissionless/bindings/compressors/token-compressor.js +7 -4
- package/dist/esm/permissionless/bindings/governance/governor.js +5 -2
- package/dist/esm/permissionless/bindings/market-configurator.js +4 -2
- package/dist/esm/permissionless/bindings/price-feed-store.js +2 -1
- package/dist/esm/permissionless/bindings/treasury-splitter.js +13 -2
- package/dist/esm/permissionless/utils/format.js +0 -7
- package/dist/esm/plugins/accounts-counter/AccountsCounterPlugin.js +2 -1
- package/dist/esm/plugins/bots/BotsPlugin.js +4 -2
- package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +13 -7
- package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +2 -1
- package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +2 -1
- package/dist/esm/plugins/zappers/ZappersPlugin.js +2 -1
- package/dist/esm/sdk/GearboxSDK.js +9 -5
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +71 -38
- package/dist/esm/sdk/base/TokensMeta.js +2 -1
- package/dist/esm/sdk/core/address-provider/createAddressProvider.js +16 -6
- package/dist/esm/sdk/gauges/GaugeStakingService.js +2 -1
- package/dist/esm/sdk/index.js +1 -0
- package/dist/esm/sdk/market/MarketConfiguratorContract.js +15 -0
- package/dist/esm/sdk/market/credit/CreditFacadeV300Contract.js +6 -2
- package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +6 -2
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +6 -0
- package/dist/esm/sdk/pools/AbstractPoolService.js +113 -0
- package/dist/esm/sdk/pools/PoolServiceV300.js +6 -0
- package/dist/esm/sdk/pools/PoolServiceV310.js +6 -0
- package/dist/esm/sdk/pools/createPoolService.js +15 -0
- package/dist/esm/sdk/pools/index.js +3 -0
- package/dist/esm/sdk/pools/types.js +0 -0
- package/dist/esm/sdk/sdk-legacy/core/endpoint.js +3 -9
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/api.js +2 -1
- package/dist/esm/sdk/utils/formatter.js +7 -0
- package/dist/types/abi/errors.d.ts +33 -0
- package/dist/types/dev/RevolverTransport.d.ts +2 -20
- package/dist/types/dev/providers.d.ts +8 -1
- package/dist/types/dev/transports.d.ts +1 -1
- package/dist/types/permissionless/utils/format.d.ts +0 -1
- package/dist/types/sdk/GearboxSDK.d.ts +1 -1
- package/dist/types/sdk/index.d.ts +1 -0
- package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +9 -0
- package/dist/types/sdk/pools/AbstractPoolService.d.ts +9 -0
- package/dist/types/sdk/pools/PoolServiceV300.d.ts +4 -0
- package/dist/types/sdk/pools/PoolServiceV310.d.ts +4 -0
- package/dist/types/sdk/pools/createPoolService.d.ts +8 -0
- package/dist/types/sdk/pools/index.d.ts +3 -0
- package/dist/types/sdk/pools/types.d.ts +92 -0
- package/dist/types/sdk/sdk-legacy/core/endpoint.d.ts +1 -3
- package/dist/types/sdk/types/state-human.d.ts +1 -1
- package/dist/types/sdk/utils/formatter.d.ts +1 -0
- package/package.json +6 -6
package/dist/cjs/abi/errors.js
CHANGED
|
@@ -21,6 +21,7 @@ __export(errors_exports, {
|
|
|
21
21
|
errorAbis: () => errorAbis,
|
|
22
22
|
iExceptionsV300Abi: () => iExceptionsV300Abi,
|
|
23
23
|
iExceptionsV310Abi: () => iExceptionsV310Abi,
|
|
24
|
+
iPartialLiquidationBotV310ErrorsAbi: () => iPartialLiquidationBotV310ErrorsAbi,
|
|
24
25
|
iRedstoneErrorsAbi: () => iRedstoneErrorsAbi,
|
|
25
26
|
iRedstonePriceFeedExceptionsAbi: () => iRedstonePriceFeedExceptionsAbi,
|
|
26
27
|
iRouterErrorsV300Abi: () => iRouterErrorsV300Abi,
|
|
@@ -399,6 +400,12 @@ const iExceptionsV310Abi = [
|
|
|
399
400
|
{ type: "error", name: "VotingContractNotAllowedException", inputs: [] },
|
|
400
401
|
{ type: "error", name: "ZeroAddressException", inputs: [] }
|
|
401
402
|
];
|
|
403
|
+
const iPartialLiquidationBotV310ErrorsAbi = [
|
|
404
|
+
{ type: "error", name: "LiquidatedLessThanNeededException", inputs: [] },
|
|
405
|
+
{ type: "error", name: "LiquidatedMoreThanNeededException", inputs: [] },
|
|
406
|
+
{ type: "error", name: "SeizedLessThanRequiredException", inputs: [] },
|
|
407
|
+
{ type: "error", name: "UnderlyingNotLiquidatableException", inputs: [] }
|
|
408
|
+
];
|
|
402
409
|
const errorAbis = [
|
|
403
410
|
...iExceptionsV300Abi,
|
|
404
411
|
...iExceptionsV310Abi,
|
|
@@ -406,13 +413,15 @@ const errorAbis = [
|
|
|
406
413
|
...iRedstoneErrorsAbi,
|
|
407
414
|
...ilpPriceFeedExceptionsAbi,
|
|
408
415
|
...iRouterErrorsV300Abi,
|
|
409
|
-
...iRouterErrorsV310Abi
|
|
416
|
+
...iRouterErrorsV310Abi,
|
|
417
|
+
...iPartialLiquidationBotV310ErrorsAbi
|
|
410
418
|
];
|
|
411
419
|
// Annotate the CommonJS export names for ESM import in node:
|
|
412
420
|
0 && (module.exports = {
|
|
413
421
|
errorAbis,
|
|
414
422
|
iExceptionsV300Abi,
|
|
415
423
|
iExceptionsV310Abi,
|
|
424
|
+
iPartialLiquidationBotV310ErrorsAbi,
|
|
416
425
|
iRedstoneErrorsAbi,
|
|
417
426
|
iRedstonePriceFeedExceptionsAbi,
|
|
418
427
|
iRouterErrorsV300Abi,
|
|
@@ -713,7 +713,8 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
713
713
|
args: [distributor.address]
|
|
714
714
|
})
|
|
715
715
|
),
|
|
716
|
-
allowFailure: false
|
|
716
|
+
allowFailure: false,
|
|
717
|
+
batchSize: 0
|
|
717
718
|
});
|
|
718
719
|
const tokensArr = tokens.asArray();
|
|
719
720
|
for (let i = 0; i < tokensArr.length; i++) {
|
|
@@ -27,7 +27,6 @@ __export(RevolverTransport_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(RevolverTransport_exports);
|
|
28
28
|
var import_viem = require("viem");
|
|
29
29
|
var import_v4 = require("zod/v4");
|
|
30
|
-
var import_sdk = require("../sdk/index.js");
|
|
31
30
|
var import_transports = require("./transports.js");
|
|
32
31
|
const providerConfigSchema = import_v4.z.object({
|
|
33
32
|
/**
|
|
@@ -45,11 +44,10 @@ const providerConfigSchema = import_v4.z.object({
|
|
|
45
44
|
/**
|
|
46
45
|
* HTTP transport options to use for this provider
|
|
47
46
|
*/
|
|
48
|
-
|
|
47
|
+
httpTransportOptions: import_transports.httpTransportOptionsSchema.optional()
|
|
49
48
|
});
|
|
50
49
|
const SelectionStrategy = import_v4.z.enum(["simple", "ordered"]);
|
|
51
50
|
const revolverTransportConfigSchema = import_v4.z.object({
|
|
52
|
-
network: import_sdk.NetworkType,
|
|
53
51
|
/**
|
|
54
52
|
* Providers to use
|
|
55
53
|
*/
|
|
@@ -66,7 +64,7 @@ const revolverTransportConfigSchema = import_v4.z.object({
|
|
|
66
64
|
/**
|
|
67
65
|
* Default HTTP options to use for all providers, can be overridden by provider config
|
|
68
66
|
*/
|
|
69
|
-
defaultHTTPOptions: import_transports.
|
|
67
|
+
defaultHTTPOptions: import_transports.httpTransportOptionsSchema.optional(),
|
|
70
68
|
/**
|
|
71
69
|
* Default cooldown, in milliseconds, to wait before try this transport again
|
|
72
70
|
*/
|
|
@@ -107,11 +105,11 @@ class RevolverTransport {
|
|
|
107
105
|
shouldRetry: config.shouldRetry ?? defaultShouldRetry
|
|
108
106
|
};
|
|
109
107
|
const transports = config.providers.map(
|
|
110
|
-
({ url, name, cooldown,
|
|
108
|
+
({ url, name, cooldown, httpTransportOptions }) => ({
|
|
111
109
|
name,
|
|
112
110
|
transport: (0, import_viem.http)(url, {
|
|
113
111
|
...config.defaultHTTPOptions,
|
|
114
|
-
...
|
|
112
|
+
...httpTransportOptions,
|
|
115
113
|
key: name,
|
|
116
114
|
name,
|
|
117
115
|
onFetchRequest: this.#config.onRequest ? (...args) => this.#config.onRequest?.(name, ...args) : void 0,
|
package/dist/cjs/dev/ltUtils.js
CHANGED
|
@@ -24,9 +24,11 @@ __export(providers_exports, {
|
|
|
24
24
|
getDrpcUrl: () => getDrpcUrl,
|
|
25
25
|
getErpcKey: () => getErpcKey,
|
|
26
26
|
getRpcProviderUrl: () => getRpcProviderUrl,
|
|
27
|
-
getThirdWebUrl: () => getThirdWebUrl
|
|
27
|
+
getThirdWebUrl: () => getThirdWebUrl,
|
|
28
|
+
rpcProvidersSchema: () => rpcProvidersSchema
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(providers_exports);
|
|
31
|
+
var import_v4 = require("zod/v4");
|
|
30
32
|
var import_sdk = require("../sdk/index.js");
|
|
31
33
|
const SUPPORTED_RPC_PROVIDERS = [
|
|
32
34
|
"alchemy",
|
|
@@ -34,6 +36,7 @@ const SUPPORTED_RPC_PROVIDERS = [
|
|
|
34
36
|
"thirdweb",
|
|
35
37
|
"ankr"
|
|
36
38
|
];
|
|
39
|
+
const rpcProvidersSchema = import_v4.z.enum(SUPPORTED_RPC_PROVIDERS);
|
|
37
40
|
function getRpcProviderUrl(provider, network, apiKey, protocol = "http") {
|
|
38
41
|
switch (provider) {
|
|
39
42
|
case "alchemy":
|
|
@@ -158,5 +161,6 @@ function getErpcKey(network, projectId, urlBase) {
|
|
|
158
161
|
getDrpcUrl,
|
|
159
162
|
getErpcKey,
|
|
160
163
|
getRpcProviderUrl,
|
|
161
|
-
getThirdWebUrl
|
|
164
|
+
getThirdWebUrl,
|
|
165
|
+
rpcProvidersSchema
|
|
162
166
|
});
|
|
@@ -18,11 +18,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var transports_exports = {};
|
|
20
20
|
__export(transports_exports, {
|
|
21
|
-
|
|
21
|
+
httpTransportOptionsSchema: () => httpTransportOptionsSchema
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(transports_exports);
|
|
24
24
|
var import_v4 = require("zod/v4");
|
|
25
|
-
const
|
|
25
|
+
const httpTransportOptionsSchema = import_v4.z.object({
|
|
26
26
|
/**
|
|
27
27
|
* Whether to enable Batch JSON-RPC.
|
|
28
28
|
* @link https://www.jsonrpc.org/specification#batch
|
|
@@ -67,5 +67,5 @@ const httpTransportConfigSchema = import_v4.z.object({
|
|
|
67
67
|
});
|
|
68
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
69
69
|
0 && (module.exports = {
|
|
70
|
-
|
|
70
|
+
httpTransportOptionsSchema
|
|
71
71
|
});
|
|
@@ -45,7 +45,8 @@ class TokenCompressorContract extends import_sdk.BaseContract {
|
|
|
45
45
|
args: []
|
|
46
46
|
}));
|
|
47
47
|
const results = await this.client.multicall({
|
|
48
|
-
contracts
|
|
48
|
+
contracts,
|
|
49
|
+
batchSize: 0
|
|
49
50
|
});
|
|
50
51
|
const multivaultToToken = /* @__PURE__ */ new Map();
|
|
51
52
|
const multivaults = [];
|
|
@@ -64,7 +65,8 @@ class TokenCompressorContract extends import_sdk.BaseContract {
|
|
|
64
65
|
functionName: "symbol",
|
|
65
66
|
args: []
|
|
66
67
|
})),
|
|
67
|
-
allowFailure: true
|
|
68
|
+
allowFailure: true,
|
|
69
|
+
batchSize: 0
|
|
68
70
|
});
|
|
69
71
|
const tokenToSymbol = /* @__PURE__ */ new Map();
|
|
70
72
|
for (let i = 0; i < resultsSymbols.length; i++) {
|
|
@@ -86,7 +88,8 @@ class TokenCompressorContract extends import_sdk.BaseContract {
|
|
|
86
88
|
abi,
|
|
87
89
|
functionName: "getTokenInfo",
|
|
88
90
|
args: [token]
|
|
89
|
-
}))
|
|
91
|
+
})),
|
|
92
|
+
batchSize: 0
|
|
90
93
|
});
|
|
91
94
|
const tokenInfos = results.map((result, index) => {
|
|
92
95
|
if (result.status === "failure") {
|
|
@@ -98,7 +101,7 @@ class TokenCompressorContract extends import_sdk.BaseContract {
|
|
|
98
101
|
const postfix = multivaultSymbol ? `[${multivaultSymbol}]` : "";
|
|
99
102
|
return {
|
|
100
103
|
...tokenInfo,
|
|
101
|
-
symbol: `${tokenInfo.symbol} ${postfix}`
|
|
104
|
+
symbol: !postfix ? tokenInfo.symbol : `${tokenInfo.symbol} ${postfix}`
|
|
102
105
|
};
|
|
103
106
|
});
|
|
104
107
|
return tokenInfos;
|
|
@@ -25,7 +25,6 @@ var import_viem = require("viem");
|
|
|
25
25
|
var import_utils = require("viem/utils");
|
|
26
26
|
var import_governor = require("../../../abi/governance/governor.js");
|
|
27
27
|
var import_sdk = require("../../../sdk/index.js");
|
|
28
|
-
var import_utils2 = require("../../utils/index.js");
|
|
29
28
|
var import_market_configurator = require("../market-configurator.js");
|
|
30
29
|
var import_treasury_splitter = require("../treasury-splitter.js");
|
|
31
30
|
var import_batches_chain = require("./batches-chain.js");
|
|
@@ -177,7 +176,7 @@ class GovernorContract extends import_sdk.BaseContract {
|
|
|
177
176
|
case "startBatch": {
|
|
178
177
|
const [eta] = args;
|
|
179
178
|
return {
|
|
180
|
-
eta: (0,
|
|
179
|
+
eta: (0, import_sdk.formatTimestamp)(Number(eta))
|
|
181
180
|
};
|
|
182
181
|
}
|
|
183
182
|
case "queueTransaction": {
|
|
@@ -190,7 +189,7 @@ class GovernorContract extends import_sdk.BaseContract {
|
|
|
190
189
|
data: (0, import_sdk.json_stringify)(
|
|
191
190
|
this.#decodeFunctionData(target, calldata)?.args ?? calldata
|
|
192
191
|
),
|
|
193
|
-
eta: (0,
|
|
192
|
+
eta: (0, import_sdk.formatTimestamp)(Number(eta))
|
|
194
193
|
};
|
|
195
194
|
}
|
|
196
195
|
case "executeBatch": {
|
|
@@ -207,7 +206,7 @@ class GovernorContract extends import_sdk.BaseContract {
|
|
|
207
206
|
data: (0, import_sdk.json_stringify)(
|
|
208
207
|
this.#decodeFunctionData(target, calldata)?.args ?? calldata
|
|
209
208
|
),
|
|
210
|
-
eta: (0,
|
|
209
|
+
eta: (0, import_sdk.formatTimestamp)(Number(eta))
|
|
211
210
|
};
|
|
212
211
|
})
|
|
213
212
|
)
|
|
@@ -418,7 +418,8 @@ class MarketConfiguratorContract extends import_sdk.BaseContract {
|
|
|
418
418
|
functionName: "getRoleHolders",
|
|
419
419
|
args: [(0, import_viem.stringToHex)("EMERGENCY_LIQUIDATOR", { size: 32 })]
|
|
420
420
|
}
|
|
421
|
-
]
|
|
421
|
+
],
|
|
422
|
+
batchSize: 0
|
|
422
423
|
});
|
|
423
424
|
return {
|
|
424
425
|
admin,
|
|
@@ -447,7 +448,8 @@ class MarketConfiguratorContract extends import_sdk.BaseContract {
|
|
|
447
448
|
address: admin,
|
|
448
449
|
abi: (0, import_viem.parseAbi)(["function contractType() view returns (bytes32)"]),
|
|
449
450
|
functionName: "contractType"
|
|
450
|
-
}))
|
|
451
|
+
})),
|
|
452
|
+
batchSize: 0
|
|
451
453
|
});
|
|
452
454
|
const pause = result.map((r, i) => ({
|
|
453
455
|
...r,
|
|
@@ -325,7 +325,8 @@ class PriceFeedStoreContract extends import_sdk.BaseContract {
|
|
|
325
325
|
args: [priceFeed]
|
|
326
326
|
}));
|
|
327
327
|
const results = await this.client.multicall({
|
|
328
|
-
contracts: multicallCalls
|
|
328
|
+
contracts: multicallCalls,
|
|
329
|
+
batchSize: 0
|
|
329
330
|
});
|
|
330
331
|
return results.map((result, index) => {
|
|
331
332
|
if (result.status === "failure") {
|
|
@@ -99,7 +99,18 @@ class TreasurySplitterContract extends import_sdk.BaseContract {
|
|
|
99
99
|
});
|
|
100
100
|
return {
|
|
101
101
|
functionName: decoded.functionName,
|
|
102
|
-
...
|
|
102
|
+
...this.parseFunctionParams(decoded)
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
case "setDefaultSplit": {
|
|
106
|
+
const [receivers, proportions] = args;
|
|
107
|
+
return {
|
|
108
|
+
receivers: (0, import_sdk.json_stringify)(receivers),
|
|
109
|
+
proportions: (0, import_sdk.json_stringify)(
|
|
110
|
+
proportions.map(
|
|
111
|
+
(proportion) => `${proportion / 100}% [${proportion}]`
|
|
112
|
+
)
|
|
113
|
+
)
|
|
103
114
|
};
|
|
104
115
|
}
|
|
105
116
|
default:
|
|
@@ -22,7 +22,6 @@ __export(format_exports, {
|
|
|
22
22
|
deepJsonParse: () => deepJsonParse,
|
|
23
23
|
formatBytecodeSize: () => formatBytecodeSize,
|
|
24
24
|
formatBytecodeVersion: () => formatBytecodeVersion,
|
|
25
|
-
formatTimestamp: () => formatTimestamp,
|
|
26
25
|
shortenHash: () => shortenHash,
|
|
27
26
|
significantTrunc: () => significantTrunc
|
|
28
27
|
});
|
|
@@ -38,12 +37,6 @@ function formatBytecodeVersion(version) {
|
|
|
38
37
|
const patch = version % 10;
|
|
39
38
|
return `v${major}.${minor}.${patch}`;
|
|
40
39
|
}
|
|
41
|
-
function formatTimestamp(timestamp) {
|
|
42
|
-
return new Date(timestamp * 1e3).toLocaleString("en-GB", {
|
|
43
|
-
dateStyle: "short",
|
|
44
|
-
timeStyle: "short"
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
40
|
function shortenHash(hash, chars = 4) {
|
|
48
41
|
if (!hash) return "";
|
|
49
42
|
const start = hash.slice(0, chars + 2);
|
|
@@ -91,7 +84,6 @@ function deepJsonParse(value) {
|
|
|
91
84
|
deepJsonParse,
|
|
92
85
|
formatBytecodeSize,
|
|
93
86
|
formatBytecodeVersion,
|
|
94
|
-
formatTimestamp,
|
|
95
87
|
shortenHash,
|
|
96
88
|
significantTrunc
|
|
97
89
|
});
|
|
@@ -70,7 +70,8 @@ class BotsPlugin extends import_sdk.BasePlugin {
|
|
|
70
70
|
})
|
|
71
71
|
),
|
|
72
72
|
allowFailure: true,
|
|
73
|
-
blockNumber: this.sdk.currentBlock
|
|
73
|
+
blockNumber: this.sdk.currentBlock,
|
|
74
|
+
batchSize: 0
|
|
74
75
|
});
|
|
75
76
|
const expectedBots = new import_sdk.AddressMap();
|
|
76
77
|
for (let i = 0; i < configs.length; i++) {
|
|
@@ -98,7 +99,8 @@ class BotsPlugin extends import_sdk.BasePlugin {
|
|
|
98
99
|
})
|
|
99
100
|
),
|
|
100
101
|
allowFailure: true,
|
|
101
|
-
blockNumber: this.sdk.currentBlock
|
|
102
|
+
blockNumber: this.sdk.currentBlock,
|
|
103
|
+
batchSize: 0
|
|
102
104
|
});
|
|
103
105
|
for (let i = 0; i < botAddrs.length; i++) {
|
|
104
106
|
const serialized = serializedBots[i];
|
|
@@ -22,6 +22,7 @@ __export(DegenDistributorsPlugin_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(DegenDistributorsPlugin_exports);
|
|
24
24
|
var import_sdk = require("../../sdk/index.js");
|
|
25
|
+
var import_MarketConfiguratorContract = require("../../sdk/market/MarketConfiguratorContract.js");
|
|
25
26
|
const MAP_LABEL = "degenDistributors";
|
|
26
27
|
class DegenDistributorsPlugin extends import_sdk.BasePlugin {
|
|
27
28
|
#distributors;
|
|
@@ -39,12 +40,15 @@ class DegenDistributorsPlugin extends import_sdk.BasePlugin {
|
|
|
39
40
|
this.sdk.logger?.debug(
|
|
40
41
|
`loading degen distributors for ${this.sdk.networkType}`
|
|
41
42
|
);
|
|
42
|
-
const distributors = await
|
|
43
|
-
|
|
43
|
+
const distributors = await import_MarketConfiguratorContract.MarketConfiguratorContract.getPeripheryContractBatch(
|
|
44
|
+
Object.values(configurators),
|
|
45
|
+
this.sdk.client,
|
|
46
|
+
"DEGEN_DISTRIBUTOR"
|
|
44
47
|
);
|
|
45
48
|
const distributorByConfigurator = configurators.reduce((acc, cfg, index) => {
|
|
46
49
|
const cfgLC = cfg.address.toLowerCase();
|
|
47
|
-
|
|
50
|
+
const distributor = distributors[index];
|
|
51
|
+
acc[cfgLC] = distributor;
|
|
48
52
|
return acc;
|
|
49
53
|
}, {});
|
|
50
54
|
this.#distributors = new import_sdk.AddressMap(void 0, MAP_LABEL);
|
|
@@ -53,11 +57,13 @@ class DegenDistributorsPlugin extends import_sdk.BasePlugin {
|
|
|
53
57
|
const cfg = m.configurator.address;
|
|
54
58
|
const cfgLC = cfg.toLowerCase();
|
|
55
59
|
const r = distributorByConfigurator?.[cfgLC];
|
|
56
|
-
if (r.status === "
|
|
57
|
-
this.#distributors?.upsert(pool, r.
|
|
60
|
+
if (r.status === "success" && r.result.length > 0) {
|
|
61
|
+
this.#distributors?.upsert(pool, r.result[0]);
|
|
58
62
|
} else {
|
|
59
|
-
this.sdk.logger?.
|
|
60
|
-
`failed to load degen distributor for market configurator ${this.labelAddress(
|
|
63
|
+
this.sdk.logger?.warn(
|
|
64
|
+
`failed to load degen distributor for market configurator ${this.labelAddress(
|
|
65
|
+
cfg
|
|
66
|
+
)} and pool ${this.labelAddress(pool)}: ${r.error}`
|
|
61
67
|
);
|
|
62
68
|
}
|
|
63
69
|
});
|
|
@@ -44,7 +44,8 @@ class DelayedWithdrawalPlugin extends import_sdk.BasePlugin {
|
|
|
44
44
|
args: [cm.creditManager.address]
|
|
45
45
|
})
|
|
46
46
|
) : [],
|
|
47
|
-
allowFailure: true
|
|
47
|
+
allowFailure: true,
|
|
48
|
+
batchSize: 0
|
|
48
49
|
});
|
|
49
50
|
this.#withdrawableAssets = new import_sdk.AddressMap(void 0, MAP_LABEL);
|
|
50
51
|
resp.forEach((r, index) => {
|
|
@@ -49,7 +49,8 @@ class Pools7DAgoPlugin extends import_sdk.BasePlugin {
|
|
|
49
49
|
args: [m.pool.pool.address]
|
|
50
50
|
})
|
|
51
51
|
),
|
|
52
|
-
blockNumber: import_sdk.BigIntMath.max(0n, targetBlock)
|
|
52
|
+
blockNumber: import_sdk.BigIntMath.max(0n, targetBlock),
|
|
53
|
+
batchSize: 0
|
|
53
54
|
});
|
|
54
55
|
this.#pools7DAgo = new import_sdk.AddressMap(void 0, MAP_LABEL);
|
|
55
56
|
resp.forEach((r, index) => {
|
|
@@ -51,7 +51,8 @@ class ZappersPlugin extends import_sdk.BasePlugin {
|
|
|
51
51
|
args: [m.configurator.address, m.pool.pool.address]
|
|
52
52
|
})
|
|
53
53
|
),
|
|
54
|
-
allowFailure: true
|
|
54
|
+
allowFailure: true,
|
|
55
|
+
batchSize: 0
|
|
55
56
|
});
|
|
56
57
|
this.#zappers = new import_sdk.AddressMap(void 0, "zappers");
|
|
57
58
|
for (let i = 0; i < resp.length; i++) {
|
|
@@ -46,7 +46,7 @@ function createClient(opts, network) {
|
|
|
46
46
|
} else {
|
|
47
47
|
const rpcs = opts.rpcURLs.map(
|
|
48
48
|
(url) => (0, import_viem.http)(url, {
|
|
49
|
-
...opts.
|
|
49
|
+
...opts.httpTransportOptions,
|
|
50
50
|
timeout: opts.timeout,
|
|
51
51
|
retryCount: opts.retryCount
|
|
52
52
|
})
|
|
@@ -62,11 +62,15 @@ function createClient(opts, network) {
|
|
|
62
62
|
async function attachClient(options, network) {
|
|
63
63
|
let { chainId, networkType } = network;
|
|
64
64
|
const attachClient2 = createClient(options);
|
|
65
|
-
if (
|
|
65
|
+
if (networkType) {
|
|
66
|
+
if (!chainId) {
|
|
67
|
+
chainId = (0, import_chain.getChain)(networkType).id;
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
66
70
|
networkType = await (0, import_chain.detectNetwork)(attachClient2);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
if (!chainId) {
|
|
72
|
+
chainId = await attachClient2.getChainId();
|
|
73
|
+
}
|
|
70
74
|
}
|
|
71
75
|
return createClient(options, { networkType, chainId });
|
|
72
76
|
}
|
|
@@ -212,9 +212,9 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
212
212
|
* @returns call result of getConnectedBots for each credit account
|
|
213
213
|
*/
|
|
214
214
|
async getConnectedBots(accountsToCheck, legacyMigrationBot, additionalBots) {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
const allResp = await this.client.multicall({
|
|
216
|
+
contracts: [
|
|
217
|
+
...accountsToCheck.map((o) => {
|
|
218
218
|
const pool = this.sdk.marketRegister.findByCreditManager(
|
|
219
219
|
o.creditManager
|
|
220
220
|
);
|
|
@@ -225,32 +225,72 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
225
225
|
args: [pool.configurator.address, o.creditAccount]
|
|
226
226
|
};
|
|
227
227
|
}),
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
]);
|
|
233
|
-
return {
|
|
234
|
-
legacy: resp,
|
|
235
|
-
additionalBots: additional,
|
|
236
|
-
legacyMigration: migration
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
async getActiveBots(accountsToCheck, bots) {
|
|
240
|
-
const result = await this.client.multicall({
|
|
241
|
-
contracts: accountsToCheck.flatMap((ca) => {
|
|
242
|
-
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
243
|
-
return bots.map((bot) => {
|
|
228
|
+
...legacyMigrationBot ? accountsToCheck.map((ca) => {
|
|
229
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
230
|
+
ca.creditManager
|
|
231
|
+
);
|
|
244
232
|
return {
|
|
245
233
|
abi: (0, import_constants.isV300)(cm.creditFacade.version) ? import_v300.iBotListV300Abi : import_generated.iBotListV310Abi,
|
|
246
234
|
address: cm.creditFacade.botList,
|
|
247
235
|
functionName: "getBotStatus",
|
|
248
|
-
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [
|
|
236
|
+
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [legacyMigrationBot, ca.creditManager, ca.creditAccount] : [legacyMigrationBot, ca.creditAccount]
|
|
249
237
|
};
|
|
250
|
-
})
|
|
251
|
-
|
|
252
|
-
|
|
238
|
+
}) : [],
|
|
239
|
+
...accountsToCheck.flatMap((ca) => {
|
|
240
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
241
|
+
ca.creditManager
|
|
242
|
+
);
|
|
243
|
+
return additionalBots.map((bot) => {
|
|
244
|
+
return {
|
|
245
|
+
abi: (0, import_constants.isV300)(cm.creditFacade.version) ? import_v300.iBotListV300Abi : import_generated.iBotListV310Abi,
|
|
246
|
+
address: cm.creditFacade.botList,
|
|
247
|
+
functionName: "getBotStatus",
|
|
248
|
+
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
})
|
|
252
|
+
],
|
|
253
|
+
allowFailure: true,
|
|
254
|
+
batchSize: 0
|
|
253
255
|
});
|
|
256
|
+
const legacyStart = 0;
|
|
257
|
+
const legacyEnd = accountsToCheck.length;
|
|
258
|
+
const legacy = allResp.slice(
|
|
259
|
+
legacyStart,
|
|
260
|
+
legacyEnd
|
|
261
|
+
);
|
|
262
|
+
const migrationStart = legacyEnd;
|
|
263
|
+
const migrationEnd = legacyMigrationBot ? migrationStart + accountsToCheck.length : migrationStart;
|
|
264
|
+
const migrationResp = allResp.slice(
|
|
265
|
+
migrationStart,
|
|
266
|
+
migrationEnd
|
|
267
|
+
);
|
|
268
|
+
const additionalStart = migrationEnd;
|
|
269
|
+
const additionalResp = allResp.slice(
|
|
270
|
+
additionalStart
|
|
271
|
+
);
|
|
272
|
+
return {
|
|
273
|
+
legacy,
|
|
274
|
+
additionalBots: this.getActiveBots(
|
|
275
|
+
accountsToCheck,
|
|
276
|
+
additionalBots,
|
|
277
|
+
additionalResp
|
|
278
|
+
),
|
|
279
|
+
legacyMigration: this.getActiveMigrationBots(
|
|
280
|
+
accountsToCheck,
|
|
281
|
+
legacyMigrationBot,
|
|
282
|
+
migrationResp
|
|
283
|
+
)
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
getActiveBots(accountsToCheck, bots, result) {
|
|
287
|
+
if (result.length !== bots.length * accountsToCheck.length) {
|
|
288
|
+
console.error(
|
|
289
|
+
"result length mismatch",
|
|
290
|
+
result.length,
|
|
291
|
+
bots.length * accountsToCheck.length
|
|
292
|
+
);
|
|
293
|
+
}
|
|
254
294
|
const botsByCAIndex = accountsToCheck.reduce((acc, _, index) => {
|
|
255
295
|
const r = result.slice(index * bots.length, (index + 1) * bots.length);
|
|
256
296
|
acc.push({
|
|
@@ -260,22 +300,15 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
260
300
|
}, []);
|
|
261
301
|
return botsByCAIndex;
|
|
262
302
|
}
|
|
263
|
-
|
|
303
|
+
getActiveMigrationBots(accountsToCheck, bot, result) {
|
|
264
304
|
if (bot) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
address: cm.creditFacade.botList,
|
|
273
|
-
functionName: "getBotStatus",
|
|
274
|
-
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
275
|
-
};
|
|
276
|
-
}),
|
|
277
|
-
allowFailure: true
|
|
278
|
-
});
|
|
305
|
+
if (result.length !== accountsToCheck.length) {
|
|
306
|
+
console.error(
|
|
307
|
+
"result length mismatch for migration bots",
|
|
308
|
+
result.length,
|
|
309
|
+
accountsToCheck.length
|
|
310
|
+
);
|
|
311
|
+
}
|
|
279
312
|
return { result, botAddress: bot };
|
|
280
313
|
}
|
|
281
314
|
return void 0;
|
|
@@ -24,14 +24,20 @@ __export(createAddressProvider_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(createAddressProvider_exports);
|
|
25
25
|
var import_iVersion = require("../../../abi/iVersion.js");
|
|
26
26
|
var import_constants = require("../../constants/index.js");
|
|
27
|
+
var import_hex = require("../../utils/hex.js");
|
|
27
28
|
var import_AddressProviderV300Contract = require("./AddressProviderV300Contract.js");
|
|
28
29
|
var import_AddressProviderV310Contract = require("./AddressProviderV310Contract.js");
|
|
29
30
|
async function createAddressProvider(sdk, address) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
let v;
|
|
32
|
+
if ((0, import_hex.hexEq)(address, import_constants.ADDRESS_PROVIDER_V310)) {
|
|
33
|
+
v = 310n;
|
|
34
|
+
} else {
|
|
35
|
+
v = await sdk.client.readContract({
|
|
36
|
+
address,
|
|
37
|
+
abi: import_iVersion.iVersionAbi,
|
|
38
|
+
functionName: "version"
|
|
39
|
+
});
|
|
40
|
+
}
|
|
35
41
|
return newAddressProvider(sdk, address, Number(v));
|
|
36
42
|
}
|
|
37
43
|
function hydrateAddressProvider(sdk, state) {
|
package/dist/cjs/sdk/index.js
CHANGED
|
@@ -27,6 +27,7 @@ __reExport(sdk_exports, require("./market/index.js"), module.exports);
|
|
|
27
27
|
__reExport(sdk_exports, require("./options.js"), module.exports);
|
|
28
28
|
__reExport(sdk_exports, require("./plugins/index.js"), module.exports);
|
|
29
29
|
__reExport(sdk_exports, require("./poolMigration/index.js"), module.exports);
|
|
30
|
+
__reExport(sdk_exports, require("./pools/index.js"), module.exports);
|
|
30
31
|
__reExport(sdk_exports, require("./router/index.js"), module.exports);
|
|
31
32
|
__reExport(sdk_exports, require("./sdk-gov-legacy/index.js"), module.exports);
|
|
32
33
|
__reExport(sdk_exports, require("./sdk-legacy/index.js"), module.exports);
|
|
@@ -47,6 +48,7 @@ __reExport(sdk_exports, require("./utils/viem/index.js"), module.exports);
|
|
|
47
48
|
...require("./options.js"),
|
|
48
49
|
...require("./plugins/index.js"),
|
|
49
50
|
...require("./poolMigration/index.js"),
|
|
51
|
+
...require("./pools/index.js"),
|
|
50
52
|
...require("./router/index.js"),
|
|
51
53
|
...require("./sdk-gov-legacy/index.js"),
|
|
52
54
|
...require("./sdk-legacy/index.js"),
|