impermax-sdk 1.1.27 → 1.1.29

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 (134) hide show
  1. package/lib/impermax-router/Account.js +3 -3
  2. package/lib/impermax-router/AccountBorrowable.js +2 -2
  3. package/lib/impermax-router/AccountCollateral.js +3 -3
  4. package/lib/impermax-router/AccountLendingPool.js +14 -14
  5. package/lib/impermax-router/Borrowable.js +4 -4
  6. package/lib/impermax-router/Collateral.js +4 -4
  7. package/lib/impermax-router/Interactions.js +10 -10
  8. package/lib/impermax-router/InteractionsLendingPool.js +7 -7
  9. package/lib/impermax-router/LendingPool.js +1 -1
  10. package/lib/impermax-router/LendingVault.js +1 -1
  11. package/lib/impermax-router/PoolToken.js +2 -2
  12. package/lib/impermax-router/index.js +1 -1
  13. package/lib/index.d.ts +35 -33
  14. package/lib/index.js +93 -66
  15. package/lib/offchain/Account.d.ts +2 -2
  16. package/lib/offchain/Account.js +5 -5
  17. package/lib/offchain/AccountBorrowable.js +3 -3
  18. package/lib/offchain/AccountCollateral.js +3 -3
  19. package/lib/offchain/AccountLendingPool.js +2 -2
  20. package/lib/offchain/Borrowable.d.ts +1 -1
  21. package/lib/offchain/Borrowable.js +10 -10
  22. package/lib/offchain/Collateral.d.ts +1 -1
  23. package/lib/offchain/Collateral.js +9 -9
  24. package/lib/offchain/LendingPool.d.ts +2 -2
  25. package/lib/offchain/LendingPool.js +7 -7
  26. package/lib/offchain/LendingVault.d.ts +4 -4
  27. package/lib/offchain/LendingVault.js +5 -5
  28. package/lib/offchain/PoolToken.d.ts +1 -1
  29. package/lib/offchain/PoolToken.js +4 -4
  30. package/lib/offchain/PriceHelper.d.ts +3 -3
  31. package/lib/offchain/PriceHelper.js +24 -24
  32. package/lib/offchain/SolidexHelper.d.ts +2 -2
  33. package/lib/offchain/SolidexHelper.js +2 -2
  34. package/lib/offchain/account/account.d.ts +19 -0
  35. package/lib/offchain/account/account.js +107 -0
  36. package/lib/offchain/account/borrowable.d.ts +12 -0
  37. package/lib/offchain/account/borrowable.js +93 -0
  38. package/lib/offchain/account/collateral.d.ts +10 -0
  39. package/lib/offchain/account/collateral.js +62 -0
  40. package/lib/offchain/account/index.d.ts +24 -0
  41. package/lib/offchain/account/index.js +118 -0
  42. package/lib/offchain/account/lendingPool/Borrowable.d.ts +14 -0
  43. package/lib/offchain/account/lendingPool/Borrowable.js +70 -0
  44. package/lib/offchain/account/lendingPool/Collateral.d.ts +12 -0
  45. package/lib/offchain/account/lendingPool/Collateral.js +39 -0
  46. package/lib/offchain/account/lendingPool/index.d.ts +20 -0
  47. package/lib/offchain/account/lendingPool/index.js +53 -0
  48. package/lib/offchain/account/lendingPool.d.ts +16 -0
  49. package/lib/offchain/account/lendingPool.js +69 -0
  50. package/lib/offchain/account/lendingVault.d.ts +11 -0
  51. package/lib/offchain/account/lendingVault.js +38 -0
  52. package/lib/offchain/account/poolToken.d.ts +6 -0
  53. package/lib/offchain/account/poolToken.js +21 -0
  54. package/lib/offchain/index.d.ts +10 -6
  55. package/lib/offchain/index.js +24 -11
  56. package/lib/offchain/initializer.js +2 -2
  57. package/lib/offchain/lendingPool/borrowable.d.ts +55 -0
  58. package/lib/offchain/lendingPool/borrowable.js +348 -0
  59. package/lib/offchain/lendingPool/collateral.d.ts +17 -0
  60. package/lib/offchain/lendingPool/collateral.js +69 -0
  61. package/lib/offchain/lendingPool/index.d.ts +43 -0
  62. package/lib/offchain/lendingPool/index.js +208 -0
  63. package/lib/on-chain/Account.js +3 -3
  64. package/lib/on-chain/AccountBorrowable.js +2 -2
  65. package/lib/on-chain/AccountCollateral.js +3 -3
  66. package/lib/on-chain/AccountLendingPool.js +14 -14
  67. package/lib/on-chain/Borrowable.js +4 -4
  68. package/lib/on-chain/Collateral.js +4 -4
  69. package/lib/on-chain/Interactions.js +10 -10
  70. package/lib/on-chain/InteractionsLendingPool.js +7 -7
  71. package/lib/on-chain/LendingPool.js +1 -1
  72. package/lib/on-chain/LendingVault.js +1 -1
  73. package/lib/on-chain/PoolToken.js +2 -2
  74. package/lib/on-chain/index.js +1 -1
  75. package/lib/onchain/Account.js +1 -1
  76. package/lib/onchain/AccountBorrowable.js +4 -4
  77. package/lib/onchain/AccountCollateral.js +2 -2
  78. package/lib/onchain/AccountLendingPool.js +8 -8
  79. package/lib/onchain/AccountPoolToken.js +1 -1
  80. package/lib/onchain/Borrowable.d.ts +2 -2
  81. package/lib/onchain/Borrowable.js +5 -5
  82. package/lib/onchain/Collateral.d.ts +2 -2
  83. package/lib/onchain/Collateral.js +5 -5
  84. package/lib/onchain/InteractionsLendingPool.js +3 -3
  85. package/lib/onchain/LendingPool.d.ts +1 -1
  86. package/lib/onchain/LendingPool.js +2 -2
  87. package/lib/onchain/LendingVault.d.ts +3 -3
  88. package/lib/onchain/LendingVault.js +4 -4
  89. package/lib/onchain/PoolToken.d.ts +2 -2
  90. package/lib/onchain/PoolToken.js +4 -4
  91. package/lib/onchain/account/index.d.ts +40 -0
  92. package/lib/onchain/account/index.js +207 -0
  93. package/lib/onchain/account/interactions/index.d.ts +27 -0
  94. package/lib/onchain/account/interactions/index.js +152 -0
  95. package/lib/onchain/account/interactions/lendingPool/borrowable.d.ts +16 -0
  96. package/lib/onchain/account/interactions/lendingPool/borrowable.js +46 -0
  97. package/lib/onchain/account/interactions/lendingPool/collateral.d.ts +15 -0
  98. package/lib/onchain/account/interactions/lendingPool/collateral.js +30 -0
  99. package/lib/onchain/account/interactions/lendingPool/index.d.ts +41 -0
  100. package/lib/onchain/account/interactions/lendingPool/index.js +121 -0
  101. package/lib/onchain/account/interactions/lendingVault.d.ts +10 -0
  102. package/lib/onchain/account/interactions/lendingVault.js +12 -0
  103. package/lib/onchain/account/interactions/poolToken.d.ts +33 -0
  104. package/lib/onchain/account/interactions/poolToken.js +180 -0
  105. package/lib/onchain/account/lendingPool/borrowable.d.ts +29 -0
  106. package/lib/onchain/account/lendingPool/borrowable.js +132 -0
  107. package/lib/onchain/account/lendingPool/collateral.d.ts +15 -0
  108. package/lib/onchain/account/lendingPool/collateral.js +63 -0
  109. package/lib/onchain/account/lendingPool/index.d.ts +58 -0
  110. package/lib/onchain/account/lendingPool/index.js +271 -0
  111. package/lib/onchain/account/lendingVault.d.ts +10 -0
  112. package/lib/onchain/account/lendingVault.js +35 -0
  113. package/lib/onchain/account/poolToken.d.ts +24 -0
  114. package/lib/onchain/account/poolToken.js +84 -0
  115. package/lib/onchain/impermaxFactory/index.d.ts +22 -0
  116. package/lib/onchain/impermaxFactory/index.js +77 -0
  117. package/lib/onchain/impermaxFactory/lendingPool/borrowable.d.ts +36 -0
  118. package/lib/onchain/impermaxFactory/lendingPool/borrowable.js +150 -0
  119. package/lib/onchain/impermaxFactory/lendingPool/collateral.d.ts +16 -0
  120. package/lib/onchain/impermaxFactory/lendingPool/collateral.js +56 -0
  121. package/lib/onchain/impermaxFactory/lendingPool/index.d.ts +70 -0
  122. package/lib/onchain/impermaxFactory/lendingPool/index.js +294 -0
  123. package/lib/onchain/index.d.ts +9 -4
  124. package/lib/onchain/index.js +42 -7
  125. package/lib/onchain/types.d.ts +1 -1
  126. package/lib/subgraph/Account.js +3 -3
  127. package/lib/subgraph/AccountBorrowable.js +3 -3
  128. package/lib/subgraph/AccountCollateral.js +3 -3
  129. package/lib/subgraph/AccountLendingPool.js +2 -2
  130. package/lib/subgraph/Borrowable.js +9 -9
  131. package/lib/subgraph/Collateral.js +8 -8
  132. package/lib/subgraph/LendingPool.js +5 -5
  133. package/lib/subgraph/PriceHelper.js +4 -4
  134. package/package.json +1 -1
