impermax-sdk 1.2.63 → 1.2.65
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.d.ts +3 -1
- package/lib/config/amms.js +12 -0
- package/lib/config/contracts/claim-aggregators.js +1 -0
- package/lib/config/contracts/impermax-chef.js +1 -0
- package/lib/config/contracts/impermax-config-manager.js +1 -0
- package/lib/config/contracts/impermax-factories.js +3 -0
- package/lib/config/contracts/imxes.js +1 -0
- package/lib/config/contracts/lending-vault-watcher.js +1 -0
- package/lib/config/contracts/merkle-distributors.js +3 -0
- package/lib/config/contracts/routers.js +4 -0
- package/lib/config/contracts/simple-uniswap-oracles.js +1 -0
- package/lib/config/contracts/weths.js +2 -1
- package/lib/config/debank-ids.js +1 -0
- package/lib/config/endpoints/merkle-distributors.js +3 -0
- package/lib/config/eth.js +2 -0
- package/lib/config/farms.d.ts +3 -1
- package/lib/config/farms.js +5 -0
- package/lib/config/subgraphs.d.ts +1 -0
- package/lib/config/subgraphs.js +7 -0
- package/lib/config/types.d.ts +2 -1
- package/lib/config/types.js +1 -0
- package/lib/offchain/account/lendingPool/borrowable.d.ts +14 -0
- package/lib/offchain/account/lendingPool/borrowable.js +73 -0
- package/lib/offchain/account/lendingPool/collateral.d.ts +12 -0
- package/lib/offchain/account/lendingPool/collateral.js +42 -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/initializer.d.ts +32 -0
- package/lib/offchain/initializer.js +627 -0
- package/lib/offchain/lendingPool/borrowable.d.ts +55 -0
- package/lib/offchain/lendingPool/borrowable.js +351 -0
- package/lib/offchain/lendingPool/collateral.d.ts +17 -0
- package/lib/offchain/lendingPool/collateral.js +72 -0
- package/lib/offchain/lendingVault.d.ts +22 -0
- package/lib/offchain/lendingVault.js +115 -0
- package/lib/offchain/offchainAPRHelper.js +2 -1
- package/lib/offchain/offchainInitializer.js +2 -0
- package/lib/offchain/poolToken.d.ts +20 -0
- package/lib/offchain/poolToken.js +120 -0
- package/lib/offchain/priceHelper.d.ts +21 -0
- package/lib/offchain/priceHelper.js +195 -0
- package/lib/offchain/query.js +247 -247
- package/lib/offchain/solidexHelper.d.ts +16 -0
- package/lib/offchain/solidexHelper.js +58 -0
- package/lib/offchain/types.d.ts +150 -0
- package/lib/offchain/types.js +3 -0
- package/lib/onchain/account/interactions/index.d.ts +28 -0
- package/lib/onchain/account/interactions/index.js +158 -0
- package/lib/onchain/account/interactions/lendingPool/borrowable.d.ts +16 -0
- package/lib/onchain/account/interactions/lendingPool/borrowable.js +49 -0
- package/lib/onchain/account/interactions/lendingPool/collateral.d.ts +15 -0
- package/lib/onchain/account/interactions/lendingPool/collateral.js +33 -0
- package/lib/onchain/account/interactions/lendingPool/index.d.ts +41 -0
- package/lib/onchain/account/interactions/lendingPool/index.js +120 -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 +135 -0
- package/lib/onchain/account/lendingPool/collateral.d.ts +15 -0
- package/lib/onchain/account/lendingPool/collateral.js +66 -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/contractsHelper.d.ts +29 -0
- package/lib/onchain/contractsHelper.js +52 -0
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.d.ts +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.js +153 -0
- package/lib/onchain/impermaxFactory/lendingPool/collateral.d.ts +17 -0
- package/lib/onchain/impermaxFactory/lendingPool/collateral.js +59 -0
- package/lib/onchain/interactions/lendingPool/borrowable.d.ts +14 -0
- package/lib/onchain/interactions/lendingPool/borrowable.js +47 -0
- package/lib/onchain/interactions/lendingPool/collateral.d.ts +13 -0
- package/lib/onchain/interactions/lendingPool/collateral.js +31 -0
- package/lib/onchain/interactions/lendingVault.d.ts +8 -0
- package/lib/onchain/interactions/lendingVault.js +15 -0
- package/lib/onchain/interactions/poolToken.d.ts +31 -0
- package/lib/onchain/interactions/poolToken.js +181 -0
- package/lib/onchain/lendingVault.d.ts +17 -0
- package/lib/onchain/lendingVault.js +56 -0
- package/lib/onchain/poolToken.d.ts +32 -0
- package/lib/onchain/poolToken.js +121 -0
- package/lib/onchain/types.d.ts +45 -0
- package/lib/onchain/types.js +14 -0
- package/lib/utils/price-from-reserves.d.ts +2 -0
- package/lib/utils/price-from-reserves.js +19 -0
- package/package.json +1 -1
|
@@ -0,0 +1,120 @@
|
|
|
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;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
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;
|