@defisaver/positions-sdk 1.0.12 → 1.0.13-dev-2

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.
Files changed (38) hide show
  1. package/cjs/config/contracts.d.ts +61 -21
  2. package/cjs/config/contracts.js +9 -1
  3. package/cjs/contracts.d.ts +1 -0
  4. package/cjs/contracts.js +2 -1
  5. package/cjs/liquityV2/index.js +17 -6
  6. package/cjs/markets/aave/marketAssets.js +1 -1
  7. package/cjs/markets/liquityV2/index.d.ts +6 -0
  8. package/cjs/markets/liquityV2/index.js +51 -4
  9. package/cjs/types/contracts/generated/LiquityV2LegacyView.d.ts +386 -0
  10. package/cjs/types/contracts/generated/LiquityV2LegacyView.js +5 -0
  11. package/cjs/types/contracts/generated/LiquityV2View.d.ts +4 -0
  12. package/cjs/types/contracts/generated/index.d.ts +1 -0
  13. package/cjs/types/liquityV2.d.ts +6 -1
  14. package/cjs/types/liquityV2.js +4 -0
  15. package/esm/config/contracts.d.ts +61 -21
  16. package/esm/config/contracts.js +9 -1
  17. package/esm/contracts.d.ts +1 -0
  18. package/esm/contracts.js +1 -0
  19. package/esm/liquityV2/index.js +18 -7
  20. package/esm/markets/aave/marketAssets.js +1 -1
  21. package/esm/markets/liquityV2/index.d.ts +6 -0
  22. package/esm/markets/liquityV2/index.js +46 -2
  23. package/esm/types/contracts/generated/LiquityV2LegacyView.d.ts +386 -0
  24. package/esm/types/contracts/generated/LiquityV2LegacyView.js +4 -0
  25. package/esm/types/contracts/generated/LiquityV2View.d.ts +4 -0
  26. package/esm/types/contracts/generated/index.d.ts +1 -0
  27. package/esm/types/liquityV2.d.ts +6 -1
  28. package/esm/types/liquityV2.js +4 -0
  29. package/package.json +3 -3
  30. package/src/config/contracts.js +9 -1
  31. package/src/contracts.ts +2 -0
  32. package/src/liquityV2/index.ts +20 -7
  33. package/src/markets/aave/marketAssets.ts +1 -1
  34. package/src/markets/liquityV2/index.ts +50 -2
  35. package/src/types/contracts/generated/LiquityV2LegacyView.ts +486 -0
  36. package/src/types/contracts/generated/LiquityV2View.ts +4 -0
  37. package/src/types/contracts/generated/index.ts +1 -0
  38. package/src/types/liquityV2.ts +6 -0
