impermax-sdk 1.2.58 → 1.2.59
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.
|
@@ -19,6 +19,7 @@ const farms_1 = require("../../config/farms");
|
|
|
19
19
|
const utils_1 = require("../../utils");
|
|
20
20
|
const amms_1 = require("../../config/amms");
|
|
21
21
|
const factories_1 = require("../../config/factories");
|
|
22
|
+
const offchainAPRHelper_1 = require("../offchainAPRHelper");
|
|
22
23
|
class OffchainLendingPool {
|
|
23
24
|
constructor(offchain, factory, pairAddress) {
|
|
24
25
|
this.getOffchain = () => this.offchain;
|
|
@@ -215,5 +216,16 @@ class OffchainLendingPool {
|
|
|
215
216
|
return totalBorrowsUSDA + totalBorrowsUSDB;
|
|
216
217
|
});
|
|
217
218
|
}
|
|
219
|
+
// Try get APR from defillama
|
|
220
|
+
getTotalAPR() {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
const uniswapV2Pair = (yield this.getLendingPoolData()).pair.uniswapV2PairAddress.toLowerCase();
|
|
223
|
+
if (Object.keys(offchainAPRHelper_1.defillama_ids).includes(uniswapV2Pair)) {
|
|
224
|
+
return yield (0, offchainAPRHelper_1.getDefiLlamaAPR)(offchainAPRHelper_1.defillama_ids[uniswapV2Pair]);
|
|
225
|
+
}
|
|
226
|
+
const [uniswapAPR, stakingAPR] = yield Promise.all([this.getUniswapAPR(), this.getStakingAPR()]);
|
|
227
|
+
return uniswapAPR + stakingAPR;
|
|
228
|
+
});
|
|
229
|
+
}
|
|
218
230
|
}
|
|
219
231
|
exports.default = OffchainLendingPool;
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getDefiLlamaAPR = exports.defillama_ids = void 0;
|
|
13
|
+
const ids = {
|
|
14
|
+
// -------------------------------------- FANTOM ------------------------------------
|
|
15
|
+
// FTM/PLUS
|
|
16
|
+
"0x964cc3a9dbad0ddddc25601abc662b6e193f92f3": "1277ae6c-58cf-43a1-a130-55c9f80e9316",
|
|
17
|
+
// FSONIC/WFTM
|
|
18
|
+
"0x767520fA98e1E24b3326fD42B24c9DCFCe8BcE14": "d3e4b430-f2e5-44b0-a9f1-196d3bf54a2d",
|
|
19
|
+
// WFTM/TANGO
|
|
20
|
+
"0x997fBfb238125dB4e90a62b423bbED2e202edd5A": "c8523f56-c4bb-4213-acdf-6799f20c9ec1",
|
|
21
|
+
// WFTM/SGOAT
|
|
22
|
+
"0xAcB5B7A37310854A6E74dD9889f6a98dA0Ef9975": "dc1f2a39-7952-4460-98eb-ec2e5d9f181c",
|
|
23
|
+
// WFTM/BAY
|
|
24
|
+
"0xA169AF5669A1d5b0a57260918CB035E152Aa3269": "bd208a0f-d9ee-4692-930e-6bcf6e50228c",
|
|
25
|
+
// EQUAL/HOOPS
|
|
26
|
+
"0xfe02fd5b3F8904e2f4108505bEE7cf91E1D179E4": "bc0ada32-62b3-44b4-963d-f09a6484b366",
|
|
27
|
+
// WFTM/ECO
|
|
28
|
+
"0xC2D4eA5547AB3d642f61A2aDadA89c9E85299e69": "48faaded-4501-4a3d-bd60-6ca9b7233dc7",
|
|
29
|
+
// WFTM/EQUAL
|
|
30
|
+
"0x3d6c56f6855b7Cc746fb80848755B0a9c3770122": "2bae2b5d-e3c9-4a3b-ad4e-923d19bb9a2f",
|
|
31
|
+
// MCLB/FBOMB
|
|
32
|
+
"0x68ca64CABbB3d40dBB0de37101A8C0b701f66fD6": "e0d0bad2-1664-49c0-9a67-345b25ec03f8",
|
|
33
|
+
};
|
|
34
|
+
// https://stackoverflow.com/questions/12539574/whats-the-best-way-most-efficient-to-turn-all-the-keys-of-an-object-to-lower
|
|
35
|
+
// Convert all keys to lowercase just in case and export this
|
|
36
|
+
exports.defillama_ids = Object.fromEntries(Object.entries(ids).map(([k, v]) => [k.toLowerCase(), v]));
|
|
37
|
+
// Get the DefiLlama APR for `poolID`
|
|
38
|
+
const getDefiLlamaAPR = (poolId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
let apy;
|
|
40
|
+
try {
|
|
41
|
+
const res = yield fetch(`https://yields.llama.fi/chart/${poolId}`).then(i => i.json());
|
|
42
|
+
apy = res.data[res.data.length - 1].apy;
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
apy = 0;
|
|
46
|
+
}
|
|
47
|
+
// in percentage to match uniswapAPR and stakingAPR
|
|
48
|
+
return apy / 100;
|
|
49
|
+
});
|
|
50
|
+
exports.getDefiLlamaAPR = getDefiLlamaAPR;
|