@@ -99,11 +99,11 @@ class Account {
99
99
  return __awaiter(this, void 0, void 0, function* () {
100
100
  if (airdropURL && airdropURL !== '') {
101
101
  try {
102
- const json = yield fetch(airdropURL + '/' + this.account);
102
+ const json = yield fetch(airdropURL + '/' + this.Account2);
103
103
  const data = yield json.json();
104
104
  if (data) {
105
105
  data.amount = ethers_1.BigNumber.from(data.amount);
106
- const isClaimed = yield merkleDistributor.methods.isClaimed(data.index).call();
106
+ const isClaimed = yield merkleDistributor.methods.isClaimed(data.Account).call();
107
107
  if (!isClaimed)
108
108
  return data;
109
109
  }
@@ -159,7 +159,7 @@ class Account {
159
159
  initializeClaimableIBEX(claimableAddress) {
160
160
  return __awaiter(this, void 0, void 0, function* () {
161
161
  const claimable = this.router.contractsHelper.newClaimable(claimableAddress);
162
- return (yield claimable.methods.claim().call({ from: this.account })) / 1e18;
162
+ return (yield claimable.methods.claim().call({ from: this.Account2 })) / 1e18;
163
163
  });
164
164
  }
165
165
  getClaimableIBEX(claimableAddress) {
@@ -24,8 +24,8 @@ class AccountBorrowable extends AccountPoolToken_1.default {
24
24
  this.getBorrowRate = () => __awaiter(this, void 0, void 0, function* () { return (yield this.poolToken.getSubgraphPoolToken()).getBorrowRate(); });
25
25
  this.getAccrualTimestamp = () => __awaiter(this, void 0, void 0, function* () { return (yield this.poolToken.getSubgraphPoolToken()).getAccrualTimestamp(); });
26
26
  this.accountLendingPool = accountLendingPool;
27
- this.account = accountLendingPool.account;
28
- this.poolToken = accountLendingPool.lendingPool.poolTokens[poolTokenType];
27
+ this.account = accountLendingPool.Account;
28
+ this.poolToken = accountLendingPool.LendingPool.poolTokens[poolTokenType];
29
29
  }
30
30
  cleanCache() {
31
31
  super.cleanCache();
@@ -19,8 +19,8 @@ class AccountCollateral extends AccountPoolToken_1.default {
19
19
  super();
20
20
  this.collateralCache = {};
21
21
  this.accountLendingPool = accountLendingPool;
22
- this.account = accountLendingPool.account;
23
- this.poolToken = accountLendingPool.lendingPool.poolTokens[poolTokenType];
22
+ this.account = accountLendingPool.Account;
23
+ this.poolToken = accountLendingPool.LendingPool.poolTokens[poolTokenType];
24
24
  }
25
25
  cleanCache() {
26
26
  super.cleanCache();
@@ -28,7 +28,7 @@ class AccountCollateral extends AccountPoolToken_1.default {
28
28
  }
29
29
  fixStakedLPExchangeRate(n) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
- const stakedLPExchangeRate = yield this.poolToken.lendingPool.getStakedLPExchangeRate();
31
+ const stakedLPExchangeRate = yield this.poolToken.LendingPool.getStakedLPExchangeRate();
32
32
  return (yield n) / stakedLPExchangeRate;
33
33
  });
34
34
  }
@@ -23,8 +23,8 @@ class AccountLendingPool {
23
23
  this.pta = () => this.accountPoolTokens[types_2.PoolTokenType.BorrowableA];
24
24
  this.ptb = () => this.accountPoolTokens[types_2.PoolTokenType.BorrowableB];
25
25
  this.ptc = () => this.accountPoolTokens[types_2.PoolTokenType.Collateral];
26
- this.getSafetyMargin = () => __awaiter(this, void 0, void 0, function* () { return (yield this.lendingPool.getSubgraphLendingPool()).getSafetyMargin(); });
27
- this.getLiquidationPenalty = () => __awaiter(this, void 0, void 0, function* () { return (yield this.lendingPool.getSubgraphLendingPool()).getLiquidationPenalty(); });
26
+ this.getSafetyMargin = () => __awaiter(this, void 0, void 0, function* () { return (yield this.index.getSubgraphLendingPool()).getSafetyMargin(); });
27
+ this.getLiquidationPenalty = () => __awaiter(this, void 0, void 0, function* () { return (yield this.index.getSubgraphLendingPool()).getLiquidationPenalty(); });
28
28
  this.getUiMargin = () => this.account.router.uiMargin;
29
29
  this.account = account;
30
30
  this.lendingPool = lendingPool;
@@ -84,7 +84,7 @@ class AccountLendingPool {
84
84
  return __awaiter(this, void 0, void 0, function* () {
85
85
  const lpEquityUSD = yield this.getLPEquityUSD();
86
86
  const tokenPrice = yield this.ptc().getTokenPriceAccurate();
87
- const stakedLPExchangeRate = yield this.lendingPool.getStakedLPExchangeRate();
87
+ const stakedLPExchangeRate = yield this.index.getStakedLPExchangeRate();
88
88
  return lpEquityUSD / tokenPrice * stakedLPExchangeRate;
89
89
  });
90
90
  }
@@ -116,13 +116,13 @@ class AccountLendingPool {
116
116
  }
117
117
  getValues(changes) {
118
118
  return __awaiter(this, void 0, void 0, function* () {
119
- const [priceA, priceB] = yield this.lendingPool.getPriceDenomLP();
119
+ const [priceA, priceB] = yield this.index.getPriceDenomLP();
120
120
  return this.getValuesFromPrice(changes, priceA, priceB);
121
121
  });
122
122
  }
123
123
  getMarketValues(changes) {
124
124
  return __awaiter(this, void 0, void 0, function* () {
125
- const [priceA, priceB] = yield this.lendingPool.getMarketPriceDenomLP();
125
+ const [priceA, priceB] = yield this.index.getMarketPriceDenomLP();
126
126
  return this.getValuesFromPrice(changes, priceA, priceB);
127
127
  });
128
128
  }
@@ -163,9 +163,9 @@ class AccountLendingPool {
163
163
  }
164
164
  getLiquidationPricesGivenValues(values) {
165
165
  return __awaiter(this, void 0, void 0, function* () {
166
- const currentPrice = yield this.lendingPool.getTWAPPrice();
166
+ const currentPrice = yield this.index.getTWAPPrice();
167
167
  const [priceSwingA, priceSwingB] = yield this.getLiquidationPriceSwingsGivenValues(values);
168
- return !this.account.router.priceInverted ? [currentPrice / priceSwingB, currentPrice * priceSwingA] : [currentPrice / priceSwingA, currentPrice * priceSwingB];
168
+ return !this.Account2.router.priceInverted ? [currentPrice / priceSwingB, currentPrice * priceSwingA] : [currentPrice / priceSwingA, currentPrice * priceSwingB];
169
169
  });
170
170
  }
171
171
  getLiquidationPriceSwings(changes) {
@@ -185,10 +185,10 @@ class AccountLendingPool {
185
185
  // Max Leverage
186
186
  getMaxLeverage() {
187
187
  return __awaiter(this, void 0, void 0, function* () {
188
- const availableCashA = yield this.pta().poolToken.getTotalBalance();
189
- const availableCashB = yield this.ptb().poolToken.getTotalBalance();
190
- const [priceA, priceB] = yield this.lendingPool.getMarketPriceDenomLP();
191
- const [priceATWAP,] = yield this.lendingPool.getPriceDenomLP();
188
+ const availableCashA = yield this.pta().PoolToken.getTotalBalance();
189
+ const availableCashB = yield this.ptb().PoolToken.getTotalBalance();
190
+ const [priceA, priceB] = yield this.index.getMarketPriceDenomLP();
191
+ const [priceATWAP,] = yield this.index.getPriceDenomLP();
192
192
  const diff = priceA > priceATWAP ? priceA / priceATWAP : priceATWAP / priceA;
193
193
  const adjustFactor = 1 / diff;
194
194
  const availableCashValue1 = availableCashA * priceA;
@@ -228,15 +228,15 @@ class AccountLendingPool {
228
228
  const result = [];
229
229
  const farmingAmount = (yield this.pta().getAvailableFarmingReward()) + (yield this.ptb().getAvailableFarmingReward());
230
230
  if (farmingAmount > 0) {
231
- const farmingSymbol = yield this.pta().poolToken.getFarmingTokenSymbol();
231
+ const farmingSymbol = yield this.pta().PoolToken.getFarmingTokenSymbol();
232
232
  result.push({
233
233
  symbol: farmingSymbol,
234
234
  amount: farmingAmount
235
235
  });
236
236
  }
237
237
  const rewarderSymbols = [
238
- yield this.pta().poolToken.getRewarderTokenSymbol(),
239
- yield this.ptb().poolToken.getRewarderTokenSymbol()
238
+ yield this.pta().PoolToken.getRewarderTokenSymbol(),
239
+ yield this.ptb().PoolToken.getRewarderTokenSymbol()
240
240
  ];
241
241
  const rewarderAmounts = [
242
242
  yield this.pta().getAvailableRewarderReward(),
@@ -30,12 +30,12 @@ class Borrowable extends PoolToken_1.default {
30
30
  }
31
31
  getPoolTokenAddress() {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
- return (yield this.lendingPool.getPoolTokenAddresses())[this.poolTokenType];
33
+ return (yield this.index.getPoolTokenAddresses())[this.poolTokenType];
34
34
  });
35
35
  }
36
36
  getSubgraphPoolToken() {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
- const lendingPool = yield this.lendingPool.getSubgraphLendingPool();
38
+ const lendingPool = yield this.index.getSubgraphLendingPool();
39
39
  return lendingPool.poolTokens[this.poolTokenType];
40
40
  });
41
41
  }
@@ -53,13 +53,13 @@ class Borrowable extends PoolToken_1.default {
53
53
  // Price Denom LP
54
54
  getPriceDenomLP() {
55
55
  return __awaiter(this, void 0, void 0, function* () {
56
- const prices = yield this.lendingPool.getPriceDenomLP();
56
+ const prices = yield this.index.getPriceDenomLP();
57
57
  return prices[this.poolTokenType === types_1.PoolTokenType.BorrowableA ? 0 : 1];
58
58
  });
59
59
  }
60
60
  getMarketPriceDenomLP() {
61
61
  return __awaiter(this, void 0, void 0, function* () {
62
- const prices = yield this.lendingPool.getMarketPriceDenomLP();
62
+ const prices = yield this.index.getMarketPriceDenomLP();
63
63
  return prices[this.poolTokenType === types_1.PoolTokenType.BorrowableA ? 0 : 1];
64
64
  });
65
65
  }
@@ -27,12 +27,12 @@ class Collateral extends PoolToken_1.default {
27
27
  }
28
28
  getPoolTokenAddress() {
29
29
  return __awaiter(this, void 0, void 0, function* () {
30
- return (yield this.lendingPool.getPoolTokenAddresses())[this.poolTokenType];
30
+ return (yield this.index.getPoolTokenAddresses())[this.poolTokenType];
31
31
  });
32
32
  }
33
33
  getSubgraphPoolToken() {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
- const lendingPool = yield this.lendingPool.getSubgraphLendingPool();
35
+ const lendingPool = yield this.index.getSubgraphLendingPool();
36
36
  return lendingPool.poolTokens[this.poolTokenType];
37
37
  });
38
38
  }
@@ -43,7 +43,7 @@ class Collateral extends PoolToken_1.default {
43
43
  }
44
44
  initializeToken() {
45
45
  return __awaiter(this, void 0, void 0, function* () {
46
- return this.lendingPool.getUniswapV2Pair();
46
+ return this.index.getUniswapV2Pair();
47
47
  });
48
48
  }
49
49
  initializeExchangeRate() {
@@ -52,7 +52,7 @@ class Collateral extends PoolToken_1.default {
52
52
  });
53
53
  return __awaiter(this, void 0, void 0, function* () {
54
54
  let exchangeRate = yield _super.initializeExchangeRate.call(this);
55
- return exchangeRate * (yield this.lendingPool.getStakedLPExchangeRate());
55
+ return exchangeRate * (yield this.index.getStakedLPExchangeRate());
56
56
  });
57
57
  }
58
58
  }
@@ -27,7 +27,7 @@ class Interactions {
27
27
  }
28
28
  initializeInteractionsLendingPool(factory, pair) {
29
29
  return __awaiter(this, void 0, void 0, function* () {
30
- const lendingPool = yield this.account.getAccountLendingPool(factory, pair);
30
+ const lendingPool = yield this.Account2.getAccountLendingPool(factory, pair);
31
31
  return new InteractionsLendingPool_1.default(this, lendingPool);
32
32
  });
33
33
  }
@@ -42,7 +42,7 @@ class Interactions {
42
42
  }
43
43
  initializeInteractionsLendingVault(vaultAddress) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
- const lendingVault = yield this.account.getAccountLendingVault(vaultAddress);
45
+ const lendingVault = yield this.Account2.getAccountLendingVault(vaultAddress);
46
46
  return new InteractionsLendingVault_1.default(this, lendingVault);
47
47
  });
48
48
  }
@@ -56,8 +56,8 @@ class Interactions {
56
56
  send(method, onTransactionHash, value = ZERO) {
57
57
  return __awaiter(this, void 0, void 0, function* () {
58
58
  try {
59
- yield method.call({ from: this.account.account, value });
60
- return method.send({ from: this.account.account, value }).on('transactionHash', onTransactionHash);
59
+ yield method.call({ from: this.Account2.Account, value });
60
+ return method.send({ from: this.Account2.Account, value }).on('transactionHash', onTransactionHash);
61
61
  }
62
62
  catch (e) {
63
63
  console.error(e);
@@ -77,7 +77,7 @@ class Interactions {
77
77
  }
78
78
  claimAirdrop(airdropData, merkleDistributor, onTransactionHash) {
79
79
  return __awaiter(this, void 0, void 0, function* () {
80
- return this.send(merkleDistributor.methods.claim(airdropData.index, this.account.account, airdropData.amount, airdropData.proof), onTransactionHash);
80
+ return this.send(merkleDistributor.methods.claim(airdropData.Account, this.Account2.Account, airdropData.amount, airdropData.proof), onTransactionHash);
81
81
  });
82
82
  }
83
83
  claims(pairAddresses, onTransactionHash) {
@@ -87,8 +87,8 @@ class Interactions {
87
87
  for (const pairAddress of pairAddresses[factory]) {
88
88
  for (const poolToken of [types_1.PoolTokenType.BorrowableA, types_1.PoolTokenType.BorrowableB]) {
89
89
  requests.push((() => __awaiter(this, void 0, void 0, function* () {
90
- const accountBorrowable = (yield this.account.getAccountLendingPool(factory, pairAddress)).accountPoolTokens[poolToken];
91
- const borrowable = accountBorrowable.poolToken;
90
+ const accountBorrowable = (yield this.Account2.getAccountLendingPool(factory, pairAddress)).accountPoolTokens[poolToken];
91
+ const borrowable = accountBorrowable.PoolToken;
92
92
  const pendingReward = (yield accountBorrowable.getAvailableFarmingReward()) + (yield accountBorrowable.getAvailableRewarderReward());
93
93
  return {
94
94
  hasPendingReward: pendingReward > 0,
@@ -107,14 +107,14 @@ class Interactions {
107
107
  toClaim.push(borrowable.borrowableAddress);
108
108
  }
109
109
  if (toClaim.length > 0) {
110
- const impermaxChef = this.account.router.contractsHelper.impermaxChef;
111
- return this.send(impermaxChef.methods.massHarvest(toClaim, this.account.account), onTransactionHash);
110
+ const impermaxChef = this.Account2.router.contractsHelper.impermaxChef;
111
+ return this.send(impermaxChef.methods.massHarvest(toClaim, this.Account2.Account), onTransactionHash);
112
112
  }
113
113
  });
114
114
  }
115
115
  claimDistributor(claimableAddress, onTransactionHash) {
116
116
  return __awaiter(this, void 0, void 0, function* () {
117
- const claimable = this.account.router.contractsHelper.newClaimable(claimableAddress);
117
+ const claimable = this.Account2.router.contractsHelper.newClaimable(claimableAddress);
118
118
  return this.send(claimable.methods.claim(), onTransactionHash);
119
119
  });
120
120
  }
@@ -33,9 +33,9 @@ class InteractionsLendingPool {
33
33
  }
34
34
  getLeverageAmounts(leverage, slippage) {
35
35
  return __awaiter(this, void 0, void 0, function* () {
36
- const [priceA, priceB] = yield this.accountLendingPool.lendingPool.getMarketPriceDenomLP();
36
+ const [priceA, priceB] = yield this.accountLendingPool.LendingPool.getMarketPriceDenomLP();
37
37
  // This function must use the market price, but the account leverage is calculated with the TWAP, so we need an adjustFactor
38
- const [priceATWAP, priceBTWAP] = yield this.accountLendingPool.lendingPool.getPriceDenomLP();
38
+ const [priceATWAP, priceBTWAP] = yield this.accountLendingPool.LendingPool.getPriceDenomLP();
39
39
  const diff = priceA > priceATWAP ? priceA / priceATWAP : priceATWAP / priceA;
40
40
  const adjustFactor = Math.pow((0, utils_1.impermanentLoss)(Math.pow(diff, 2)), leverage);
41
41
  const currentLeverage = yield this.accountLendingPool.getLeverage();
@@ -64,14 +64,14 @@ class InteractionsLendingPool {
64
64
  return console.error("Permits deadline are not equal");
65
65
  const deadline = permitDataA ? permitDataA.deadline : permitDataB ? permitDataB.deadline : general_1.DEADLINE;
66
66
  const pairAddress = this.getRouterLendingPool().pairAddress;
67
- const account = this.accountLendingPool.account.account;
67
+ const account = this.accountLendingPool.Account.Account;
68
68
  return this.send(router.methods.leverage(pairAddress, amountA, amountB, amountAMin, amountBMin, account, deadline, dataA, dataB), onTransactionHash);
69
69
  });
70
70
  }
71
71
  getDeleverageAmounts(changeCollateralAmount, slippage) {
72
72
  return __awaiter(this, void 0, void 0, function* () {
73
73
  changeCollateralAmount = changeCollateralAmount !== null && changeCollateralAmount !== void 0 ? changeCollateralAmount : 0;
74
- const [priceA, priceB] = yield this.accountLendingPool.lendingPool.getMarketPriceDenomLP();
74
+ const [priceA, priceB] = yield this.accountLendingPool.LendingPool.getMarketPriceDenomLP();
75
75
  const valueForEach = changeCollateralAmount / 2;
76
76
  const bAmountA = priceA > 0 ? valueForEach / priceA : 0;
77
77
  const bAmountB = priceB > 0 ? valueForEach / priceB : 0;
@@ -95,8 +95,8 @@ class InteractionsLendingPool {
95
95
  }
96
96
  trackBorrows(onTransactionHash) {
97
97
  return __awaiter(this, void 0, void 0, function* () {
98
- const account = this.accountLendingPool.account.account;
99
- const claimAggregator = this.interactions.account.router.contractsHelper.claimAggregator;
98
+ const account = this.accountLendingPool.Account.Account;
99
+ const claimAggregator = this.interactions.Account.router.contractsHelper.claimAggregator;
100
100
  const toTrack = [];
101
101
  for (const borrowable of [types_1.PoolTokenType.BorrowableA, types_1.PoolTokenType.BorrowableB]) {
102
102
  const b = this.accountLendingPool.accountPoolTokens[borrowable];
@@ -109,7 +109,7 @@ class InteractionsLendingPool {
109
109
  }
110
110
  reinvest(onTransactionHash) {
111
111
  return __awaiter(this, void 0, void 0, function* () {
112
- const account = this.accountLendingPool.account.account;
112
+ const account = this.accountLendingPool.Account.Account;
113
113
  const stakedLPToken = yield this.getRouterLendingPool().getStakedLPToken();
114
114
  return this.send(stakedLPToken.methods.reinvest(), onTransactionHash);
115
115
  });
@@ -42,7 +42,7 @@ class LendingPool {
42
42
  }
43
43
  getSubgraphLendingPool() {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
- return this.factory.router.subgraph.getLendingPool(this.factory.factory, this.pairAddress);
45
+ return this.factory.router.offchain.getLendingPool(this.factory.factory, this.pairAddress);
46
46
  });
47
47
  }
48
48
  initializePoolTokenAddresses() {
@@ -32,7 +32,7 @@ class LendingVault extends PoolToken_1.default {
32
32
  }
33
33
  getSubgraphPoolToken() {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
- return yield this.router.subgraph.getLendingVault(this.vaultAddress);
35
+ return yield this.router.offchain.getLendingVault(this.vaultAddress);
36
36
  });
37
37
  }
38
38
  initializePoolToken() {
@@ -20,9 +20,9 @@ class PoolToken {
20
20
  }
21
21
  getPoolToken() {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
- if (!this.cache.poolToken)
23
+ if (!this.cache.PoolToken)
24
24
  this.cache.poolToken = this.initializePoolToken();
25
- return this.cache.poolToken;
25
+ return this.cache.PoolToken;
26
26
  });
27
27
  }
28
28
  getToken() {
@@ -9,7 +9,7 @@ const LendingVault_1 = __importDefault(require("./LendingVault"));
9
9
  class ImpermaxRouter {
10
10
  constructor(cfg) {
11
11
  this.network = cfg.network;
12
- this.subgraph = cfg.subgraph;
12
+ this.subgraph = cfg.offchain;
13
13
  this.web3 = cfg.web3;
14
14
  this.chainId = cfg.chainId;
15
15
  this.uiMargin = 1.1;
package/lib/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import Offchain from './offchain';
2
2
  import Onchain from './onchain';
3
+ import * as offchain from './offchain';
4
+ import * as onchain from './onchain';
3
5
  import { CLAIM_AGGREGATOR } from './config/contracts/claim-aggregators';
4
6
  import { IMPERMAX_CHEF } from './config/contracts/impermax-chef';
5
7
  import { IMX } from './config/contracts/imxes';
@@ -16,38 +18,38 @@ import { FarmIndex, Farms, getFarmByStakedLPFactory, hrFarms, STAKED_LP_FACTORY
16
18
  import { APPROVE_AMOUNT, DEADLINE, NOT_SYNCED, ZERO } from './config/general';
17
19
  import { BLOCKS_SUBGRAPH_URL, IMPERMAX_CHEF_SUBGRAPH_URL, IMPERMAX_SUBGRAPH_URL, XIMX_SUBGRAPH_URL } from './config/subgraphs';
18
20
  import { Address, AddressIndex, AmmIndex, DistributorDetails, Factory, FactoryIndex, LendingPoolIndex, NetworkFactoryIndex, NetworkIndex, Networks, PoolTokenType } from './config/types';
19
- import OffchainAccount from './offchain/Account';
20
- import OffchainAccountLendingPool from './offchain/AccountLendingPool';
21
- import OffchainAccountPoolToken from './offchain/AccountPoolToken';
22
- import OffchainAccountCollateral from './offchain/AccountCollateral';
23
- import OffchainAccountBorrowable from './offchain/AccountBorrowable';
24
- import OffchainAccountLendingVault from './offchain/AccountLendingVault';
25
- import OffchainLendingPool from './offchain/LendingPool';
26
- import OffchainPoolToken from './offchain/PoolToken';
27
- import OffchainCollateral from './offchain/Collateral';
28
- import OffchainBorrowable from './offchain/Borrowable';
29
- import OffchainLendingVault from './offchain/LendingVault';
30
- import OffchainPriceHelper from './offchain/PriceHelper';
31
- import OffchainSolidexHelper from './offchain/SolidexHelper';
32
- import OnchainAccount from './onchain/Account';
33
- import OnchainAccountLendingPool from './onchain/AccountLendingPool';
34
- import OnchainAccountPoolToken from './onchain/AccountPoolToken';
35
- import OnchainAccountCollateral from './onchain/AccountCollateral';
36
- import OnchainAccountBorrowable from './onchain/AccountBorrowable';
37
- import OnchainAccountLendingVault from './onchain/AccountLendingVault';
38
- import OnchainContractsHelper from './onchain/ContractsHelper';
39
- import OnchainImpermaxFactory from './onchain/ImpermaxFactory';
40
- import OnchainInteractions from './onchain/Interactions';
41
- import OnchainInteractionsLendingPool from './onchain/InteractionsLendingPool';
42
- import OnchainInteractionsPoolToken from './onchain/InteractionsPoolToken';
43
- import OnchainInteractionsCollateral from './onchain/InteractionsCollateral';
44
- import OnchainInteractionsBorrowable from './onchain/InteractionsBorrowable';
45
- import OnchainInteractionsLendingVault from './onchain/InteractionsLendingVault';
46
- import OnchainLendingPool from './onchain/LendingPool';
47
- import OnchainPoolToken from './onchain/PoolToken';
48
- import OnchainCollateral from './onchain/Collateral';
49
- import OnchainBorrowable from './onchain/Borrowable';
50
- import OnchainLendingVault from './onchain/LendingVault';
21
+ import OffchainAccount from './offchain/account';
22
+ import OffchainAccountLendingPool from './offchain/account/lendingPool';
23
+ import OffchainAccountPoolToken from './offchain/account/poolToken';
24
+ import OffchainAccountCollateral from './offchain/account/lendingPool/collateral';
25
+ import OffchainAccountBorrowable from './offchain/account/lendingPool/borrowable';
26
+ import OffchainAccountLendingVault from './offchain/account/lendingVault';
27
+ import OffchainLendingPool from './offchain/lendingPool';
28
+ import OffchainPoolToken from './offchain/poolToken';
29
+ import OffchainCollateral from './offchain/lendingPool/collateral';
30
+ import OffchainBorrowable from './offchain/lendingPool/borrowable';
31
+ import OffchainLendingVault from './offchain/lendingVault';
32
+ import OffchainPriceHelper from './offchain/priceHelper';
33
+ import OffchainSolidexHelper from './offchain/solidexHelper';
34
+ import OnchainAccount from './onchain/account';
35
+ import OnchainAccountLendingPool from './onchain/account/lendingPool';
36
+ import OnchainAccountPoolToken from './onchain/account/poolToken';
37
+ import OnchainAccountCollateral from './onchain/account/lendingPool/collateral';
38
+ import OnchainAccountBorrowable from './onchain/account/lendingPool/borrowable';
39
+ import OnchainAccountLendingVault from './onchain/account/lendingVault';
40
+ import OnchainContractsHelper from './onchain/contractsHelper';
41
+ import OnchainImpermaxFactory from './onchain/impermaxFactory';
42
+ import OnchainInteractions from './onchain/account/interactions';
43
+ import OnchainInteractionsLendingPool from './onchain/account/interactions/lendingPool';
44
+ import OnchainInteractionsPoolToken from './onchain/account/interactions/poolToken';
45
+ import OnchainInteractionsCollateral from './onchain/account/interactions/lendingPool/collateral';
46
+ import OnchainInteractionsBorrowable from './onchain/account/interactions/lendingPool/borrowable';
47
+ import OnchainInteractionsLendingVault from './onchain/account/interactions/lendingVault';
48
+ import OnchainLendingPool from './onchain/impermaxFactory/lendingPool';
49
+ import OnchainPoolToken from './onchain/poolToken';
50
+ import OnchainCollateral from './onchain/impermaxFactory/lendingPool/collateral';
51
+ import OnchainBorrowable from './onchain/impermaxFactory/lendingPool/borrowable';
52
+ import OnchainLendingVault from './onchain/lendingVault';
51
53
  import { AirdropData, ApprovalType, Changes, Contract, OnchainConfig, NO_CHANGES, PendingRewardUI, PermitData, Values } from './onchain/types';
52
54
  import { BorrowableData, BorrowablePastData, BorrowPosition, CollateralData, CollateralPosition, FarmingPoolData, LendingPoolData, LendingPoolPastData, PairData, PoolTokenData, RewardData, SupplyPosition, TokenData, TvlData, UserData, XimxData } from './offchain/types';
53
- export { CLAIM_AGGREGATOR, IMPERMAX_CHEF, IMX, MERKLE_DISTRIBUTOR_IBEX, MERKLE_DISTRIBUTOR_IBEX_2, MERKLE_DISTRIBUTOR_ETH, ROUTER, SIMPLE_UNISWAP_ORACLE, WETH, MERKLE_URL_ETH, MERKLE_URL_IBEX, MERKLE_URL_IBEX_2, hrAmms, AMM_FACTORY, getAmmByFactory, AMM_SUBGRAPH_URLS, ADD_LIQUIDITY_URLS, AMM_LP_FEE, DEBANK_IDS, ETH_SYMBOL, ETH_NAME, SOLIDEX_FACTORIES, BORROW_FEE_FACTORIES, OLD_KINK_MULTIPLIER_FACTORIES, LIQUIDATION_FEE_FACTORIES, V2_FACTORIES, Farms, hrFarms, FarmIndex, STAKED_LP_FACTORY, getFarmByStakedLPFactory, NOT_SYNCED, DEADLINE, ZERO, APPROVE_AMOUNT, IMPERMAX_SUBGRAPH_URL, IMPERMAX_CHEF_SUBGRAPH_URL, BLOCKS_SUBGRAPH_URL, XIMX_SUBGRAPH_URL, Networks, Factory, PoolTokenType, Amms, Address, NetworkIndex, FactoryIndex, AddressIndex, NetworkFactoryIndex, LendingPoolIndex, AmmIndex, DistributorDetails, Offchain, OffchainLendingPool, OffchainPoolToken, OffchainCollateral, OffchainBorrowable, OffchainLendingVault, OffchainAccount, OffchainAccountLendingPool, OffchainAccountPoolToken, OffchainAccountCollateral, OffchainAccountBorrowable, OffchainAccountLendingVault, OffchainPriceHelper, OffchainSolidexHelper, PoolTokenData, BorrowableData, CollateralData, BorrowablePastData, TokenData, RewardData, PairData, FarmingPoolData, LendingPoolPastData, LendingPoolData, CollateralPosition, SupplyPosition, BorrowPosition, UserData, TvlData, XimxData, Onchain, OnchainLendingPool, OnchainPoolToken, OnchainBorrowable, OnchainCollateral, OnchainLendingVault, OnchainAccount, OnchainAccountLendingPool, OnchainAccountPoolToken, OnchainAccountBorrowable, OnchainAccountCollateral, OnchainAccountLendingVault, OnchainContractsHelper, OnchainImpermaxFactory, OnchainInteractions, OnchainInteractionsLendingPool, OnchainInteractionsPoolToken, OnchainInteractionsCollateral, OnchainInteractionsBorrowable, OnchainInteractionsLendingVault, Contract, ApprovalType, PermitData, OnchainConfig, Changes, NO_CHANGES, Values, AirdropData, PendingRewardUI, };
55
+ export { offchain, onchain, CLAIM_AGGREGATOR, IMPERMAX_CHEF, IMX, MERKLE_DISTRIBUTOR_IBEX, MERKLE_DISTRIBUTOR_IBEX_2, MERKLE_DISTRIBUTOR_ETH, ROUTER, SIMPLE_UNISWAP_ORACLE, WETH, MERKLE_URL_ETH, MERKLE_URL_IBEX, MERKLE_URL_IBEX_2, hrAmms, AMM_FACTORY, getAmmByFactory, AMM_SUBGRAPH_URLS, ADD_LIQUIDITY_URLS, AMM_LP_FEE, DEBANK_IDS, ETH_SYMBOL, ETH_NAME, SOLIDEX_FACTORIES, BORROW_FEE_FACTORIES, OLD_KINK_MULTIPLIER_FACTORIES, LIQUIDATION_FEE_FACTORIES, V2_FACTORIES, Farms, hrFarms, FarmIndex, STAKED_LP_FACTORY, getFarmByStakedLPFactory, NOT_SYNCED, DEADLINE, ZERO, APPROVE_AMOUNT, IMPERMAX_SUBGRAPH_URL, IMPERMAX_CHEF_SUBGRAPH_URL, BLOCKS_SUBGRAPH_URL, XIMX_SUBGRAPH_URL, Networks, Factory, PoolTokenType, Amms, Address, NetworkIndex, FactoryIndex, AddressIndex, NetworkFactoryIndex, LendingPoolIndex, AmmIndex, DistributorDetails, Offchain, OffchainLendingPool, OffchainPoolToken, OffchainCollateral, OffchainBorrowable, OffchainLendingVault, OffchainAccount, OffchainAccountLendingPool, OffchainAccountPoolToken, OffchainAccountCollateral, OffchainAccountBorrowable, OffchainAccountLendingVault, OffchainPriceHelper, OffchainSolidexHelper, PoolTokenData, BorrowableData, CollateralData, BorrowablePastData, TokenData, RewardData, PairData, FarmingPoolData, LendingPoolPastData, LendingPoolData, CollateralPosition, SupplyPosition, BorrowPosition, UserData, TvlData, XimxData, Onchain, OnchainLendingPool, OnchainPoolToken, OnchainBorrowable, OnchainCollateral, OnchainLendingVault, OnchainAccount, OnchainAccountLendingPool, OnchainAccountPoolToken, OnchainAccountBorrowable, OnchainAccountCollateral, OnchainAccountLendingVault, OnchainContractsHelper, OnchainImpermaxFactory, OnchainInteractions, OnchainInteractionsLendingPool, OnchainInteractionsPoolToken, OnchainInteractionsCollateral, OnchainInteractionsBorrowable, OnchainInteractionsLendingVault, Contract, ApprovalType, PermitData, OnchainConfig, Changes, NO_CHANGES, Values, AirdropData, PendingRewardUI, };