@@ -0,0 +1,386 @@
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, BaseContract } from "./types";
7
+ export interface EventOptions {
8
+ filter?: object;
9
+ fromBlock?: BlockType;
10
+ topics?: string[];
11
+ }
12
+ export declare namespace IBorrowerOperations {
13
+ type InterestBatchManagerStruct = [number | string | BN, number | string | BN, number | string | BN] | {
14
+ minInterestRate: number | string | BN;
15
+ maxInterestRate: number | string | BN;
16
+ minInterestRateChangePeriod: number | string | BN;
17
+ };
18
+ type InterestBatchManagerStructOutputArray = [string, string, string];
19
+ type InterestBatchManagerStructOutputStruct = {
20
+ minInterestRate: string;
21
+ maxInterestRate: string;
22
+ minInterestRateChangePeriod: string;
23
+ };
24
+ type InterestBatchManagerStructOutput = InterestBatchManagerStructOutputArray & InterestBatchManagerStructOutputStruct;
25
+ }
26
+ export declare namespace ITroveManager {
27
+ type LatestBatchDataStruct = [
28
+ number | string | BN,
29
+ number | string | BN,
30
+ number | string | BN,
31
+ number | string | BN,
32
+ number | string | BN,
33
+ number | string | BN,
34
+ number | string | BN,
35
+ number | string | BN,
36
+ number | string | BN,
37
+ number | string | BN,
38
+ number | string | BN
39
+ ] | {
40
+ entireDebtWithoutRedistribution: number | string | BN;
41
+ entireCollWithoutRedistribution: number | string | BN;
42
+ accruedInterest: number | string | BN;
43
+ recordedDebt: number | string | BN;
44
+ annualInterestRate: number | string | BN;
45
+ weightedRecordedDebt: number | string | BN;
46
+ annualManagementFee: number | string | BN;
47
+ accruedManagementFee: number | string | BN;
48
+ weightedRecordedBatchManagementFee: number | string | BN;
49
+ lastDebtUpdateTime: number | string | BN;
50
+ lastInterestRateAdjTime: number | string | BN;
51
+ };
52
+ type LatestBatchDataStructOutputArray = [
53
+ string,
54
+ string,
55
+ string,
56
+ string,
57
+ string,
58
+ string,
59
+ string,
60
+ string,
61
+ string,
62
+ string,
63
+ string
64
+ ];
65
+ type LatestBatchDataStructOutputStruct = {
66
+ entireDebtWithoutRedistribution: string;
67
+ entireCollWithoutRedistribution: string;
68
+ accruedInterest: string;
69
+ recordedDebt: string;
70
+ annualInterestRate: string;
71
+ weightedRecordedDebt: string;
72
+ annualManagementFee: string;
73
+ accruedManagementFee: string;
74
+ weightedRecordedBatchManagementFee: string;
75
+ lastDebtUpdateTime: string;
76
+ lastInterestRateAdjTime: string;
77
+ };
78
+ type LatestBatchDataStructOutput = LatestBatchDataStructOutputArray & LatestBatchDataStructOutputStruct;
79
+ }
80
+ export declare namespace LiquityV2View {
81
+ type MarketDataStruct = [
82
+ string,
83
+ number | string | BN,
84
+ number | string | BN,
85
+ number | string | BN,
86
+ number | string | BN,
87
+ number | string | BN,
88
+ number | string | BN,
89
+ number | string | BN,
90
+ string,
91
+ string,
92
+ string,
93
+ string,
94
+ string,
95
+ string,
96
+ string,
97
+ string,
98
+ string,
99
+ string,
100
+ number | string | BN,
101
+ boolean,
102
+ number | string | BN
103
+ ] | {
104
+ market: string;
105
+ CCR: number | string | BN;
106
+ MCR: number | string | BN;
107
+ SCR: number | string | BN;
108
+ LIQUIDATION_PENALTY_SP: number | string | BN;
109
+ LIQUIDATION_PENALTY_REDISTRIBUTION: number | string | BN;
110
+ entireSystemColl: number | string | BN;
111
+ entireSystemDebt: number | string | BN;
112
+ collToken: string;
113
+ troveNFT: string;
114
+ borrowerOperations: string;
115
+ troveManager: string;
116
+ stabilityPool: string;
117
+ sortedTroves: string;
118
+ collSurplusPool: string;
119
+ activePool: string;
120
+ hintHelpers: string;
121
+ priceFeed: string;
122
+ collPrice: number | string | BN;
123
+ isShutDown: boolean;
124
+ boldDepositInSp: number | string | BN;
125
+ };
126
+ type MarketDataStructOutputArray = [
127
+ string,
128
+ string,
129
+ string,
130
+ string,
131
+ string,
132
+ string,
133
+ string,
134
+ string,
135
+ string,
136
+ string,
137
+ string,
138
+ string,
139
+ string,
140
+ string,
141
+ string,
142
+ string,
143
+ string,
144
+ string,
145
+ string,
146
+ boolean,
147
+ string
148
+ ];
149
+ type MarketDataStructOutputStruct = {
150
+ market: string;
151
+ CCR: string;
152
+ MCR: string;
153
+ SCR: string;
154
+ LIQUIDATION_PENALTY_SP: string;
155
+ LIQUIDATION_PENALTY_REDISTRIBUTION: string;
156
+ entireSystemColl: string;
157
+ entireSystemDebt: string;
158
+ collToken: string;
159
+ troveNFT: string;
160
+ borrowerOperations: string;
161
+ troveManager: string;
162
+ stabilityPool: string;
163
+ sortedTroves: string;
164
+ collSurplusPool: string;
165
+ activePool: string;
166
+ hintHelpers: string;
167
+ priceFeed: string;
168
+ collPrice: string;
169
+ isShutDown: boolean;
170
+ boldDepositInSp: string;
171
+ };
172
+ type MarketDataStructOutput = MarketDataStructOutputArray & MarketDataStructOutputStruct;
173
+ type TroveDataStruct = [
174
+ number | string | BN,
175
+ string,
176
+ string,
177
+ number | string | BN,
178
+ number | string | BN,
179
+ number | string | BN,
180
+ number | string | BN,
181
+ number | string | BN,
182
+ number | string | BN,
183
+ string,
184
+ number | string | BN,
185
+ number | string | BN
186
+ ] | {
187
+ troveId: number | string | BN;
188
+ owner: string;
189
+ collToken: string;
190
+ status: number | string | BN;
191
+ collAmount: number | string | BN;
192
+ debtAmount: number | string | BN;
193
+ collPrice: number | string | BN;
194
+ TCRatio: number | string | BN;
195
+ annualInterestRate: number | string | BN;
196
+ interestBatchManager: string;
197
+ batchDebtShares: number | string | BN;
198
+ lastInterestRateAdjTime: number | string | BN;
199
+ };
200
+ type TroveDataStructOutputArray = [
201
+ string,
202
+ string,
203
+ string,
204
+ string,
205
+ string,
206
+ string,
207
+ string,
208
+ string,
209
+ string,
210
+ string,
211
+ string,
212
+ string
213
+ ];
214
+ type TroveDataStructOutputStruct = {
215
+ troveId: string;
216
+ owner: string;
217
+ collToken: string;
218
+ status: string;
219
+ collAmount: string;
220
+ debtAmount: string;
221
+ collPrice: string;
222
+ TCRatio: string;
223
+ annualInterestRate: string;
224
+ interestBatchManager: string;
225
+ batchDebtShares: string;
226
+ lastInterestRateAdjTime: string;
227
+ };
228
+ type TroveDataStructOutput = TroveDataStructOutputArray & TroveDataStructOutputStruct;
229
+ type ExistingTroveStruct = [number | string | BN, boolean] | {
230
+ troveId: number | string | BN;
231
+ ownedByUser: boolean;
232
+ };
233
+ type ExistingTroveStructOutputArray = [string, boolean];
234
+ type ExistingTroveStructOutputStruct = {
235
+ troveId: string;
236
+ ownedByUser: boolean;
237
+ };
238
+ type ExistingTroveStructOutput = ExistingTroveStructOutputArray & ExistingTroveStructOutputStruct;
239
+ }
240
+ export declare namespace IMultiTroveGetter {
241
+ type CombinedTroveDataStruct = [
242
+ number | string | BN,
243
+ number | string | BN,
244
+ number | string | BN,
245
+ number | string | BN,
246
+ number | string | BN,
247
+ number | string | BN,
248
+ number | string | BN,
249
+ string,
250
+ number | string | BN,
251
+ number | string | BN,
252
+ number | string | BN,
253
+ number | string | BN
254
+ ] | {
255
+ id: number | string | BN;
256
+ debt: number | string | BN;
257
+ coll: number | string | BN;
258
+ stake: number | string | BN;
259
+ annualInterestRate: number | string | BN;
260
+ lastDebtUpdateTime: number | string | BN;
261
+ lastInterestRateAdjTime: number | string | BN;
262
+ interestBatchManager: string;
263
+ batchDebtShares: number | string | BN;
264
+ batchCollShares: number | string | BN;
265
+ snapshotETH: number | string | BN;
266
+ snapshotBoldDebt: number | string | BN;
267
+ };
268
+ type CombinedTroveDataStructOutputArray = [
269
+ string,
270
+ string,
271
+ string,
272
+ string,
273
+ string,
274
+ string,
275
+ string,
276
+ string,
277
+ string,
278
+ string,
279
+ string,
280
+ string
281
+ ];
282
+ type CombinedTroveDataStructOutputStruct = {
283
+ id: string;
284
+ debt: string;
285
+ coll: string;
286
+ stake: string;
287
+ annualInterestRate: string;
288
+ lastDebtUpdateTime: string;
289
+ lastInterestRateAdjTime: string;
290
+ interestBatchManager: string;
291
+ batchDebtShares: string;
292
+ batchCollShares: string;
293
+ snapshotETH: string;
294
+ snapshotBoldDebt: string;
295
+ };
296
+ type CombinedTroveDataStructOutput = CombinedTroveDataStructOutputArray & CombinedTroveDataStructOutputStruct;
297
+ }
298
+ export interface LiquityV2LegacyView extends BaseContract {
299
+ constructor(jsonInterface: any[], address?: string, options?: ContractOptions): LiquityV2LegacyView;
300
+ clone(): LiquityV2LegacyView;
301
+ methods: {
302
+ findInsertPosition(_market: string, _interestRate: number | string | BN, _prevId: number | string | BN, _nextId: number | string | BN): NonPayableTransactionObject<[
303
+ string,
304
+ string
305
+ ] & {
306
+ prevId: string;
307
+ nextId: string;
308
+ }>;
309
+ getApproxHint(_market: string, _collIndex: number | string | BN, _interestRate: number | string | BN, _numTrials: number | string | BN, _inputRandomSeed: number | string | BN): NonPayableTransactionObject<[
310
+ string,
311
+ string,
312
+ string
313
+ ] & {
314
+ hintId: string;
315
+ diff: string;
316
+ latestRandomSeed: string;
317
+ }>;
318
+ getBatchManagerInfo(_market: string, _manager: string): NonPayableTransactionObject<[
319
+ IBorrowerOperations.InterestBatchManagerStructOutput,
320
+ ITroveManager.LatestBatchDataStructOutput
321
+ ] & {
322
+ managerData: IBorrowerOperations.InterestBatchManagerStructOutput;
323
+ batchData: ITroveManager.LatestBatchDataStructOutput;
324
+ }>;
325
+ getDebtInFront(_market: string, _troveId: number | string | BN, _acc: number | string | BN, _iterations: number | string | BN): NonPayableTransactionObject<[
326
+ string,
327
+ string
328
+ ] & {
329
+ next: string;
330
+ debt: string;
331
+ }>;
332
+ getDebtInFrontByInterestRate(_market: string, _troveId: number | string | BN, _acc: number | string | BN, _iterations: number | string | BN, _targetIR: number | string | BN): NonPayableTransactionObject<[
333
+ string,
334
+ string
335
+ ] & {
336
+ next: string;
337
+ debt: string;
338
+ }>;
339
+ getDebtInFrontByTroveNum(_market: string, _numTroves: number | string | BN): NonPayableTransactionObject<string>;
340
+ getDepositorInfo(_market: string, _depositor: string): NonPayableTransactionObject<[
341
+ string,
342
+ string,
343
+ string
344
+ ] & {
345
+ compoundedBOLD: string;
346
+ collGain: string;
347
+ boldGain: string;
348
+ }>;
349
+ getInsertPosition(_market: string, _collIndex: number | string | BN, _interestRate: number | string | BN, _numTrials: number | string | BN, _inputRandomSeed: number | string | BN): NonPayableTransactionObject<[
350
+ string,
351
+ string
352
+ ] & {
353
+ prevId: string;
354
+ nextId: string;
355
+ }>;
356
+ getMarketData(_market: string): NonPayableTransactionObject<LiquityV2View.MarketDataStructOutput>;
357
+ getMultipleSortedTroves(_market: string, _startIdx: number | string | BN, _count: number | string | BN): NonPayableTransactionObject<IMultiTroveGetter.CombinedTroveDataStructOutput[]>;
358
+ getNumOfTrovesInFrontOfTrove(_market: string, _troveId: number | string | BN, _iterations: number | string | BN): NonPayableTransactionObject<[
359
+ string,
360
+ string
361
+ ] & {
362
+ next: string;
363
+ numTroves: string;
364
+ }>;
365
+ getTroveInfo(_market: string, _troveId: number | string | BN): NonPayableTransactionObject<LiquityV2View.TroveDataStructOutput>;
366
+ getTrovePosition(_market: string, _collIndex: number | string | BN, _troveId: number | string | BN, _numTrials: number | string | BN, _inputRandomSeed: number | string | BN): NonPayableTransactionObject<[
367
+ string,
368
+ string
369
+ ] & {
370
+ prevId: string;
371
+ nextId: string;
372
+ }>;
373
+ getUserTroves(_user: string, _market: string, _startIndex: number | string | BN, _endIndex: number | string | BN): NonPayableTransactionObject<[
374
+ LiquityV2View.ExistingTroveStructOutput[],
375
+ string
376
+ ] & {
377
+ troves: LiquityV2View.ExistingTroveStructOutput[];
378
+ nextFreeTroveIndex: string;
379
+ }>;
380
+ isShutDown(_market: string): NonPayableTransactionObject<boolean>;
381
+ predictAdjustTroveUpfrontFee(_market: string, _collIndex: number | string | BN, _troveId: number | string | BN, _debtIncrease: number | string | BN): NonPayableTransactionObject<string>;
382
+ };
383
+ events: {
384
+ allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
385
+ };
386
+ }
@@ -0,0 +1,4 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ export {};
@@ -87,6 +87,7 @@ export declare namespace LiquityV2View {
87
87
  number | string | BN,
88
88
  number | string | BN,
89
89
  number | string | BN,
90
+ number | string | BN,
90
91
  string,
91
92
  string,
92
93
  string,
@@ -105,6 +106,7 @@ export declare namespace LiquityV2View {
105
106
  CCR: number | string | BN;
106
107
  MCR: number | string | BN;
107
108
  SCR: number | string | BN;
109
+ BCR: number | string | BN;
108
110
  LIQUIDATION_PENALTY_SP: number | string | BN;
109
111
  LIQUIDATION_PENALTY_REDISTRIBUTION: number | string | BN;
110
112
  entireSystemColl: number | string | BN;
@@ -143,6 +145,7 @@ export declare namespace LiquityV2View {
143
145
  string,
144
146
  string,
145
147
  string,
148
+ string,
146
149
  boolean,
147
150
  string
148
151
  ];
@@ -151,6 +154,7 @@ export declare namespace LiquityV2View {
151
154
  CCR: string;
152
155
  MCR: string;
153
156
  SCR: string;
157
+ BCR: string;
154
158
  LIQUIDATION_PENALTY_SP: string;
155
159
  LIQUIDATION_PENALTY_REDISTRIBUTION: string;
156
160
  entireSystemColl: string;
@@ -38,6 +38,7 @@ export type { LendingPoolAddressesProvider } from "./LendingPoolAddressesProvide
38
38
  export type { Lido } from "./Lido";
39
39
  export type { LiquityActivePool } from "./LiquityActivePool";
40
40
  export type { LiquityV2CollSurplusPool } from "./LiquityV2CollSurplusPool";
41
+ export type { LiquityV2LegacyView } from "./LiquityV2LegacyView";
41
42
  export type { LiquityV2StabilityPool } from "./LiquityV2StabilityPool";
42
43
  export type { LiquityV2TroveNFT } from "./LiquityV2TroveNFT";
43
44
  export type { LiquityV2View } from "./LiquityV2View";
@@ -2,7 +2,10 @@ import { EthAddress, NetworkNumber } from './common';
2
2
  export declare enum LiquityV2Versions {
3
3
  LiquityV2Eth = "liquityv2eth",
4
4
  LiquityV2WstEth = "liquityv2wsteth",
5
- LiquityV2REth = "liquityv2reth"
5
+ LiquityV2REth = "liquityv2reth",
6
+ LiquityV2EthLegacy = "liquityv2ethlegacy",
7
+ LiquityV2WstEthLegacy = "liquityv2wstethlegacy",
8
+ LiquityV2REthLegacy = "liquityv2rethlegacy"
6
9
  }
7
10
  export declare enum LIQUITY_V2_TROVE_STATUS_ENUM {
8
11
  nonExistent = 0,
@@ -28,6 +31,7 @@ export interface LiquityV2MarketInfo {
28
31
  collateralToken: string;
29
32
  marketAddress: string;
30
33
  protocolName: string;
34
+ isLegacy: boolean;
31
35
  }
32
36
  export interface LiquityV2AssetData {
33
37
  symbol: string;
@@ -49,6 +53,7 @@ export interface InnerLiquityV2MarketData {
49
53
  minCollRatio: string;
50
54
  totalCollRatio: string;
51
55
  criticalCollRatio: string;
56
+ batchCollRatio: string;
52
57
  isUnderCollateralized: boolean;
53
58
  hintHelperAddress: EthAddress;
54
59
  troveNFTAddress: EthAddress;
@@ -3,6 +3,10 @@ export var LiquityV2Versions;
3
3
  LiquityV2Versions["LiquityV2Eth"] = "liquityv2eth";
4
4
  LiquityV2Versions["LiquityV2WstEth"] = "liquityv2wsteth";
5
5
  LiquityV2Versions["LiquityV2REth"] = "liquityv2reth";
6
+ // Legacy
7
+ LiquityV2Versions["LiquityV2EthLegacy"] = "liquityv2ethlegacy";
8
+ LiquityV2Versions["LiquityV2WstEthLegacy"] = "liquityv2wstethlegacy";
9
+ LiquityV2Versions["LiquityV2REthLegacy"] = "liquityv2rethlegacy";
6
10
  })(LiquityV2Versions || (LiquityV2Versions = {}));
7
11
  export var LIQUITY_V2_TROVE_STATUS_ENUM;
8
12
  (function (LIQUITY_V2_TROVE_STATUS_ENUM) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "1.0.12",
3
+ "version": "1.0.13-dev-2",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -13,7 +13,7 @@
13
13
  "lint": "eslint src/ --fix",
14
14
  "lint-check": "eslint src/",
15
15
  "generate-contracts": "node scripts/generateContracts.js",
16
- "test": "mocha tests/*",
16
+ "test": "mocha tests/liquityv2.ts",
17
17
  "test-single": "mocha ./tests/$npm_config_name.ts",
18
18
  "test:debugger": "mocha --inspect-brk tests/*",
19
19
  "build-test": "npm run build && npm run test",
@@ -23,7 +23,7 @@
23
23
  "author": "",
24
24
  "license": "ISC",
25
25
  "dependencies": {
26
- "@defisaver/tokens": "^1.6.2",
26
+ "@defisaver/tokens": "^1.6.4-dev-1",
27
27
  "@ethersproject/bignumber": "^5.7.0",
28
28
  "@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
29
29
  "@types/lodash": "^4.17.15",