impermax-sdk 2.1.20 → 2.1.22
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/lending-vault-watcher.js +1 -1
- package/lib/config/private-api.d.ts +8 -0
- package/lib/config/private-api.js +62 -0
- package/lib/config/subgraphs.js +2 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -1
- package/lib/offchain/offchain.js +1 -0
- package/lib/offchain/offchainPriceHelper.js +9 -4
- package/lib/offchain/vault/offchainLendingVault.d.ts +2 -3
- package/lib/offchain/vault/offchainLendingVault.js +20 -21
- package/lib/offchain/vault/offchainVault.d.ts +12 -0
- package/lib/offchain/vault/offchainVault.js +27 -1
- package/lib/onchain/onchainPermitHelper.js +5 -4
- package/lib/onchain/onchainTypes.d.ts +8 -2
- package/lib/onchain/onchainTypes.js +8 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ exports.LENDING_VAULT_WATCHER = {
|
|
|
17
17
|
[types_1.Networks.Sxnetwork]: '',
|
|
18
18
|
[types_1.Networks.Canto]: '',
|
|
19
19
|
[types_1.Networks.ZksyncEra]: '',
|
|
20
|
-
[types_1.Networks.Blast]: '',
|
|
20
|
+
[types_1.Networks.Blast]: '0x5833C2BCe6C29323401e9eD171f1599001f5B288',
|
|
21
21
|
[types_1.Networks.Base]: '0x1c79103cEc595b8af673Cd41271861FFA3B2BEDA',
|
|
22
22
|
[types_1.Networks.Mantle]: '',
|
|
23
23
|
[types_1.Networks.Scroll]: '0x0774eBA9e1b20B0f191AbC59a5798838F4bd938c',
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Address, NetworkVaultTypeIndex, NetworkFactoryIndex } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Private API Endpoints which we might need to use in future for non-core
|
|
4
|
+
* things (ie. charts, leaderboards, etc.). The app must function well
|
|
5
|
+
* without any of these endpoints, so just nice to haves.
|
|
6
|
+
*/
|
|
7
|
+
export declare const IMPERMAX_POOLS_API: NetworkFactoryIndex<Address>;
|
|
8
|
+
export declare const IMPERMAX_VAULT_API: NetworkVaultTypeIndex<Address>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IMPERMAX_VAULT_API = exports.IMPERMAX_POOLS_API = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
/**
|
|
6
|
+
* Private API Endpoints which we might need to use in future for non-core
|
|
7
|
+
* things (ie. charts, leaderboards, etc.). The app must function well
|
|
8
|
+
* without any of these endpoints, so just nice to haves.
|
|
9
|
+
*/
|
|
10
|
+
// For lending pools
|
|
11
|
+
exports.IMPERMAX_POOLS_API = {
|
|
12
|
+
[types_1.Networks.Ropsten]: {},
|
|
13
|
+
[types_1.Networks.Mainnet]: {},
|
|
14
|
+
[types_1.Networks.Polygon]: {},
|
|
15
|
+
[types_1.Networks.Arbitrum]: {},
|
|
16
|
+
[types_1.Networks.Avalanche]: {},
|
|
17
|
+
[types_1.Networks.Moonriver]: {},
|
|
18
|
+
[types_1.Networks.Aurora]: {},
|
|
19
|
+
[types_1.Networks.Cronos]: {},
|
|
20
|
+
[types_1.Networks.Fantom]: {},
|
|
21
|
+
[types_1.Networks.Harmony]: {},
|
|
22
|
+
[types_1.Networks.Moonbeam]: {},
|
|
23
|
+
[types_1.Networks.Sxnetwork]: {},
|
|
24
|
+
[types_1.Networks.Canto]: {},
|
|
25
|
+
[types_1.Networks.ZksyncEra]: {},
|
|
26
|
+
[types_1.Networks.Base]: {},
|
|
27
|
+
[types_1.Networks.Mantle]: {},
|
|
28
|
+
[types_1.Networks.Scroll]: {},
|
|
29
|
+
[types_1.Networks.Optimism]: {},
|
|
30
|
+
[types_1.Networks.Real]: {},
|
|
31
|
+
[types_1.Networks.Blast]: {},
|
|
32
|
+
};
|
|
33
|
+
// For lending pools
|
|
34
|
+
exports.IMPERMAX_VAULT_API = {
|
|
35
|
+
[types_1.Networks.Ropsten]: {},
|
|
36
|
+
[types_1.Networks.Mainnet]: {},
|
|
37
|
+
[types_1.Networks.Polygon]: {
|
|
38
|
+
[types_1.VaultType.LENDING]: "https://polygon-lendingvaults-production.up.railway.app/vaults/"
|
|
39
|
+
},
|
|
40
|
+
[types_1.Networks.Arbitrum]: {},
|
|
41
|
+
[types_1.Networks.Avalanche]: {},
|
|
42
|
+
[types_1.Networks.Moonriver]: {},
|
|
43
|
+
[types_1.Networks.Aurora]: {},
|
|
44
|
+
[types_1.Networks.Cronos]: {},
|
|
45
|
+
[types_1.Networks.Fantom]: {},
|
|
46
|
+
[types_1.Networks.Harmony]: {},
|
|
47
|
+
[types_1.Networks.Moonbeam]: {},
|
|
48
|
+
[types_1.Networks.Sxnetwork]: {},
|
|
49
|
+
[types_1.Networks.Canto]: {},
|
|
50
|
+
[types_1.Networks.ZksyncEra]: {},
|
|
51
|
+
[types_1.Networks.Base]: {
|
|
52
|
+
[types_1.VaultType.LENDING]: "https://base-lendingvaults-production.up.railway.app/vaults/"
|
|
53
|
+
},
|
|
54
|
+
[types_1.Networks.Mantle]: {},
|
|
55
|
+
[types_1.Networks.Scroll]: {},
|
|
56
|
+
[types_1.Networks.Optimism]: {},
|
|
57
|
+
[types_1.Networks.Real]: {},
|
|
58
|
+
[types_1.Networks.Blast]: {
|
|
59
|
+
[types_1.VaultType.LENDING]: "https://blast-lendingvaults-production.up.railway.app/vaults/"
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
// Add more here
|
package/lib/config/subgraphs.js
CHANGED
|
@@ -137,6 +137,7 @@ exports.VAULT_SUBGRAPH_URL = {
|
|
|
137
137
|
[types_1.Networks.Polygon]: {
|
|
138
138
|
[types_1.VaultType.LENDING]: [
|
|
139
139
|
"https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/BNWJQpKBT24mYzLYZ7hdBiJpvfBoEwjSemNkQ1Rryknp",
|
|
140
|
+
"https://polygon-lendingvaults-production.up.railway.app/"
|
|
140
141
|
],
|
|
141
142
|
[types_1.VaultType.HEDGED]: [],
|
|
142
143
|
[types_1.VaultType.LEVERAGED]: [],
|
|
@@ -179,6 +180,7 @@ exports.VAULT_SUBGRAPH_URL = {
|
|
|
179
180
|
[types_1.Networks.Blast]: {
|
|
180
181
|
[types_1.VaultType.LENDING]: [
|
|
181
182
|
"https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/8UbzkWkh1zqWhkgkomcVAVR7tmvDNq9LUtfmvRwtDQTh",
|
|
183
|
+
"https://blast-lendingvaults-production.up.railway.app/"
|
|
182
184
|
],
|
|
183
185
|
[types_1.VaultType.HEDGED]: [],
|
|
184
186
|
[types_1.VaultType.LEVERAGED]: [],
|
package/lib/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { FarmIndex, Farms, getFarmByStakedLPFactory, hrFarms, STAKED_LP_FACTORY
|
|
|
19
19
|
import { APPROVE_AMOUNT, DEADLINE, NOT_SYNCED, ZERO } from './config/general';
|
|
20
20
|
import { BLOCKS_SUBGRAPH_URL, IMPERMAX_CHEF_SUBGRAPH_URL, IMPERMAX_SUBGRAPH_URL, XIMX_SUBGRAPH_URL } from './config/subgraphs';
|
|
21
21
|
import { Address, AddressIndex, AmmIndex, DistributorDetails, Factory, FactoryIndex, LendingPoolIndex, NetworkFactoryIndex, NetworkIndex, Networks, PoolTokenType, ProposalState, WhitelistState, VaultType } from './config/types';
|
|
22
|
-
import { AirdropData, ApprovalType, Changes, Contract, OnchainConfig, NO_CHANGES, PendingRewardUI, PermitData, Values, CollateralConfig, BorrowableConfig, PairConfig } from './onchain/onchainTypes';
|
|
22
|
+
import { AirdropData, ApprovalType, Changes, Contract, OnchainConfig, NO_CHANGES, PendingRewardUI, PermitData, Values, CollateralConfig, BorrowableConfig, PairConfig, Permits, Permit, PermitType } from './onchain/onchainTypes';
|
|
23
23
|
import { BorrowableData, BorrowablePastData, BorrowPosition, CollateralData, CollateralPosition, FarmingPoolData, LendingPoolData, LendingPoolPastData, PairData, PoolTokenData, RewardData, SupplyPosition, TokenData, TvlData, UserData, XimxData, LendingVaultData, VaultPosition, PairConfigData, ProposalData, ProposalMetadata } from './offchain/offchainTypes';
|
|
24
24
|
import { OffchainBorrowable, OffchainCollateral } from './offchain/lendingPool';
|
|
25
25
|
import OffchainConfigManager, { OffchainPairConfig, OffchainProposal } from './offchain/configManager';
|
|
@@ -36,4 +36,4 @@ import OffchainVault, { OffchainLendingVault, OffchainLeveragedVault, OffchainHe
|
|
|
36
36
|
import { SortDirection, VaultListOrderBy, VaultListParams, LendingPoolListParams, LendingPoolListOrderBy } from "./offchain/offchainMultichain";
|
|
37
37
|
import { VaultRisk } from "./offchain/vault/offchainVault";
|
|
38
38
|
import { LendingPoolVersion } from "./offchain/lendingPool/offchainLendingPool";
|
|
39
|
-
export { offchain, OffchainMultichain, Offchain, OffchainLendingPool, OffchainPoolToken, OffchainCollateral, OffchainBorrowable, OffchainVault, OffchainLeveragedVault, OffchainLendingVault, OffchainHedgedVault, OffchainConfigManager, OffchainPairConfig, OffchainProposal, OffchainMultichainAccount, OffchainAccount, OffchainAccountLendingPool, OffchainAccountPoolToken, OffchainAccountCollateral, OffchainAccountBorrowable, OffchainLeveragedPosition, OffchainAccountVault, OffchainPriceHelper, OffchainSolidexHelper, PoolTokenData, BorrowableData, CollateralData, BorrowablePastData, TokenData, RewardData, PairData, FarmingPoolData, LendingPoolPastData, LendingPoolData, CollateralPosition, SupplyPosition, BorrowPosition, UserData, TvlData, XimxData, LendingVaultData, VaultPosition, PairConfigData, ProposalData, ProposalMetadata, VaultRisk, VaultType, onchain, Onchain, OnchainLendingPool, OnchainPoolToken, OnchainBorrowable, OnchainCollateral, OnchainLendingVault, OnchainConfigManager, OnchainProposal, OnchainPairConfig, OnchainAccount, OnchainAccountLendingPool, OnchainAccountPoolToken, OnchainAccountBorrowable, OnchainAccountCollateral, OnchainAccountLendingVault, OnchainContractsHelper, OnchainImpermaxFactory, OnchainInteractions, OnchainInteractionsLendingPool, OnchainInteractionsPoolToken, OnchainInteractionsCollateral, OnchainInteractionsBorrowable, OnchainInteractionsLendingVault, OnchainInteractionsConfigManager, Contract, ApprovalType, PermitData, OnchainConfig, Changes, NO_CHANGES, Values, AirdropData, PendingRewardUI, CollateralConfig, BorrowableConfig, PairConfig, CLAIM_AGGREGATOR, IMPERMAX_CHEF, IMX, IMPERMAX_FACTORY, getNetworkFactories, LENDING_VAULT_WATCHER, 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, ProposalState, WhitelistState, VaultListOrderBy, VaultListParams, LendingPoolListOrderBy, LendingPoolListParams, SortDirection, LendingPoolVersion };
|
|
39
|
+
export { offchain, OffchainMultichain, Offchain, OffchainLendingPool, OffchainPoolToken, OffchainCollateral, OffchainBorrowable, OffchainVault, OffchainLeveragedVault, OffchainLendingVault, OffchainHedgedVault, OffchainConfigManager, OffchainPairConfig, OffchainProposal, OffchainMultichainAccount, OffchainAccount, OffchainAccountLendingPool, OffchainAccountPoolToken, OffchainAccountCollateral, OffchainAccountBorrowable, OffchainLeveragedPosition, OffchainAccountVault, OffchainPriceHelper, OffchainSolidexHelper, PoolTokenData, BorrowableData, CollateralData, BorrowablePastData, TokenData, RewardData, PairData, FarmingPoolData, LendingPoolPastData, LendingPoolData, CollateralPosition, SupplyPosition, BorrowPosition, UserData, TvlData, XimxData, LendingVaultData, VaultPosition, PairConfigData, ProposalData, ProposalMetadata, VaultRisk, VaultType, onchain, Onchain, OnchainLendingPool, OnchainPoolToken, OnchainBorrowable, OnchainCollateral, OnchainLendingVault, OnchainConfigManager, OnchainProposal, OnchainPairConfig, OnchainAccount, OnchainAccountLendingPool, OnchainAccountPoolToken, OnchainAccountBorrowable, OnchainAccountCollateral, OnchainAccountLendingVault, OnchainContractsHelper, OnchainImpermaxFactory, OnchainInteractions, OnchainInteractionsLendingPool, OnchainInteractionsPoolToken, OnchainInteractionsCollateral, OnchainInteractionsBorrowable, OnchainInteractionsLendingVault, OnchainInteractionsConfigManager, Contract, ApprovalType, PermitData, OnchainConfig, Changes, NO_CHANGES, Values, AirdropData, PendingRewardUI, CollateralConfig, BorrowableConfig, PairConfig, CLAIM_AGGREGATOR, IMPERMAX_CHEF, IMX, IMPERMAX_FACTORY, getNetworkFactories, LENDING_VAULT_WATCHER, 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, ProposalState, WhitelistState, VaultListOrderBy, VaultListParams, LendingPoolListOrderBy, LendingPoolListParams, SortDirection, LendingPoolVersion, PermitType, Permits, Permit, };
|
package/lib/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.OnchainInteractionsLendingVault = exports.OnchainInteractionsBorrowable = exports.OnchainInteractionsCollateral = exports.OnchainInteractionsPoolToken = exports.OnchainInteractionsLendingPool = exports.OnchainInteractions = exports.OnchainImpermaxFactory = exports.OnchainContractsHelper = exports.OnchainAccountLendingVault = exports.OnchainAccountCollateral = exports.OnchainAccountBorrowable = exports.OnchainAccountPoolToken = exports.OnchainAccountLendingPool = exports.OnchainAccount = exports.OnchainPairConfig = exports.OnchainProposal = exports.OnchainConfigManager = exports.OnchainLendingVault = exports.OnchainCollateral = exports.OnchainBorrowable = exports.OnchainPoolToken = exports.OnchainLendingPool = exports.Onchain = exports.onchain = exports.VaultType = exports.VaultRisk = exports.OffchainSolidexHelper = exports.OffchainPriceHelper = exports.OffchainAccountVault = exports.OffchainLeveragedPosition = exports.OffchainAccountBorrowable = exports.OffchainAccountCollateral = exports.OffchainAccountPoolToken = exports.OffchainAccountLendingPool = exports.OffchainAccount = exports.OffchainMultichainAccount = exports.OffchainProposal = exports.OffchainPairConfig = exports.OffchainConfigManager = exports.OffchainHedgedVault = exports.OffchainLendingVault = exports.OffchainLeveragedVault = exports.OffchainVault = exports.OffchainBorrowable = exports.OffchainCollateral = exports.OffchainPoolToken = exports.OffchainLendingPool = exports.Offchain = exports.OffchainMultichain = exports.offchain = void 0;
|
|
27
27
|
exports.WhitelistState = exports.ProposalState = exports.Amms = exports.PoolTokenType = exports.Factory = exports.Networks = exports.XIMX_SUBGRAPH_URL = exports.BLOCKS_SUBGRAPH_URL = exports.IMPERMAX_CHEF_SUBGRAPH_URL = exports.IMPERMAX_SUBGRAPH_URL = exports.APPROVE_AMOUNT = exports.ZERO = exports.DEADLINE = exports.NOT_SYNCED = exports.getFarmByStakedLPFactory = exports.STAKED_LP_FACTORY = exports.hrFarms = exports.Farms = exports.V2_FACTORIES = exports.LIQUIDATION_FEE_FACTORIES = exports.OLD_KINK_MULTIPLIER_FACTORIES = exports.BORROW_FEE_FACTORIES = exports.SOLIDEX_FACTORIES = exports.ETH_NAME = exports.ETH_SYMBOL = exports.DEBANK_IDS = exports.AMM_LP_FEE = exports.ADD_LIQUIDITY_URLS = exports.AMM_SUBGRAPH_URLS = exports.getAmmByFactory = exports.AMM_FACTORY = exports.hrAmms = exports.MERKLE_URL_IBEX_2 = exports.MERKLE_URL_IBEX = exports.MERKLE_URL_ETH = exports.WETH = exports.SIMPLE_UNISWAP_ORACLE = exports.ROUTER = exports.MERKLE_DISTRIBUTOR_ETH = exports.MERKLE_DISTRIBUTOR_IBEX_2 = exports.MERKLE_DISTRIBUTOR_IBEX = exports.LENDING_VAULT_WATCHER = exports.getNetworkFactories = exports.IMPERMAX_FACTORY = exports.IMX = exports.IMPERMAX_CHEF = exports.CLAIM_AGGREGATOR = exports.NO_CHANGES = exports.ApprovalType = exports.OnchainInteractionsConfigManager = void 0;
|
|
28
|
-
exports.LendingPoolVersion = exports.SortDirection = exports.LendingPoolListOrderBy = exports.VaultListOrderBy = void 0;
|
|
28
|
+
exports.PermitType = exports.LendingPoolVersion = exports.SortDirection = exports.LendingPoolListOrderBy = exports.VaultListOrderBy = void 0;
|
|
29
29
|
const offchain_1 = __importStar(require("./offchain"));
|
|
30
30
|
exports.Offchain = offchain_1.default;
|
|
31
31
|
Object.defineProperty(exports, "OffchainAccount", { enumerable: true, get: function () { return offchain_1.OffchainAccount; } });
|
|
@@ -113,6 +113,7 @@ Object.defineProperty(exports, "VaultType", { enumerable: true, get: function ()
|
|
|
113
113
|
const onchainTypes_1 = require("./onchain/onchainTypes");
|
|
114
114
|
Object.defineProperty(exports, "ApprovalType", { enumerable: true, get: function () { return onchainTypes_1.ApprovalType; } });
|
|
115
115
|
Object.defineProperty(exports, "NO_CHANGES", { enumerable: true, get: function () { return onchainTypes_1.NO_CHANGES; } });
|
|
116
|
+
Object.defineProperty(exports, "PermitType", { enumerable: true, get: function () { return onchainTypes_1.PermitType; } });
|
|
116
117
|
const lendingPool_1 = require("./offchain/lendingPool");
|
|
117
118
|
Object.defineProperty(exports, "OffchainBorrowable", { enumerable: true, get: function () { return lendingPool_1.OffchainBorrowable; } });
|
|
118
119
|
Object.defineProperty(exports, "OffchainCollateral", { enumerable: true, get: function () { return lendingPool_1.OffchainCollateral; } });
|
package/lib/offchain/offchain.js
CHANGED
|
@@ -132,6 +132,8 @@ const fantom_ids = {
|
|
|
132
132
|
class OffchainPriceHelper {
|
|
133
133
|
// No need for dexscreener mutex since it allows only one token per call
|
|
134
134
|
constructor(offchainMultichain) {
|
|
135
|
+
// Initialize the subgraph prices for each network
|
|
136
|
+
this.subgraphTokensPrice = {};
|
|
135
137
|
this.coingeckoInitialized = null;
|
|
136
138
|
this.fantomTokenPricesInitialized = null;
|
|
137
139
|
this.fantomTokenPrices = {};
|
|
@@ -139,7 +141,7 @@ class OffchainPriceHelper {
|
|
|
139
141
|
this.debankTokensPrice = {};
|
|
140
142
|
}
|
|
141
143
|
cleanCache() {
|
|
142
|
-
this.subgraphTokensPrice =
|
|
144
|
+
this.subgraphTokensPrice = {};
|
|
143
145
|
this.debankTokensPrice = {};
|
|
144
146
|
}
|
|
145
147
|
// First source of token price: Offchain (less accurate, faster)
|
|
@@ -182,9 +184,12 @@ class OffchainPriceHelper {
|
|
|
182
184
|
}
|
|
183
185
|
getSubgraphTokensPrice(network) {
|
|
184
186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
if
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
// Initialize this network's prices if not already done
|
|
188
|
+
if (!this.subgraphTokensPrice[network]) {
|
|
189
|
+
this.subgraphTokensPrice[network] =
|
|
190
|
+
this.initializeSubgraphTokenPrice(network);
|
|
191
|
+
}
|
|
192
|
+
return this.subgraphTokensPrice[network];
|
|
188
193
|
});
|
|
189
194
|
}
|
|
190
195
|
/* -----------------------------------------------------------------------
|
|
@@ -13,10 +13,9 @@ export default class OffchainLendingVault extends OffchainVault {
|
|
|
13
13
|
getRiskLevel(): Promise<RiskLevel>;
|
|
14
14
|
getAvailableLiquidity(): Promise<number>;
|
|
15
15
|
getAvailableLiquidityUSD(): Promise<number>;
|
|
16
|
-
|
|
17
|
-
/** Get all borrowables with the AMM of the collateral's underlying pair, if found. can be null */
|
|
16
|
+
getBorrowableAmm(borrowable: VaultBorrowable): Promise<Amms | null>;
|
|
18
17
|
getBorrowablesWithAmm(): Promise<Array<VaultBorrowable & {
|
|
19
18
|
amm: Amms | null;
|
|
20
19
|
}>>;
|
|
21
|
-
|
|
20
|
+
getBorrowables(): Promise<Array<VaultBorrowable>>;
|
|
22
21
|
}
|
|
@@ -45,17 +45,23 @@ class OffchainLendingVault extends offchainVault_1.default {
|
|
|
45
45
|
return availableLiquidity * tokenPrice;
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
getBorrowableAmm(borrowable) {
|
|
49
|
+
var _a, _b;
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
const lendingPoolsData = yield this.getOffchain().getLendingPoolsData();
|
|
52
|
+
for (const factory in lendingPoolsData) {
|
|
53
|
+
const pair = lendingPoolsData[factory][borrowable.pairAddress];
|
|
54
|
+
if (pair) {
|
|
55
|
+
// TODO: Rename dexfactory in subgraph to find common solution
|
|
56
|
+
const factoryAddress = factory === "8"
|
|
57
|
+
? (_a = pair.nftlp) === null || _a === void 0 ? void 0 : _a.dexFactory
|
|
58
|
+
: (_b = pair.pair) === null || _b === void 0 ? void 0 : _b.uniswapV2Factory;
|
|
59
|
+
return (0, amms_1.getAmmByFactory)(this.getOffchain().network, factoryAddress);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
55
63
|
});
|
|
56
64
|
}
|
|
57
|
-
// WARN: Experimental - Might be removed if can find better way of handling this
|
|
58
|
-
/** Get all borrowables with the AMM of the collateral's underlying pair, if found. can be null */
|
|
59
65
|
getBorrowablesWithAmm() {
|
|
60
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
67
|
const borrowables = yield this.getBorrowables();
|
|
@@ -65,20 +71,13 @@ class OffchainLendingVault extends offchainVault_1.default {
|
|
|
65
71
|
return borrowablesWithAmm;
|
|
66
72
|
});
|
|
67
73
|
}
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
var _a, _b;
|
|
74
|
+
// See the LendingVaultData type in ../offchainTypes.ts
|
|
75
|
+
getBorrowables() {
|
|
71
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// TODO: Rename dexfactory in subgraph to find common solution
|
|
77
|
-
const factoryAddress = factory === "8" ? (_a = pair.nftlp) === null || _a === void 0 ? void 0 : _a.dexFactory : (_b = pair.pair) === null || _b === void 0 ? void 0 : _b.uniswapV2Factory;
|
|
78
|
-
return (0, amms_1.getAmmByFactory)(this.getOffchain().network, factoryAddress);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return null;
|
|
77
|
+
const vaultData = (yield this.getPoolTokenData());
|
|
78
|
+
if (!vaultData.borrowables)
|
|
79
|
+
return [];
|
|
80
|
+
return vaultData.borrowables;
|
|
82
81
|
});
|
|
83
82
|
}
|
|
84
83
|
}
|
|
@@ -14,12 +14,22 @@ export declare enum VaultStatus {
|
|
|
14
14
|
BLACKLISTED = "Blacklisted",
|
|
15
15
|
ACTIVE = "Active"
|
|
16
16
|
}
|
|
17
|
+
type VaultDayData = {
|
|
18
|
+
id: string;
|
|
19
|
+
supplyAPR: string;
|
|
20
|
+
totalSupply: string;
|
|
21
|
+
exchangeRate: string;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
timestampUTC: string;
|
|
24
|
+
vault: string;
|
|
25
|
+
};
|
|
17
26
|
export default class OffchainVault extends OffchainPoolToken {
|
|
18
27
|
private readonly offchain;
|
|
19
28
|
private readonly vaultAddress;
|
|
20
29
|
protected vaultType: VaultType;
|
|
21
30
|
protected vaultRisk: VaultRisk;
|
|
22
31
|
protected vaultStatus: VaultStatus;
|
|
32
|
+
protected vaultDayData: Array<VaultDayData> | null;
|
|
23
33
|
constructor(offchain: Offchain, vaultAddress: Address);
|
|
24
34
|
getOffchain: () => Offchain;
|
|
25
35
|
getVaultAddress: () => string;
|
|
@@ -42,4 +52,6 @@ export default class OffchainVault extends OffchainPoolToken {
|
|
|
42
52
|
isBlacklisted(): Promise<boolean>;
|
|
43
53
|
isStable(): Promise<boolean>;
|
|
44
54
|
isHighTVL(): Promise<boolean>;
|
|
55
|
+
getVaultChart(): Promise<Array<VaultDayData> | null>;
|
|
45
56
|
}
|
|
57
|
+
export {};
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.VaultStatus = exports.VaultRisk = void 0;
|
|
16
16
|
const offchainPoolToken_1 = __importDefault(require("../offchainPoolToken"));
|
|
17
17
|
const utils_1 = require("../../utils");
|
|
18
|
+
const private_api_1 = require("../../config/private-api");
|
|
18
19
|
var VaultRisk;
|
|
19
20
|
(function (VaultRisk) {
|
|
20
21
|
VaultRisk["VERY_LOW"] = "very-low";
|
|
@@ -32,6 +33,7 @@ var VaultStatus;
|
|
|
32
33
|
class OffchainVault extends offchainPoolToken_1.default {
|
|
33
34
|
constructor(offchain, vaultAddress) {
|
|
34
35
|
super();
|
|
36
|
+
this.vaultDayData = null;
|
|
35
37
|
this.getOffchain = () => this.offchain;
|
|
36
38
|
this.getVaultAddress = () => this.vaultAddress;
|
|
37
39
|
this.getVaultType = () => this.vaultType;
|
|
@@ -40,7 +42,6 @@ class OffchainVault extends offchainPoolToken_1.default {
|
|
|
40
42
|
this.offchain = offchain;
|
|
41
43
|
this.vaultAddress = vaultAddress;
|
|
42
44
|
}
|
|
43
|
-
// NOTE: Rename this to `getVaultData` ?
|
|
44
45
|
getPoolTokenData() {
|
|
45
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
47
|
return this.offchain.getVaultData(this.vaultAddress);
|
|
@@ -137,5 +138,30 @@ class OffchainVault extends offchainPoolToken_1.default {
|
|
|
137
138
|
return false;
|
|
138
139
|
});
|
|
139
140
|
}
|
|
141
|
+
//
|
|
142
|
+
// API Functions (ie. not part of core, see `config/private-api.ts`)
|
|
143
|
+
//
|
|
144
|
+
// Avoid doing this through initializer and do it as-needed
|
|
145
|
+
getVaultChart() {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
if (this.vaultDayData)
|
|
148
|
+
return this.vaultDayData;
|
|
149
|
+
const network = this.getOffchain().network;
|
|
150
|
+
const vaultAddress = this.getVaultAddress();
|
|
151
|
+
const api = private_api_1.IMPERMAX_VAULT_API[network][this.vaultType];
|
|
152
|
+
if (!api) {
|
|
153
|
+
console.log(`Missing API for ${vaultAddress} on ${network}?`);
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
this.vaultDayData = yield fetch(api.concat(vaultAddress)).then((i) => i.json());
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
console.log(`No vault data found for ${vaultAddress} on ${network}`);
|
|
161
|
+
this.vaultDayData = []; // Leave empty to prevent refeteching
|
|
162
|
+
}
|
|
163
|
+
return this.vaultDayData;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
140
166
|
}
|
|
141
167
|
exports.default = OffchainVault;
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const onchainTypes_1 = require("./onchainTypes");
|
|
12
13
|
const ethers_1 = require("ethers");
|
|
13
14
|
const general_1 = require("../config/general");
|
|
14
15
|
const PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
@@ -138,8 +139,8 @@ class OnchainPermitHelper {
|
|
|
138
139
|
if (!signature)
|
|
139
140
|
return callBack(null);
|
|
140
141
|
callBack({
|
|
141
|
-
permitType:
|
|
142
|
-
permitData: ethers_1.ethers.utils.defaultAbiCoder.encode(['address', 'uint256', 'uint256'], [token.
|
|
142
|
+
permitType: onchainTypes_1.PermitType.PERMIT1,
|
|
143
|
+
permitData: ethers_1.ethers.utils.defaultAbiCoder.encode(['address', 'uint256', 'uint256'], [token._address, value.toString(), this.deadline]),
|
|
143
144
|
signature
|
|
144
145
|
});
|
|
145
146
|
});
|
|
@@ -158,7 +159,7 @@ class OnchainPermitHelper {
|
|
|
158
159
|
if (!signature)
|
|
159
160
|
return callBack(null);
|
|
160
161
|
callBack({
|
|
161
|
-
permitType:
|
|
162
|
+
permitType: onchainTypes_1.PermitType.PERMIT_NFT,
|
|
162
163
|
permitData: ethers_1.ethers.utils.defaultAbiCoder.encode(['address', 'uint256', 'uint256'], [token.address, tokenId.toString(), this.deadline]),
|
|
163
164
|
signature
|
|
164
165
|
});
|
|
@@ -187,7 +188,7 @@ class OnchainPermitHelper {
|
|
|
187
188
|
if (!signature)
|
|
188
189
|
return callBack(null);
|
|
189
190
|
callBack({
|
|
190
|
-
permitType:
|
|
191
|
+
permitType: onchainTypes_1.PermitType.PERMIT2_SINGLE,
|
|
191
192
|
permitData: ethers_1.ethers.utils.defaultAbiCoder.encode([permitDetailsType, 'address', 'uint256'], [token, spender, this.deadline]),
|
|
192
193
|
signature
|
|
193
194
|
});
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { BigNumber } from "ethers";
|
|
2
2
|
import Offchain from "../offchain";
|
|
3
|
-
import { Networks } from
|
|
3
|
+
import { Networks } from "../config/types";
|
|
4
4
|
export type Contract = any;
|
|
5
5
|
export declare enum ApprovalType {
|
|
6
6
|
POOL_TOKEN = 0,
|
|
7
7
|
UNDERLYING = 1,
|
|
8
8
|
BORROW = 2
|
|
9
9
|
}
|
|
10
|
+
export declare enum PermitType {
|
|
11
|
+
PERMIT1 = 0,
|
|
12
|
+
PERMIT_NFT = 1,
|
|
13
|
+
PERMIT2_SINGLE = 2,
|
|
14
|
+
PERMIT2_BATCH = 3
|
|
15
|
+
}
|
|
10
16
|
export interface PermitData {
|
|
11
17
|
permitData: string;
|
|
12
18
|
amount: BigNumber;
|
|
13
19
|
deadline: BigNumber;
|
|
14
20
|
}
|
|
15
21
|
export interface Permit {
|
|
16
|
-
permitType:
|
|
22
|
+
permitType: PermitType;
|
|
17
23
|
permitData: string;
|
|
18
24
|
signature: string;
|
|
19
25
|
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NO_CHANGES = exports.ApprovalType = void 0;
|
|
3
|
+
exports.NO_CHANGES = exports.PermitType = exports.ApprovalType = void 0;
|
|
4
4
|
var ApprovalType;
|
|
5
5
|
(function (ApprovalType) {
|
|
6
6
|
ApprovalType[ApprovalType["POOL_TOKEN"] = 0] = "POOL_TOKEN";
|
|
7
7
|
ApprovalType[ApprovalType["UNDERLYING"] = 1] = "UNDERLYING";
|
|
8
8
|
ApprovalType[ApprovalType["BORROW"] = 2] = "BORROW";
|
|
9
9
|
})(ApprovalType = exports.ApprovalType || (exports.ApprovalType = {}));
|
|
10
|
+
var PermitType;
|
|
11
|
+
(function (PermitType) {
|
|
12
|
+
PermitType[PermitType["PERMIT1"] = 0] = "PERMIT1";
|
|
13
|
+
PermitType[PermitType["PERMIT_NFT"] = 1] = "PERMIT_NFT";
|
|
14
|
+
PermitType[PermitType["PERMIT2_SINGLE"] = 2] = "PERMIT2_SINGLE";
|
|
15
|
+
PermitType[PermitType["PERMIT2_BATCH"] = 3] = "PERMIT2_BATCH";
|
|
16
|
+
})(PermitType = exports.PermitType || (exports.PermitType = {}));
|
|
10
17
|
exports.NO_CHANGES = {
|
|
11
18
|
changeBorrowedA: 0,
|
|
12
19
|
changeBorrowedB: 0,
|