impermax-sdk 1.2.66 → 1.2.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config/amms.js +1 -1
- package/lib/offchain/offchainPriceHelper.js +8 -2
- package/lib/offchain/query.js +247 -247
- package/package.json +1 -1
- package/lib/offchain/account/lendingPool/borrowable.d.ts +0 -14
- package/lib/offchain/account/lendingPool/borrowable.js +0 -73
- package/lib/offchain/account/lendingPool/collateral.d.ts +0 -12
- package/lib/offchain/account/lendingPool/collateral.js +0 -42
- package/lib/offchain/account/lendingVault.d.ts +0 -11
- package/lib/offchain/account/lendingVault.js +0 -38
- package/lib/offchain/account/poolToken.d.ts +0 -6
- package/lib/offchain/account/poolToken.js +0 -21
- package/lib/offchain/initializer.d.ts +0 -32
- package/lib/offchain/initializer.js +0 -627
- package/lib/offchain/lendingPool/borrowable.d.ts +0 -55
- package/lib/offchain/lendingPool/borrowable.js +0 -351
- package/lib/offchain/lendingPool/collateral.d.ts +0 -17
- package/lib/offchain/lendingPool/collateral.js +0 -72
- package/lib/offchain/lendingVault.d.ts +0 -22
- package/lib/offchain/lendingVault.js +0 -115
- package/lib/offchain/poolToken.d.ts +0 -20
- package/lib/offchain/poolToken.js +0 -120
- package/lib/offchain/priceHelper.d.ts +0 -21
- package/lib/offchain/priceHelper.js +0 -195
- package/lib/offchain/solidexHelper.d.ts +0 -16
- package/lib/offchain/solidexHelper.js +0 -58
- package/lib/offchain/types.d.ts +0 -150
- package/lib/offchain/types.js +0 -3
- package/lib/onchain/account/interactions/index.d.ts +0 -28
- package/lib/onchain/account/interactions/index.js +0 -158
- package/lib/onchain/account/interactions/lendingPool/borrowable.d.ts +0 -16
- package/lib/onchain/account/interactions/lendingPool/borrowable.js +0 -49
- package/lib/onchain/account/interactions/lendingPool/collateral.d.ts +0 -15
- package/lib/onchain/account/interactions/lendingPool/collateral.js +0 -33
- package/lib/onchain/account/interactions/lendingPool/index.d.ts +0 -41
- package/lib/onchain/account/interactions/lendingPool/index.js +0 -120
- package/lib/onchain/account/interactions/lendingVault.d.ts +0 -10
- package/lib/onchain/account/interactions/lendingVault.js +0 -12
- package/lib/onchain/account/interactions/poolToken.d.ts +0 -33
- package/lib/onchain/account/interactions/poolToken.js +0 -180
- package/lib/onchain/account/lendingPool/borrowable.d.ts +0 -29
- package/lib/onchain/account/lendingPool/borrowable.js +0 -135
- package/lib/onchain/account/lendingPool/collateral.d.ts +0 -15
- package/lib/onchain/account/lendingPool/collateral.js +0 -66
- package/lib/onchain/account/lendingVault.d.ts +0 -10
- package/lib/onchain/account/lendingVault.js +0 -35
- package/lib/onchain/account/poolToken.d.ts +0 -24
- package/lib/onchain/account/poolToken.js +0 -84
- package/lib/onchain/contractsHelper.d.ts +0 -29
- package/lib/onchain/contractsHelper.js +0 -52
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.d.ts +0 -36
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.js +0 -153
- package/lib/onchain/impermaxFactory/lendingPool/collateral.d.ts +0 -17
- package/lib/onchain/impermaxFactory/lendingPool/collateral.js +0 -59
- package/lib/onchain/interactions/lendingPool/borrowable.d.ts +0 -14
- package/lib/onchain/interactions/lendingPool/borrowable.js +0 -47
- package/lib/onchain/interactions/lendingPool/collateral.d.ts +0 -13
- package/lib/onchain/interactions/lendingPool/collateral.js +0 -31
- package/lib/onchain/interactions/lendingVault.d.ts +0 -8
- package/lib/onchain/interactions/lendingVault.js +0 -15
- package/lib/onchain/interactions/poolToken.d.ts +0 -31
- package/lib/onchain/interactions/poolToken.js +0 -181
- package/lib/onchain/lendingVault.d.ts +0 -17
- package/lib/onchain/lendingVault.js +0 -56
- package/lib/onchain/poolToken.d.ts +0 -32
- package/lib/onchain/poolToken.js +0 -121
- package/lib/onchain/types.d.ts +0 -45
- package/lib/onchain/types.js +0 -14
- package/lib/utils/price-from-reserves.d.ts +0 -2
- package/lib/utils/price-from-reserves.js +0 -19
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const eth_1 = require("../config/eth");
|
|
13
|
-
const weths_1 = require("../config/contracts/weths");
|
|
14
|
-
class PoolToken {
|
|
15
|
-
// Helpers
|
|
16
|
-
getPoolTokenParam(param) {
|
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const poolTokenData = yield this.getPoolTokenData();
|
|
19
|
-
return poolTokenData[param];
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
getPoolTokenParamFloat(param) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
return parseFloat(yield this.getPoolTokenParam(param));
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
getUnderlyingParam(param) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const poolTokenData = yield this.getPoolTokenData();
|
|
30
|
-
return poolTokenData.underlying[param];
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
// Name
|
|
34
|
-
getName() {
|
|
35
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const underlying = yield this.getUnderlyingAddress();
|
|
37
|
-
if (underlying.toLowerCase() === weths_1.WETH[this.getOffchain().network].toLowerCase())
|
|
38
|
-
return eth_1.ETH_NAME[this.getOffchain().network];
|
|
39
|
-
if (underlying.toLowerCase() === "0xa3fa99a148fa48d14ed51d610c367c61876997f1")
|
|
40
|
-
return "MIMATIC";
|
|
41
|
-
if (underlying.toLowerCase() === "0x2e9a6df78e42a30712c10a9dc4b1c8656f8f2879")
|
|
42
|
-
return "Maker";
|
|
43
|
-
return this.getUnderlyingParam("name");
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Symbol
|
|
47
|
-
getSymbol() {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const underlying = yield this.getUnderlyingAddress();
|
|
50
|
-
if (underlying.toLowerCase() === weths_1.WETH[this.getOffchain().network].toLowerCase())
|
|
51
|
-
return eth_1.ETH_SYMBOL[this.getOffchain().network];
|
|
52
|
-
if (underlying.toLowerCase() === "0xa3fa99a148fa48d14ed51d610c367c61876997f1")
|
|
53
|
-
return "MAI";
|
|
54
|
-
if (underlying.toLowerCase() === "0x2e9a6df78e42a30712c10a9dc4b1c8656f8f2879")
|
|
55
|
-
return "MKR";
|
|
56
|
-
if (underlying.toLowerCase() === "0xc165d941481e68696f43ee6e99bfb2b23e0e3114")
|
|
57
|
-
return "OXDv1";
|
|
58
|
-
if (underlying.toLowerCase() === "0xc5a9848b9d145965d821aaec8fa32aaee026492d")
|
|
59
|
-
return "OXDv2";
|
|
60
|
-
if (underlying.toLowerCase() === "0x6ae7dfc73e0dde2aa99ac063dcf7e8a63265108c")
|
|
61
|
-
return "JPYCv1";
|
|
62
|
-
if (underlying.toLowerCase() === "0x431d5dff03120afa4bdf332c61a6e1766ef37bdb")
|
|
63
|
-
return "JPYCv2";
|
|
64
|
-
return this.getUnderlyingParam("symbol");
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
// Decimals
|
|
68
|
-
getDecimals() {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
return parseInt(yield this.getUnderlyingParam("decimals"));
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
// ExchangeRate
|
|
74
|
-
getExchangeRate() {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
return this.getPoolTokenParamFloat("exchangeRate");
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
// Underlying Address
|
|
80
|
-
getUnderlyingAddress() {
|
|
81
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
return this.getUnderlyingParam("id");
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
// Total balance
|
|
86
|
-
getTotalBalance() {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
return this.getPoolTokenParamFloat("totalBalance");
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
getTotalBalanceUSD() {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
const totalBalance = yield this.getTotalBalance();
|
|
94
|
-
const tokenPrice = yield this.getTokenPriceFast();
|
|
95
|
-
return totalBalance * tokenPrice;
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
// Calculate collateral price -> returns the price of the collateral, not necessarily of the underlying LP
|
|
99
|
-
calculateCollateralPrice(reserve0, reserve1, totalSupply, price0, price1) {
|
|
100
|
-
if (totalSupply === 0) {
|
|
101
|
-
console.error("Warning: totalSupply is 0");
|
|
102
|
-
return 0;
|
|
103
|
-
}
|
|
104
|
-
const reserve0USD = reserve0 * price0;
|
|
105
|
-
const reserve1USD = reserve1 * price1;
|
|
106
|
-
// adjust reserves taking the latest price passed as parameters
|
|
107
|
-
const adjustedReserveUSD = Math.sqrt(reserve0USD * reserve1USD) * 2;
|
|
108
|
-
return adjustedReserveUSD / totalSupply;
|
|
109
|
-
}
|
|
110
|
-
// Token price getters
|
|
111
|
-
getTokenPriceFast(fallback = true) {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
if (fallback) {
|
|
114
|
-
return this.getTokenPriceAccurate();
|
|
115
|
-
}
|
|
116
|
-
return 0;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.default = PoolToken;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import Offchain from "./index";
|
|
2
|
-
import { Address } from '../config/types';
|
|
3
|
-
export default class PriceHelper {
|
|
4
|
-
offchain: Offchain;
|
|
5
|
-
subgraphTokensPrice: Promise<{
|
|
6
|
-
[key in Address]?: number;
|
|
7
|
-
}> | null;
|
|
8
|
-
debankTokensPrice: {
|
|
9
|
-
[key in Address]?: Promise<number>;
|
|
10
|
-
};
|
|
11
|
-
constructor(offchain: Offchain);
|
|
12
|
-
cleanCache(): void;
|
|
13
|
-
private addPriceIfMissing;
|
|
14
|
-
private initializeSubgraphTokenPrice;
|
|
15
|
-
getSubgraphTokensPrice(): Promise<{
|
|
16
|
-
[key in Address]: number | undefined;
|
|
17
|
-
}>;
|
|
18
|
-
private getCoingeckoTokenPrice;
|
|
19
|
-
private initializeDebankTokenPrice;
|
|
20
|
-
getDebankTokenPrice(tokenAddress: Address): Promise<number>;
|
|
21
|
-
}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const debank_ids_1 = require("../config/debank-ids");
|
|
13
|
-
// coingecko has priority over debank for initialized tokens
|
|
14
|
-
const coingecko_ids = {
|
|
15
|
-
// Arbitrum
|
|
16
|
-
"0xb348b87b23d5977e2948e6f36ca07e1ec94d7328": "swapfish",
|
|
17
|
-
"0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f": "wrapped-bitcoin",
|
|
18
|
-
"0x463913d3a3d3d291667d53b8325c598eb88d3b0e": "solidlizard",
|
|
19
|
-
"0xaaa6c1e32c55a7bfa8066a6fae9b42650f262418": "ramses-exchange",
|
|
20
|
-
"0xd5954c3084a1ccd70b4da011e67760b8e78aee84": "arbitrum-exchange",
|
|
21
|
-
"0xff191514a9baba76bfd19e3943a4d37e8ec9a111": "auragi",
|
|
22
|
-
"0x15b2fb8f08e4ac1ce019eadae02ee92aedf06851": "chronos-finance",
|
|
23
|
-
"0xaae0c3856e665ff9b3e2872b6d75939d810b7e40": "yieldfarming-index",
|
|
24
|
-
"0xe80772eaf6e2e18b651f160bc9158b2a5cafca65": "usd",
|
|
25
|
-
// Avalanche
|
|
26
|
-
"0x3712871408a829c5cd4e86da1f4ce727efcd28f6": "glacier",
|
|
27
|
-
// ZkSync
|
|
28
|
-
"0x503234f203fc7eb888eec8513210612a43cf6115": "liquity-usd",
|
|
29
|
-
"0x85d84c774cf8e9ff85342684b0e795df72a24908": "velocore",
|
|
30
|
-
"0x5756a28e2aae01f600fc2c01358395f5c1f8ad3a": "vesync",
|
|
31
|
-
};
|
|
32
|
-
class PriceHelper {
|
|
33
|
-
constructor(offchain) {
|
|
34
|
-
this.offchain = offchain;
|
|
35
|
-
this.debankTokensPrice = {};
|
|
36
|
-
}
|
|
37
|
-
cleanCache() {
|
|
38
|
-
this.subgraphTokensPrice = null;
|
|
39
|
-
this.debankTokensPrice = {};
|
|
40
|
-
}
|
|
41
|
-
// First source of token price: Offchain (less accurate, faster)
|
|
42
|
-
addPriceIfMissing(offchainTokenPrice, token) {
|
|
43
|
-
if (offchainTokenPrice[token.id])
|
|
44
|
-
return;
|
|
45
|
-
offchainTokenPrice[token.id] = parseFloat(token.derivedUSD);
|
|
46
|
-
}
|
|
47
|
-
initializeSubgraphTokenPrice() {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const lendingPoolsData = yield this.offchain.getLendingPoolsData();
|
|
50
|
-
const offchainTokenPrice = {};
|
|
51
|
-
for (const factory in lendingPoolsData) {
|
|
52
|
-
for (const id in lendingPoolsData[factory]) {
|
|
53
|
-
const lendingPool = lendingPoolsData[factory][id];
|
|
54
|
-
this.addPriceIfMissing(offchainTokenPrice, lendingPool.borrowable0.underlying);
|
|
55
|
-
this.addPriceIfMissing(offchainTokenPrice, lendingPool.borrowable1.underlying);
|
|
56
|
-
for (const reward of lendingPool.pair.rewards) {
|
|
57
|
-
this.addPriceIfMissing(offchainTokenPrice, reward.rewardsToken);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
//fix for IMX
|
|
62
|
-
offchainTokenPrice["0x9c67ee39e3c4954396b9142010653f17257dd39c"] = 0;
|
|
63
|
-
offchainTokenPrice["0x7b35ce522cb72e4077baeb96cb923a5529764a00"] = 0;
|
|
64
|
-
offchainTokenPrice["0xea6887e4a9cda1b77e70129e5fba830cdb5cddef"] = 0;
|
|
65
|
-
offchainTokenPrice["0x60bb3d364b765c497c8ce50ae0ae3f0882c5bd05"] = 0;
|
|
66
|
-
offchainTokenPrice["0x900f1ec5819fa087d368877cd03b265bf1802667"] = 0;
|
|
67
|
-
offchainTokenPrice["0xea38f1ccf77bf43f352636241b05dd8f6f5f52b2"] = 0;
|
|
68
|
-
return offchainTokenPrice;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
getSubgraphTokensPrice() {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
if (!this.subgraphTokensPrice)
|
|
74
|
-
this.subgraphTokensPrice = this.initializeSubgraphTokenPrice();
|
|
75
|
-
return this.subgraphTokensPrice;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
// Second source of token price: Debank (more accurate, slower)
|
|
79
|
-
getCoingeckoTokenPrice(tokenAddress) {
|
|
80
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
try {
|
|
82
|
-
const tokenId = coingecko_ids[tokenAddress];
|
|
83
|
-
const response = yield fetch("https://api.coingecko.com/api/v3/simple/price?ids=" + tokenId + "&vs_currencies=usd");
|
|
84
|
-
if (response.status != 200)
|
|
85
|
-
return 0;
|
|
86
|
-
const data = yield response.json();
|
|
87
|
-
if (!data)
|
|
88
|
-
return 0;
|
|
89
|
-
return data[tokenId].usd ? data[tokenId].usd : 0;
|
|
90
|
-
}
|
|
91
|
-
catch (_a) {
|
|
92
|
-
return 0;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
initializeDebankTokenPrice(tokenAddress) {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
if (Object.keys(coingecko_ids).includes(tokenAddress.toLowerCase())) {
|
|
99
|
-
const result = yield this.getCoingeckoTokenPrice(tokenAddress.toLowerCase());
|
|
100
|
-
if (result)
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
try {
|
|
104
|
-
const response = yield fetch("https://openapi.debank.com/v1/token?chain_id=" + debank_ids_1.DEBANK_IDS[this.offchain.network] + "&id=" + tokenAddress);
|
|
105
|
-
/*const response = await fetch(
|
|
106
|
-
"https://pro-openapi.debank.com/v1/token?chain_id=" + debank_chain_ids[this.offchain.network] + "&id=" + tokenAddress,
|
|
107
|
-
{headers: {"AccessKey": "0ac0fba6aeb0905b4c9a1c5cfd9d48d74fbc60e0"}}
|
|
108
|
-
);*/
|
|
109
|
-
if (response.status != 200)
|
|
110
|
-
return 0;
|
|
111
|
-
const data = yield response.json();
|
|
112
|
-
if (!data)
|
|
113
|
-
return 0;
|
|
114
|
-
return data.price ? data.price : 0;
|
|
115
|
-
}
|
|
116
|
-
catch (_a) {
|
|
117
|
-
return 0;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
getDebankTokenPrice(tokenAddress) {
|
|
122
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
if (tokenAddress.toLowerCase() === '0xf28164a485b0b2c90639e47b0f377b4a438a16b1') { // fix for dQuick
|
|
124
|
-
return (yield this.getDebankTokenPrice('0x831753dd7087cac61ab5644b308642cc1c33dc13')) * 1.68;
|
|
125
|
-
}
|
|
126
|
-
if (tokenAddress.toLowerCase() === '0x63468133ed352e602beb61dd254d6060ad2fe419') { // fix for sTHO
|
|
127
|
-
return (yield this.getDebankTokenPrice('0xae4aa155d2987b454c29450ef4f862cf00907b61')) * 1.1;
|
|
128
|
-
}
|
|
129
|
-
if (tokenAddress.toLowerCase() === '0xfcef8a994209d6916eb2c86cdd2afd60aa6f54b1') { // fix for fBEETS
|
|
130
|
-
return (yield this.getDebankTokenPrice('0xf24bcf4d1e507740041c9cfd2dddb29585adce1e')) * 0.93;
|
|
131
|
-
}
|
|
132
|
-
if (tokenAddress.toLowerCase() === '0x5979d7b546e38e414f7e9822514be443a4800529') { // TEMPORARY fix for WSTETH
|
|
133
|
-
return (yield this.getDebankTokenPrice('0x82af49447d8a07e3bd95bd0d56f35241523fbab1')) / 0.92;
|
|
134
|
-
}
|
|
135
|
-
if (tokenAddress.toLowerCase() === '0x3f56e0c36d275367b8c502090edf38289b3dea0d') { // TEMPORARY fix for MAI
|
|
136
|
-
return 1;
|
|
137
|
-
}
|
|
138
|
-
if (tokenAddress.toLowerCase() === '0xc71aaf8e486e3f33841bb56ca3fd2ac3fa8d29a8') { // TEMPORARY fix for WSTETH Canto
|
|
139
|
-
return (yield this.getDebankTokenPrice('0x5fd55a1b9fc24967c4db09c513c3ba0dfa7ff687')) * 1.12;
|
|
140
|
-
}
|
|
141
|
-
if (tokenAddress.toLowerCase() === '0x152b9d0fdc40c096757f570a51e494bd4b943e50') { // TEMPORARY fix for BTC.b AVAX
|
|
142
|
-
return (yield this.getDebankTokenPrice('0x50b7545627a5162f82a992c33b87adc75187b218'));
|
|
143
|
-
}
|
|
144
|
-
if (tokenAddress.toLowerCase() === '0x9fc3104f6fc188fee65c85bbc4b94a48282ae76d') { // TEMPORARY fix for SATIN
|
|
145
|
-
return 0;
|
|
146
|
-
}
|
|
147
|
-
if ([
|
|
148
|
-
"0x9c67ee39e3c4954396b9142010653f17257dd39c",
|
|
149
|
-
"0x7b35ce522cb72e4077baeb96cb923a5529764a00",
|
|
150
|
-
"0xea6887e4a9cda1b77e70129e5fba830cdb5cddef",
|
|
151
|
-
"0x60bb3d364b765c497c8ce50ae0ae3f0882c5bd05",
|
|
152
|
-
"0x900f1ec5819fa087d368877cd03b265bf1802667",
|
|
153
|
-
"0xea38f1ccf77bf43f352636241b05dd8f6f5f52b2",
|
|
154
|
-
].includes(tokenAddress.toLowerCase())) { // fix for IMX
|
|
155
|
-
return 0;
|
|
156
|
-
}
|
|
157
|
-
if (tokenAddress.toLowerCase() === '0xda0053f0befcbcac208a3f867bb243716734d809') { // TEMPORARY fix for oxSOLID
|
|
158
|
-
return (yield this.getDebankTokenPrice('0x888ef71766ca594ded1f0fa3ae64ed2941740a20')) * 0.88;
|
|
159
|
-
}
|
|
160
|
-
if (tokenAddress.toLowerCase() === '0x431d5dff03120afa4bdf332c61a6e1766ef37bdb') { // TEMPORARY fix for JPYCv2
|
|
161
|
-
return (yield this.getDebankTokenPrice('0x6ae7dfc73e0dde2aa99ac063dcf7e8a63265108c'));
|
|
162
|
-
}
|
|
163
|
-
if (!this.debankTokensPrice[tokenAddress])
|
|
164
|
-
this.debankTokensPrice[tokenAddress] = this.initializeDebankTokenPrice(tokenAddress);
|
|
165
|
-
const tokenPrice = yield this.debankTokensPrice[tokenAddress];
|
|
166
|
-
if (tokenPrice === 0) {
|
|
167
|
-
//manual fallback
|
|
168
|
-
if (tokenAddress.toLowerCase() === '0xaaa6c1e32c55a7bfa8066a6fae9b42650f262418') { // fix for RAM
|
|
169
|
-
return 0.02;
|
|
170
|
-
}
|
|
171
|
-
if (tokenAddress.toLowerCase() === '0xd5954c3084a1ccd70b4da011e67760b8e78aee84') { // fix for ARX
|
|
172
|
-
return 0.5;
|
|
173
|
-
}
|
|
174
|
-
if (tokenAddress.toLowerCase() === '0xe80772eaf6e2e18b651f160bc9158b2a5cafca65') { // fix for USD+
|
|
175
|
-
return 1;
|
|
176
|
-
}
|
|
177
|
-
if (tokenAddress.toLowerCase() === '0x3712871408a829c5cd4e86da1f4ce727efcd28f6') { // fix for GLCR
|
|
178
|
-
return 0.011;
|
|
179
|
-
}
|
|
180
|
-
if (tokenAddress.toLowerCase() === '0x5756a28e2aae01f600fc2c01358395f5c1f8ad3a') { // fix for VS
|
|
181
|
-
return 0.05;
|
|
182
|
-
}
|
|
183
|
-
if (tokenAddress.toLowerCase() === '0x1c28edf9e0d66f3124f141a3cf3ef1217f7019c4') { // fix for SLNA
|
|
184
|
-
return 0.00045;
|
|
185
|
-
}
|
|
186
|
-
// try fallback on offchain
|
|
187
|
-
const subgraphTokensPrice = yield this.getSubgraphTokensPrice();
|
|
188
|
-
const subgraphTokenPrice = subgraphTokensPrice[tokenAddress];
|
|
189
|
-
return subgraphTokenPrice ? subgraphTokenPrice : 0;
|
|
190
|
-
}
|
|
191
|
-
return tokenPrice;
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
exports.default = PriceHelper;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Offchain from "./index";
|
|
2
|
-
import { Address } from "../config/types";
|
|
3
|
-
export type SolidexLPDetails = {
|
|
4
|
-
[key in Address]: Array<{
|
|
5
|
-
APR: number;
|
|
6
|
-
symbol: string;
|
|
7
|
-
}>;
|
|
8
|
-
};
|
|
9
|
-
export default class SolidexHelper {
|
|
10
|
-
offchain: Offchain;
|
|
11
|
-
solidexLPDetails: Promise<SolidexLPDetails> | null;
|
|
12
|
-
constructor(offchain: Offchain);
|
|
13
|
-
cleanCache(): void;
|
|
14
|
-
private initializeSolidexLPDetails;
|
|
15
|
-
getSolidexLPDetails(): Promise<SolidexLPDetails>;
|
|
16
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
class SolidexHelper {
|
|
13
|
-
constructor(offchain) {
|
|
14
|
-
this.offchain = offchain;
|
|
15
|
-
}
|
|
16
|
-
cleanCache() {
|
|
17
|
-
this.solidexLPDetails = null;
|
|
18
|
-
}
|
|
19
|
-
initializeSolidexLPDetails() {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
try {
|
|
22
|
-
const response = yield fetch("https://api.solidexfinance.com/api/getLPDetails?v=fantom");
|
|
23
|
-
if (response.status != 200)
|
|
24
|
-
return {};
|
|
25
|
-
const data = yield response.json();
|
|
26
|
-
if (!data || !data.success)
|
|
27
|
-
return {};
|
|
28
|
-
const solidexLPDetails = {};
|
|
29
|
-
for (const pool of data.data.poolDetailsAll) {
|
|
30
|
-
if (!pool.solidexTVL)
|
|
31
|
-
continue;
|
|
32
|
-
solidexLPDetails[pool.poolAddress.toLowerCase()] = [
|
|
33
|
-
{
|
|
34
|
-
APR: pool.solidexTVL.realsolidAPR / 100,
|
|
35
|
-
symbol: "SOLID",
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
APR: pool.solidexTVL.realsexAPR / 100,
|
|
39
|
-
symbol: "SEX",
|
|
40
|
-
},
|
|
41
|
-
];
|
|
42
|
-
}
|
|
43
|
-
return solidexLPDetails;
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
return {};
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
getSolidexLPDetails() {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
if (!this.solidexLPDetails)
|
|
53
|
-
this.solidexLPDetails = this.initializeSolidexLPDetails();
|
|
54
|
-
return this.solidexLPDetails;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.default = SolidexHelper;
|
package/lib/offchain/types.d.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { Address, PoolTokenType } from '../config/types';
|
|
2
|
-
export interface PoolTokenData {
|
|
3
|
-
id: Address;
|
|
4
|
-
totalBalance: string;
|
|
5
|
-
exchangeRate: string;
|
|
6
|
-
totalBalanceUSD: string;
|
|
7
|
-
}
|
|
8
|
-
export interface BorrowableData extends PoolTokenData {
|
|
9
|
-
underlying: TokenData;
|
|
10
|
-
totalBorrows: string;
|
|
11
|
-
borrowRate: string;
|
|
12
|
-
reserveFactor: string;
|
|
13
|
-
kinkBorrowRate: string;
|
|
14
|
-
kinkUtilizationRate: string;
|
|
15
|
-
borrowIndex: string;
|
|
16
|
-
accrualTimestamp: string;
|
|
17
|
-
farmingPool: FarmingPoolData;
|
|
18
|
-
rewards?: Array<{
|
|
19
|
-
rewardToken: Address;
|
|
20
|
-
rewardRate: number;
|
|
21
|
-
}>;
|
|
22
|
-
}
|
|
23
|
-
export interface CollateralData extends PoolTokenData {
|
|
24
|
-
safetyMargin: string;
|
|
25
|
-
liquidationIncentive: string;
|
|
26
|
-
liquidationFee: string;
|
|
27
|
-
}
|
|
28
|
-
export interface BorrowablePastData {
|
|
29
|
-
borrowIndex: string;
|
|
30
|
-
accrualTimestamp: string;
|
|
31
|
-
exchangeRate: string;
|
|
32
|
-
}
|
|
33
|
-
export interface TokenData {
|
|
34
|
-
id: Address;
|
|
35
|
-
symbol: string;
|
|
36
|
-
name: string;
|
|
37
|
-
decimals: string;
|
|
38
|
-
derivedUSD: string;
|
|
39
|
-
}
|
|
40
|
-
export interface RewardData {
|
|
41
|
-
id: Address;
|
|
42
|
-
rewardRate: string;
|
|
43
|
-
rewardsToken: TokenData;
|
|
44
|
-
periodFinish: string;
|
|
45
|
-
}
|
|
46
|
-
export interface PairData {
|
|
47
|
-
id: Address;
|
|
48
|
-
factory: string;
|
|
49
|
-
reserve0: string;
|
|
50
|
-
reserve1: string;
|
|
51
|
-
totalSupply: string;
|
|
52
|
-
reserveUSD: string;
|
|
53
|
-
token0Price: string;
|
|
54
|
-
token1Price: string;
|
|
55
|
-
derivedUSD: string;
|
|
56
|
-
uniswapV2PairAddress: string;
|
|
57
|
-
uniswapV2Factory: string;
|
|
58
|
-
isStakedLPToken: boolean;
|
|
59
|
-
exchangeRate: string;
|
|
60
|
-
stakingRewards: string;
|
|
61
|
-
masterChef: string;
|
|
62
|
-
pid: string;
|
|
63
|
-
stakedTotalSupply: string;
|
|
64
|
-
rewards: Array<RewardData>;
|
|
65
|
-
uniswapAPR: number;
|
|
66
|
-
}
|
|
67
|
-
export interface FarmingPoolData {
|
|
68
|
-
epochAmount: string;
|
|
69
|
-
epochBegin: string;
|
|
70
|
-
segmentLength: string;
|
|
71
|
-
vestingBegin: string;
|
|
72
|
-
sharePercentage: string;
|
|
73
|
-
}
|
|
74
|
-
export interface LendingPoolPastData {
|
|
75
|
-
[PoolTokenType.Collateral]: undefined;
|
|
76
|
-
[PoolTokenType.BorrowableA]: BorrowablePastData;
|
|
77
|
-
[PoolTokenType.BorrowableB]: BorrowablePastData;
|
|
78
|
-
}
|
|
79
|
-
export interface LendingPoolData {
|
|
80
|
-
id: Address;
|
|
81
|
-
[PoolTokenType.Collateral]: CollateralData;
|
|
82
|
-
[PoolTokenType.BorrowableA]: BorrowableData;
|
|
83
|
-
[PoolTokenType.BorrowableB]: BorrowableData;
|
|
84
|
-
pair: PairData;
|
|
85
|
-
past24h?: LendingPoolPastData;
|
|
86
|
-
past7d?: LendingPoolPastData;
|
|
87
|
-
}
|
|
88
|
-
export interface CollateralPosition {
|
|
89
|
-
balance: string;
|
|
90
|
-
collateral: {
|
|
91
|
-
lendingPool: {
|
|
92
|
-
id: Address;
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
export interface SupplyPosition {
|
|
97
|
-
balance: string;
|
|
98
|
-
borrowable: {
|
|
99
|
-
underlying: {
|
|
100
|
-
id: Address;
|
|
101
|
-
};
|
|
102
|
-
lendingPool: {
|
|
103
|
-
id: Address;
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
export interface BorrowPosition {
|
|
108
|
-
borrowBalance: string;
|
|
109
|
-
borrowIndex: string;
|
|
110
|
-
borrowable: {
|
|
111
|
-
underlying: {
|
|
112
|
-
id: Address;
|
|
113
|
-
};
|
|
114
|
-
lendingPool: {
|
|
115
|
-
id: Address;
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
export interface RawUserData {
|
|
120
|
-
collateralPositions: CollateralPosition[];
|
|
121
|
-
supplyPositions: SupplyPosition[];
|
|
122
|
-
borrowPositions: BorrowPosition[];
|
|
123
|
-
}
|
|
124
|
-
export interface UserData {
|
|
125
|
-
collateralPositions: {
|
|
126
|
-
[key in Address]: CollateralPosition;
|
|
127
|
-
};
|
|
128
|
-
supplyPositions: {
|
|
129
|
-
[key in Address]: {
|
|
130
|
-
[key in PoolTokenType]?: SupplyPosition;
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
borrowPositions: {
|
|
134
|
-
[key in Address]: {
|
|
135
|
-
[key in PoolTokenType]?: BorrowPosition;
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
export interface TvlData {
|
|
140
|
-
crossChainTVLUSD: number;
|
|
141
|
-
totalBalanceUSD: number;
|
|
142
|
-
totalBorrowsUSD: number;
|
|
143
|
-
totalSupplyUSD: number;
|
|
144
|
-
}
|
|
145
|
-
export interface XimxData {
|
|
146
|
-
totalSupply: string;
|
|
147
|
-
totalBalance: string;
|
|
148
|
-
exchangeRate: string;
|
|
149
|
-
dailyAPR: string;
|
|
150
|
-
}
|
package/lib/offchain/types.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
|
-
import Account from "../index";
|
|
3
|
-
import * as lendingPool from './lendingPool';
|
|
4
|
-
import LendingPool from "./lendingPool";
|
|
5
|
-
import PoolToken from "./poolToken";
|
|
6
|
-
import { AirdropData, Contract } from "../../types";
|
|
7
|
-
import { Address, AddressIndex, Factory, FactoryIndex, LendingPoolIndex } from '../../../config/types';
|
|
8
|
-
import LendingVault from './lendingVault';
|
|
9
|
-
export { lendingPool, LendingPool, PoolToken, LendingVault, };
|
|
10
|
-
export default class Interactions {
|
|
11
|
-
account: Account;
|
|
12
|
-
interactionsLLPs: LendingPoolIndex<Promise<LendingPool>>;
|
|
13
|
-
interactionsLVs: AddressIndex<Promise<LendingVault>>;
|
|
14
|
-
cache: {
|
|
15
|
-
defaultRouterContract?: Contract;
|
|
16
|
-
};
|
|
17
|
-
constructor(account: Account);
|
|
18
|
-
cleanCache(): Promise<void>;
|
|
19
|
-
private initializeInteractionsLendingPool;
|
|
20
|
-
getInteractionsLendingPool(factory: Factory, pair: Address): Promise<LendingPool>;
|
|
21
|
-
private initializeInteractionsLendingVault;
|
|
22
|
-
getInteractionsLendingVault(vaultAddress: Address): Promise<LendingVault>;
|
|
23
|
-
send(method: any, onTransactionHash: Function, value?: BigNumber): Promise<any>;
|
|
24
|
-
getDefaultRouterContract(): any;
|
|
25
|
-
claimAirdrop(airdropData: AirdropData, merkleDistributor: Contract, onTransactionHash: Function): Promise<any>;
|
|
26
|
-
claims(pairAddresses: FactoryIndex<Address[]>, onTransactionHash: Function): Promise<any>;
|
|
27
|
-
claimDistributor(claimableAddress: Address, onTransactionHash: Function): Promise<any>;
|
|
28
|
-
}
|