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.
- package/lib/impermax-router/Account.js +3 -3
- package/lib/impermax-router/AccountBorrowable.js +2 -2
- package/lib/impermax-router/AccountCollateral.js +3 -3
- package/lib/impermax-router/AccountLendingPool.js +14 -14
- package/lib/impermax-router/Borrowable.js +4 -4
- package/lib/impermax-router/Collateral.js +4 -4
- package/lib/impermax-router/Interactions.js +10 -10
- package/lib/impermax-router/InteractionsLendingPool.js +7 -7
- package/lib/impermax-router/LendingPool.js +1 -1
- package/lib/impermax-router/LendingVault.js +1 -1
- package/lib/impermax-router/PoolToken.js +2 -2
- package/lib/impermax-router/index.js +1 -1
- package/lib/index.d.ts +35 -33
- package/lib/index.js +93 -66
- package/lib/offchain/Account.d.ts +2 -2
- package/lib/offchain/Account.js +5 -5
- package/lib/offchain/AccountBorrowable.js +3 -3
- package/lib/offchain/AccountCollateral.js +3 -3
- package/lib/offchain/AccountLendingPool.js +2 -2
- package/lib/offchain/Borrowable.d.ts +1 -1
- package/lib/offchain/Borrowable.js +10 -10
- package/lib/offchain/Collateral.d.ts +1 -1
- package/lib/offchain/Collateral.js +9 -9
- package/lib/offchain/LendingPool.d.ts +2 -2
- package/lib/offchain/LendingPool.js +7 -7
- package/lib/offchain/LendingVault.d.ts +4 -4
- package/lib/offchain/LendingVault.js +5 -5
- package/lib/offchain/PoolToken.d.ts +1 -1
- package/lib/offchain/PoolToken.js +4 -4
- package/lib/offchain/PriceHelper.d.ts +3 -3
- package/lib/offchain/PriceHelper.js +24 -24
- package/lib/offchain/SolidexHelper.d.ts +2 -2
- package/lib/offchain/SolidexHelper.js +2 -2
- package/lib/offchain/account/account.d.ts +19 -0
- package/lib/offchain/account/account.js +107 -0
- package/lib/offchain/account/borrowable.d.ts +12 -0
- package/lib/offchain/account/borrowable.js +93 -0
- package/lib/offchain/account/collateral.d.ts +10 -0
- package/lib/offchain/account/collateral.js +62 -0
- package/lib/offchain/account/index.d.ts +24 -0
- package/lib/offchain/account/index.js +118 -0
- package/lib/offchain/account/lendingPool/Borrowable.d.ts +14 -0
- package/lib/offchain/account/lendingPool/Borrowable.js +70 -0
- package/lib/offchain/account/lendingPool/Collateral.d.ts +12 -0
- package/lib/offchain/account/lendingPool/Collateral.js +39 -0
- package/lib/offchain/account/lendingPool/index.d.ts +20 -0
- package/lib/offchain/account/lendingPool/index.js +53 -0
- package/lib/offchain/account/lendingPool.d.ts +16 -0
- package/lib/offchain/account/lendingPool.js +69 -0
- package/lib/offchain/account/lendingVault.d.ts +11 -0
- package/lib/offchain/account/lendingVault.js +38 -0
- package/lib/offchain/account/poolToken.d.ts +6 -0
- package/lib/offchain/account/poolToken.js +21 -0
- package/lib/offchain/index.d.ts +10 -6
- package/lib/offchain/index.js +24 -11
- package/lib/offchain/initializer.js +2 -2
- package/lib/offchain/lendingPool/borrowable.d.ts +55 -0
- package/lib/offchain/lendingPool/borrowable.js +348 -0
- package/lib/offchain/lendingPool/collateral.d.ts +17 -0
- package/lib/offchain/lendingPool/collateral.js +69 -0
- package/lib/offchain/lendingPool/index.d.ts +43 -0
- package/lib/offchain/lendingPool/index.js +208 -0
- package/lib/on-chain/Account.js +3 -3
- package/lib/on-chain/AccountBorrowable.js +2 -2
- package/lib/on-chain/AccountCollateral.js +3 -3
- package/lib/on-chain/AccountLendingPool.js +14 -14
- package/lib/on-chain/Borrowable.js +4 -4
- package/lib/on-chain/Collateral.js +4 -4
- package/lib/on-chain/Interactions.js +10 -10
- package/lib/on-chain/InteractionsLendingPool.js +7 -7
- package/lib/on-chain/LendingPool.js +1 -1
- package/lib/on-chain/LendingVault.js +1 -1
- package/lib/on-chain/PoolToken.js +2 -2
- package/lib/on-chain/index.js +1 -1
- package/lib/onchain/Account.js +1 -1
- package/lib/onchain/AccountBorrowable.js +4 -4
- package/lib/onchain/AccountCollateral.js +2 -2
- package/lib/onchain/AccountLendingPool.js +8 -8
- package/lib/onchain/AccountPoolToken.js +1 -1
- package/lib/onchain/Borrowable.d.ts +2 -2
- package/lib/onchain/Borrowable.js +5 -5
- package/lib/onchain/Collateral.d.ts +2 -2
- package/lib/onchain/Collateral.js +5 -5
- package/lib/onchain/InteractionsLendingPool.js +3 -3
- package/lib/onchain/LendingPool.d.ts +1 -1
- package/lib/onchain/LendingPool.js +2 -2
- package/lib/onchain/LendingVault.d.ts +3 -3
- package/lib/onchain/LendingVault.js +4 -4
- package/lib/onchain/PoolToken.d.ts +2 -2
- package/lib/onchain/PoolToken.js +4 -4
- package/lib/onchain/account/index.d.ts +40 -0
- package/lib/onchain/account/index.js +207 -0
- package/lib/onchain/account/interactions/index.d.ts +27 -0
- package/lib/onchain/account/interactions/index.js +152 -0
- package/lib/onchain/account/interactions/lendingPool/borrowable.d.ts +16 -0
- package/lib/onchain/account/interactions/lendingPool/borrowable.js +46 -0
- package/lib/onchain/account/interactions/lendingPool/collateral.d.ts +15 -0
- package/lib/onchain/account/interactions/lendingPool/collateral.js +30 -0
- package/lib/onchain/account/interactions/lendingPool/index.d.ts +41 -0
- package/lib/onchain/account/interactions/lendingPool/index.js +121 -0
- package/lib/onchain/account/interactions/lendingVault.d.ts +10 -0
- package/lib/onchain/account/interactions/lendingVault.js +12 -0
- package/lib/onchain/account/interactions/poolToken.d.ts +33 -0
- package/lib/onchain/account/interactions/poolToken.js +180 -0
- package/lib/onchain/account/lendingPool/borrowable.d.ts +29 -0
- package/lib/onchain/account/lendingPool/borrowable.js +132 -0
- package/lib/onchain/account/lendingPool/collateral.d.ts +15 -0
- package/lib/onchain/account/lendingPool/collateral.js +63 -0
- package/lib/onchain/account/lendingPool/index.d.ts +58 -0
- package/lib/onchain/account/lendingPool/index.js +271 -0
- package/lib/onchain/account/lendingVault.d.ts +10 -0
- package/lib/onchain/account/lendingVault.js +35 -0
- package/lib/onchain/account/poolToken.d.ts +24 -0
- package/lib/onchain/account/poolToken.js +84 -0
- package/lib/onchain/impermaxFactory/index.d.ts +22 -0
- package/lib/onchain/impermaxFactory/index.js +77 -0
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.d.ts +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.js +150 -0
- package/lib/onchain/impermaxFactory/lendingPool/collateral.d.ts +16 -0
- package/lib/onchain/impermaxFactory/lendingPool/collateral.js +56 -0
- package/lib/onchain/impermaxFactory/lendingPool/index.d.ts +70 -0
- package/lib/onchain/impermaxFactory/lendingPool/index.js +294 -0
- package/lib/onchain/index.d.ts +9 -4
- package/lib/onchain/index.js +42 -7
- package/lib/onchain/types.d.ts +1 -1
- package/lib/subgraph/Account.js +3 -3
- package/lib/subgraph/AccountBorrowable.js +3 -3
- package/lib/subgraph/AccountCollateral.js +3 -3
- package/lib/subgraph/AccountLendingPool.js +2 -2
- package/lib/subgraph/Borrowable.js +9 -9
- package/lib/subgraph/Collateral.js +8 -8
- package/lib/subgraph/LendingPool.js +5 -5
- package/lib/subgraph/PriceHelper.js +4 -4
- 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.
|
|
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.
|
|
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.
|
|
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.
|
|
28
|
-
this.poolToken = accountLendingPool.
|
|
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.
|
|
23
|
-
this.poolToken = accountLendingPool.
|
|
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.
|
|
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.
|
|
27
|
-
this.getLiquidationPenalty = () => __awaiter(this, void 0, void 0, function* () { return (yield this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
166
|
+
const currentPrice = yield this.index.getTWAPPrice();
|
|
167
167
|
const [priceSwingA, priceSwingB] = yield this.getLiquidationPriceSwingsGivenValues(values);
|
|
168
|
-
return !this.
|
|
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().
|
|
189
|
-
const availableCashB = yield this.ptb().
|
|
190
|
-
const [priceA, priceB] = yield this.
|
|
191
|
-
const [priceATWAP,] = yield this.
|
|
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().
|
|
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().
|
|
239
|
-
yield this.ptb().
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
60
|
-
return method.send({ from: this.
|
|
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.
|
|
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.
|
|
91
|
-
const borrowable = accountBorrowable.
|
|
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.
|
|
111
|
-
return this.send(impermaxChef.methods.massHarvest(toClaim, this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
99
|
-
const claimAggregator = this.interactions.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
23
|
+
if (!this.cache.PoolToken)
|
|
24
24
|
this.cache.poolToken = this.initializePoolToken();
|
|
25
|
-
return this.cache.
|
|
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.
|
|
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/
|
|
20
|
-
import OffchainAccountLendingPool from './offchain/
|
|
21
|
-
import OffchainAccountPoolToken from './offchain/
|
|
22
|
-
import OffchainAccountCollateral from './offchain/
|
|
23
|
-
import OffchainAccountBorrowable from './offchain/
|
|
24
|
-
import OffchainAccountLendingVault from './offchain/
|
|
25
|
-
import OffchainLendingPool from './offchain/
|
|
26
|
-
import OffchainPoolToken from './offchain/
|
|
27
|
-
import OffchainCollateral from './offchain/
|
|
28
|
-
import OffchainBorrowable from './offchain/
|
|
29
|
-
import OffchainLendingVault from './offchain/
|
|
30
|
-
import OffchainPriceHelper from './offchain/
|
|
31
|
-
import OffchainSolidexHelper from './offchain/
|
|
32
|
-
import OnchainAccount from './onchain/
|
|
33
|
-
import OnchainAccountLendingPool from './onchain/
|
|
34
|
-
import OnchainAccountPoolToken from './onchain/
|
|
35
|
-
import OnchainAccountCollateral from './onchain/
|
|
36
|
-
import OnchainAccountBorrowable from './onchain/
|
|
37
|
-
import OnchainAccountLendingVault from './onchain/
|
|
38
|
-
import OnchainContractsHelper from './onchain/
|
|
39
|
-
import OnchainImpermaxFactory from './onchain/
|
|
40
|
-
import OnchainInteractions from './onchain/
|
|
41
|
-
import OnchainInteractionsLendingPool from './onchain/
|
|
42
|
-
import OnchainInteractionsPoolToken from './onchain/
|
|
43
|
-
import OnchainInteractionsCollateral from './onchain/
|
|
44
|
-
import OnchainInteractionsBorrowable from './onchain/
|
|
45
|
-
import OnchainInteractionsLendingVault from './onchain/
|
|
46
|
-
import OnchainLendingPool from './onchain/
|
|
47
|
-
import OnchainPoolToken from './onchain/
|
|
48
|
-
import OnchainCollateral from './onchain/
|
|
49
|
-
import OnchainBorrowable from './onchain/
|
|
50
|
-
import OnchainLendingVault from './onchain/
|
|
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, };
|