@gearbox-protocol/sdk 13.6.0-kyc.7 → 13.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dev/AccountOpener.js +5 -45
- package/dist/cjs/plugins/adapters/abi/actionAbi.js +1 -1
- package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +1 -1
- package/dist/cjs/plugins/adapters/createAdapter.js +1 -1
- package/dist/cjs/plugins/adapters/types.js +1 -1
- package/dist/cjs/plugins/apy/ApyPlugin.js +266 -0
- package/dist/cjs/plugins/apy/apy-cache.js +120 -0
- package/dist/cjs/plugins/apy/apy-parser.js +169 -0
- package/dist/cjs/{sdk/market/kyc/securitize → plugins/apy}/constants.js +6 -3
- package/dist/cjs/{sdk/market/kyc/securitize → plugins/apy}/index.js +14 -6
- package/dist/cjs/{sdk/market/kyc/securitize/types.js → plugins/apy/pool-apy-types.js} +2 -2
- package/dist/cjs/plugins/apy/pool-apy-utils.js +141 -0
- package/dist/cjs/rewards/rewards/extra-apy.js +10 -8
- package/dist/cjs/sdk/GearboxSDK.js +5 -52
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +16 -324
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1 -7
- package/dist/cjs/sdk/base/TokensMeta.js +43 -32
- package/dist/cjs/sdk/base/token-types.js +0 -9
- package/dist/cjs/sdk/chain/chains.js +32 -17
- package/dist/cjs/sdk/constants/address-provider.js +0 -3
- package/dist/cjs/sdk/market/MarketRegister.js +116 -70
- package/dist/cjs/sdk/market/MarketSuite.js +0 -3
- package/dist/cjs/sdk/market/index.js +0 -2
- package/dist/cjs/sdk/market/pool/PoolSuite.js +0 -3
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +2 -11
- package/dist/cjs/sdk/market/pool/index.js +0 -2
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
- package/dist/cjs/sdk/options.js +1 -7
- package/dist/cjs/sdk/pools/PoolService.js +12 -104
- package/dist/cjs/sdk/utils/viem/index.js +0 -2
- package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +39 -2
- package/dist/esm/dev/AccountOpener.js +6 -47
- package/dist/esm/plugins/adapters/abi/actionAbi.js +1 -1
- package/dist/esm/plugins/adapters/abi/conctructorAbi.js +1 -1
- package/dist/esm/plugins/adapters/createAdapter.js +1 -1
- package/dist/esm/plugins/adapters/types.js +1 -1
- package/dist/esm/plugins/apy/ApyPlugin.js +255 -0
- package/dist/esm/plugins/apy/apy-cache.js +86 -0
- package/dist/esm/plugins/apy/apy-parser.js +143 -0
- package/dist/esm/plugins/apy/constants.js +6 -0
- package/dist/esm/plugins/apy/index.js +7 -0
- package/dist/esm/plugins/apy/pool-apy-utils.js +113 -0
- package/dist/esm/rewards/rewards/extra-apy.js +10 -8
- package/dist/esm/sdk/GearboxSDK.js +6 -56
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +17 -328
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1 -7
- package/dist/esm/sdk/base/TokensMeta.js +45 -32
- package/dist/esm/sdk/base/token-types.js +0 -6
- package/dist/esm/sdk/chain/chains.js +32 -17
- package/dist/esm/sdk/constants/address-provider.js +0 -2
- package/dist/esm/sdk/market/MarketRegister.js +118 -74
- package/dist/esm/sdk/market/MarketSuite.js +0 -3
- package/dist/esm/sdk/market/index.js +0 -1
- package/dist/esm/sdk/market/pool/PoolSuite.js +0 -3
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +2 -11
- package/dist/esm/sdk/market/pool/index.js +0 -1
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
- package/dist/esm/sdk/options.js +1 -7
- package/dist/esm/sdk/pools/PoolService.js +13 -109
- package/dist/esm/sdk/utils/viem/index.js +0 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +41 -2
- package/dist/types/plugins/adapters/types.d.ts +2 -2
- package/dist/types/plugins/apy/ApyPlugin.d.ts +46 -0
- package/dist/types/plugins/apy/apy-cache.d.ts +28 -0
- package/dist/types/plugins/apy/apy-parser.d.ts +5 -0
- package/dist/types/plugins/apy/constants.d.ts +2 -0
- package/dist/types/plugins/apy/index.d.ts +7 -0
- package/dist/types/plugins/apy/pool-apy-types.d.ts +41 -0
- package/dist/types/plugins/apy/pool-apy-utils.d.ts +73 -0
- package/dist/types/plugins/apy/types.d.ts +37 -0
- package/dist/types/rewards/rewards/api.d.ts +10 -1
- package/dist/types/rewards/rewards/common.d.ts +0 -10
- package/dist/types/rewards/rewards/extra-apy.d.ts +4 -6
- package/dist/types/sdk/GearboxSDK.d.ts +0 -7
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +2 -52
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +13 -93
- package/dist/types/sdk/base/TokensMeta.d.ts +3 -14
- package/dist/types/sdk/base/token-types.d.ts +4 -44
- package/dist/types/sdk/base/types.d.ts +11 -116
- package/dist/types/sdk/chain/chains.d.ts +5 -5
- package/dist/types/sdk/constants/address-provider.d.ts +0 -1
- package/dist/types/sdk/market/MarketRegister.d.ts +9 -6
- package/dist/types/sdk/market/MarketSuite.d.ts +0 -2
- package/dist/types/sdk/market/index.d.ts +0 -1
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +2 -3
- package/dist/types/sdk/market/oracle/types.d.ts +10 -3
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +0 -2
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -6
- package/dist/types/sdk/market/pool/index.d.ts +0 -1
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +1 -1
- package/dist/types/sdk/market/types.d.ts +1 -1
- package/dist/types/sdk/options.d.ts +0 -1
- package/dist/types/sdk/pools/PoolService.d.ts +8 -8
- package/dist/types/sdk/pools/types.d.ts +1 -1
- package/dist/types/sdk/types/state-human.d.ts +0 -2
- package/dist/types/sdk/types/state.d.ts +0 -5
- package/dist/types/sdk/utils/viem/index.d.ts +0 -1
- package/package.json +2 -3
- package/dist/cjs/abi/kyc/iDSRegistryService.js +0 -70
- package/dist/cjs/abi/kyc/iDSToken.js +0 -71
- package/dist/cjs/abi/kyc/iKYCCompressor.js +0 -196
- package/dist/cjs/abi/kyc/iKYCFactory.js +0 -122
- package/dist/cjs/abi/kyc/iKYCUnderlying.js +0 -401
- package/dist/cjs/abi/kyc/iSecuritizeDegenNFT.js +0 -326
- package/dist/cjs/abi/kyc/iSecuritizeKYCFactory.js +0 -319
- package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +0 -108
- package/dist/cjs/plugins/pools-history/index.js +0 -24
- package/dist/cjs/sdk/market/kyc/KYCRegistry.js +0 -269
- package/dist/cjs/sdk/market/kyc/index.js +0 -26
- package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -244
- package/dist/cjs/sdk/market/kyc/types.js +0 -34
- package/dist/cjs/sdk/utils/viem/executeDelegatedMulticalls.js +0 -38
- package/dist/esm/abi/kyc/iDSRegistryService.js +0 -46
- package/dist/esm/abi/kyc/iDSToken.js +0 -47
- package/dist/esm/abi/kyc/iKYCCompressor.js +0 -172
- package/dist/esm/abi/kyc/iKYCFactory.js +0 -98
- package/dist/esm/abi/kyc/iKYCUnderlying.js +0 -377
- package/dist/esm/abi/kyc/iSecuritizeDegenNFT.js +0 -302
- package/dist/esm/abi/kyc/iSecuritizeKYCFactory.js +0 -295
- package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +0 -90
- package/dist/esm/plugins/pools-history/index.js +0 -2
- package/dist/esm/sdk/market/kyc/KYCRegistry.js +0 -253
- package/dist/esm/sdk/market/kyc/index.js +0 -3
- package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -220
- package/dist/esm/sdk/market/kyc/securitize/constants.js +0 -4
- package/dist/esm/sdk/market/kyc/securitize/index.js +0 -3
- package/dist/esm/sdk/market/kyc/types.js +0 -9
- package/dist/esm/sdk/utils/viem/executeDelegatedMulticalls.js +0 -14
- package/dist/types/abi/kyc/iDSRegistryService.d.ts +0 -71
- package/dist/types/abi/kyc/iDSToken.d.ts +0 -67
- package/dist/types/abi/kyc/iKYCCompressor.d.ts +0 -228
- package/dist/types/abi/kyc/iKYCFactory.d.ts +0 -139
- package/dist/types/abi/kyc/iKYCUnderlying.d.ts +0 -548
- package/dist/types/abi/kyc/iSecuritizeDegenNFT.d.ts +0 -404
- package/dist/types/abi/kyc/iSecuritizeKYCFactory.d.ts +0 -376
- package/dist/types/plugins/pools-history/Pools7DAgoPlugin.d.ts +0 -20
- package/dist/types/plugins/pools-history/index.d.ts +0 -2
- package/dist/types/plugins/pools-history/types.d.ts +0 -9
- package/dist/types/sdk/market/kyc/KYCRegistry.d.ts +0 -52
- package/dist/types/sdk/market/kyc/index.d.ts +0 -3
- package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +0 -428
- package/dist/types/sdk/market/kyc/securitize/constants.d.ts +0 -1
- package/dist/types/sdk/market/kyc/securitize/index.d.ts +0 -3
- package/dist/types/sdk/market/kyc/securitize/types.d.ts +0 -127
- package/dist/types/sdk/market/kyc/types.d.ts +0 -170
- package/dist/types/sdk/utils/viem/executeDelegatedMulticalls.d.ts +0 -28
- /package/dist/cjs/plugins/{pools-history → apy}/package.json +0 -0
- /package/dist/cjs/plugins/{pools-history → apy}/types.js +0 -0
- /package/dist/esm/plugins/{pools-history → apy}/package.json +0 -0
- /package/dist/esm/plugins/{pools-history/types.js → apy/pool-apy-types.js} +0 -0
- /package/dist/esm/{sdk/market/kyc/securitize → plugins/apy}/types.js +0 -0
|
@@ -65,15 +65,15 @@ const chains = {
|
|
|
65
65
|
"0x601067eba24bb5b558a184fc082525637e96a42d": "Gami Labs"
|
|
66
66
|
},
|
|
67
67
|
testMarketConfigurators: {
|
|
68
|
-
"0x99df7330bf42d596af2e9d9836d4fc2077c574aa": "M11 Credit"
|
|
69
|
-
"0xE0527dE5908B3fc2e054B7eEE0DeF6c9965AbF24": "Securitize"
|
|
68
|
+
"0x99df7330bf42d596af2e9d9836d4fc2077c574aa": "M11 Credit"
|
|
70
69
|
},
|
|
71
70
|
isPublic: true,
|
|
72
71
|
wellKnownToken: {
|
|
73
72
|
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
74
73
|
symbol: "USDC"
|
|
75
74
|
},
|
|
76
|
-
firstBlock: 22358644n
|
|
75
|
+
firstBlock: 22358644n,
|
|
76
|
+
gasLimit: 550000000n
|
|
77
77
|
},
|
|
78
78
|
"ethereum-rpc"
|
|
79
79
|
),
|
|
@@ -89,7 +89,8 @@ const chains = {
|
|
|
89
89
|
address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
90
90
|
symbol: "USDC"
|
|
91
91
|
},
|
|
92
|
-
firstBlock: 184650310n
|
|
92
|
+
firstBlock: 184650310n,
|
|
93
|
+
gasLimit: 550000000n
|
|
93
94
|
},
|
|
94
95
|
"arbitrum-one-rpc"
|
|
95
96
|
),
|
|
@@ -106,7 +107,8 @@ const chains = {
|
|
|
106
107
|
address: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
107
108
|
symbol: "USDC"
|
|
108
109
|
},
|
|
109
|
-
firstBlock: 118410666n
|
|
110
|
+
firstBlock: 118410666n,
|
|
111
|
+
gasLimit: 550000000n
|
|
110
112
|
},
|
|
111
113
|
"optimism-rpc"
|
|
112
114
|
),
|
|
@@ -119,7 +121,8 @@ const chains = {
|
|
|
119
121
|
wellKnownToken: {
|
|
120
122
|
address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
121
123
|
symbol: "USDC"
|
|
122
|
-
}
|
|
124
|
+
},
|
|
125
|
+
gasLimit: 550000000n
|
|
123
126
|
},
|
|
124
127
|
"base-rpc"
|
|
125
128
|
),
|
|
@@ -142,6 +145,7 @@ const chains = {
|
|
|
142
145
|
address: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
|
|
143
146
|
symbol: "USDC"
|
|
144
147
|
},
|
|
148
|
+
gasLimit: 550000000n,
|
|
145
149
|
firstBlock: 9779380n
|
|
146
150
|
}),
|
|
147
151
|
"sonic-rpc"
|
|
@@ -154,7 +158,8 @@ const chains = {
|
|
|
154
158
|
wellKnownToken: {
|
|
155
159
|
address: "0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",
|
|
156
160
|
symbol: "USDm"
|
|
157
|
-
}
|
|
161
|
+
},
|
|
162
|
+
gasLimit: 550000000n
|
|
158
163
|
}),
|
|
159
164
|
// NOTE: Monad chain configs should be updated once the public mainnet is available
|
|
160
165
|
Monad: defineChain({
|
|
@@ -175,7 +180,8 @@ const chains = {
|
|
|
175
180
|
address: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
|
|
176
181
|
symbol: "USDT0"
|
|
177
182
|
},
|
|
178
|
-
firstBlock: 34650262n
|
|
183
|
+
firstBlock: 34650262n,
|
|
184
|
+
gasLimit: 200000000n
|
|
179
185
|
}),
|
|
180
186
|
Berachain: withPublicNode(
|
|
181
187
|
{
|
|
@@ -193,7 +199,8 @@ const chains = {
|
|
|
193
199
|
wellKnownToken: {
|
|
194
200
|
address: "0x549943e04f40284185054145c6e4e9568c1d3241",
|
|
195
201
|
symbol: "USDC.e"
|
|
196
|
-
}
|
|
202
|
+
},
|
|
203
|
+
gasLimit: 550000000n
|
|
197
204
|
},
|
|
198
205
|
"berachain-rpc"
|
|
199
206
|
),
|
|
@@ -206,7 +213,8 @@ const chains = {
|
|
|
206
213
|
wellKnownToken: {
|
|
207
214
|
address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
208
215
|
symbol: "USDC"
|
|
209
|
-
}
|
|
216
|
+
},
|
|
217
|
+
gasLimit: 550000000n
|
|
210
218
|
},
|
|
211
219
|
"avalanche-c-chain-rpc"
|
|
212
220
|
),
|
|
@@ -224,7 +232,8 @@ const chains = {
|
|
|
224
232
|
address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
|
|
225
233
|
symbol: "USDC"
|
|
226
234
|
},
|
|
227
|
-
firstBlock: 48761804n
|
|
235
|
+
firstBlock: 48761804n,
|
|
236
|
+
gasLimit: 550000000n
|
|
228
237
|
},
|
|
229
238
|
"bsc-rpc"
|
|
230
239
|
),
|
|
@@ -236,8 +245,9 @@ const chains = {
|
|
|
236
245
|
wellKnownToken: {
|
|
237
246
|
address: "0x79a02482a880bce3f13e09da970dc34db4cd24d1",
|
|
238
247
|
symbol: "USDC"
|
|
239
|
-
}
|
|
248
|
+
},
|
|
240
249
|
// TODO: has no block explorer API
|
|
250
|
+
gasLimit: 550000000n
|
|
241
251
|
}),
|
|
242
252
|
Etherlink: defineChain({
|
|
243
253
|
...etherlink,
|
|
@@ -250,7 +260,8 @@ const chains = {
|
|
|
250
260
|
address: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9",
|
|
251
261
|
symbol: "USDC"
|
|
252
262
|
},
|
|
253
|
-
firstBlock: 16672963n
|
|
263
|
+
firstBlock: 16672963n,
|
|
264
|
+
gasLimit: 550000000n
|
|
254
265
|
}),
|
|
255
266
|
Hemi: defineChain({
|
|
256
267
|
...hemi,
|
|
@@ -268,7 +279,8 @@ const chains = {
|
|
|
268
279
|
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
269
280
|
blockCreated: 484490
|
|
270
281
|
}
|
|
271
|
-
}
|
|
282
|
+
},
|
|
283
|
+
gasLimit: 550000000n
|
|
272
284
|
}),
|
|
273
285
|
Lisk: defineChain({
|
|
274
286
|
...lisk,
|
|
@@ -280,7 +292,8 @@ const chains = {
|
|
|
280
292
|
wellKnownToken: {
|
|
281
293
|
address: "0xF242275d3a6527d877f2c927a82D9b057609cc71",
|
|
282
294
|
symbol: "USDC.e"
|
|
283
|
-
}
|
|
295
|
+
},
|
|
296
|
+
gasLimit: 550000000n
|
|
284
297
|
}),
|
|
285
298
|
Plasma: defineChain({
|
|
286
299
|
...plasma,
|
|
@@ -301,7 +314,8 @@ const chains = {
|
|
|
301
314
|
address: "0xcA11bde05977b3631167028862bE2a173976CA11"
|
|
302
315
|
}
|
|
303
316
|
},
|
|
304
|
-
firstBlock: 670913n
|
|
317
|
+
firstBlock: 670913n,
|
|
318
|
+
gasLimit: 550000000n
|
|
305
319
|
}),
|
|
306
320
|
Somnia: defineChain({
|
|
307
321
|
...somnia,
|
|
@@ -321,7 +335,8 @@ const chains = {
|
|
|
321
335
|
address: "0x67B302E35Aef5EEE8c32D934F5856869EF428330",
|
|
322
336
|
symbol: "USDT"
|
|
323
337
|
},
|
|
324
|
-
firstBlock: 147687380n
|
|
338
|
+
firstBlock: 147687380n,
|
|
339
|
+
gasLimit: 550000000n
|
|
325
340
|
})
|
|
326
341
|
};
|
|
327
342
|
const networkByChainId = Object.values(chains).reduce((acc, chain) => {
|
|
@@ -31,7 +31,6 @@ const AP_WETH_GATEWAY = "WETH_GATEWAY";
|
|
|
31
31
|
const AP_WETH_TOKEN = "WETH_TOKEN";
|
|
32
32
|
const AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
|
|
33
33
|
const AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
|
|
34
|
-
const AP_KYC_COMPRESSOR = "GLOBAL::KYC_COMPRESSOR";
|
|
35
34
|
const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
|
|
36
35
|
export {
|
|
37
36
|
ADDRESS_PROVIDER_V310,
|
|
@@ -52,7 +51,6 @@ export {
|
|
|
52
51
|
AP_GEAR_TOKEN,
|
|
53
52
|
AP_INFLATION_ATTACK_BLOCKER,
|
|
54
53
|
AP_INSOLVENCY_CHECKER,
|
|
55
|
-
AP_KYC_COMPRESSOR,
|
|
56
54
|
AP_MARKET_COMPRESSOR,
|
|
57
55
|
AP_MARKET_CONFIGURATOR,
|
|
58
56
|
AP_PARTIAL_LIQUIDATION_BOT,
|
|
@@ -4,17 +4,12 @@ import {
|
|
|
4
4
|
AP_MARKET_COMPRESSOR,
|
|
5
5
|
VERSION_RANGE_310
|
|
6
6
|
} from "../constants/index.js";
|
|
7
|
-
import { AddressMap
|
|
8
|
-
import {
|
|
9
|
-
executeDelegatedMulticalls
|
|
10
|
-
} from "../utils/viem/index.js";
|
|
7
|
+
import { AddressMap } from "../utils/index.js";
|
|
8
|
+
import { simulateWithPriceUpdates } from "../utils/viem/index.js";
|
|
11
9
|
import { MarketConfiguratorContract } from "./MarketConfiguratorContract.js";
|
|
12
10
|
import { MarketSuite } from "./MarketSuite.js";
|
|
13
11
|
import { ZapperRegister } from "./ZapperRegister.js";
|
|
14
12
|
class MarketRegister extends ZapperRegister {
|
|
15
|
-
/**
|
|
16
|
-
* Mapping pool.address -> MarketSuite
|
|
17
|
-
*/
|
|
18
13
|
#markets = new AddressMap(void 0, "markets");
|
|
19
14
|
#marketFilter;
|
|
20
15
|
#marketConfigurators = new AddressMap(
|
|
@@ -28,7 +23,9 @@ class MarketRegister extends ZapperRegister {
|
|
|
28
23
|
**/
|
|
29
24
|
constructor(sdk, ignoreMarkets = []) {
|
|
30
25
|
super(sdk);
|
|
31
|
-
this.#ignoreMarkets = new
|
|
26
|
+
this.#ignoreMarkets = new Set(
|
|
27
|
+
ignoreMarkets.map((m) => m.toLowerCase())
|
|
28
|
+
);
|
|
32
29
|
}
|
|
33
30
|
/**
|
|
34
31
|
* Restores market state from a previously serialized snapshot,
|
|
@@ -36,41 +33,40 @@ class MarketRegister extends ZapperRegister {
|
|
|
36
33
|
* @param state - Array of market data snapshots.
|
|
37
34
|
**/
|
|
38
35
|
hydrate(state) {
|
|
36
|
+
this.#markets.clear();
|
|
39
37
|
const configurators = new Set(state.map((m) => m.configurator));
|
|
40
38
|
this.#setMarketFilter([...configurators]);
|
|
41
|
-
|
|
39
|
+
for (const data of state) {
|
|
40
|
+
const pool = data.pool.baseParams.addr;
|
|
41
|
+
if (this.#ignoreMarkets.has(pool.toLowerCase())) {
|
|
42
|
+
this.logger?.debug(
|
|
43
|
+
`ignoring market of pool ${pool} (${data.pool.name})`
|
|
44
|
+
);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
this.#markets.upsert(
|
|
48
|
+
data.pool.baseParams.addr,
|
|
49
|
+
new MarketSuite(this.sdk, data)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
42
52
|
}
|
|
43
53
|
/**
|
|
44
|
-
*
|
|
45
|
-
* Returns delegated multicalls for loading all markets from the on-chain
|
|
46
|
-
* market compressor. Used by the SDK to compose batched RPC calls.
|
|
54
|
+
* Fetches all markets from the on-chain for the given market configurators.
|
|
47
55
|
*
|
|
48
|
-
* @param
|
|
56
|
+
* @param marketConfigurators - Addresses of market configurator contracts to query.
|
|
57
|
+
* @param ignoreUpdateablePrices - When `true`, skips generating off-chain
|
|
58
|
+
* price updates before loading
|
|
49
59
|
**/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
call: {
|
|
59
|
-
abi: marketCompressorAbi,
|
|
60
|
-
address: marketCompressorAddress,
|
|
61
|
-
functionName: "getMarkets",
|
|
62
|
-
args: [this.marketFilter]
|
|
63
|
-
},
|
|
64
|
-
onResult: (resp) => {
|
|
65
|
-
this.#setMarkets(resp);
|
|
66
|
-
this.logger?.info(
|
|
67
|
-
`loaded ${this.#markets.size} markets in block ${this.sdk.currentBlock}`
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
];
|
|
60
|
+
async loadMarkets(marketConfigurators, ignoreUpdateablePrices) {
|
|
61
|
+
if (!marketConfigurators.length) {
|
|
62
|
+
this.logger?.warn(
|
|
63
|
+
"no market configurators provided, skipping loadMarkets"
|
|
64
|
+
);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
await this.#loadMarkets(marketConfigurators, [], ignoreUpdateablePrices);
|
|
72
68
|
}
|
|
73
|
-
#setMarketFilter(configurators) {
|
|
69
|
+
#setMarketFilter(configurators, pools = []) {
|
|
74
70
|
for (const c of configurators) {
|
|
75
71
|
this.#marketConfigurators.upsert(
|
|
76
72
|
c,
|
|
@@ -79,7 +75,7 @@ class MarketRegister extends ZapperRegister {
|
|
|
79
75
|
}
|
|
80
76
|
this.#marketFilter = {
|
|
81
77
|
configurators,
|
|
82
|
-
pools
|
|
78
|
+
pools,
|
|
83
79
|
underlying: ADDRESS_0X0
|
|
84
80
|
};
|
|
85
81
|
}
|
|
@@ -106,45 +102,106 @@ class MarketRegister extends ZapperRegister {
|
|
|
106
102
|
**/
|
|
107
103
|
async syncState(ignoreUpdateablePrices) {
|
|
108
104
|
const dirty = this.markets.some((m) => m.dirty) || this.marketConfigurators.some((c) => c.dirty);
|
|
109
|
-
let multicalls;
|
|
110
|
-
let txs = [];
|
|
111
105
|
if (dirty) {
|
|
112
106
|
this.logger?.debug(
|
|
113
107
|
"some markets or market configurators are dirty, reloading everything"
|
|
114
108
|
);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(updatables);
|
|
121
|
-
txs = updates.txs;
|
|
122
|
-
}
|
|
109
|
+
await this.#loadMarkets(
|
|
110
|
+
[...this.marketFilter.configurators],
|
|
111
|
+
[...this.marketFilter.pools],
|
|
112
|
+
ignoreUpdateablePrices
|
|
113
|
+
);
|
|
123
114
|
} else if (!ignoreUpdateablePrices) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
115
|
+
await this.updatePrices();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async #loadMarkets(configurators, pools, ignoreUpdateablePrices) {
|
|
119
|
+
this.#setMarketFilter(configurators, pools);
|
|
120
|
+
const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
121
|
+
AP_MARKET_COMPRESSOR,
|
|
122
|
+
VERSION_RANGE_310
|
|
123
|
+
);
|
|
124
|
+
let txs = [];
|
|
125
|
+
if (!ignoreUpdateablePrices) {
|
|
126
|
+
const updatables = await this.sdk.priceFeeds.getPartialUpdatablePriceFeeds(
|
|
127
|
+
configurators,
|
|
128
|
+
pools
|
|
129
|
+
);
|
|
130
|
+
const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(updatables);
|
|
130
131
|
txs = updates.txs;
|
|
132
|
+
}
|
|
133
|
+
this.logger?.debug(
|
|
134
|
+
{ configurators, pools },
|
|
135
|
+
`calling getMarkets with ${txs.length} price updates in block ${this.sdk.currentBlock}`
|
|
136
|
+
);
|
|
137
|
+
let markets = [];
|
|
138
|
+
if (txs.length) {
|
|
139
|
+
const [resp] = await simulateWithPriceUpdates(this.client, {
|
|
140
|
+
priceUpdates: txs,
|
|
141
|
+
contracts: [
|
|
142
|
+
{
|
|
143
|
+
abi: marketCompressorAbi,
|
|
144
|
+
address: marketCompressorAddress,
|
|
145
|
+
functionName: "getMarkets",
|
|
146
|
+
args: [this.marketFilter]
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
blockNumber: this.sdk.currentBlock,
|
|
150
|
+
gas: this.sdk.gasLimit
|
|
151
|
+
});
|
|
152
|
+
markets = resp;
|
|
131
153
|
} else {
|
|
132
|
-
|
|
154
|
+
markets = await this.client.readContract({
|
|
155
|
+
abi: marketCompressorAbi,
|
|
156
|
+
address: marketCompressorAddress,
|
|
157
|
+
functionName: "getMarkets",
|
|
158
|
+
args: [this.marketFilter],
|
|
159
|
+
blockNumber: this.sdk.currentBlock,
|
|
160
|
+
// @ts-expect-error
|
|
161
|
+
gas: this.sdk.gasLimit
|
|
162
|
+
});
|
|
133
163
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
164
|
+
for (const data of markets) {
|
|
165
|
+
const pool = data.pool.baseParams.addr;
|
|
166
|
+
if (this.#ignoreMarkets.has(pool.toLowerCase())) {
|
|
167
|
+
this.logger?.debug(
|
|
168
|
+
`ignoring market of pool ${pool} (${data.pool.name})`
|
|
169
|
+
);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
this.#markets.upsert(pool, new MarketSuite(this.sdk, data));
|
|
173
|
+
}
|
|
174
|
+
this.logger?.info(
|
|
175
|
+
`loaded ${this.#markets.size} markets in block ${this.sdk.currentBlock}`
|
|
176
|
+
);
|
|
139
177
|
}
|
|
140
|
-
|
|
178
|
+
/**
|
|
179
|
+
* Loads new prices and price feeds for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
180
|
+
*/
|
|
181
|
+
async updatePrices(oracles) {
|
|
141
182
|
const uniqOracles = new AddressMap();
|
|
142
183
|
for (const m of this.markets) {
|
|
143
184
|
if (!oracles || oracles.includes(m.priceOracle.address)) {
|
|
144
185
|
uniqOracles.upsert(m.priceOracle.address, m.priceOracle);
|
|
145
186
|
}
|
|
146
187
|
}
|
|
147
|
-
|
|
188
|
+
const multicalls = uniqOracles.values().map((o) => o.syncStateMulticall());
|
|
189
|
+
if (!multicalls.length) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
this.logger?.debug(`syncing prices on ${multicalls.length} oracles`);
|
|
193
|
+
const { txs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
|
|
194
|
+
const oraclesStates = await simulateWithPriceUpdates(this.client, {
|
|
195
|
+
priceUpdates: txs,
|
|
196
|
+
contracts: multicalls.map((mc) => mc.call),
|
|
197
|
+
gas: this.sdk.gasLimit,
|
|
198
|
+
blockNumber: this.sdk.currentBlock
|
|
199
|
+
});
|
|
200
|
+
for (let i = 0; i < multicalls.length; i++) {
|
|
201
|
+
const handler = multicalls[i].onResult;
|
|
202
|
+
const result = oraclesStates[i];
|
|
203
|
+
handler(result);
|
|
204
|
+
}
|
|
148
205
|
}
|
|
149
206
|
get watchAddresses() {
|
|
150
207
|
return /* @__PURE__ */ new Set([
|
|
@@ -265,19 +322,6 @@ class MarketRegister extends ZapperRegister {
|
|
|
265
322
|
get markets() {
|
|
266
323
|
return this.#markets.values();
|
|
267
324
|
}
|
|
268
|
-
#setMarkets(markets) {
|
|
269
|
-
this.#markets.clear();
|
|
270
|
-
for (const data of markets) {
|
|
271
|
-
const pool = data.pool.baseParams.addr;
|
|
272
|
-
if (this.#ignoreMarkets.has(pool)) {
|
|
273
|
-
this.logger?.debug(
|
|
274
|
-
`ignoring market of pool ${pool} (${data.pool.name})`
|
|
275
|
-
);
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
this.#markets.upsert(pool, new MarketSuite(this.sdk, data));
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
325
|
}
|
|
282
326
|
export {
|
|
283
327
|
MarketRegister
|
|
@@ -44,9 +44,6 @@ class MarketSuite extends SDKConstruct {
|
|
|
44
44
|
get underlying() {
|
|
45
45
|
return this.pool.underlying;
|
|
46
46
|
}
|
|
47
|
-
get kycFactory() {
|
|
48
|
-
return this.pool.kycFactory;
|
|
49
|
-
}
|
|
50
47
|
get dirty() {
|
|
51
48
|
return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
|
|
52
49
|
}
|
|
@@ -55,9 +55,6 @@ class PoolSuite extends SDKConstruct {
|
|
|
55
55
|
get underlying() {
|
|
56
56
|
return this.pool.underlying;
|
|
57
57
|
}
|
|
58
|
-
get kycFactory() {
|
|
59
|
-
return this.pool.kycFactory;
|
|
60
|
-
}
|
|
61
58
|
get dirty() {
|
|
62
59
|
return this.pool.dirty || this.rateKeeper.dirty || this.pqk.dirty || this.interestRateModel.dirty;
|
|
63
60
|
}
|
|
@@ -10,15 +10,13 @@ import {
|
|
|
10
10
|
const abi = [...iPoolV310Abi, ...iPausableAbi];
|
|
11
11
|
class PoolV310Contract extends BaseContract {
|
|
12
12
|
creditManagerDebtParams;
|
|
13
|
-
|
|
14
|
-
constructor(sdk, data) {
|
|
13
|
+
constructor(options, data) {
|
|
15
14
|
const { baseParams, creditManagerDebtParams, ...rest } = data;
|
|
16
|
-
super(
|
|
15
|
+
super(options, {
|
|
17
16
|
...data.baseParams,
|
|
18
17
|
name: `PoolV3(${data.name})`,
|
|
19
18
|
abi
|
|
20
19
|
});
|
|
21
|
-
this.#sdk = sdk;
|
|
22
20
|
Object.assign(this, rest);
|
|
23
21
|
this.creditManagerDebtParams = new AddressMap(
|
|
24
22
|
creditManagerDebtParams.map((p) => [p.creditManager, p])
|
|
@@ -30,13 +28,6 @@ class PoolV310Contract extends BaseContract {
|
|
|
30
28
|
symbol: data.symbol
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
|
-
get kycFactory() {
|
|
34
|
-
const meta = this.#sdk.tokensMeta.mustGet(this.underlying);
|
|
35
|
-
if (this.#sdk.tokensMeta.isKYCUnderlying(meta)) {
|
|
36
|
-
return this.#sdk.mustGetContract(meta.kycFactory);
|
|
37
|
-
}
|
|
38
|
-
return void 0;
|
|
39
|
-
}
|
|
40
31
|
stateHuman(raw = true) {
|
|
41
32
|
return {
|
|
42
33
|
...super.stateHuman(raw),
|
|
@@ -221,13 +221,13 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
221
221
|
* Loads PARTIAL information about all updatable price feeds from MarketCompressor
|
|
222
222
|
* Discovered price feeds are not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
|
|
223
223
|
*/
|
|
224
|
-
async getPartialUpdatablePriceFeeds(configurators) {
|
|
224
|
+
async getPartialUpdatablePriceFeeds(configurators, pools) {
|
|
225
225
|
const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
226
226
|
AP_PRICE_FEED_COMPRESSOR,
|
|
227
227
|
VERSION_RANGE_310
|
|
228
228
|
);
|
|
229
229
|
this.logger?.debug(
|
|
230
|
-
{ configurators },
|
|
230
|
+
{ configurators, pools },
|
|
231
231
|
`calling getUpdatablePriceFeeds in block ${this.sdk.currentBlock}`
|
|
232
232
|
);
|
|
233
233
|
const result = await this.client.readContract({
|
|
@@ -237,7 +237,7 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
237
237
|
args: [
|
|
238
238
|
{
|
|
239
239
|
configurators,
|
|
240
|
-
pools: [],
|
|
240
|
+
pools: pools ?? [],
|
|
241
241
|
underlying: ADDRESS_0X0
|
|
242
242
|
}
|
|
243
243
|
],
|
package/dist/esm/sdk/options.js
CHANGED
|
@@ -16,12 +16,6 @@ const SDKOptions = z.object({
|
|
|
16
16
|
* (from {@link GearboxChain.defaultMarketConfigurators})
|
|
17
17
|
**/
|
|
18
18
|
marketConfigurators: z.array(ZodAddress()).optional(),
|
|
19
|
-
/**
|
|
20
|
-
* Addresses of KYC factory contracts to load.
|
|
21
|
-
* If not set, all default KYC factories for the chain are loaded
|
|
22
|
-
* (from {@link GearboxChain.kycFactories})
|
|
23
|
-
**/
|
|
24
|
-
kycFactories: z.array(ZodAddress()).optional(),
|
|
25
19
|
/**
|
|
26
20
|
* Pin SDK to a specific block number during attach.
|
|
27
21
|
* When set, all on-chain reads use this block instead of `latest`.
|
|
@@ -60,7 +54,7 @@ const SDKOptions = z.object({
|
|
|
60
54
|
/**
|
|
61
55
|
* Explicit gas limit for read-only `eth_call` requests.
|
|
62
56
|
* `null` disables the gas limit entirely; `undefined` uses the SDK default.
|
|
63
|
-
* Default
|
|
57
|
+
* Default to value from {@link GearboxChain.gasLimit}
|
|
64
58
|
**/
|
|
65
59
|
gasLimit: z.bigint().nonnegative().nullable().optional()
|
|
66
60
|
});
|