impermax-sdk 1.0.21 → 1.0.23
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/config/contracts/impermax-chef.js +2 -1
- package/lib/config/subgraphs.js +2 -1
- package/lib/impermax-router/Account.js +1 -0
- package/lib/impermax-router/AccountBorrowable.d.ts +3 -3
- package/lib/impermax-router/AccountBorrowable.js +14 -27
- package/lib/impermax-router/AccountLendingPool.js +10 -8
- package/lib/impermax-router/Borrowable.d.ts +4 -2
- package/lib/impermax-router/Borrowable.js +17 -6
- package/lib/impermax-router/Interactions.js +5 -16
- package/lib/subgraph/PoolToken.js +8 -1
- package/package.json +1 -1
|
@@ -6,7 +6,8 @@ exports.IMPERMAX_CHEF = {
|
|
|
6
6
|
[types_1.Networks.Ropsten]: '',
|
|
7
7
|
[types_1.Networks.Mainnet]: '',
|
|
8
8
|
[types_1.Networks.Polygon]: '0x89703cA5c6C3BD35f9D288Ff9710BecBFA8C6f7b',
|
|
9
|
-
[types_1.Networks.Arbitrum]: '
|
|
9
|
+
[types_1.Networks.Arbitrum]: '0xcF16FF305eab2E44B568d3148E2EBBBfD48DB126',
|
|
10
|
+
//[Networks.Arbitrum]: '0x99CF05461dd5F94761d4Fae6a2abDa47A93451f5',
|
|
10
11
|
[types_1.Networks.Avalanche]: '0x5475aEd9d11BeaA822e122C36ACDfa0dA2eb086f',
|
|
11
12
|
[types_1.Networks.Moonriver]: '0xD299D53Fc3B09038765af2091a0647e2304a7caa',
|
|
12
13
|
[types_1.Networks.Aurora]: '',
|
package/lib/config/subgraphs.js
CHANGED
|
@@ -42,7 +42,8 @@ exports.IMPERMAX_CHEF_SUBGRAPH_URL = {
|
|
|
42
42
|
[types_1.Networks.Ropsten]: '',
|
|
43
43
|
[types_1.Networks.Mainnet]: '',
|
|
44
44
|
[types_1.Networks.Polygon]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-chef-polygon',
|
|
45
|
-
[
|
|
45
|
+
//[Networks.Arbitrum]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-chef-arbitrum',
|
|
46
|
+
[types_1.Networks.Arbitrum]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-chef-arbitrum-ibex',
|
|
46
47
|
[types_1.Networks.Avalanche]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-chef-avalanche',
|
|
47
48
|
[types_1.Networks.Moonriver]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-chef-moonriver',
|
|
48
49
|
[types_1.Networks.Fantom]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-chef-fantom',
|
|
@@ -60,6 +60,7 @@ class Account {
|
|
|
60
60
|
for (const factory of factories) {
|
|
61
61
|
const requestsLocal = [];
|
|
62
62
|
for (const pairAddress of pairs[factory]) {
|
|
63
|
+
// TODO remove await
|
|
63
64
|
requestsLocal.push((yield this.getAccountLendingPool(factory, pairAddress)).getAvailableReward());
|
|
64
65
|
}
|
|
65
66
|
requests.push(Promise.all(requestsLocal));
|
|
@@ -5,7 +5,7 @@ export default class AccountBorrowable extends AccountPoolToken {
|
|
|
5
5
|
borrowableCache: {
|
|
6
6
|
borrowed?: Promise<number>;
|
|
7
7
|
farmingShares?: Promise<number>;
|
|
8
|
-
|
|
8
|
+
availableFarmingReward?: Promise<number>;
|
|
9
9
|
availableRewarderReward?: Promise<number>;
|
|
10
10
|
};
|
|
11
11
|
cleanCache(): void;
|
|
@@ -15,8 +15,8 @@ export default class AccountBorrowable extends AccountPoolToken {
|
|
|
15
15
|
getMaxBorrowable(): Promise<number>;
|
|
16
16
|
private initializeFarmingShares;
|
|
17
17
|
getFarmingShares(): Promise<number>;
|
|
18
|
-
private
|
|
19
|
-
|
|
18
|
+
private initializeAvailableFarmingReward;
|
|
19
|
+
getAvailableFarmingReward(): Promise<number>;
|
|
20
20
|
private initializeAvailableRewarderReward;
|
|
21
21
|
getAvailableRewarderReward(): Promise<number>;
|
|
22
22
|
}
|
|
@@ -68,16 +68,9 @@ class AccountBorrowable extends AccountPoolToken_1.default {
|
|
|
68
68
|
// Farming Shares
|
|
69
69
|
initializeFarmingShares() {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
if (!(yield this.poolToken.
|
|
71
|
+
if (!(yield this.poolToken.hasImpermaxChef()))
|
|
72
72
|
return 0;
|
|
73
|
-
|
|
74
|
-
const c = (yield this.poolToken.getImpermaxChef().methods.userInfo(yield this.poolToken.getPoolTokenAddress(), this.getAccount()).call()).shares;
|
|
75
|
-
return c;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
const farmingPool = yield this.poolToken.getFarmingPool();
|
|
79
|
-
return (yield farmingPool.methods.recipients(this.getAccount()).call()).shares;
|
|
80
|
-
}
|
|
73
|
+
return (yield this.poolToken.getImpermaxChef().methods.userInfo(yield this.poolToken.getPoolTokenAddress(), this.getAccount()).call()).shares;
|
|
81
74
|
});
|
|
82
75
|
}
|
|
83
76
|
getFarmingShares() {
|
|
@@ -88,31 +81,25 @@ class AccountBorrowable extends AccountPoolToken_1.default {
|
|
|
88
81
|
});
|
|
89
82
|
}
|
|
90
83
|
// Available Reward
|
|
91
|
-
|
|
84
|
+
initializeAvailableFarmingReward() {
|
|
92
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
if (!(yield this.poolToken.
|
|
86
|
+
if (!(yield this.poolToken.hasImpermaxChef()))
|
|
94
87
|
return 0;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return (yield this.poolToken.getImpermaxChef().methods.pendingReward(borrowableAddress, this.getAccount()).call()) / 1e18;
|
|
99
|
-
}
|
|
100
|
-
catch (_a) {
|
|
101
|
-
console.log("Warning: pending reward negative");
|
|
102
|
-
return 0;
|
|
103
|
-
}
|
|
88
|
+
const borrowableAddress = yield this.poolToken.getPoolTokenAddress();
|
|
89
|
+
try {
|
|
90
|
+
return (yield this.poolToken.getImpermaxChef().methods.pendingReward(borrowableAddress, this.getAccount()).call()) / 1e18;
|
|
104
91
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return
|
|
92
|
+
catch (_a) {
|
|
93
|
+
console.log("Warning: pending reward negative");
|
|
94
|
+
return 0;
|
|
108
95
|
}
|
|
109
96
|
});
|
|
110
97
|
}
|
|
111
|
-
|
|
98
|
+
getAvailableFarmingReward() {
|
|
112
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
if (!this.borrowableCache.
|
|
114
|
-
this.borrowableCache.
|
|
115
|
-
return this.borrowableCache.
|
|
100
|
+
if (!this.borrowableCache.availableFarmingReward)
|
|
101
|
+
this.borrowableCache.availableFarmingReward = this.initializeAvailableFarmingReward();
|
|
102
|
+
return this.borrowableCache.availableFarmingReward;
|
|
116
103
|
});
|
|
117
104
|
}
|
|
118
105
|
initializeAvailableRewarderReward() {
|
|
@@ -226,13 +226,15 @@ class AccountLendingPool {
|
|
|
226
226
|
getAvailableReward() {
|
|
227
227
|
return __awaiter(this, void 0, void 0, function* () {
|
|
228
228
|
const result = [];
|
|
229
|
-
const
|
|
230
|
-
if (
|
|
229
|
+
const farmingAmount = (yield this.pta().getAvailableFarmingReward()) + (yield this.ptb().getAvailableFarmingReward());
|
|
230
|
+
if (farmingAmount > 0) {
|
|
231
|
+
const farmingSymbol = yield this.pta().poolToken.getRewarderTokenSymbol();
|
|
231
232
|
result.push({
|
|
232
|
-
symbol:
|
|
233
|
-
amount:
|
|
233
|
+
symbol: farmingSymbol,
|
|
234
|
+
amount: farmingAmount
|
|
234
235
|
});
|
|
235
|
-
|
|
236
|
+
}
|
|
237
|
+
const rewarderSymbols = [
|
|
236
238
|
yield this.pta().poolToken.getRewarderTokenSymbol(),
|
|
237
239
|
yield this.ptb().poolToken.getRewarderTokenSymbol()
|
|
238
240
|
];
|
|
@@ -240,12 +242,12 @@ class AccountLendingPool {
|
|
|
240
242
|
yield this.pta().getAvailableRewarderReward(),
|
|
241
243
|
yield this.ptb().getAvailableRewarderReward()
|
|
242
244
|
];
|
|
243
|
-
if (
|
|
245
|
+
if (rewarderSymbols[0] === rewarderSymbols[1]) {
|
|
244
246
|
const rewarderAmount = rewarderAmounts[0] + rewarderAmounts[1];
|
|
245
247
|
if (rewarderAmount === 0)
|
|
246
248
|
return result;
|
|
247
249
|
result.push({
|
|
248
|
-
symbol:
|
|
250
|
+
symbol: rewarderSymbols[0],
|
|
249
251
|
amount: rewarderAmount
|
|
250
252
|
});
|
|
251
253
|
}
|
|
@@ -254,7 +256,7 @@ class AccountLendingPool {
|
|
|
254
256
|
if (rewarderAmounts[i] === 0)
|
|
255
257
|
continue;
|
|
256
258
|
result.push({
|
|
257
|
-
symbol:
|
|
259
|
+
symbol: rewarderSymbols[i],
|
|
258
260
|
amount: rewarderAmounts[i]
|
|
259
261
|
});
|
|
260
262
|
}
|
|
@@ -6,6 +6,7 @@ export default class Borrowable extends PoolToken {
|
|
|
6
6
|
borrowTracker?: Promise<Address>;
|
|
7
7
|
rewarder?: Promise<Contract>;
|
|
8
8
|
rewarderTokenSymbol?: Promise<string>;
|
|
9
|
+
farmingTokenSymbol?: Promise<string>;
|
|
9
10
|
rewardSpeed?: Promise<number>;
|
|
10
11
|
};
|
|
11
12
|
cleanCache(): void;
|
|
@@ -16,9 +17,10 @@ export default class Borrowable extends PoolToken {
|
|
|
16
17
|
private initializeBorrowTracker;
|
|
17
18
|
getBorrowTracker(): Promise<string>;
|
|
18
19
|
hasFarming(): Promise<boolean>;
|
|
19
|
-
hasImpermaxChef(): Promise<boolean>;
|
|
20
|
-
getFarmingPool(): Promise<Contract>;
|
|
21
20
|
getImpermaxChef: () => any;
|
|
21
|
+
hasImpermaxChef(): Promise<boolean>;
|
|
22
|
+
private initializeFarmingTokenSymbol;
|
|
23
|
+
getFarmingTokenSymbol(): Promise<string>;
|
|
22
24
|
private initializeRewarder;
|
|
23
25
|
getRewarder(): Promise<any>;
|
|
24
26
|
hasRewarder(): Promise<boolean>;
|
|
@@ -18,6 +18,7 @@ class Borrowable extends PoolToken_1.default {
|
|
|
18
18
|
constructor() {
|
|
19
19
|
super(...arguments);
|
|
20
20
|
this.borrowableCache = {};
|
|
21
|
+
// Impermax Chef
|
|
21
22
|
this.getImpermaxChef = () => this.getContractHelper().impermaxChef;
|
|
22
23
|
}
|
|
23
24
|
cleanCache() {
|
|
@@ -64,8 +65,8 @@ class Borrowable extends PoolToken_1.default {
|
|
|
64
65
|
}
|
|
65
66
|
hasFarming() {
|
|
66
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
|
|
68
|
-
return
|
|
68
|
+
// remove old farming contracts, now it only has farming if it has the impermaxChef
|
|
69
|
+
return this.hasImpermaxChef();
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
hasImpermaxChef() {
|
|
@@ -75,13 +76,23 @@ class Borrowable extends PoolToken_1.default {
|
|
|
75
76
|
return borrowTracker.toLowerCase() === ((_a = this.getImpermaxChef()._address) !== null && _a !== void 0 ? _a : "").toLowerCase();
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
+
initializeFarmingTokenSymbol() {
|
|
79
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
if (!(yield this.
|
|
81
|
-
return
|
|
82
|
-
|
|
81
|
+
if (!(yield this.hasImpermaxChef()))
|
|
82
|
+
return "";
|
|
83
|
+
const impermaxChef = yield this.getImpermaxChef();
|
|
84
|
+
const farmingTokenAddress = yield impermaxChef.methods.rewardToken().call();
|
|
85
|
+
return this.getContractHelper().newERC20(farmingTokenAddress).methods.symbol().call();
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
getFarmingTokenSymbol() {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
if (!this.borrowableCache.farmingTokenSymbol)
|
|
91
|
+
this.borrowableCache.farmingTokenSymbol = this.initializeFarmingTokenSymbol();
|
|
92
|
+
return this.borrowableCache.farmingTokenSymbol;
|
|
83
93
|
});
|
|
84
94
|
}
|
|
95
|
+
// Farming Pool Rewarder
|
|
85
96
|
initializeRewarder() {
|
|
86
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
98
|
const poolTokenAddress = yield this.getPoolTokenAddress();
|
|
@@ -61,11 +61,10 @@ class Interactions {
|
|
|
61
61
|
requests.push((() => __awaiter(this, void 0, void 0, function* () {
|
|
62
62
|
const accountBorrowable = (yield this.account.getAccountLendingPool(factory, pairAddress)).accountPoolTokens[poolToken];
|
|
63
63
|
const borrowable = accountBorrowable.poolToken;
|
|
64
|
-
const pendingReward = (yield accountBorrowable.
|
|
64
|
+
const pendingReward = (yield accountBorrowable.getAvailableFarmingReward()) + (yield accountBorrowable.getAvailableRewarderReward());
|
|
65
65
|
return {
|
|
66
66
|
hasPendingReward: pendingReward > 0,
|
|
67
67
|
hasImpermaxChef: yield borrowable.hasImpermaxChef(),
|
|
68
|
-
farmingPool: yield borrowable.getFarmingPool(),
|
|
69
68
|
borrowableAddress: yield borrowable.getPoolTokenAddress(),
|
|
70
69
|
};
|
|
71
70
|
}))());
|
|
@@ -73,25 +72,15 @@ class Interactions {
|
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
const data = yield Promise.all(requests);
|
|
76
|
-
const
|
|
77
|
-
const toClaimThroughAggregator = [];
|
|
75
|
+
const toClaim = [];
|
|
78
76
|
for (const borrowable of data) {
|
|
79
77
|
if (!borrowable.hasPendingReward)
|
|
80
78
|
continue;
|
|
81
|
-
|
|
82
|
-
toClaimThroughChef.push(borrowable.borrowableAddress);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
toClaimThroughAggregator.push(borrowable.farmingPool._address);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (toClaimThroughAggregator.length > 0) {
|
|
89
|
-
const claimAggregator = this.account.router.contractsHelper.claimAggregator;
|
|
90
|
-
return this.send(claimAggregator.methods.claims(this.account.account, toClaimThroughAggregator), onTransactionHash);
|
|
79
|
+
toClaim.push(borrowable.borrowableAddress);
|
|
91
80
|
}
|
|
92
|
-
|
|
81
|
+
if (toClaim.length > 0) {
|
|
93
82
|
const impermaxChef = this.account.router.contractsHelper.impermaxChef;
|
|
94
|
-
return this.send(impermaxChef.methods.massHarvest(
|
|
83
|
+
return this.send(impermaxChef.methods.massHarvest(toClaim, this.account.account), onTransactionHash);
|
|
95
84
|
}
|
|
96
85
|
});
|
|
97
86
|
}
|
|
@@ -321,7 +321,14 @@ class PoolToken {
|
|
|
321
321
|
APR: (0, utils_1.toAPR)((rewardPrice * reward.rewardRate) / totalBorrowedUSD),
|
|
322
322
|
symbol: reward.rewardToken == "0x98878b06940ae243284ca214f92bb71a2b032b8a" ? "WMOVR" :
|
|
323
323
|
reward.rewardToken == "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270" ? "WMATIC" :
|
|
324
|
-
"IMX"
|
|
324
|
+
reward.rewardToken == "0x6659a9c5cd313974343e30b4fdffd95bd4b4dcd2" ? "IMX" :
|
|
325
|
+
reward.rewardToken == "0x7b35ce522cb72e4077baeb96cb923a5529764a00" ? "IMX" :
|
|
326
|
+
reward.rewardToken == "0x60bb3d364b765c497c8ce50ae0ae3f0882c5bd05" ? "IMX" :
|
|
327
|
+
reward.rewardToken == "0x9c67ee39e3c4954396b9142010653f17257dd39c" ? "IMX" :
|
|
328
|
+
reward.rewardToken == "0xea6887e4a9cda1b77e70129e5fba830cdb5cddef" ? "IMX" :
|
|
329
|
+
reward.rewardToken == "0x900f1Ec5819FA087d368877cD03B265Bf1802667" ? "IMX" :
|
|
330
|
+
reward.rewardToken == "0xea38f1ccf77bf43f352636241b05dd8f6f5f52b2" ? "IMX" :
|
|
331
|
+
"IBEX",
|
|
325
332
|
});
|
|
326
333
|
}
|
|
327
334
|
return rewards;
|