@defisaver/positions-sdk 0.0.20 → 0.0.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/README.md +63 -0
- package/cjs/aaveV2/index.js +9 -4
- package/cjs/aaveV3/index.js +9 -4
- package/cjs/compoundV2/index.d.ts +1 -0
- package/cjs/compoundV2/index.js +15 -8
- package/cjs/config/contracts.d.ts +373 -201
- package/cjs/config/contracts.js +22 -0
- package/cjs/helpers/aaveHelpers/index.js +0 -5
- package/cjs/helpers/compoundHelpers/index.js +2 -2
- package/cjs/markets/compound/index.d.ts +2 -0
- package/cjs/markets/compound/index.js +60 -13
- package/cjs/markets/compound/marketsAssets.d.ts +7 -1
- package/cjs/markets/compound/marketsAssets.js +12 -2
- package/cjs/morphoAaveV2/index.js +4 -3
- package/cjs/morphoAaveV3/index.js +9 -4
- package/cjs/spark/index.js +9 -4
- package/cjs/types/aave.d.ts +0 -5
- package/cjs/types/compound.d.ts +6 -4
- package/cjs/types/compound.js +1 -0
- package/cjs/types/contracts/generated/CUSDCev3.d.ts +441 -0
- package/cjs/types/contracts/generated/CUSDCev3.js +5 -0
- package/cjs/types/contracts/generated/CompV3USDCBulkerArb.d.ts +41 -0
- package/cjs/types/contracts/generated/CompV3USDCBulkerArb.js +5 -0
- package/cjs/types/contracts/generated/index.d.ts +2 -0
- package/esm/aaveV2/index.js +11 -6
- package/esm/aaveV3/index.js +11 -6
- package/esm/compoundV2/index.d.ts +1 -0
- package/esm/compoundV2/index.js +13 -7
- package/esm/config/contracts.d.ts +373 -201
- package/esm/config/contracts.js +22 -0
- package/esm/helpers/aaveHelpers/index.js +0 -5
- package/esm/helpers/compoundHelpers/index.js +2 -2
- package/esm/markets/compound/index.d.ts +2 -0
- package/esm/markets/compound/index.js +59 -13
- package/esm/markets/compound/marketsAssets.d.ts +7 -1
- package/esm/markets/compound/marketsAssets.js +11 -1
- package/esm/morphoAaveV2/index.js +4 -3
- package/esm/morphoAaveV3/index.js +9 -4
- package/esm/spark/index.js +11 -6
- package/esm/types/aave.d.ts +0 -5
- package/esm/types/compound.d.ts +6 -4
- package/esm/types/compound.js +1 -0
- package/esm/types/contracts/generated/CUSDCev3.d.ts +441 -0
- package/esm/types/contracts/generated/CUSDCev3.js +4 -0
- package/esm/types/contracts/generated/CompV3USDCBulkerArb.d.ts +41 -0
- package/esm/types/contracts/generated/CompV3USDCBulkerArb.js +4 -0
- package/esm/types/contracts/generated/index.d.ts +2 -0
- package/package.json +40 -40
- package/src/aaveV2/index.ts +226 -220
- package/src/aaveV3/index.ts +561 -554
- package/src/assets/index.ts +60 -60
- package/src/chickenBonds/index.ts +123 -123
- package/src/compoundV2/index.ts +219 -206
- package/src/compoundV3/index.ts +275 -275
- package/src/config/contracts.js +673 -651
- package/src/constants/index.ts +3 -3
- package/src/contracts.ts +100 -100
- package/src/curveUsd/index.ts +228 -228
- package/src/exchange/index.ts +17 -17
- package/src/helpers/aaveHelpers/index.ts +134 -141
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +181 -181
- package/src/helpers/curveUsdHelpers/index.ts +32 -32
- package/src/helpers/index.ts +5 -5
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/sparkHelpers/index.ts +106 -106
- package/src/index.ts +40 -40
- package/src/liquity/index.ts +116 -116
- package/src/maker/index.ts +101 -101
- package/src/markets/aave/index.ts +80 -80
- package/src/markets/aave/marketAssets.ts +32 -32
- package/src/markets/compound/index.ts +141 -85
- package/src/markets/compound/marketsAssets.ts +46 -35
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/index.ts +3 -3
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +9 -9
- package/src/moneymarket/moneymarketCommonService.ts +75 -75
- package/src/morpho/markets.ts +39 -39
- package/src/morphoAaveV2/index.ts +255 -254
- package/src/morphoAaveV3/index.ts +619 -614
- package/src/multicall/index.ts +22 -22
- package/src/services/dsrService.ts +15 -15
- package/src/services/priceService.ts +21 -21
- package/src/services/utils.ts +34 -34
- package/src/spark/index.ts +421 -413
- package/src/staking/staking.ts +167 -167
- package/src/types/aave.ts +256 -261
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +83 -83
- package/src/types/compound.ts +128 -122
- package/src/types/contracts/generated/CUSDCev3.ts +685 -0
- package/src/types/contracts/generated/CompV3USDCBulkerArb.ts +85 -0
- package/src/types/contracts/generated/index.ts +2 -0
- package/src/types/curveUsd.ts +112 -112
- package/src/types/index.ts +6 -6
- package/src/types/liquity.ts +30 -30
- package/src/types/maker.ts +50 -50
- package/src/types/spark.ts +106 -106
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type BN from "bn.js";
|
|
3
|
+
import type { ContractOptions } from "web3-eth-contract";
|
|
4
|
+
import type { EventLog } from "web3-core";
|
|
5
|
+
import type { EventEmitter } from "events";
|
|
6
|
+
import type { Callback, NonPayableTransactionObject, BlockType, ContractEventLog, BaseContract } from "./types";
|
|
7
|
+
export interface EventOptions {
|
|
8
|
+
filter?: object;
|
|
9
|
+
fromBlock?: BlockType;
|
|
10
|
+
topics?: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare namespace CometConfiguration {
|
|
13
|
+
type AssetConfigStruct = [
|
|
14
|
+
string,
|
|
15
|
+
string,
|
|
16
|
+
number | string | BN,
|
|
17
|
+
number | string | BN,
|
|
18
|
+
number | string | BN,
|
|
19
|
+
number | string | BN,
|
|
20
|
+
number | string | BN
|
|
21
|
+
] | {
|
|
22
|
+
asset: string;
|
|
23
|
+
priceFeed: string;
|
|
24
|
+
decimals: number | string | BN;
|
|
25
|
+
borrowCollateralFactor: number | string | BN;
|
|
26
|
+
liquidateCollateralFactor: number | string | BN;
|
|
27
|
+
liquidationFactor: number | string | BN;
|
|
28
|
+
supplyCap: number | string | BN;
|
|
29
|
+
};
|
|
30
|
+
type AssetConfigStructOutputArray = [
|
|
31
|
+
string,
|
|
32
|
+
string,
|
|
33
|
+
string,
|
|
34
|
+
string,
|
|
35
|
+
string,
|
|
36
|
+
string,
|
|
37
|
+
string
|
|
38
|
+
];
|
|
39
|
+
type AssetConfigStructOutputStruct = {
|
|
40
|
+
asset: string;
|
|
41
|
+
priceFeed: string;
|
|
42
|
+
decimals: string;
|
|
43
|
+
borrowCollateralFactor: string;
|
|
44
|
+
liquidateCollateralFactor: string;
|
|
45
|
+
liquidationFactor: string;
|
|
46
|
+
supplyCap: string;
|
|
47
|
+
};
|
|
48
|
+
type AssetConfigStructOutput = AssetConfigStructOutputArray & AssetConfigStructOutputStruct;
|
|
49
|
+
type ConfigurationStruct = [
|
|
50
|
+
string,
|
|
51
|
+
string,
|
|
52
|
+
string,
|
|
53
|
+
string,
|
|
54
|
+
string,
|
|
55
|
+
number | string | BN,
|
|
56
|
+
number | string | BN,
|
|
57
|
+
number | string | BN,
|
|
58
|
+
number | string | BN,
|
|
59
|
+
number | string | BN,
|
|
60
|
+
number | string | BN,
|
|
61
|
+
number | string | BN,
|
|
62
|
+
number | string | BN,
|
|
63
|
+
number | string | BN,
|
|
64
|
+
number | string | BN,
|
|
65
|
+
number | string | BN,
|
|
66
|
+
number | string | BN,
|
|
67
|
+
number | string | BN,
|
|
68
|
+
number | string | BN,
|
|
69
|
+
number | string | BN,
|
|
70
|
+
CometConfiguration.AssetConfigStruct[]
|
|
71
|
+
] | {
|
|
72
|
+
governor: string;
|
|
73
|
+
pauseGuardian: string;
|
|
74
|
+
baseToken: string;
|
|
75
|
+
baseTokenPriceFeed: string;
|
|
76
|
+
extensionDelegate: string;
|
|
77
|
+
supplyKink: number | string | BN;
|
|
78
|
+
supplyPerYearInterestRateSlopeLow: number | string | BN;
|
|
79
|
+
supplyPerYearInterestRateSlopeHigh: number | string | BN;
|
|
80
|
+
supplyPerYearInterestRateBase: number | string | BN;
|
|
81
|
+
borrowKink: number | string | BN;
|
|
82
|
+
borrowPerYearInterestRateSlopeLow: number | string | BN;
|
|
83
|
+
borrowPerYearInterestRateSlopeHigh: number | string | BN;
|
|
84
|
+
borrowPerYearInterestRateBase: number | string | BN;
|
|
85
|
+
storeFrontPriceFactor: number | string | BN;
|
|
86
|
+
trackingIndexScale: number | string | BN;
|
|
87
|
+
baseTrackingSupplySpeed: number | string | BN;
|
|
88
|
+
baseTrackingBorrowSpeed: number | string | BN;
|
|
89
|
+
baseMinForRewards: number | string | BN;
|
|
90
|
+
baseBorrowMin: number | string | BN;
|
|
91
|
+
targetReserves: number | string | BN;
|
|
92
|
+
assetConfigs: CometConfiguration.AssetConfigStruct[];
|
|
93
|
+
};
|
|
94
|
+
type ConfigurationStructOutputArray = [
|
|
95
|
+
string,
|
|
96
|
+
string,
|
|
97
|
+
string,
|
|
98
|
+
string,
|
|
99
|
+
string,
|
|
100
|
+
string,
|
|
101
|
+
string,
|
|
102
|
+
string,
|
|
103
|
+
string,
|
|
104
|
+
string,
|
|
105
|
+
string,
|
|
106
|
+
string,
|
|
107
|
+
string,
|
|
108
|
+
string,
|
|
109
|
+
string,
|
|
110
|
+
string,
|
|
111
|
+
string,
|
|
112
|
+
string,
|
|
113
|
+
string,
|
|
114
|
+
string,
|
|
115
|
+
CometConfiguration.AssetConfigStructOutput[]
|
|
116
|
+
];
|
|
117
|
+
type ConfigurationStructOutputStruct = {
|
|
118
|
+
governor: string;
|
|
119
|
+
pauseGuardian: string;
|
|
120
|
+
baseToken: string;
|
|
121
|
+
baseTokenPriceFeed: string;
|
|
122
|
+
extensionDelegate: string;
|
|
123
|
+
supplyKink: string;
|
|
124
|
+
supplyPerYearInterestRateSlopeLow: string;
|
|
125
|
+
supplyPerYearInterestRateSlopeHigh: string;
|
|
126
|
+
supplyPerYearInterestRateBase: string;
|
|
127
|
+
borrowKink: string;
|
|
128
|
+
borrowPerYearInterestRateSlopeLow: string;
|
|
129
|
+
borrowPerYearInterestRateSlopeHigh: string;
|
|
130
|
+
borrowPerYearInterestRateBase: string;
|
|
131
|
+
storeFrontPriceFactor: string;
|
|
132
|
+
trackingIndexScale: string;
|
|
133
|
+
baseTrackingSupplySpeed: string;
|
|
134
|
+
baseTrackingBorrowSpeed: string;
|
|
135
|
+
baseMinForRewards: string;
|
|
136
|
+
baseBorrowMin: string;
|
|
137
|
+
targetReserves: string;
|
|
138
|
+
assetConfigs: CometConfiguration.AssetConfigStructOutput[];
|
|
139
|
+
};
|
|
140
|
+
type ConfigurationStructOutput = ConfigurationStructOutputArray & ConfigurationStructOutputStruct;
|
|
141
|
+
}
|
|
142
|
+
export declare namespace CometCore {
|
|
143
|
+
type AssetInfoStruct = [
|
|
144
|
+
number | string | BN,
|
|
145
|
+
string,
|
|
146
|
+
string,
|
|
147
|
+
number | string | BN,
|
|
148
|
+
number | string | BN,
|
|
149
|
+
number | string | BN,
|
|
150
|
+
number | string | BN,
|
|
151
|
+
number | string | BN
|
|
152
|
+
] | {
|
|
153
|
+
offset: number | string | BN;
|
|
154
|
+
asset: string;
|
|
155
|
+
priceFeed: string;
|
|
156
|
+
scale: number | string | BN;
|
|
157
|
+
borrowCollateralFactor: number | string | BN;
|
|
158
|
+
liquidateCollateralFactor: number | string | BN;
|
|
159
|
+
liquidationFactor: number | string | BN;
|
|
160
|
+
supplyCap: number | string | BN;
|
|
161
|
+
};
|
|
162
|
+
type AssetInfoStructOutputArray = [
|
|
163
|
+
string,
|
|
164
|
+
string,
|
|
165
|
+
string,
|
|
166
|
+
string,
|
|
167
|
+
string,
|
|
168
|
+
string,
|
|
169
|
+
string,
|
|
170
|
+
string
|
|
171
|
+
];
|
|
172
|
+
type AssetInfoStructOutputStruct = {
|
|
173
|
+
offset: string;
|
|
174
|
+
asset: string;
|
|
175
|
+
priceFeed: string;
|
|
176
|
+
scale: string;
|
|
177
|
+
borrowCollateralFactor: string;
|
|
178
|
+
liquidateCollateralFactor: string;
|
|
179
|
+
liquidationFactor: string;
|
|
180
|
+
supplyCap: string;
|
|
181
|
+
};
|
|
182
|
+
type AssetInfoStructOutput = AssetInfoStructOutputArray & AssetInfoStructOutputStruct;
|
|
183
|
+
}
|
|
184
|
+
export type AbsorbCollateral = ContractEventLog<{
|
|
185
|
+
absorber: string;
|
|
186
|
+
borrower: string;
|
|
187
|
+
asset: string;
|
|
188
|
+
collateralAbsorbed: string;
|
|
189
|
+
usdValue: string;
|
|
190
|
+
0: string;
|
|
191
|
+
1: string;
|
|
192
|
+
2: string;
|
|
193
|
+
3: string;
|
|
194
|
+
4: string;
|
|
195
|
+
}>;
|
|
196
|
+
export type AbsorbDebt = ContractEventLog<{
|
|
197
|
+
absorber: string;
|
|
198
|
+
borrower: string;
|
|
199
|
+
basePaidOut: string;
|
|
200
|
+
usdValue: string;
|
|
201
|
+
0: string;
|
|
202
|
+
1: string;
|
|
203
|
+
2: string;
|
|
204
|
+
3: string;
|
|
205
|
+
}>;
|
|
206
|
+
export type BuyCollateral = ContractEventLog<{
|
|
207
|
+
buyer: string;
|
|
208
|
+
asset: string;
|
|
209
|
+
baseAmount: string;
|
|
210
|
+
collateralAmount: string;
|
|
211
|
+
0: string;
|
|
212
|
+
1: string;
|
|
213
|
+
2: string;
|
|
214
|
+
3: string;
|
|
215
|
+
}>;
|
|
216
|
+
export type PauseAction = ContractEventLog<{
|
|
217
|
+
supplyPaused: boolean;
|
|
218
|
+
transferPaused: boolean;
|
|
219
|
+
withdrawPaused: boolean;
|
|
220
|
+
absorbPaused: boolean;
|
|
221
|
+
buyPaused: boolean;
|
|
222
|
+
0: boolean;
|
|
223
|
+
1: boolean;
|
|
224
|
+
2: boolean;
|
|
225
|
+
3: boolean;
|
|
226
|
+
4: boolean;
|
|
227
|
+
}>;
|
|
228
|
+
export type Supply = ContractEventLog<{
|
|
229
|
+
from: string;
|
|
230
|
+
dst: string;
|
|
231
|
+
amount: string;
|
|
232
|
+
0: string;
|
|
233
|
+
1: string;
|
|
234
|
+
2: string;
|
|
235
|
+
}>;
|
|
236
|
+
export type SupplyCollateral = ContractEventLog<{
|
|
237
|
+
from: string;
|
|
238
|
+
dst: string;
|
|
239
|
+
asset: string;
|
|
240
|
+
amount: string;
|
|
241
|
+
0: string;
|
|
242
|
+
1: string;
|
|
243
|
+
2: string;
|
|
244
|
+
3: string;
|
|
245
|
+
}>;
|
|
246
|
+
export type Transfer = ContractEventLog<{
|
|
247
|
+
from: string;
|
|
248
|
+
to: string;
|
|
249
|
+
amount: string;
|
|
250
|
+
0: string;
|
|
251
|
+
1: string;
|
|
252
|
+
2: string;
|
|
253
|
+
}>;
|
|
254
|
+
export type TransferCollateral = ContractEventLog<{
|
|
255
|
+
from: string;
|
|
256
|
+
to: string;
|
|
257
|
+
asset: string;
|
|
258
|
+
amount: string;
|
|
259
|
+
0: string;
|
|
260
|
+
1: string;
|
|
261
|
+
2: string;
|
|
262
|
+
3: string;
|
|
263
|
+
}>;
|
|
264
|
+
export type Withdraw = ContractEventLog<{
|
|
265
|
+
src: string;
|
|
266
|
+
to: string;
|
|
267
|
+
amount: string;
|
|
268
|
+
0: string;
|
|
269
|
+
1: string;
|
|
270
|
+
2: string;
|
|
271
|
+
}>;
|
|
272
|
+
export type WithdrawCollateral = ContractEventLog<{
|
|
273
|
+
src: string;
|
|
274
|
+
to: string;
|
|
275
|
+
asset: string;
|
|
276
|
+
amount: string;
|
|
277
|
+
0: string;
|
|
278
|
+
1: string;
|
|
279
|
+
2: string;
|
|
280
|
+
3: string;
|
|
281
|
+
}>;
|
|
282
|
+
export type WithdrawReserves = ContractEventLog<{
|
|
283
|
+
to: string;
|
|
284
|
+
amount: string;
|
|
285
|
+
0: string;
|
|
286
|
+
1: string;
|
|
287
|
+
}>;
|
|
288
|
+
export interface CUSDCev3 extends BaseContract {
|
|
289
|
+
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): CUSDCev3;
|
|
290
|
+
clone(): CUSDCev3;
|
|
291
|
+
methods: {
|
|
292
|
+
absorb(absorber: string, accounts: string[]): NonPayableTransactionObject<void>;
|
|
293
|
+
accrueAccount(account: string): NonPayableTransactionObject<void>;
|
|
294
|
+
approveThis(manager: string, asset: string, amount: number | string | BN): NonPayableTransactionObject<void>;
|
|
295
|
+
balanceOf(account: string): NonPayableTransactionObject<string>;
|
|
296
|
+
baseBorrowMin(): NonPayableTransactionObject<string>;
|
|
297
|
+
baseMinForRewards(): NonPayableTransactionObject<string>;
|
|
298
|
+
baseScale(): NonPayableTransactionObject<string>;
|
|
299
|
+
baseToken(): NonPayableTransactionObject<string>;
|
|
300
|
+
baseTokenPriceFeed(): NonPayableTransactionObject<string>;
|
|
301
|
+
baseTrackingBorrowSpeed(): NonPayableTransactionObject<string>;
|
|
302
|
+
baseTrackingSupplySpeed(): NonPayableTransactionObject<string>;
|
|
303
|
+
borrowBalanceOf(account: string): NonPayableTransactionObject<string>;
|
|
304
|
+
borrowKink(): NonPayableTransactionObject<string>;
|
|
305
|
+
borrowPerSecondInterestRateBase(): NonPayableTransactionObject<string>;
|
|
306
|
+
borrowPerSecondInterestRateSlopeHigh(): NonPayableTransactionObject<string>;
|
|
307
|
+
borrowPerSecondInterestRateSlopeLow(): NonPayableTransactionObject<string>;
|
|
308
|
+
buyCollateral(asset: string, minAmount: number | string | BN, baseAmount: number | string | BN, recipient: string): NonPayableTransactionObject<void>;
|
|
309
|
+
decimals(): NonPayableTransactionObject<string>;
|
|
310
|
+
extensionDelegate(): NonPayableTransactionObject<string>;
|
|
311
|
+
getAssetInfo(i: number | string | BN): NonPayableTransactionObject<CometCore.AssetInfoStructOutput>;
|
|
312
|
+
getAssetInfoByAddress(asset: string): NonPayableTransactionObject<CometCore.AssetInfoStructOutput>;
|
|
313
|
+
getBorrowRate(utilization: number | string | BN): NonPayableTransactionObject<string>;
|
|
314
|
+
getCollateralReserves(asset: string): NonPayableTransactionObject<string>;
|
|
315
|
+
getPrice(priceFeed: string): NonPayableTransactionObject<string>;
|
|
316
|
+
getReserves(): NonPayableTransactionObject<string>;
|
|
317
|
+
getSupplyRate(utilization: number | string | BN): NonPayableTransactionObject<string>;
|
|
318
|
+
getUtilization(): NonPayableTransactionObject<string>;
|
|
319
|
+
governor(): NonPayableTransactionObject<string>;
|
|
320
|
+
hasPermission(owner: string, manager: string): NonPayableTransactionObject<boolean>;
|
|
321
|
+
initializeStorage(): NonPayableTransactionObject<void>;
|
|
322
|
+
isAbsorbPaused(): NonPayableTransactionObject<boolean>;
|
|
323
|
+
isAllowed(arg0: string, arg1: string): NonPayableTransactionObject<boolean>;
|
|
324
|
+
isBorrowCollateralized(account: string): NonPayableTransactionObject<boolean>;
|
|
325
|
+
isBuyPaused(): NonPayableTransactionObject<boolean>;
|
|
326
|
+
isLiquidatable(account: string): NonPayableTransactionObject<boolean>;
|
|
327
|
+
isSupplyPaused(): NonPayableTransactionObject<boolean>;
|
|
328
|
+
isTransferPaused(): NonPayableTransactionObject<boolean>;
|
|
329
|
+
isWithdrawPaused(): NonPayableTransactionObject<boolean>;
|
|
330
|
+
liquidatorPoints(arg0: string): NonPayableTransactionObject<[
|
|
331
|
+
string,
|
|
332
|
+
string,
|
|
333
|
+
string,
|
|
334
|
+
string
|
|
335
|
+
] & {
|
|
336
|
+
numAbsorbs: string;
|
|
337
|
+
numAbsorbed: string;
|
|
338
|
+
approxSpend: string;
|
|
339
|
+
_reserved: string;
|
|
340
|
+
}>;
|
|
341
|
+
numAssets(): NonPayableTransactionObject<string>;
|
|
342
|
+
pause(supplyPaused: boolean, transferPaused: boolean, withdrawPaused: boolean, absorbPaused: boolean, buyPaused: boolean): NonPayableTransactionObject<void>;
|
|
343
|
+
pauseGuardian(): NonPayableTransactionObject<string>;
|
|
344
|
+
quoteCollateral(asset: string, baseAmount: number | string | BN): NonPayableTransactionObject<string>;
|
|
345
|
+
storeFrontPriceFactor(): NonPayableTransactionObject<string>;
|
|
346
|
+
supply(asset: string, amount: number | string | BN): NonPayableTransactionObject<void>;
|
|
347
|
+
supplyFrom(from: string, dst: string, asset: string, amount: number | string | BN): NonPayableTransactionObject<void>;
|
|
348
|
+
supplyKink(): NonPayableTransactionObject<string>;
|
|
349
|
+
supplyPerSecondInterestRateBase(): NonPayableTransactionObject<string>;
|
|
350
|
+
supplyPerSecondInterestRateSlopeHigh(): NonPayableTransactionObject<string>;
|
|
351
|
+
supplyPerSecondInterestRateSlopeLow(): NonPayableTransactionObject<string>;
|
|
352
|
+
supplyTo(dst: string, asset: string, amount: number | string | BN): NonPayableTransactionObject<void>;
|
|
353
|
+
targetReserves(): NonPayableTransactionObject<string>;
|
|
354
|
+
totalBorrow(): NonPayableTransactionObject<string>;
|
|
355
|
+
totalSupply(): NonPayableTransactionObject<string>;
|
|
356
|
+
totalsCollateral(arg0: string): NonPayableTransactionObject<[
|
|
357
|
+
string,
|
|
358
|
+
string
|
|
359
|
+
] & {
|
|
360
|
+
totalSupplyAsset: string;
|
|
361
|
+
_reserved: string;
|
|
362
|
+
}>;
|
|
363
|
+
trackingIndexScale(): NonPayableTransactionObject<string>;
|
|
364
|
+
transfer(dst: string, amount: number | string | BN): NonPayableTransactionObject<boolean>;
|
|
365
|
+
transferAsset(dst: string, asset: string, amount: number | string | BN): NonPayableTransactionObject<void>;
|
|
366
|
+
transferAssetFrom(src: string, dst: string, asset: string, amount: number | string | BN): NonPayableTransactionObject<void>;
|
|
367
|
+
transferFrom(src: string, dst: string, amount: number | string | BN): NonPayableTransactionObject<boolean>;
|
|
368
|
+
userBasic(arg0: string): NonPayableTransactionObject<[
|
|
369
|
+
string,
|
|
370
|
+
string,
|
|
371
|
+
string,
|
|
372
|
+
string,
|
|
373
|
+
string
|
|
374
|
+
] & {
|
|
375
|
+
principal: string;
|
|
376
|
+
baseTrackingIndex: string;
|
|
377
|
+
baseTrackingAccrued: string;
|
|
378
|
+
assetsIn: string;
|
|
379
|
+
_reserved: string;
|
|
380
|
+
}>;
|
|
381
|
+
userCollateral(arg0: string, arg1: string): NonPayableTransactionObject<[
|
|
382
|
+
string,
|
|
383
|
+
string
|
|
384
|
+
] & {
|
|
385
|
+
balance: string;
|
|
386
|
+
_reserved: string;
|
|
387
|
+
}>;
|
|
388
|
+
userNonce(arg0: string): NonPayableTransactionObject<string>;
|
|
389
|
+
withdraw(asset: string, amount: number | string | BN): NonPayableTransactionObject<void>;
|
|
390
|
+
withdrawFrom(src: string, to: string, asset: string, amount: number | string | BN): NonPayableTransactionObject<void>;
|
|
391
|
+
withdrawReserves(to: string, amount: number | string | BN): NonPayableTransactionObject<void>;
|
|
392
|
+
withdrawTo(to: string, asset: string, amount: number | string | BN): NonPayableTransactionObject<void>;
|
|
393
|
+
};
|
|
394
|
+
events: {
|
|
395
|
+
AbsorbCollateral(cb?: Callback<AbsorbCollateral>): EventEmitter;
|
|
396
|
+
AbsorbCollateral(options?: EventOptions, cb?: Callback<AbsorbCollateral>): EventEmitter;
|
|
397
|
+
AbsorbDebt(cb?: Callback<AbsorbDebt>): EventEmitter;
|
|
398
|
+
AbsorbDebt(options?: EventOptions, cb?: Callback<AbsorbDebt>): EventEmitter;
|
|
399
|
+
BuyCollateral(cb?: Callback<BuyCollateral>): EventEmitter;
|
|
400
|
+
BuyCollateral(options?: EventOptions, cb?: Callback<BuyCollateral>): EventEmitter;
|
|
401
|
+
PauseAction(cb?: Callback<PauseAction>): EventEmitter;
|
|
402
|
+
PauseAction(options?: EventOptions, cb?: Callback<PauseAction>): EventEmitter;
|
|
403
|
+
Supply(cb?: Callback<Supply>): EventEmitter;
|
|
404
|
+
Supply(options?: EventOptions, cb?: Callback<Supply>): EventEmitter;
|
|
405
|
+
SupplyCollateral(cb?: Callback<SupplyCollateral>): EventEmitter;
|
|
406
|
+
SupplyCollateral(options?: EventOptions, cb?: Callback<SupplyCollateral>): EventEmitter;
|
|
407
|
+
Transfer(cb?: Callback<Transfer>): EventEmitter;
|
|
408
|
+
Transfer(options?: EventOptions, cb?: Callback<Transfer>): EventEmitter;
|
|
409
|
+
TransferCollateral(cb?: Callback<TransferCollateral>): EventEmitter;
|
|
410
|
+
TransferCollateral(options?: EventOptions, cb?: Callback<TransferCollateral>): EventEmitter;
|
|
411
|
+
Withdraw(cb?: Callback<Withdraw>): EventEmitter;
|
|
412
|
+
Withdraw(options?: EventOptions, cb?: Callback<Withdraw>): EventEmitter;
|
|
413
|
+
WithdrawCollateral(cb?: Callback<WithdrawCollateral>): EventEmitter;
|
|
414
|
+
WithdrawCollateral(options?: EventOptions, cb?: Callback<WithdrawCollateral>): EventEmitter;
|
|
415
|
+
WithdrawReserves(cb?: Callback<WithdrawReserves>): EventEmitter;
|
|
416
|
+
WithdrawReserves(options?: EventOptions, cb?: Callback<WithdrawReserves>): EventEmitter;
|
|
417
|
+
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
418
|
+
};
|
|
419
|
+
once(event: "AbsorbCollateral", cb: Callback<AbsorbCollateral>): void;
|
|
420
|
+
once(event: "AbsorbCollateral", options: EventOptions, cb: Callback<AbsorbCollateral>): void;
|
|
421
|
+
once(event: "AbsorbDebt", cb: Callback<AbsorbDebt>): void;
|
|
422
|
+
once(event: "AbsorbDebt", options: EventOptions, cb: Callback<AbsorbDebt>): void;
|
|
423
|
+
once(event: "BuyCollateral", cb: Callback<BuyCollateral>): void;
|
|
424
|
+
once(event: "BuyCollateral", options: EventOptions, cb: Callback<BuyCollateral>): void;
|
|
425
|
+
once(event: "PauseAction", cb: Callback<PauseAction>): void;
|
|
426
|
+
once(event: "PauseAction", options: EventOptions, cb: Callback<PauseAction>): void;
|
|
427
|
+
once(event: "Supply", cb: Callback<Supply>): void;
|
|
428
|
+
once(event: "Supply", options: EventOptions, cb: Callback<Supply>): void;
|
|
429
|
+
once(event: "SupplyCollateral", cb: Callback<SupplyCollateral>): void;
|
|
430
|
+
once(event: "SupplyCollateral", options: EventOptions, cb: Callback<SupplyCollateral>): void;
|
|
431
|
+
once(event: "Transfer", cb: Callback<Transfer>): void;
|
|
432
|
+
once(event: "Transfer", options: EventOptions, cb: Callback<Transfer>): void;
|
|
433
|
+
once(event: "TransferCollateral", cb: Callback<TransferCollateral>): void;
|
|
434
|
+
once(event: "TransferCollateral", options: EventOptions, cb: Callback<TransferCollateral>): void;
|
|
435
|
+
once(event: "Withdraw", cb: Callback<Withdraw>): void;
|
|
436
|
+
once(event: "Withdraw", options: EventOptions, cb: Callback<Withdraw>): void;
|
|
437
|
+
once(event: "WithdrawCollateral", cb: Callback<WithdrawCollateral>): void;
|
|
438
|
+
once(event: "WithdrawCollateral", options: EventOptions, cb: Callback<WithdrawCollateral>): void;
|
|
439
|
+
once(event: "WithdrawReserves", cb: Callback<WithdrawReserves>): void;
|
|
440
|
+
once(event: "WithdrawReserves", options: EventOptions, cb: Callback<WithdrawReserves>): void;
|
|
441
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ContractOptions } from "web3-eth-contract";
|
|
3
|
+
import type { EventLog } from "web3-core";
|
|
4
|
+
import type { EventEmitter } from "events";
|
|
5
|
+
import type { Callback, PayableTransactionObject, NonPayableTransactionObject, BlockType, ContractEventLog, BaseContract } from "./types";
|
|
6
|
+
export interface EventOptions {
|
|
7
|
+
filter?: object;
|
|
8
|
+
fromBlock?: BlockType;
|
|
9
|
+
topics?: string[];
|
|
10
|
+
}
|
|
11
|
+
export type AdminTransferred = ContractEventLog<{
|
|
12
|
+
oldAdmin: string;
|
|
13
|
+
newAdmin: string;
|
|
14
|
+
0: string;
|
|
15
|
+
1: string;
|
|
16
|
+
}>;
|
|
17
|
+
export interface CompV3USDCBulkerArb extends BaseContract {
|
|
18
|
+
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): CompV3USDCBulkerArb;
|
|
19
|
+
clone(): CompV3USDCBulkerArb;
|
|
20
|
+
methods: {
|
|
21
|
+
ACTION_CLAIM_REWARD(): NonPayableTransactionObject<string>;
|
|
22
|
+
ACTION_SUPPLY_ASSET(): NonPayableTransactionObject<string>;
|
|
23
|
+
ACTION_SUPPLY_NATIVE_TOKEN(): NonPayableTransactionObject<string>;
|
|
24
|
+
ACTION_TRANSFER_ASSET(): NonPayableTransactionObject<string>;
|
|
25
|
+
ACTION_WITHDRAW_ASSET(): NonPayableTransactionObject<string>;
|
|
26
|
+
ACTION_WITHDRAW_NATIVE_TOKEN(): NonPayableTransactionObject<string>;
|
|
27
|
+
admin(): NonPayableTransactionObject<string>;
|
|
28
|
+
invoke(actions: string | number[][], data: string | number[][]): PayableTransactionObject<void>;
|
|
29
|
+
sweepNativeToken(recipient: string): NonPayableTransactionObject<void>;
|
|
30
|
+
sweepToken(recipient: string, asset: string): NonPayableTransactionObject<void>;
|
|
31
|
+
transferAdmin(newAdmin: string): NonPayableTransactionObject<void>;
|
|
32
|
+
wrappedNativeToken(): NonPayableTransactionObject<string>;
|
|
33
|
+
};
|
|
34
|
+
events: {
|
|
35
|
+
AdminTransferred(cb?: Callback<AdminTransferred>): EventEmitter;
|
|
36
|
+
AdminTransferred(options?: EventOptions, cb?: Callback<AdminTransferred>): EventEmitter;
|
|
37
|
+
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
38
|
+
};
|
|
39
|
+
once(event: "AdminTransferred", cb: Callback<AdminTransferred>): void;
|
|
40
|
+
once(event: "AdminTransferred", options: EventOptions, cb: Callback<AdminTransferred>): void;
|
|
41
|
+
}
|
|
@@ -14,6 +14,7 @@ export type { ChickenBondsView } from "./ChickenBondsView";
|
|
|
14
14
|
export type { CollSurplusPool } from "./CollSurplusPool";
|
|
15
15
|
export type { CompV3ETHBulker } from "./CompV3ETHBulker";
|
|
16
16
|
export type { CompV3USDCBulker } from "./CompV3USDCBulker";
|
|
17
|
+
export type { CompV3USDCBulkerArb } from "./CompV3USDCBulkerArb";
|
|
17
18
|
export type { CompV3USDbCBulker } from "./CompV3USDbCBulker";
|
|
18
19
|
export type { CompV3View } from "./CompV3View";
|
|
19
20
|
export type { CompoundLoanInfo } from "./CompoundLoanInfo";
|
|
@@ -48,6 +49,7 @@ export type { TroveManager } from "./TroveManager";
|
|
|
48
49
|
export type { USDCPriceFeed } from "./USDCPriceFeed";
|
|
49
50
|
export type { UniMulticall } from "./UniMulticall";
|
|
50
51
|
export type { CETHv3 } from "./CETHv3";
|
|
52
|
+
export type { CUSDCev3 } from "./CUSDCev3";
|
|
51
53
|
export type { CUSDCv3 } from "./CUSDCv3";
|
|
52
54
|
export type { CUSDbCv3 } from "./CUSDbCv3";
|
|
53
55
|
export type { CrvUSDETHAmm } from "./CrvUSDETHAmm";
|
package/esm/aaveV2/index.js
CHANGED
|
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
|
|
12
12
|
import { calculateNetApy, getStETHApr } from '../staking';
|
|
13
|
-
import { ethToWeth, wethToEth } from '../services/utils';
|
|
14
|
-
import { AaveLoanInfoV2Contract } from '../contracts';
|
|
13
|
+
import { ethToWeth, wethToEth, wethToEthByAddress } from '../services/utils';
|
|
14
|
+
import { AaveLoanInfoV2Contract, createContractWrapper } from '../contracts';
|
|
15
15
|
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
16
16
|
import { EMPTY_AAVE_DATA } from '../aaveV3';
|
|
17
17
|
import { AAVE_V2 } from '../markets/aave';
|
|
@@ -87,18 +87,23 @@ export const getAaveV2AccountBalances = (web3, network, block, addressMapping, a
|
|
|
87
87
|
const market = AAVE_V2;
|
|
88
88
|
const loanInfoContract = AaveLoanInfoV2Contract(web3, network, block);
|
|
89
89
|
const marketAddress = market.providerAddress;
|
|
90
|
-
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
const protocolDataProviderContract = createContractWrapper(web3, network, market.protocolData, market.protocolDataAddress);
|
|
92
|
+
const reserveTokens = yield protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
93
|
+
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
94
|
+
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
|
91
95
|
const loanInfo = yield loanInfoContract.methods.getTokenBalances(marketAddress, address, _addresses).call({}, block);
|
|
92
96
|
loanInfo.forEach((_tokenInfo, i) => {
|
|
93
|
-
const asset = wethToEth(
|
|
97
|
+
const asset = wethToEth(symbols[i]);
|
|
98
|
+
const assetAddr = wethToEthByAddress(_addresses[i], network).toLowerCase();
|
|
94
99
|
const tokenInfo = Object.assign({}, _tokenInfo);
|
|
95
100
|
// known bug: stETH leaves 1 wei on every transfer
|
|
96
101
|
if (asset === 'stETH' && tokenInfo.balance.toString() === '1') {
|
|
97
102
|
tokenInfo.balance = '0';
|
|
98
103
|
}
|
|
99
104
|
balances = {
|
|
100
|
-
collateral: Object.assign(Object.assign({}, balances.collateral), { [addressMapping ?
|
|
101
|
-
debt: Object.assign(Object.assign({}, balances.debt), { [addressMapping ?
|
|
105
|
+
collateral: Object.assign(Object.assign({}, balances.collateral), { [addressMapping ? assetAddr : asset]: tokenInfo.balance.toString() }),
|
|
106
|
+
debt: Object.assign(Object.assign({}, balances.debt), { [addressMapping ? assetAddr : asset]: new Dec(tokenInfo.borrowsStable.toString()).add(tokenInfo.borrowsVariable.toString()).toString() }),
|
|
102
107
|
};
|
|
103
108
|
});
|
|
104
109
|
return balances;
|
package/esm/aaveV3/index.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { assetAmountInEth, assetAmountInWei, getAssetInfo } from '@defisaver/tokens';
|
|
12
|
-
import { AaveIncentiveDataProviderV3Contract, AaveV3ViewContract, getConfigContractAbi, getConfigContractAddress, GhoTokenContract, } from '../contracts';
|
|
13
|
-
import { addToObjectIf, ethToWeth, getAbiItem, isLayer2Network, wethToEth, } from '../services/utils';
|
|
12
|
+
import { AaveIncentiveDataProviderV3Contract, AaveV3ViewContract, createContractWrapper, getConfigContractAbi, getConfigContractAddress, GhoTokenContract, } from '../contracts';
|
|
13
|
+
import { addToObjectIf, ethToWeth, getAbiItem, isLayer2Network, wethToEth, wethToEthByAddress, } from '../services/utils';
|
|
14
14
|
import { NetworkNumber, } from '../types/common';
|
|
15
15
|
import { getStakingApy } from '../staking';
|
|
16
16
|
import { multicall } from '../multicall';
|
|
@@ -251,7 +251,11 @@ export const getAaveV3AccountBalances = (web3, network, block, addressMapping, a
|
|
|
251
251
|
const loanInfoContract = AaveV3ViewContract(web3, network, block);
|
|
252
252
|
const market = AAVE_V3(network);
|
|
253
253
|
const marketAddress = market.providerAddress;
|
|
254
|
-
|
|
254
|
+
// @ts-ignore
|
|
255
|
+
const protocolDataProviderContract = createContractWrapper(web3, network, market.protocolData, market.protocolDataAddress);
|
|
256
|
+
const reserveTokens = yield protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
257
|
+
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
258
|
+
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
|
255
259
|
// split addresses in half to avoid gas limit by multicall
|
|
256
260
|
const middleAddressIndex = Math.floor(_addresses.length / 2);
|
|
257
261
|
const multicallData = [
|
|
@@ -269,10 +273,11 @@ export const getAaveV3AccountBalances = (web3, network, block, addressMapping, a
|
|
|
269
273
|
const multicallRes = yield multicall(multicallData, web3, network, block);
|
|
270
274
|
const loanInfo = [...multicallRes[0][0], ...multicallRes[1][0]];
|
|
271
275
|
loanInfo.forEach((tokenInfo, i) => {
|
|
272
|
-
const asset = wethToEth(
|
|
276
|
+
const asset = wethToEth(symbols[i]);
|
|
277
|
+
const assetAddr = wethToEthByAddress(_addresses[i], network).toLowerCase();
|
|
273
278
|
balances = {
|
|
274
|
-
collateral: Object.assign(Object.assign({}, balances.collateral), { [addressMapping ?
|
|
275
|
-
debt: Object.assign(Object.assign({}, balances.debt), { [addressMapping ?
|
|
279
|
+
collateral: Object.assign(Object.assign({}, balances.collateral), { [addressMapping ? assetAddr : asset]: tokenInfo.balance.toString() }),
|
|
280
|
+
debt: Object.assign(Object.assign({}, balances.debt), { [addressMapping ? assetAddr : asset]: new Dec(tokenInfo.borrowsStable.toString()).add(tokenInfo.borrowsVariable.toString()).toString() }),
|
|
276
281
|
};
|
|
277
282
|
});
|
|
278
283
|
return balances;
|
|
@@ -16,6 +16,7 @@ export declare const EMPTY_COMPOUND_DATA: {
|
|
|
16
16
|
borrowStableSupplyUnstable: boolean;
|
|
17
17
|
};
|
|
18
18
|
export declare const getCollateralAssetsAddresses: (web3: Web3, network: NetworkNumber, account: string) => Promise<string[]>;
|
|
19
|
+
export declare const getAllMarketAddresses: (web3: Web3, network: NetworkNumber, block: Blockish) => Promise<string[]>;
|
|
19
20
|
export declare const getCompoundV2AccountBalances: (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress) => Promise<PositionBalances>;
|
|
20
21
|
export declare const getCompoundV2AccountData: (web3: Web3, network: NetworkNumber, address: string, assetsData: CompoundV2AssetsData) => Promise<CompoundV2PositionData>;
|
|
21
22
|
export declare const getCompoundV2FullPositionData: (web3: Web3, network: NetworkNumber, address: string) => Promise<CompoundV2PositionData>;
|
package/esm/compoundV2/index.js
CHANGED
|
@@ -88,6 +88,10 @@ export const getCollateralAssetsAddresses = (web3, network, account) => __awaite
|
|
|
88
88
|
const contract = ComptrollerContract(web3, network);
|
|
89
89
|
return contract.methods.getAssetsIn(account).call();
|
|
90
90
|
});
|
|
91
|
+
export const getAllMarketAddresses = (web3, network, block) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
const contract = ComptrollerContract(web3, network);
|
|
93
|
+
return contract.methods.getAllMarkets().call({}, block);
|
|
94
|
+
});
|
|
91
95
|
export const getCompoundV2AccountBalances = (web3, network, block, addressMapping, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
96
|
let balances = {
|
|
93
97
|
collateral: {},
|
|
@@ -96,20 +100,22 @@ export const getCompoundV2AccountBalances = (web3, network, block, addressMappin
|
|
|
96
100
|
if (!address) {
|
|
97
101
|
return balances;
|
|
98
102
|
}
|
|
103
|
+
const assets = yield getAllMarketAddresses(web3, network, block);
|
|
104
|
+
const assetInfo = assets.map(a => getAssetInfoByAddress(a, network));
|
|
99
105
|
const loanInfoContract = CompoundLoanInfoContract(web3, network, block);
|
|
100
|
-
const loanInfo = yield loanInfoContract.methods.getTokenBalances(address,
|
|
106
|
+
const loanInfo = yield loanInfoContract.methods.getTokenBalances(address, assets).call({}, block);
|
|
101
107
|
loanInfo.balances.forEach((weiAmount, i) => {
|
|
102
|
-
const asset = wethToEth(
|
|
103
|
-
? `${
|
|
104
|
-
:
|
|
108
|
+
const asset = wethToEth(assetInfo[i].symbol === 'cWBTC Legacy'
|
|
109
|
+
? `${assetInfo[i].underlyingAsset} Legacy`
|
|
110
|
+
: assetInfo[i].underlyingAsset);
|
|
105
111
|
balances = {
|
|
106
112
|
collateral: Object.assign(Object.assign({}, balances.collateral), { [addressMapping ? getAssetInfo(asset, network).address.toLowerCase() : asset]: weiAmount.toString() }),
|
|
107
113
|
};
|
|
108
114
|
});
|
|
109
115
|
loanInfo.borrows.forEach((weiAmount, i) => {
|
|
110
|
-
const asset = wethToEth(
|
|
111
|
-
? `${
|
|
112
|
-
:
|
|
116
|
+
const asset = wethToEth(assetInfo[i].symbol === 'cWBTC Legacy'
|
|
117
|
+
? `${assetInfo[i].underlyingAsset} Legacy`
|
|
118
|
+
: assetInfo[i].underlyingAsset);
|
|
113
119
|
balances = Object.assign(Object.assign({}, balances), { debt: Object.assign(Object.assign({}, balances.debt), { [addressMapping ? getAssetInfo(asset, network).address.toLowerCase() : asset]: weiAmount.toString() }) });
|
|
114
120
|
});
|
|
115
121
|
return balances;
|