impermax-sdk 1.2.67 → 1.2.68

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 (69) hide show
  1. package/lib/offchain/offchainPriceHelper.js +2 -2
  2. package/lib/offchain/query.js +247 -247
  3. package/package.json +1 -1
  4. package/lib/offchain/account/lendingPool/borrowable.d.ts +0 -14
  5. package/lib/offchain/account/lendingPool/borrowable.js +0 -73
  6. package/lib/offchain/account/lendingPool/collateral.d.ts +0 -12
  7. package/lib/offchain/account/lendingPool/collateral.js +0 -42
  8. package/lib/offchain/account/lendingVault.d.ts +0 -11
  9. package/lib/offchain/account/lendingVault.js +0 -38
  10. package/lib/offchain/account/poolToken.d.ts +0 -6
  11. package/lib/offchain/account/poolToken.js +0 -21
  12. package/lib/offchain/initializer.d.ts +0 -32
  13. package/lib/offchain/initializer.js +0 -627
  14. package/lib/offchain/lendingPool/borrowable.d.ts +0 -55
  15. package/lib/offchain/lendingPool/borrowable.js +0 -351
  16. package/lib/offchain/lendingPool/collateral.d.ts +0 -17
  17. package/lib/offchain/lendingPool/collateral.js +0 -72
  18. package/lib/offchain/lendingVault.d.ts +0 -22
  19. package/lib/offchain/lendingVault.js +0 -115
  20. package/lib/offchain/poolToken.d.ts +0 -20
  21. package/lib/offchain/poolToken.js +0 -120
  22. package/lib/offchain/priceHelper.d.ts +0 -21
  23. package/lib/offchain/priceHelper.js +0 -195
  24. package/lib/offchain/solidexHelper.d.ts +0 -16
  25. package/lib/offchain/solidexHelper.js +0 -58
  26. package/lib/offchain/types.d.ts +0 -150
  27. package/lib/offchain/types.js +0 -3
  28. package/lib/onchain/account/interactions/index.d.ts +0 -28
  29. package/lib/onchain/account/interactions/index.js +0 -158
  30. package/lib/onchain/account/interactions/lendingPool/borrowable.d.ts +0 -16
  31. package/lib/onchain/account/interactions/lendingPool/borrowable.js +0 -49
  32. package/lib/onchain/account/interactions/lendingPool/collateral.d.ts +0 -15
  33. package/lib/onchain/account/interactions/lendingPool/collateral.js +0 -33
  34. package/lib/onchain/account/interactions/lendingPool/index.d.ts +0 -41
  35. package/lib/onchain/account/interactions/lendingPool/index.js +0 -120
  36. package/lib/onchain/account/interactions/lendingVault.d.ts +0 -10
  37. package/lib/onchain/account/interactions/lendingVault.js +0 -12
  38. package/lib/onchain/account/interactions/poolToken.d.ts +0 -33
  39. package/lib/onchain/account/interactions/poolToken.js +0 -180
  40. package/lib/onchain/account/lendingPool/borrowable.d.ts +0 -29
  41. package/lib/onchain/account/lendingPool/borrowable.js +0 -135
  42. package/lib/onchain/account/lendingPool/collateral.d.ts +0 -15
  43. package/lib/onchain/account/lendingPool/collateral.js +0 -66
  44. package/lib/onchain/account/lendingVault.d.ts +0 -10
  45. package/lib/onchain/account/lendingVault.js +0 -35
  46. package/lib/onchain/account/poolToken.d.ts +0 -24
  47. package/lib/onchain/account/poolToken.js +0 -84
  48. package/lib/onchain/contractsHelper.d.ts +0 -29
  49. package/lib/onchain/contractsHelper.js +0 -52
  50. package/lib/onchain/impermaxFactory/lendingPool/borrowable.d.ts +0 -36
  51. package/lib/onchain/impermaxFactory/lendingPool/borrowable.js +0 -153
  52. package/lib/onchain/impermaxFactory/lendingPool/collateral.d.ts +0 -17
  53. package/lib/onchain/impermaxFactory/lendingPool/collateral.js +0 -59
  54. package/lib/onchain/interactions/lendingPool/borrowable.d.ts +0 -14
  55. package/lib/onchain/interactions/lendingPool/borrowable.js +0 -47
  56. package/lib/onchain/interactions/lendingPool/collateral.d.ts +0 -13
  57. package/lib/onchain/interactions/lendingPool/collateral.js +0 -31
  58. package/lib/onchain/interactions/lendingVault.d.ts +0 -8
  59. package/lib/onchain/interactions/lendingVault.js +0 -15
  60. package/lib/onchain/interactions/poolToken.d.ts +0 -31
  61. package/lib/onchain/interactions/poolToken.js +0 -181
  62. package/lib/onchain/lendingVault.d.ts +0 -17
  63. package/lib/onchain/lendingVault.js +0 -56
  64. package/lib/onchain/poolToken.d.ts +0 -32
  65. package/lib/onchain/poolToken.js +0 -121
  66. package/lib/onchain/types.d.ts +0 -45
  67. package/lib/onchain/types.js +0 -14
  68. package/lib/utils/price-from-reserves.d.ts +0 -2
  69. package/lib/utils/price-from-reserves.js +0 -19
