@raac/rpc 2.0.0-beta.20 → 2.0.0-beta.22
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/RPCLibrary.js +10 -3
- package/dist/artifacts/core/pools/StabilityPool/LiquidationSwap.sol/LiquidationSwap.json +472 -0
- package/dist/contracts/governance/gauge/getUserGaugeState.js +11 -11
- package/dist/contracts/psm/getVaultInfo.js +1 -7
- package/dist/contracts/resolveTokenInfo.js +65 -0
- package/dist/contracts/yearn/vault/getUserInfo.js +4 -6
- package/dist/contracts/zap/aladdin/inspectCurvePool.js +3 -4
- package/dist/pools/rwaVault/getRegisteredAdapters.js +11 -6
- package/dist/pools/stabilityPool/liquidation.js +211 -138
- package/dist/prices/getCurveLPPriceUSD.js +7 -7
- package/dist/types/RPCLibrary.d.ts +11 -4
- package/dist/types/contracts/governance/gauge/getUserGaugeState.d.ts +6 -7
- package/dist/types/contracts/psm/getVaultInfo.d.ts +1 -3
- package/dist/types/contracts/resolveTokenInfo.d.ts +18 -0
- package/dist/types/contracts/yearn/vault/getUserInfo.d.ts +3 -4
- package/dist/types/pools/stabilityPool/liquidation.d.ts +166 -52
- package/dist/types/utils/artifacts.d.ts +113 -0
- package/dist/types/wallet/assets/getBalance.d.ts +5 -4
- package/dist/utils/artifacts.js +2 -0
- package/dist/wallet/assets/getBalance.js +19 -8
- package/package.json +2 -1
package/dist/RPCLibrary.js
CHANGED
|
@@ -101,6 +101,7 @@ const findContract_1 = require("./contracts/findContract");
|
|
|
101
101
|
const decodeCall_1 = require("./contracts/decodeCall");
|
|
102
102
|
const resolveName_1 = require("./contracts/resolveName");
|
|
103
103
|
const getTokenMetadata_1 = require("./contracts/getTokenMetadata");
|
|
104
|
+
const resolveTokenInfo_1 = require("./contracts/resolveTokenInfo");
|
|
104
105
|
// House Prices
|
|
105
106
|
const getLatestPrice_1 = __importDefault(require("./contracts/housePrices/getLatestPrice"));
|
|
106
107
|
const setOracle_1 = __importDefault(require("./contracts/housePrices/setOracle"));
|
|
@@ -558,6 +559,7 @@ class RPCLibrary {
|
|
|
558
559
|
resolveName: resolveName_1.resolveName,
|
|
559
560
|
resolveNames: resolveName_1.resolveNames,
|
|
560
561
|
getTokenMetadata: getTokenMetadata_1.getTokenMetadata,
|
|
562
|
+
resolveTokenInfo: resolveTokenInfo_1.resolveTokenInfo,
|
|
561
563
|
feeCollector: {
|
|
562
564
|
claimRewardFromPool: claimRewardFromPool_1.default,
|
|
563
565
|
getState: getState_2.default,
|
|
@@ -823,10 +825,15 @@ class RPCLibrary {
|
|
|
823
825
|
liquidation: {
|
|
824
826
|
getContext: liquidation_1.readLiquidationContext,
|
|
825
827
|
getTarget: liquidation_1.readLiquidationTarget,
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
828
|
+
plan: liquidation_1.planLiquidation,
|
|
829
|
+
curveQuote: liquidation_1.curveQuote,
|
|
830
|
+
largestClearingFloor: liquidation_1.largestClearingFloor,
|
|
831
|
+
toleranceNeeded: liquidation_1.toleranceNeeded,
|
|
832
|
+
priceImpact: liquidation_1.priceImpact,
|
|
833
|
+
valueAtNav: liquidation_1.valueAtNav,
|
|
834
|
+
sharesAtNav: liquidation_1.sharesAtNav,
|
|
829
835
|
minSharesOut: liquidation_1.minSharesOut,
|
|
836
|
+
DEFAULT_PLAN_PARAMS: liquidation_1.DEFAULT_PLAN_PARAMS,
|
|
830
837
|
},
|
|
831
838
|
},
|
|
832
839
|
// LendingPool
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_format": "hh-sol-artifact-1",
|
|
3
|
+
"contractName": "LiquidationSwap",
|
|
4
|
+
"sourceName": "contracts/core/pools/StabilityPool/LiquidationSwap.sol",
|
|
5
|
+
"abi": [
|
|
6
|
+
{
|
|
7
|
+
"inputs": [
|
|
8
|
+
{
|
|
9
|
+
"internalType": "address",
|
|
10
|
+
"name": "_vaultToken",
|
|
11
|
+
"type": "address"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"internalType": "address",
|
|
15
|
+
"name": "_swapToken",
|
|
16
|
+
"type": "address"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"internalType": "address",
|
|
20
|
+
"name": "_rwaVault",
|
|
21
|
+
"type": "address"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"internalType": "address",
|
|
25
|
+
"name": "_crvusdToUSDOracle",
|
|
26
|
+
"type": "address"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"internalType": "address",
|
|
30
|
+
"name": "_initialOwner",
|
|
31
|
+
"type": "address"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"stateMutability": "nonpayable",
|
|
35
|
+
"type": "constructor"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"inputs": [],
|
|
39
|
+
"name": "ApprovalFailed",
|
|
40
|
+
"type": "error"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"inputs": [],
|
|
44
|
+
"name": "InvalidAddress",
|
|
45
|
+
"type": "error"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"inputs": [],
|
|
49
|
+
"name": "InvalidExchange",
|
|
50
|
+
"type": "error"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"inputs": [],
|
|
54
|
+
"name": "InvalidIndex",
|
|
55
|
+
"type": "error"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"inputs": [],
|
|
59
|
+
"name": "InvalidSlippageProtection",
|
|
60
|
+
"type": "error"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"inputs": [
|
|
64
|
+
{
|
|
65
|
+
"internalType": "address",
|
|
66
|
+
"name": "owner",
|
|
67
|
+
"type": "address"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"name": "OwnableInvalidOwner",
|
|
71
|
+
"type": "error"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"inputs": [
|
|
75
|
+
{
|
|
76
|
+
"internalType": "address",
|
|
77
|
+
"name": "account",
|
|
78
|
+
"type": "address"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"name": "OwnableUnauthorizedAccount",
|
|
82
|
+
"type": "error"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"inputs": [],
|
|
86
|
+
"name": "ReentrancyGuardReentrantCall",
|
|
87
|
+
"type": "error"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"inputs": [
|
|
91
|
+
{
|
|
92
|
+
"internalType": "address",
|
|
93
|
+
"name": "token",
|
|
94
|
+
"type": "address"
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"name": "SafeERC20FailedOperation",
|
|
98
|
+
"type": "error"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"inputs": [],
|
|
102
|
+
"name": "Unauthorized",
|
|
103
|
+
"type": "error"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"inputs": [],
|
|
107
|
+
"name": "ZeroAmount",
|
|
108
|
+
"type": "error"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"anonymous": false,
|
|
112
|
+
"inputs": [
|
|
113
|
+
{
|
|
114
|
+
"indexed": true,
|
|
115
|
+
"internalType": "address",
|
|
116
|
+
"name": "oracle",
|
|
117
|
+
"type": "address"
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"name": "CrvusdToUSDOracleSet",
|
|
121
|
+
"type": "event"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"anonymous": false,
|
|
125
|
+
"inputs": [
|
|
126
|
+
{
|
|
127
|
+
"indexed": true,
|
|
128
|
+
"internalType": "address",
|
|
129
|
+
"name": "liquidityPool",
|
|
130
|
+
"type": "address"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"indexed": false,
|
|
134
|
+
"internalType": "uint256",
|
|
135
|
+
"name": "slippageProtectionBps",
|
|
136
|
+
"type": "uint256"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"indexed": false,
|
|
140
|
+
"internalType": "uint256",
|
|
141
|
+
"name": "iIn",
|
|
142
|
+
"type": "uint256"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"indexed": false,
|
|
146
|
+
"internalType": "uint256",
|
|
147
|
+
"name": "iOut",
|
|
148
|
+
"type": "uint256"
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
"name": "LiquidityPoolSet",
|
|
152
|
+
"type": "event"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"anonymous": false,
|
|
156
|
+
"inputs": [
|
|
157
|
+
{
|
|
158
|
+
"indexed": true,
|
|
159
|
+
"internalType": "address",
|
|
160
|
+
"name": "previousOwner",
|
|
161
|
+
"type": "address"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"indexed": true,
|
|
165
|
+
"internalType": "address",
|
|
166
|
+
"name": "newOwner",
|
|
167
|
+
"type": "address"
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
"name": "OwnershipTransferred",
|
|
171
|
+
"type": "event"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"anonymous": false,
|
|
175
|
+
"inputs": [
|
|
176
|
+
{
|
|
177
|
+
"indexed": false,
|
|
178
|
+
"internalType": "bool",
|
|
179
|
+
"name": "enabled",
|
|
180
|
+
"type": "bool"
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
"name": "SlippageProtectionEnabled",
|
|
184
|
+
"type": "event"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"anonymous": false,
|
|
188
|
+
"inputs": [
|
|
189
|
+
{
|
|
190
|
+
"indexed": true,
|
|
191
|
+
"internalType": "address",
|
|
192
|
+
"name": "stabilityPool",
|
|
193
|
+
"type": "address"
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
"name": "StabilityPoolSet",
|
|
197
|
+
"type": "event"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"anonymous": false,
|
|
201
|
+
"inputs": [
|
|
202
|
+
{
|
|
203
|
+
"indexed": false,
|
|
204
|
+
"internalType": "address",
|
|
205
|
+
"name": "caller",
|
|
206
|
+
"type": "address"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"indexed": false,
|
|
210
|
+
"internalType": "uint256",
|
|
211
|
+
"name": "vaultTokenAmount",
|
|
212
|
+
"type": "uint256"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"indexed": false,
|
|
216
|
+
"internalType": "uint256",
|
|
217
|
+
"name": "swapTokenAmount",
|
|
218
|
+
"type": "uint256"
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
"name": "Swapped",
|
|
222
|
+
"type": "event"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"inputs": [],
|
|
226
|
+
"name": "crvusdToUSDOracle",
|
|
227
|
+
"outputs": [
|
|
228
|
+
{
|
|
229
|
+
"internalType": "address",
|
|
230
|
+
"name": "",
|
|
231
|
+
"type": "address"
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
"stateMutability": "view",
|
|
235
|
+
"type": "function"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"inputs": [],
|
|
239
|
+
"name": "enableSlippageProtection",
|
|
240
|
+
"outputs": [
|
|
241
|
+
{
|
|
242
|
+
"internalType": "bool",
|
|
243
|
+
"name": "",
|
|
244
|
+
"type": "bool"
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
"stateMutability": "view",
|
|
248
|
+
"type": "function"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"inputs": [],
|
|
252
|
+
"name": "iIn",
|
|
253
|
+
"outputs": [
|
|
254
|
+
{
|
|
255
|
+
"internalType": "uint256",
|
|
256
|
+
"name": "",
|
|
257
|
+
"type": "uint256"
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
"stateMutability": "view",
|
|
261
|
+
"type": "function"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"inputs": [],
|
|
265
|
+
"name": "iOut",
|
|
266
|
+
"outputs": [
|
|
267
|
+
{
|
|
268
|
+
"internalType": "uint256",
|
|
269
|
+
"name": "",
|
|
270
|
+
"type": "uint256"
|
|
271
|
+
}
|
|
272
|
+
],
|
|
273
|
+
"stateMutability": "view",
|
|
274
|
+
"type": "function"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"inputs": [],
|
|
278
|
+
"name": "liquidityPool",
|
|
279
|
+
"outputs": [
|
|
280
|
+
{
|
|
281
|
+
"internalType": "contract ILiquidityPool",
|
|
282
|
+
"name": "",
|
|
283
|
+
"type": "address"
|
|
284
|
+
}
|
|
285
|
+
],
|
|
286
|
+
"stateMutability": "view",
|
|
287
|
+
"type": "function"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"inputs": [],
|
|
291
|
+
"name": "owner",
|
|
292
|
+
"outputs": [
|
|
293
|
+
{
|
|
294
|
+
"internalType": "address",
|
|
295
|
+
"name": "",
|
|
296
|
+
"type": "address"
|
|
297
|
+
}
|
|
298
|
+
],
|
|
299
|
+
"stateMutability": "view",
|
|
300
|
+
"type": "function"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"inputs": [],
|
|
304
|
+
"name": "renounceOwnership",
|
|
305
|
+
"outputs": [],
|
|
306
|
+
"stateMutability": "nonpayable",
|
|
307
|
+
"type": "function"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"inputs": [],
|
|
311
|
+
"name": "rwaVault",
|
|
312
|
+
"outputs": [
|
|
313
|
+
{
|
|
314
|
+
"internalType": "address",
|
|
315
|
+
"name": "",
|
|
316
|
+
"type": "address"
|
|
317
|
+
}
|
|
318
|
+
],
|
|
319
|
+
"stateMutability": "view",
|
|
320
|
+
"type": "function"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"inputs": [
|
|
324
|
+
{
|
|
325
|
+
"internalType": "address",
|
|
326
|
+
"name": "_oracle",
|
|
327
|
+
"type": "address"
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
"name": "setCrvusdToUSDOracle",
|
|
331
|
+
"outputs": [],
|
|
332
|
+
"stateMutability": "nonpayable",
|
|
333
|
+
"type": "function"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
"inputs": [
|
|
337
|
+
{
|
|
338
|
+
"internalType": "bool",
|
|
339
|
+
"name": "_enable",
|
|
340
|
+
"type": "bool"
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
"name": "setEnableSlippageProtection",
|
|
344
|
+
"outputs": [],
|
|
345
|
+
"stateMutability": "nonpayable",
|
|
346
|
+
"type": "function"
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"inputs": [
|
|
350
|
+
{
|
|
351
|
+
"internalType": "address",
|
|
352
|
+
"name": "_liquidityPool",
|
|
353
|
+
"type": "address"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"internalType": "uint256",
|
|
357
|
+
"name": "_slippageProtectionBps",
|
|
358
|
+
"type": "uint256"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"internalType": "uint256",
|
|
362
|
+
"name": "_in",
|
|
363
|
+
"type": "uint256"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"internalType": "uint256",
|
|
367
|
+
"name": "_out",
|
|
368
|
+
"type": "uint256"
|
|
369
|
+
}
|
|
370
|
+
],
|
|
371
|
+
"name": "setLiquidityPool",
|
|
372
|
+
"outputs": [],
|
|
373
|
+
"stateMutability": "nonpayable",
|
|
374
|
+
"type": "function"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"inputs": [
|
|
378
|
+
{
|
|
379
|
+
"internalType": "address",
|
|
380
|
+
"name": "_sp",
|
|
381
|
+
"type": "address"
|
|
382
|
+
}
|
|
383
|
+
],
|
|
384
|
+
"name": "setStabilityPool",
|
|
385
|
+
"outputs": [],
|
|
386
|
+
"stateMutability": "nonpayable",
|
|
387
|
+
"type": "function"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"inputs": [],
|
|
391
|
+
"name": "slippageProtectionBps",
|
|
392
|
+
"outputs": [
|
|
393
|
+
{
|
|
394
|
+
"internalType": "uint256",
|
|
395
|
+
"name": "",
|
|
396
|
+
"type": "uint256"
|
|
397
|
+
}
|
|
398
|
+
],
|
|
399
|
+
"stateMutability": "view",
|
|
400
|
+
"type": "function"
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"inputs": [],
|
|
404
|
+
"name": "stabilityPool",
|
|
405
|
+
"outputs": [
|
|
406
|
+
{
|
|
407
|
+
"internalType": "address",
|
|
408
|
+
"name": "",
|
|
409
|
+
"type": "address"
|
|
410
|
+
}
|
|
411
|
+
],
|
|
412
|
+
"stateMutability": "view",
|
|
413
|
+
"type": "function"
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
"inputs": [
|
|
417
|
+
{
|
|
418
|
+
"internalType": "uint256",
|
|
419
|
+
"name": "amount",
|
|
420
|
+
"type": "uint256"
|
|
421
|
+
}
|
|
422
|
+
],
|
|
423
|
+
"name": "swap",
|
|
424
|
+
"outputs": [],
|
|
425
|
+
"stateMutability": "nonpayable",
|
|
426
|
+
"type": "function"
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"inputs": [],
|
|
430
|
+
"name": "swapToken",
|
|
431
|
+
"outputs": [
|
|
432
|
+
{
|
|
433
|
+
"internalType": "address",
|
|
434
|
+
"name": "",
|
|
435
|
+
"type": "address"
|
|
436
|
+
}
|
|
437
|
+
],
|
|
438
|
+
"stateMutability": "view",
|
|
439
|
+
"type": "function"
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
"inputs": [
|
|
443
|
+
{
|
|
444
|
+
"internalType": "address",
|
|
445
|
+
"name": "newOwner",
|
|
446
|
+
"type": "address"
|
|
447
|
+
}
|
|
448
|
+
],
|
|
449
|
+
"name": "transferOwnership",
|
|
450
|
+
"outputs": [],
|
|
451
|
+
"stateMutability": "nonpayable",
|
|
452
|
+
"type": "function"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"inputs": [],
|
|
456
|
+
"name": "vaultToken",
|
|
457
|
+
"outputs": [
|
|
458
|
+
{
|
|
459
|
+
"internalType": "address",
|
|
460
|
+
"name": "",
|
|
461
|
+
"type": "address"
|
|
462
|
+
}
|
|
463
|
+
],
|
|
464
|
+
"stateMutability": "view",
|
|
465
|
+
"type": "function"
|
|
466
|
+
}
|
|
467
|
+
],
|
|
468
|
+
"bytecode": "0x6080346101b057601f610d9038819003918201601f19168301916001600160401b038311848410176101b45780849260a0946040528339810103126101b057610047816101c8565b610053602083016101c8565b91610060604082016101c8565b61006c606083016101c8565b916001600160a01b0390610082906080016101c8565b1693841561019d575f80546001600160a01b031981168717825560405196916001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a3600180556032600355600854936001600160a01b03168015801561018c575b801561017b575b801561016a575b61015b57600480546001600160a01b03199081169290921790556005805482166001600160a01b0393841617905560078054909116928216929092179091556001600160a81b0319909216911617600855610bb390816101dd8239f35b63e6c4247b60e01b5f5260045ffd5b506001600160a01b038416156100fe565b506001600160a01b038316156100f7565b506001600160a01b038216156100f0565b631e4fbdf760e01b5f525f60045260245ffd5b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b03821682036101b05756fe6080806040526004361015610012575f80fd5b5f3560e01c9081630348631f14610a0b57508063048c661d146109e35780633f52905e146109c6578063631ca5b71461099e578063665a11ca14610976578063703bafd51461094e578063715018a61461090a5780638da5cb5b146108e357806394b918de146104db57806398d721e0146104735780639d8f895f146102cd578063a4a1711f146102a5578063b4ac3d6014610239578063dc73e49c14610211578063ec0693b3146101f4578063f2fde38b14610182578063f7a7c4251461010b5763fd1a3c82146100e2575f80fd5b34610107575f36600319011261010757602060ff60085460a01c166040519015158152f35b5f80fd5b3461010757602036600319011261010757610124610a25565b61012c610a91565b6001600160a01b0316801561017357600880546001600160a01b031916821790557f960714fdc34a992b607f3f01894aadf65114184125a184dc486d51c8d4957c005f80a2005b63e6c4247b60e01b5f5260045ffd5b346101075760203660031901126101075761019b610a25565b6101a3610a91565b6001600160a01b031680156101e1575f80546001600160a01b03198116831782556001600160a01b0316905f516020610b3e5f395f51905f529080a3005b631e4fbdf760e01b5f525f60045260245ffd5b34610107575f366003190112610107576020600354604051908152f35b34610107575f366003190112610107576005546040516001600160a01b039091168152602090f35b34610107576020366003190112610107576004358015158091036101075760207f47bbaf5fe6f61efc450523fdb4c263f7c9f703b0640f921b44b8cdd8a63aced191610283610a91565b6008805460ff60a01b191660a083901b60ff60a01b16179055604051908152a1005b34610107575f366003190112610107576008546040516001600160a01b039091168152602090f35b34610107576080366003190112610107576102e6610a25565b60243590604435606435916102f9610a91565b6001600160a01b0316928315610173576127108111610464578282146103b857600280546001600160a01b0319168517905560405163c661065760e01b815260048101839052602081602481885afa90811561043a575f91610445575b506004546001600160a01b039182169116148015906103c7575b6103b8577f68862c19223471c062880bb6077c71de378a4b314792dfb4523c47931e3baa5992606092826003558060095581600a5560405192835260208301526040820152a2005b6363df817160e01b5f5260045ffd5b5060405163c661065760e01b815260048101849052602081602481885afa90811561043a575f9161040b575b506005546001600160a01b0391821691161415610370565b61042d915060203d602011610433575b6104258183610a3b565b810190610a72565b856103f3565b503d61041b565b6040513d5f823e3d90fd5b61045e915060203d602011610433576104258183610a3b565b85610356565b63de85e1e160e01b5f5260045ffd5b346101075760203660031901126101075761048c610a25565b610494610a91565b6001600160a01b0316801561017357600680546001600160a01b031916821790557f51f43ead43c9a90d53ec229fbf48feb76b24efa7a147089ad9ed34ad384a94d35f80a2005b34610107576020366003190112610107576004356002600154146108d45760026001556006546001600160a01b031633036108c65780156108b7576002546001600160a01b031615610173576004546040516323b872dd60e01b60208201523360248201523060448201526064808201849052815261056d916001600160a01b0316610568608483610a3b565b610ae5565b6004805460025460405163095ea7b360e01b81529260209284926001600160a01b039182169284925f9284926105a8928b9216908401610ab7565b03925af190811561043a575f9161087c575b501561086d57600754604051634ca9858360e11b815290602090829060049082906001600160a01b03165afa801561043a5782905f90610837575b6105ff9250610ad2565b600854604051634c6afee560e11b815290916020826004816001600160a01b0387165afa91821561043a575f92610803575b5081156107ef57049081156107e05760a01c60ff16156107d957600354612710039061271082116107c5576127109161066991610ad2565b045b602060018060a01b036002541660a46009545f600a54936040519687958694630532419d60e51b86526004860152602485015288604485015260648401523060848401525af1801561043a57610796575b506005546040516370a0823160e01b8152306004820152906001600160a01b0316602082602481845afa91821561043a575f92610753575b5f516020610b5e5f395f51905f526060858561073b866040519063a9059cbb60e01b60208301526105688261072d863360248401610ab7565b03601f198101845283610a3b565b6040519133835260208301526040820152a160018055005b9150916020823d60201161078e575b8161076f60209383610a3b565b8101031261010757905190915f516020610b5e5f395f51905f526106f4565b3d9150610762565b6020813d6020116107bd575b816107af60209383610a3b565b8101031261010757516106bc565b3d91506107a2565b634e487b7160e01b5f52601160045260245ffd5b505f61066b565b6340892c3360e01b5f5260045ffd5b634e487b7160e01b5f52601260045260245ffd5b9091506020813d60201161082f575b8161081f60209383610a3b565b8101031261010757519084610631565b3d9150610812565b50506020813d602011610865575b8161085260209383610a3b565b8101031261010757816105ff91516105f5565b3d9150610845565b6340b27c2160e11b5f5260045ffd5b90506020813d6020116108af575b8161089760209383610a3b565b810103126101075751801515810361010757826105ba565b3d915061088a565b631f2a200560e01b5f5260045ffd5b6282b42960e81b5f5260045ffd5b633ee5aeb560e01b5f5260045ffd5b34610107575f366003190112610107575f546040516001600160a01b039091168152602090f35b34610107575f36600319011261010757610922610a91565b5f80546001600160a01b0319811682556001600160a01b03165f516020610b3e5f395f51905f528280a3005b34610107575f366003190112610107576004546040516001600160a01b039091168152602090f35b34610107575f366003190112610107576002546040516001600160a01b039091168152602090f35b34610107575f366003190112610107576007546040516001600160a01b039091168152602090f35b34610107575f366003190112610107576020600954604051908152f35b34610107575f366003190112610107576006546040516001600160a01b039091168152602090f35b34610107575f36600319011261010757602090600a548152f35b600435906001600160a01b038216820361010757565b601f909101601f19168101906001600160401b03821190821017610a5e57604052565b634e487b7160e01b5f52604160045260245ffd5b9081602091031261010757516001600160a01b03811681036101075790565b5f546001600160a01b03163303610aa457565b63118cdaa760e01b5f523360045260245ffd5b6001600160a01b039091168152602081019190915260400190565b818102929181159184041417156107c557565b905f602091828151910182855af11561043a575f513d610b3457506001600160a01b0381163b155b610b145750565b635274afe760e01b5f9081526001600160a01b0391909116600452602490fd5b60011415610b0d56fe8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e03a9a9f34f5831e9c8ecb66ab3aa308b2ff31eaca434615f6c9cadc656a9af71ca264697066735822122058f02fa8753f5084833c4bdca3e811cda08eac60b47294ab5d9e179663139ac064736f6c634300081e0033",
|
|
469
|
+
"deployedBytecode": "0x6080806040526004361015610012575f80fd5b5f3560e01c9081630348631f14610a0b57508063048c661d146109e35780633f52905e146109c6578063631ca5b71461099e578063665a11ca14610976578063703bafd51461094e578063715018a61461090a5780638da5cb5b146108e357806394b918de146104db57806398d721e0146104735780639d8f895f146102cd578063a4a1711f146102a5578063b4ac3d6014610239578063dc73e49c14610211578063ec0693b3146101f4578063f2fde38b14610182578063f7a7c4251461010b5763fd1a3c82146100e2575f80fd5b34610107575f36600319011261010757602060ff60085460a01c166040519015158152f35b5f80fd5b3461010757602036600319011261010757610124610a25565b61012c610a91565b6001600160a01b0316801561017357600880546001600160a01b031916821790557f960714fdc34a992b607f3f01894aadf65114184125a184dc486d51c8d4957c005f80a2005b63e6c4247b60e01b5f5260045ffd5b346101075760203660031901126101075761019b610a25565b6101a3610a91565b6001600160a01b031680156101e1575f80546001600160a01b03198116831782556001600160a01b0316905f516020610b3e5f395f51905f529080a3005b631e4fbdf760e01b5f525f60045260245ffd5b34610107575f366003190112610107576020600354604051908152f35b34610107575f366003190112610107576005546040516001600160a01b039091168152602090f35b34610107576020366003190112610107576004358015158091036101075760207f47bbaf5fe6f61efc450523fdb4c263f7c9f703b0640f921b44b8cdd8a63aced191610283610a91565b6008805460ff60a01b191660a083901b60ff60a01b16179055604051908152a1005b34610107575f366003190112610107576008546040516001600160a01b039091168152602090f35b34610107576080366003190112610107576102e6610a25565b60243590604435606435916102f9610a91565b6001600160a01b0316928315610173576127108111610464578282146103b857600280546001600160a01b0319168517905560405163c661065760e01b815260048101839052602081602481885afa90811561043a575f91610445575b506004546001600160a01b039182169116148015906103c7575b6103b8577f68862c19223471c062880bb6077c71de378a4b314792dfb4523c47931e3baa5992606092826003558060095581600a5560405192835260208301526040820152a2005b6363df817160e01b5f5260045ffd5b5060405163c661065760e01b815260048101849052602081602481885afa90811561043a575f9161040b575b506005546001600160a01b0391821691161415610370565b61042d915060203d602011610433575b6104258183610a3b565b810190610a72565b856103f3565b503d61041b565b6040513d5f823e3d90fd5b61045e915060203d602011610433576104258183610a3b565b85610356565b63de85e1e160e01b5f5260045ffd5b346101075760203660031901126101075761048c610a25565b610494610a91565b6001600160a01b0316801561017357600680546001600160a01b031916821790557f51f43ead43c9a90d53ec229fbf48feb76b24efa7a147089ad9ed34ad384a94d35f80a2005b34610107576020366003190112610107576004356002600154146108d45760026001556006546001600160a01b031633036108c65780156108b7576002546001600160a01b031615610173576004546040516323b872dd60e01b60208201523360248201523060448201526064808201849052815261056d916001600160a01b0316610568608483610a3b565b610ae5565b6004805460025460405163095ea7b360e01b81529260209284926001600160a01b039182169284925f9284926105a8928b9216908401610ab7565b03925af190811561043a575f9161087c575b501561086d57600754604051634ca9858360e11b815290602090829060049082906001600160a01b03165afa801561043a5782905f90610837575b6105ff9250610ad2565b600854604051634c6afee560e11b815290916020826004816001600160a01b0387165afa91821561043a575f92610803575b5081156107ef57049081156107e05760a01c60ff16156107d957600354612710039061271082116107c5576127109161066991610ad2565b045b602060018060a01b036002541660a46009545f600a54936040519687958694630532419d60e51b86526004860152602485015288604485015260648401523060848401525af1801561043a57610796575b506005546040516370a0823160e01b8152306004820152906001600160a01b0316602082602481845afa91821561043a575f92610753575b5f516020610b5e5f395f51905f526060858561073b866040519063a9059cbb60e01b60208301526105688261072d863360248401610ab7565b03601f198101845283610a3b565b6040519133835260208301526040820152a160018055005b9150916020823d60201161078e575b8161076f60209383610a3b565b8101031261010757905190915f516020610b5e5f395f51905f526106f4565b3d9150610762565b6020813d6020116107bd575b816107af60209383610a3b565b8101031261010757516106bc565b3d91506107a2565b634e487b7160e01b5f52601160045260245ffd5b505f61066b565b6340892c3360e01b5f5260045ffd5b634e487b7160e01b5f52601260045260245ffd5b9091506020813d60201161082f575b8161081f60209383610a3b565b8101031261010757519084610631565b3d9150610812565b50506020813d602011610865575b8161085260209383610a3b565b8101031261010757816105ff91516105f5565b3d9150610845565b6340b27c2160e11b5f5260045ffd5b90506020813d6020116108af575b8161089760209383610a3b565b810103126101075751801515810361010757826105ba565b3d915061088a565b631f2a200560e01b5f5260045ffd5b6282b42960e81b5f5260045ffd5b633ee5aeb560e01b5f5260045ffd5b34610107575f366003190112610107575f546040516001600160a01b039091168152602090f35b34610107575f36600319011261010757610922610a91565b5f80546001600160a01b0319811682556001600160a01b03165f516020610b3e5f395f51905f528280a3005b34610107575f366003190112610107576004546040516001600160a01b039091168152602090f35b34610107575f366003190112610107576002546040516001600160a01b039091168152602090f35b34610107575f366003190112610107576007546040516001600160a01b039091168152602090f35b34610107575f366003190112610107576020600954604051908152f35b34610107575f366003190112610107576006546040516001600160a01b039091168152602090f35b34610107575f36600319011261010757602090600a548152f35b600435906001600160a01b038216820361010757565b601f909101601f19168101906001600160401b03821190821017610a5e57604052565b634e487b7160e01b5f52604160045260245ffd5b9081602091031261010757516001600160a01b03811681036101075790565b5f546001600160a01b03163303610aa457565b63118cdaa760e01b5f523360045260245ffd5b6001600160a01b039091168152602081019190915260400190565b818102929181159184041417156107c557565b905f602091828151910182855af11561043a575f513d610b3457506001600160a01b0381163b155b610b145750565b635274afe760e01b5f9081526001600160a01b0391909116600452602490fd5b60011415610b0d56fe8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e03a9a9f34f5831e9c8ecb66ab3aa308b2ff31eaca434615f6c9cadc656a9af71ca264697066735822122058f02fa8753f5084833c4bdca3e811cda08eac60b47294ab5d9e179663139ac064736f6c634300081e0033",
|
|
470
|
+
"linkReferences": {},
|
|
471
|
+
"deployedLinkReferences": {}
|
|
472
|
+
}
|
|
@@ -8,33 +8,33 @@ const ethers_1 = require("ethers");
|
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
9
|
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
10
10
|
const amount_1 = require("../../../utils/amount");
|
|
11
|
+
const resolveTokenInfo_1 = require("../../resolveTokenInfo");
|
|
11
12
|
const _tokens_1 = require("./_tokens");
|
|
12
13
|
const RAW_BALANCE_OF_ABI = ["function rawBalanceOf(address account) view returns (uint256)"];
|
|
13
14
|
const tokenState = async (chainId, token, user, spender, provider) => {
|
|
14
15
|
const contract = new ethers_1.ethers.Contract(token, _tokens_1.ERC20_ABI, provider);
|
|
15
|
-
const [
|
|
16
|
-
contract.balanceOf(user),
|
|
16
|
+
const [allowance, { decimals, symbol }] = await Promise.all([
|
|
17
17
|
contract.allowance(user, spender),
|
|
18
|
+
(0, resolveTokenInfo_1.resolveTokenInfo)(chainId, token, provider),
|
|
18
19
|
]);
|
|
19
|
-
const balanceAmount = (0, amount_1.toTokenAmount)(chainId, token, balance);
|
|
20
20
|
return {
|
|
21
21
|
address: ethers_1.ethers.getAddress(token),
|
|
22
|
-
symbol
|
|
23
|
-
decimals
|
|
24
|
-
|
|
25
|
-
allowance: (0, amount_1.toTokenAmount)(chainId, token, allowance),
|
|
22
|
+
symbol,
|
|
23
|
+
decimals,
|
|
24
|
+
allowance: (0, amount_1.toAmount)(allowance, decimals, symbol),
|
|
26
25
|
spender: ethers_1.ethers.getAddress(spender),
|
|
27
26
|
};
|
|
28
27
|
};
|
|
29
28
|
/**
|
|
30
|
-
* What a wallet needs to stake in, wrap for, or unstake from a gauge: its stake, its
|
|
31
|
-
*
|
|
29
|
+
* What a wallet needs to stake in, wrap for, or unstake from a gauge: its stake, its allowance of the staking token to the
|
|
30
|
+
* gauge, and for a wrapped gauge its allowance of the underlying to the wrapper. Read the wallet's token balances with
|
|
31
|
+
* `wallet.assets.getBalance`.
|
|
32
32
|
*
|
|
33
33
|
* @param chainId - The chain/network to use.
|
|
34
34
|
* @param gaugeAddressOrId - Address of the gauge contract or its config ID.
|
|
35
35
|
* @param user - The wallet.
|
|
36
36
|
* @param provider - Optional ethers.js Provider instance.
|
|
37
|
-
* @returns The wallet's gauge state. Every amount carries its own token's
|
|
37
|
+
* @returns The wallet's gauge state. Every amount carries its own token's decimals and symbol.
|
|
38
38
|
*/
|
|
39
39
|
const getUserGaugeState = async (chainId, gaugeAddressOrId, user, provider) => {
|
|
40
40
|
if (!provider) {
|
|
@@ -47,6 +47,6 @@ const getUserGaugeState = async (chainId, gaugeAddressOrId, user, provider) => {
|
|
|
47
47
|
tokenState(chainId, stakingToken, user, gauge, provider),
|
|
48
48
|
underlying ? tokenState(chainId, underlying, user, stakingToken, provider) : Promise.resolve(null),
|
|
49
49
|
]);
|
|
50
|
-
return { gauge, staked: (0, amount_1.
|
|
50
|
+
return { gauge, staked: (0, amount_1.toAmount)(staked, staking.decimals, staking.symbol), stakingToken: staking, underlying: wrappable };
|
|
51
51
|
};
|
|
52
52
|
exports.getUserGaugeState = getUserGaugeState;
|
|
@@ -65,18 +65,12 @@ async function getVaultInfo(chainId, vaultKeyOrAddress, userAddress, provider) {
|
|
|
65
65
|
let user = null;
|
|
66
66
|
if (userAddress) {
|
|
67
67
|
const baseAssetContract = (0, _helpers_1.getTokenReaderContract)(baseAsset, provider);
|
|
68
|
-
const [
|
|
69
|
-
vault.balanceOf(userAddress),
|
|
70
|
-
savingsTokenContract.balanceOf(userAddress),
|
|
71
|
-
baseAssetContract.balanceOf(userAddress),
|
|
68
|
+
const [redeemRequest, savingsTokenAllowance, baseAssetAllowance] = await Promise.all([
|
|
72
69
|
vault.redeemRequests(userAddress),
|
|
73
70
|
savingsTokenContract.allowance(userAddress, contractAddress),
|
|
74
71
|
baseAssetContract.allowance(userAddress, contractAddress),
|
|
75
72
|
]);
|
|
76
73
|
user = {
|
|
77
|
-
shareBalance: (0, amount_1.toAmount)(shareBalance, Number(vaultDecimals), entry.id),
|
|
78
|
-
savingsTokenBalance: (0, amount_1.toTokenAmount)(chainId, "susds", savingsTokenBalance),
|
|
79
|
-
baseAssetBalance: (0, amount_1.toTokenAmount)(chainId, "pmusd", baseAssetBalance),
|
|
80
74
|
redeemRequest: {
|
|
81
75
|
shares: (0, amount_1.toAmount)(redeemRequest[0], Number(vaultDecimals), entry.id),
|
|
82
76
|
exitTime: Number(redeemRequest[1]),
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveTokenInfo = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../configs/chains"));
|
|
9
|
+
const amount_1 = require("../utils/amount");
|
|
10
|
+
const rpcError_1 = require("../utils/rpcError");
|
|
11
|
+
const ERC20_METADATA_ABI = ["function symbol() view returns (string)", "function decimals() view returns (uint8)"];
|
|
12
|
+
/** The address Curve pools (and others) list native ETH under. */
|
|
13
|
+
const NATIVE_ETH_PLACEHOLDER = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
14
|
+
/** Tokens read from the chain, keyed `chainId:address`. Holds the request, so concurrent callers share it. */
|
|
15
|
+
const resolved = new Map();
|
|
16
|
+
/**
|
|
17
|
+
* A token's decimals and symbol for any address: the chain config registry first, then the token itself for an address
|
|
18
|
+
* the registry does not list. An on-chain read happens once per chain and token; a failed read is not remembered, so
|
|
19
|
+
* the next call tries again.
|
|
20
|
+
*
|
|
21
|
+
* Use this wherever a method takes a token address it cannot know in advance. Methods that take an asset key keep
|
|
22
|
+
* using `toTokenAmount`, which reads only the registry.
|
|
23
|
+
*
|
|
24
|
+
* @param chainId The chain id.
|
|
25
|
+
* @param idOrAddress An asset key from the registry, or a token contract address, any casing.
|
|
26
|
+
* @param provider Optional ethers.js Provider instance.
|
|
27
|
+
* @returns The token's decimals, and its symbol when it has one: a token without a readable `symbol()` gets none.
|
|
28
|
+
* @throws If an asset key is not in the registry, or an unlisted token has no readable `decimals()`.
|
|
29
|
+
*/
|
|
30
|
+
const resolveTokenInfo = (chainId, idOrAddress, provider) => {
|
|
31
|
+
const known = (0, amount_1.getTokenInfo)(chainId, idOrAddress);
|
|
32
|
+
if (known)
|
|
33
|
+
return Promise.resolve(known);
|
|
34
|
+
if (!ethers_1.ethers.isAddress(idOrAddress)) {
|
|
35
|
+
return Promise.reject(new Error(`Token ${idOrAddress} is not in the asset registry of chain ${chainId}`));
|
|
36
|
+
}
|
|
37
|
+
const address = idOrAddress.toLowerCase();
|
|
38
|
+
if (address === NATIVE_ETH_PLACEHOLDER)
|
|
39
|
+
return Promise.resolve({ decimals: amount_1.WAD_DECIMALS, symbol: "ETH" });
|
|
40
|
+
const key = `${chainId}:${address}`;
|
|
41
|
+
let info = resolved.get(key);
|
|
42
|
+
if (!info) {
|
|
43
|
+
info = readTokenInfo(chainId, address, provider);
|
|
44
|
+
resolved.set(key, info);
|
|
45
|
+
info.catch(() => resolved.delete(key));
|
|
46
|
+
}
|
|
47
|
+
return info;
|
|
48
|
+
};
|
|
49
|
+
exports.resolveTokenInfo = resolveTokenInfo;
|
|
50
|
+
const readTokenInfo = async (chainId, address, provider) => {
|
|
51
|
+
if (!provider) {
|
|
52
|
+
provider = new ethers_1.ethers.JsonRpcProvider(chains_1.default[chainId].rpcs[0]);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const token = new ethers_1.ethers.Contract(address, ERC20_METADATA_ABI, provider);
|
|
56
|
+
const [decimals, symbol] = await Promise.all([
|
|
57
|
+
token.decimals(),
|
|
58
|
+
token.symbol().catch(() => undefined),
|
|
59
|
+
]);
|
|
60
|
+
return symbol === undefined ? { decimals: Number(decimals) } : { decimals: Number(decimals), symbol };
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
throw (0, rpcError_1.toRpcError)("contracts.resolveTokenInfo", error, { chainId, address });
|
|
64
|
+
}
|
|
65
|
+
};
|