@@ -62,8 +62,8 @@ const dexscreener_ids = {
62
62
  "0x56659245931cb6920e39c189d2a0e7dd0da2d57b": "arbitrum",
63
63
  // ibex on zksync
64
64
  "0xbe9f8c0d6f0fd7e46cdacca340747ea2f247991d": "zksync",
65
- // fantom-bomb on scroll
66
- "0x74ccbe53f77b08632ce0cb91d3a545bf6b8e0979": "scroll",
65
+ // preon on scroll
66
+ "0x135f9b3d5dec9d73c042cf380adfff95f4fe9e35": "scroll",
67
67
  // more on scroll
68
68
  "0x25ea98ac87a38142561ea70143fd44c4772a16b6": "scroll",
69
69
  // axlOP on base
@@ -7,317 +7,317 @@ exports.whitelistQuery = exports.proposalQuery = exports.proposalsMetaQuery = ex
7
7
  const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
8
  const factories_1 = require("../config/factories");
9
9
  function blockQuery(timestamp) {
10
- return (0, graphql_tag_1.default) `{
11
- blocks (first: 1, orderBy: timestamp, orderDirection: desc, where: { timestamp_gt: ${timestamp}, timestamp_lt: ${timestamp + 600} }) {
12
- number
13
- }
14
- _meta {
15
- block {
16
- number
17
- }
18
- }
10
+ return (0, graphql_tag_1.default) `{
11
+ blocks (first: 1, orderBy: timestamp, orderDirection: desc, where: { timestamp_gt: ${timestamp}, timestamp_lt: ${timestamp + 600} }) {
12
+ number
13
+ }
14
+ _meta {
15
+ block {
16
+ number
17
+ }
18
+ }
19
19
  }`;
20
20
  }
21
21
  exports.blockQuery = blockQuery;
22
22
  function lendingPoolsQuery(factory, addressesFilter) {
23
- const tokenStr = `{
24
- id
25
- symbol
26
- name
27
- decimals
28
- derivedUSD
23
+ const tokenStr = `{
24
+ id
25
+ symbol
26
+ name
27
+ decimals
28
+ derivedUSD
29
29
  }`;
30
- const distributorStr = `{
31
- id
30
+ const distributorStr = `{
31
+ id
32
32
  }`;
33
- const farmingPoolStr = `{
34
- epochAmount
35
- epochBegin
36
- segmentLength
37
- vestingBegin
38
- sharePercentage
39
- distributor ${distributorStr}
33
+ const farmingPoolStr = `{
34
+ epochAmount
35
+ epochBegin
36
+ segmentLength
37
+ vestingBegin
38
+ sharePercentage
39
+ distributor ${distributorStr}
40
40
  }`;
41
- const borrowableStr = `{
42
- id
43
- underlying ${tokenStr}
44
- totalBalance
45
- totalBorrows
46
- borrowRate
47
- reserveFactor
48
- kinkBorrowRate
49
- kinkUtilizationRate
50
- adjustSpeed
51
- borrowIndex
52
- accrualTimestamp
53
- exchangeRate
54
- totalBalanceUSD
55
- totalSupplyUSD
56
- totalBorrowsUSD
57
- borrowTracker
58
- farmingPool ${farmingPoolStr}
41
+ const borrowableStr = `{
42
+ id
43
+ underlying ${tokenStr}
44
+ totalBalance
45
+ totalBorrows
46
+ borrowRate
47
+ reserveFactor
48
+ kinkBorrowRate
49
+ kinkUtilizationRate
50
+ adjustSpeed
51
+ borrowIndex
52
+ accrualTimestamp
53
+ exchangeRate
54
+ totalBalanceUSD
55
+ totalSupplyUSD
56
+ totalBorrowsUSD
57
+ borrowTracker
58
+ farmingPool ${farmingPoolStr}
59
59
  }`;
60
- const collateralStr = `{
61
- id
62
- totalBalance
63
- totalBalanceUSD
64
- safetyMargin
65
- liquidationIncentive
66
- ${factories_1.LIQUIDATION_FEE_FACTORIES.includes(factory) ? "liquidationFee" : ""}
67
- exchangeRate
60
+ const collateralStr = `{
61
+ id
62
+ totalBalance
63
+ totalBalanceUSD
64
+ safetyMargin
65
+ liquidationIncentive
66
+ ${factories_1.LIQUIDATION_FEE_FACTORIES.includes(factory) ? "liquidationFee" : ""}
67
+ exchangeRate
68
68
  }`;
69
- const pairStr = `{
70
- factory
71
- reserve0
72
- reserve1
73
- totalSupply
74
- reserveUSD
75
- token0Price
76
- token1Price
77
- derivedUSD
78
- uniswapV2PairAddress
79
- uniswapV2Factory
80
- isStakedLPToken
81
- exchangeRate
82
- stakingRewards
83
- masterChef
84
- pid
85
- stakedTotalSupply
86
- rewards {
87
- id
88
- rewardRate
89
- rewardsToken ${tokenStr}
90
- periodFinish
91
- }
69
+ const pairStr = `{
70
+ factory
71
+ reserve0
72
+ reserve1
73
+ totalSupply
74
+ reserveUSD
75
+ token0Price
76
+ token1Price
77
+ derivedUSD
78
+ uniswapV2PairAddress
79
+ uniswapV2Factory
80
+ isStakedLPToken
81
+ exchangeRate
82
+ stakingRewards
83
+ masterChef
84
+ pid
85
+ stakedTotalSupply
86
+ rewards {
87
+ id
88
+ rewardRate
89
+ rewardsToken ${tokenStr}
90
+ periodFinish
91
+ }
92
92
  }`;
93
93
  const id_in_string = addressesFilter.length > 0 ? `where: {id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
94
- return (0, graphql_tag_1.default) `{
95
- lendingPools(first: 1000, orderBy: totalBorrowsUSD, orderDirection: desc ${id_in_string}) {
96
- id
97
- borrowable0 ${borrowableStr}
98
- borrowable1 ${borrowableStr}
99
- collateral ${collateralStr}
100
- pair ${pairStr}
101
- }
102
- _meta {
103
- block {
104
- number
105
- }
106
- hasIndexingErrors
107
- }
94
+ return (0, graphql_tag_1.default) `{
95
+ lendingPools(first: 1000, orderBy: totalBorrowsUSD, orderDirection: desc ${id_in_string}) {
96
+ id
97
+ borrowable0 ${borrowableStr}
98
+ borrowable1 ${borrowableStr}
99
+ collateral ${collateralStr}
100
+ pair ${pairStr}
101
+ }
102
+ _meta {
103
+ block {
104
+ number
105
+ }
106
+ hasIndexingErrors
107
+ }
108
108
  }`;
109
109
  }
110
110
  exports.lendingPoolsQuery = lendingPoolsQuery;
111
111
  function lendingPoolsPastQuery(blockNumber, addressesFilter) {
112
- const borrowablePastStr = `{
113
- borrowIndex
114
- accrualTimestamp
115
- exchangeRate
112
+ const borrowablePastStr = `{
113
+ borrowIndex
114
+ accrualTimestamp
115
+ exchangeRate
116
116
  }`;
117
117
  const id_in_string = addressesFilter.length > 0 ? `where: {id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
118
- return (0, graphql_tag_1.default) `{
119
- lendingPools(first: 1000, orderBy: totalBorrowsUSD, orderDirection: desc, block: {number: ${blockNumber}} ${id_in_string}) {
120
- id
121
- borrowable0 ${borrowablePastStr}
122
- borrowable1 ${borrowablePastStr}
123
- }
118
+ return (0, graphql_tag_1.default) `{
119
+ lendingPools(first: 1000, orderBy: totalBorrowsUSD, orderDirection: desc, block: {number: ${blockNumber}} ${id_in_string}) {
120
+ id
121
+ borrowable0 ${borrowablePastStr}
122
+ borrowable1 ${borrowablePastStr}
123
+ }
124
124
  }`;
125
125
  }
126
126
  exports.lendingPoolsPastQuery = lendingPoolsPastQuery;
127
127
  function impermaxChefQuery() {
128
- return (0, graphql_tag_1.default) `{
129
- impermaxChefs(first: 1) {
130
- id
131
- rewardToken
132
- rewardPerSec
133
- totalAllocPoint
134
- }
135
- pools(first: 1000) {
136
- id
137
- allocPoint
138
- rewarder {id}
139
- }
140
- impermaxRewarders(first: 1000) {
141
- rewardToken
142
- rewardPerSec
143
- totalAllocPoint
144
- pools(first: 1000) {
145
- borrowable
146
- allocPoint
147
- }
148
- }
128
+ return (0, graphql_tag_1.default) `{
129
+ impermaxChefs(first: 1) {
130
+ id
131
+ rewardToken
132
+ rewardPerSec
133
+ totalAllocPoint
134
+ }
135
+ pools(first: 1000) {
136
+ id
137
+ allocPoint
138
+ rewarder {id}
139
+ }
140
+ impermaxRewarders(first: 1000) {
141
+ rewardToken
142
+ rewardPerSec
143
+ totalAllocPoint
144
+ pools(first: 1000) {
145
+ borrowable
146
+ allocPoint
147
+ }
148
+ }
149
149
  }`;
150
150
  }
151
151
  exports.impermaxChefQuery = impermaxChefQuery;
152
152
  function pastVolumeQuery(blockNumber, addressesFilter) {
153
153
  const id_in_string = addressesFilter.length > 0 ? `where: {id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
154
- return (0, graphql_tag_1.default) `{
155
- pairs (block: {number: ${blockNumber}} ${id_in_string}) {
156
- id
157
- volumeUSD
158
- }
154
+ return (0, graphql_tag_1.default) `{
155
+ pairs (block: {number: ${blockNumber}} ${id_in_string}) {
156
+ id
157
+ volumeUSD
158
+ }
159
159
  }`;
160
160
  }
161
161
  exports.pastVolumeQuery = pastVolumeQuery;
162
162
  function currentVolumeAndReservesQuery(addressesFilter) {
163
163
  const id_in_string = addressesFilter.length > 0 ? `where: {id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
164
- return (0, graphql_tag_1.default) `{
165
- pairs (${id_in_string}) {
166
- id
167
- reserveUSD
168
- volumeUSD
169
- }
164
+ return (0, graphql_tag_1.default) `{
165
+ pairs (${id_in_string}) {
166
+ id
167
+ reserveUSD
168
+ volumeUSD
169
+ }
170
170
  }`;
171
171
  }
172
172
  exports.currentVolumeAndReservesQuery = currentVolumeAndReservesQuery;
173
173
  function tvlQuery() {
174
- return (0, graphql_tag_1.default) `{
175
- impermaxFactories(first: 1) {
176
- totalBalanceUSD
177
- totalSupplyUSD
178
- totalBorrowsUSD
179
- }
174
+ return (0, graphql_tag_1.default) `{
175
+ impermaxFactories(first: 1) {
176
+ totalBalanceUSD
177
+ totalSupplyUSD
178
+ totalBorrowsUSD
179
+ }
180
180
  }`;
181
181
  }
182
182
  exports.tvlQuery = tvlQuery;
183
183
  function userQuery(account) {
184
- return (0, graphql_tag_1.default) `{
185
- user(id: "${account.toLowerCase()}") {
186
- collateralPositions(first:1000) {
187
- balance
188
- collateral {
189
- lendingPool {
190
- id
191
- }
192
- }
193
- }
194
- supplyPositions(first:1000) {
195
- balance
196
- borrowable {
197
- underlying {
198
- id
199
- }
200
- lendingPool {
201
- id
202
- }
203
- }
204
- }
205
- borrowPositions(first:1000) {
206
- borrowBalance
207
- borrowIndex
208
- borrowable {
209
- underlying {
210
- id
211
- }
212
- lendingPool {
213
- id
214
- }
215
- }
216
- }
217
- }
184
+ return (0, graphql_tag_1.default) `{
185
+ user(id: "${account.toLowerCase()}") {
186
+ collateralPositions(first:1000) {
187
+ balance
188
+ collateral {
189
+ lendingPool {
190
+ id
191
+ }
192
+ }
193
+ }
194
+ supplyPositions(first:1000) {
195
+ balance
196
+ borrowable {
197
+ underlying {
198
+ id
199
+ }
200
+ lendingPool {
201
+ id
202
+ }
203
+ }
204
+ }
205
+ borrowPositions(first:1000) {
206
+ borrowBalance
207
+ borrowIndex
208
+ borrowable {
209
+ underlying {
210
+ id
211
+ }
212
+ lendingPool {
213
+ id
214
+ }
215
+ }
216
+ }
217
+ }
218
218
  }`;
219
219
  }
220
220
  exports.userQuery = userQuery;
221
221
  function ximxQuery() {
222
- return (0, graphql_tag_1.default) `{
223
- ximxes(first: 1) {
224
- totalSupply
225
- totalBalance
226
- exchangeRate
227
- dailyAPR
228
- }
222
+ return (0, graphql_tag_1.default) `{
223
+ ximxes(first: 1) {
224
+ totalSupply
225
+ totalBalance
226
+ exchangeRate
227
+ dailyAPR
228
+ }
229
229
  }`;
230
230
  }
231
231
  exports.ximxQuery = ximxQuery;
232
232
  function lendingVaultsQuery(addressesFilter) {
233
233
  const id_in_string = addressesFilter.length > 0 ? `where: {id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
234
- return (0, graphql_tag_1.default) `{
235
- lendingVaults(first: 1000 ${id_in_string}) {
236
- id
237
- underlying {
238
- id
239
- symbol
240
- name
241
- decimals
242
- }
243
- totalBalance
244
- totalSupply
245
- supplyRate
246
- reserveFactor
247
- exchangeRate
248
- availableLiquidity
249
- lastUpdate
250
- }
251
- _meta {
252
- block {
253
- number
254
- }
255
- hasIndexingErrors
256
- }
234
+ return (0, graphql_tag_1.default) `{
235
+ lendingVaults(first: 1000 ${id_in_string}) {
236
+ id
237
+ underlying {
238
+ id
239
+ symbol
240
+ name
241
+ decimals
242
+ }
243
+ totalBalance
244
+ totalSupply
245
+ supplyRate
246
+ reserveFactor
247
+ exchangeRate
248
+ availableLiquidity
249
+ lastUpdate
250
+ }
251
+ _meta {
252
+ block {
253
+ number
254
+ }
255
+ hasIndexingErrors
256
+ }
257
257
  }`;
258
258
  }
259
259
  exports.lendingVaultsQuery = lendingVaultsQuery;
260
260
  function lendingVaultsUserQuery(account) {
261
- return (0, graphql_tag_1.default) `{
262
- user(id: "${account.toLowerCase()}") {
263
- positions(first:1000) {
264
- tokenBalance
265
- lastExchangeRate
266
- cumulativeEarnings
267
- lendingVault {
268
- id
269
- }
270
- }
271
- }
261
+ return (0, graphql_tag_1.default) `{
262
+ user(id: "${account.toLowerCase()}") {
263
+ positions(first:1000) {
264
+ tokenBalance
265
+ lastExchangeRate
266
+ cumulativeEarnings
267
+ lendingVault {
268
+ id
269
+ }
270
+ }
271
+ }
272
272
  }`;
273
273
  }
274
274
  exports.lendingVaultsUserQuery = lendingVaultsUserQuery;
275
275
  function proposalsMetaQuery(rangeBegin, rangeLength, descending) {
276
- return (0, graphql_tag_1.default) `{
277
- proposals(
278
- orderBy: idInt,
279
- orderDirection: ${descending ? "desc" : "asc"},
280
- first: ${rangeLength},
281
- skip: ${rangeBegin}
282
- ) {
283
- id
284
- state
285
- }
276
+ return (0, graphql_tag_1.default) `{
277
+ proposals(
278
+ orderBy: idInt,
279
+ orderDirection: ${descending ? "desc" : "asc"},
280
+ first: ${rangeLength},
281
+ skip: ${rangeBegin}
282
+ ) {
283
+ id
284
+ state
285
+ }
286
286
  }`;
287
287
  }
288
288
  exports.proposalsMetaQuery = proposalsMetaQuery;
289
289
  function proposalQuery(id) {
290
- return (0, graphql_tag_1.default) `{
291
- proposal(id:${id}) {
292
- id
293
- state
294
- pairConfig {
295
- factory
296
- pair
297
- safetyMarginSqrt
298
- liquidationIncentive
299
- liquidationFee
300
- reserveFactor0
301
- reserveFactor1
302
- kinkUtilizationRate0
303
- kinkUtilizationRate1
304
- adjustSpeed0
305
- adjustSpeed1
306
- borrowTracker0
307
- borrowTracker1
308
- whiteListState
309
- }
310
- }
290
+ return (0, graphql_tag_1.default) `{
291
+ proposal(id:${id}) {
292
+ id
293
+ state
294
+ pairConfig {
295
+ factory
296
+ pair
297
+ safetyMarginSqrt
298
+ liquidationIncentive
299
+ liquidationFee
300
+ reserveFactor0
301
+ reserveFactor1
302
+ kinkUtilizationRate0
303
+ kinkUtilizationRate1
304
+ adjustSpeed0
305
+ adjustSpeed1
306
+ borrowTracker0
307
+ borrowTracker1
308
+ whiteListState
309
+ }
310
+ }
311
311
  }`;
312
312
  }
313
313
  exports.proposalQuery = proposalQuery;
314
314
  function whitelistQuery() {
315
- return (0, graphql_tag_1.default) `{
316
- whitelistStates(first:1000) {
317
- factory
318
- pair
319
- state
320
- }
315
+ return (0, graphql_tag_1.default) `{
316
+ whitelistStates(first:1000) {
317
+ factory
318
+ pair
319
+ state
320
+ }
321
321
  }`;
322
322
  }
323
323
  exports.whitelistQuery = whitelistQuery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "1.2.67",
3
+ "version": "1.2.68",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -1,14 +0,0 @@
1
- import { PoolTokenType } from '../../../config/types';
2
- import LendingPool from './index';
3
- import PoolToken from '../poolToken';
4
- import * as offchain from '../../index';
5
- export default class Borrowable extends PoolToken {
6
- accountLendingPool: LendingPool;
7
- poolToken: offchain.lendingPool.Borrowable;
8
- constructor(accountLendingPool: LendingPool, poolTokenType: PoolTokenType);
9
- private getSupplyPosition;
10
- getAmount(): Promise<number>;
11
- private getBorrowPosition;
12
- getBorrowedAmount(): Promise<number>;
13
- getBorrowedValue(): Promise<number>;
14
- }
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const poolToken_1 = __importDefault(require("../poolToken"));
16
- class Borrowable extends poolToken_1.default {
17
- constructor(accountLendingPool, poolTokenType) {
18
- super();
19
- this.accountLendingPool = accountLendingPool;
20
- this.poolToken = accountLendingPool.lendingPool.poolTokens[poolTokenType];
21
- }
22
- getSupplyPosition() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const userData = yield this.lendingPool.getUserData();
25
- if (!userData)
26
- return undefined;
27
- const supplyPositions = userData.supplyPositions[this.offchainPoolToken.lendingPool.pairAddress];
28
- if (!supplyPositions)
29
- return undefined;
30
- return supplyPositions[this.offchainPoolToken.poolTokenType];
31
- });
32
- }
33
- getAmount() {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- const supplyPosition = yield this.getSupplyPosition();
36
- if (!supplyPosition)
37
- return 0;
38
- const exchangeRate = yield this.offchainPoolToken.getExchangeRate();
39
- const supplyBalance = parseFloat(supplyPosition.balance);
40
- return supplyBalance * exchangeRate;
41
- });
42
- }
43
- getBorrowPosition() {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const userData = yield this.lendingPool.getUserData();
46
- if (!userData)
47
- return undefined;
48
- const borrowPositions = userData.borrowPositions[this.offchainPoolToken.lendingPool.pairAddress];
49
- if (!borrowPositions)
50
- return undefined;
51
- return borrowPositions[this.offchainPoolToken.poolTokenType];
52
- });
53
- }
54
- getBorrowedAmount() {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- const borrowPosition = yield this.getBorrowPosition();
57
- const borrowIndex = yield this.offchainPoolToken.getBorrowIndex();
58
- if (!borrowPosition)
59
- return 0;
60
- const borrowBalance = parseFloat(borrowPosition.borrowBalance);
61
- const userBorrowIndex = parseFloat(borrowPosition.borrowIndex);
62
- return borrowBalance * borrowIndex / userBorrowIndex;
63
- });
64
- }
65
- getBorrowedValue() {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const tokenPrice = yield this.offchainPoolToken.getTokenPriceAccurate();
68
- const borrowedAmount = yield this.getBorrowedAmount();
69
- return borrowedAmount * tokenPrice;
70
- });
71
- }
72
- }
73
- exports.default = Borrowable;
@@ -1,12 +0,0 @@
1
- import { CollateralPosition } from "../../types";
2
- import { PoolTokenType } from '../../../config/types';
3
- import LendingPool from './index';
4
- import PoolToken from '../poolToken';
5
- import * as offchain from '../../index';
6
- export default class Collateral extends PoolToken {
7
- accountLendingPool: LendingPool;
8
- poolToken: offchain.lendingPool.Collateral;
9
- constructor(accountLendingPool: LendingPool, poolTokenType: PoolTokenType);
10
- getCollateralPosition(): Promise<CollateralPosition | undefined>;
11
- getAmount(): Promise<number>;
12
- }