impermax-sdk 2.1.7 → 2.1.9
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 +5 -2
- package/lib/config/contracts/impermax-factories.js +1 -0
- package/lib/config/subgraphs.js +4 -0
- package/lib/config/types.d.ts +3 -4
- package/lib/index.d.ts +3 -2
- package/lib/index.js +5 -2
- package/lib/offchain/lendingPool/offchainLendingPool.d.ts +14 -14
- package/lib/offchain/lendingPool/offchainLendingPool.js +65 -35
- package/lib/offchain/offchainAPRHelper.js +16 -11
- package/lib/offchain/offchainInitializer.js +22 -10
- package/lib/offchain/offchainMultichain.d.ts +2 -2
- package/lib/offchain/offchainMultichain.js +38 -23
- package/lib/offchain/queries/apis/ponder/index.d.ts +1 -0
- package/lib/offchain/queries/apis/ponder/index.js +81 -0
- package/lib/offchain/queries/apis/thegraph/index.d.ts +1 -0
- package/lib/offchain/queries/apis/thegraph/index.js +3 -0
- package/lib/offchain/queries/interfaces/query-builder.d.ts +1 -0
- package/package.json +1 -1
package/lib/config/amms.d.ts
CHANGED
|
@@ -45,10 +45,12 @@ export declare enum Amms {
|
|
|
45
45
|
equalizer = "equalizer",
|
|
46
46
|
wigoswap = "wigoswap",
|
|
47
47
|
velodrome = "velodrome",
|
|
48
|
-
alien = "alien"
|
|
48
|
+
alien = "alien",
|
|
49
|
+
uniswapv3 = "uniswapv3"
|
|
49
50
|
}
|
|
50
51
|
export declare const hrAmms: {
|
|
51
52
|
uniswap: string;
|
|
53
|
+
uniswapv3: string;
|
|
52
54
|
quickswap: string;
|
|
53
55
|
satin: string;
|
|
54
56
|
pearl: string;
|
package/lib/config/amms.js
CHANGED
|
@@ -50,9 +50,11 @@ var Amms;
|
|
|
50
50
|
Amms["wigoswap"] = "wigoswap";
|
|
51
51
|
Amms["velodrome"] = "velodrome";
|
|
52
52
|
Amms["alien"] = "alien";
|
|
53
|
+
Amms["uniswapv3"] = "uniswapv3";
|
|
53
54
|
})(Amms = exports.Amms || (exports.Amms = {}));
|
|
54
55
|
exports.hrAmms = {
|
|
55
|
-
[Amms.uniswap]: '
|
|
56
|
+
[Amms.uniswap]: 'UniswapV2',
|
|
57
|
+
[Amms.uniswapv3]: 'UniswapV3',
|
|
56
58
|
[Amms.quickswap]: 'QuickSwap',
|
|
57
59
|
[Amms.satin]: 'Satin',
|
|
58
60
|
[Amms.pearl]: 'Pearl',
|
|
@@ -173,7 +175,8 @@ exports.AMM_FACTORY = {
|
|
|
173
175
|
[Amms.aeroStable1]: '0x9111b8D7Cc1a676A70015BEA3A3a9968A44C52c3',
|
|
174
176
|
[Amms.scale]: '0xEd8db60aCc29e14bC867a497D94ca6e3CeB5eC04',
|
|
175
177
|
[Amms.uniswap]: '0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6',
|
|
176
|
-
[Amms.alien]: '0x3E84D913803b02A4a7f027165E8cA42C14C0FdE7'
|
|
178
|
+
[Amms.alien]: '0x3E84D913803b02A4a7f027165E8cA42C14C0FdE7',
|
|
179
|
+
[Amms.uniswapv3]: '0x33128a8fc17869897dce68ed026d694621f6fdfd'
|
|
177
180
|
},
|
|
178
181
|
[types_1.Networks.Scroll]: {
|
|
179
182
|
[Amms.tokan]: '0x074568F090e93194289c2C2BF285eE7f60b485a9',
|
|
@@ -50,6 +50,7 @@ exports.IMPERMAX_FACTORY = {
|
|
|
50
50
|
[types_1.Factory.SOLV2]: '0x66ca66E002a9CEE8dEfE25dB6f0c6225117C2d9f',
|
|
51
51
|
[types_1.Factory.SOL_STABLE]: '0x8aDc5F73e63b3Af3fd0648281fE451738D8B9D86',
|
|
52
52
|
[types_1.Factory.V2V2]: '0x47183bB55AD0F891887E099Cec3570d3C667cD00',
|
|
53
|
+
[types_1.Factory.V3]: '0xfa13d3fda783824949bef75f5e95bb546cfddf6f',
|
|
53
54
|
},
|
|
54
55
|
[types_1.Networks.Scroll]: {
|
|
55
56
|
[types_1.Factory.SOLV2]: '0x02Ff7B4d96EeBF8c9B34Fae0418E591e11da3099',
|
package/lib/config/subgraphs.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WHITELIST_SUBGRAPH_URL = exports.CONFIG_MANAGER_SUBGRAPH_URL = exports.XIMX_SUBGRAPH_URL = exports.BLOCKS_SUBGRAPH_URL = exports.IMPERMAX_CHEF_SUBGRAPH_URL = exports.VAULT_SUBGRAPH_URL = exports.IMPERMAX_SUBGRAPH_URL = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
|
+
// @ts-ignore
|
|
5
6
|
exports.IMPERMAX_SUBGRAPH_URL = {
|
|
6
7
|
[types_1.Networks.Ropsten]: {},
|
|
7
8
|
[types_1.Networks.Mainnet]: {
|
|
@@ -102,6 +103,9 @@ exports.IMPERMAX_SUBGRAPH_URL = {
|
|
|
102
103
|
"https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/B7xsBeef3FohKaFPcsAsviyLKaWXTqcSELjAsPj2B7iW",
|
|
103
104
|
"https://base-start-production.up.railway.app/",
|
|
104
105
|
],
|
|
106
|
+
[types_1.Factory.V3]: [
|
|
107
|
+
"https://impermax-indexer-production.up.railway.app/",
|
|
108
|
+
],
|
|
105
109
|
},
|
|
106
110
|
[types_1.Networks.Scroll]: {
|
|
107
111
|
[types_1.Factory.SOLV2]: [
|
package/lib/config/types.d.ts
CHANGED
|
@@ -88,8 +88,7 @@ export declare enum VaultType {
|
|
|
88
88
|
HEDGED = "Hedged",
|
|
89
89
|
LEVERAGED = "Leverage"
|
|
90
90
|
}
|
|
91
|
-
export type
|
|
92
|
-
[key in
|
|
93
|
-
[key in VaultType]?: Type;
|
|
94
|
-
};
|
|
91
|
+
export type VaultTypeIndex<Type> = {
|
|
92
|
+
[key in VaultType]?: Type;
|
|
95
93
|
};
|
|
94
|
+
export type NetworkVaultTypeIndex<Type> = NetworkIndex<VaultTypeIndex<Type>>;
|
package/lib/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { OnchainInteractionsLendingPool, OnchainInteractionsLendingVault, Onchai
|
|
|
33
33
|
import { OnchainInteractionsBorrowable, OnchainInteractionsCollateral } from './onchain/interactions/lendingPool';
|
|
34
34
|
import { LENDING_VAULT_WATCHER } from './config/contracts/lending-vault-watcher';
|
|
35
35
|
import OffchainVault, { OffchainLendingVault, OffchainLeveragedVault, OffchainHedgedVault } from './offchain/vault';
|
|
36
|
-
import { SortDirection,
|
|
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 };
|
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.SortDirection = exports.
|
|
28
|
+
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; } });
|
|
@@ -162,6 +162,9 @@ Object.defineProperty(exports, "OffchainHedgedVault", { enumerable: true, get: f
|
|
|
162
162
|
// Data helpers (sort, filter)
|
|
163
163
|
const offchainMultichain_1 = require("./offchain/offchainMultichain");
|
|
164
164
|
Object.defineProperty(exports, "SortDirection", { enumerable: true, get: function () { return offchainMultichain_1.SortDirection; } });
|
|
165
|
-
Object.defineProperty(exports, "
|
|
165
|
+
Object.defineProperty(exports, "VaultListOrderBy", { enumerable: true, get: function () { return offchainMultichain_1.VaultListOrderBy; } });
|
|
166
|
+
Object.defineProperty(exports, "LendingPoolListOrderBy", { enumerable: true, get: function () { return offchainMultichain_1.LendingPoolListOrderBy; } });
|
|
166
167
|
const offchainVault_1 = require("./offchain/vault/offchainVault");
|
|
167
168
|
Object.defineProperty(exports, "VaultRisk", { enumerable: true, get: function () { return offchainVault_1.VaultRisk; } });
|
|
169
|
+
const offchainLendingPool_1 = require("./offchain/lendingPool/offchainLendingPool");
|
|
170
|
+
Object.defineProperty(exports, "LendingPoolVersion", { enumerable: true, get: function () { return offchainLendingPool_1.LendingPoolVersion; } });
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import Offchain from
|
|
2
|
-
import { Address, Borrowable, Factory, PoolTokenType, WhitelistState } from
|
|
3
|
-
import OffchainCollateral from
|
|
4
|
-
import OffchainBorrowable from
|
|
5
|
-
import OffchainPoolToken from
|
|
6
|
-
import { LendingPoolData, LendingPoolPastData } from
|
|
7
|
-
import { Farms } from
|
|
8
|
-
import { Amms } from
|
|
1
|
+
import Offchain from "../index";
|
|
2
|
+
import { Address, Borrowable, Factory, PoolTokenType, WhitelistState } from "../../config/types";
|
|
3
|
+
import OffchainCollateral from "./offchainCollateral";
|
|
4
|
+
import OffchainBorrowable from "./offchainBorrowable";
|
|
5
|
+
import OffchainPoolToken from "../offchainPoolToken";
|
|
6
|
+
import { LendingPoolData, LendingPoolPastData } from "../offchainTypes";
|
|
7
|
+
import { Farms } from "../../config/farms";
|
|
8
|
+
import { Amms } from "../../config/amms";
|
|
9
9
|
export declare enum LendingPoolVersion {
|
|
10
|
-
V1 =
|
|
11
|
-
V2 =
|
|
12
|
-
V3 =
|
|
10
|
+
V1 = "V1",
|
|
11
|
+
V2 = "V2",
|
|
12
|
+
V3 = "V3"
|
|
13
13
|
}
|
|
14
14
|
export default class OffchainLendingPool {
|
|
15
15
|
private readonly offchain;
|
|
@@ -48,13 +48,13 @@ export default class OffchainLendingPool {
|
|
|
48
48
|
getCollateralPrice(fast?: boolean): Promise<number>;
|
|
49
49
|
getUnderlyingLPPrice(fast?: boolean): Promise<number>;
|
|
50
50
|
getKinkMultiplier(): 2 | 5;
|
|
51
|
-
getTotalBorrowsUSD(): Promise<number>;
|
|
52
51
|
getTotalAPR(): Promise<number>;
|
|
53
52
|
getTVL(): Promise<number>;
|
|
54
53
|
isDeprecated(): Promise<boolean>;
|
|
55
54
|
isBlacklisted(): Promise<boolean>;
|
|
56
|
-
isStable(): Promise<boolean>;
|
|
57
55
|
isLowTVL(): Promise<boolean>;
|
|
58
56
|
isHighTVL(): Promise<boolean>;
|
|
59
|
-
|
|
57
|
+
isStable(): boolean;
|
|
58
|
+
getLendingPoolVersion(): LendingPoolVersion;
|
|
59
|
+
getTotalBorrowsUSD(): Promise<number>;
|
|
60
60
|
}
|
|
@@ -22,9 +22,9 @@ const amms_1 = require("../../config/amms");
|
|
|
22
22
|
const factories_1 = require("../../config/factories");
|
|
23
23
|
var LendingPoolVersion;
|
|
24
24
|
(function (LendingPoolVersion) {
|
|
25
|
-
LendingPoolVersion[
|
|
26
|
-
LendingPoolVersion[
|
|
27
|
-
LendingPoolVersion[
|
|
25
|
+
LendingPoolVersion["V1"] = "V1";
|
|
26
|
+
LendingPoolVersion["V2"] = "V2";
|
|
27
|
+
LendingPoolVersion["V3"] = "V3";
|
|
28
28
|
})(LendingPoolVersion = exports.LendingPoolVersion || (exports.LendingPoolVersion = {}));
|
|
29
29
|
class OffchainLendingPool {
|
|
30
30
|
constructor(offchain, factory, pairAddress) {
|
|
@@ -83,7 +83,7 @@ class OffchainLendingPool {
|
|
|
83
83
|
}
|
|
84
84
|
getLiquidationPenalty() {
|
|
85
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
return (yield this.getLiquidationIncentive()) + (yield this.getLiquidationFee());
|
|
86
|
+
return ((yield this.getLiquidationIncentive()) + (yield this.getLiquidationFee()));
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
// Uniswap APR
|
|
@@ -110,8 +110,13 @@ class OffchainLendingPool {
|
|
|
110
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
111
|
const farm = yield this.getFarm();
|
|
112
112
|
const lendingPoolData = yield this.getLendingPoolData();
|
|
113
|
-
if (farm === farms_1.Farms.solidex ||
|
|
114
|
-
|
|
113
|
+
if (farm === farms_1.Farms.solidex ||
|
|
114
|
+
farm === farms_1.Farms.solidexB ||
|
|
115
|
+
farm === farms_1.Farms.solidexUSDC ||
|
|
116
|
+
farm === farms_1.Farms.solidexUSDCB) {
|
|
117
|
+
const solidexLPDetails = yield this.offchain
|
|
118
|
+
.getSolidexHelper()
|
|
119
|
+
.getSolidexLPDetails();
|
|
115
120
|
const result = solidexLPDetails[lendingPoolData.pair.uniswapV2PairAddress];
|
|
116
121
|
if (result)
|
|
117
122
|
return result;
|
|
@@ -123,14 +128,19 @@ class OffchainLendingPool {
|
|
|
123
128
|
for (const reward of lendingPoolData.pair.rewards) {
|
|
124
129
|
const multiplier = farm === farms_1.Farms.traderJoeV2 ? 0.5 : 1;
|
|
125
130
|
const periodFinish = parseInt(reward.periodFinish);
|
|
126
|
-
if (
|
|
131
|
+
if (new Date().getTime() / 1000 - FINISH_DELAY > periodFinish &&
|
|
132
|
+
periodFinish !== 0)
|
|
127
133
|
continue;
|
|
128
134
|
let rewardRate = parseFloat(reward.rewardRate);
|
|
129
135
|
if (farm == farms_1.Farms.traderJoeV4)
|
|
130
136
|
rewardRate = rewardRate * 0.45;
|
|
131
|
-
const rewardPrice = yield this.offchain
|
|
137
|
+
const rewardPrice = yield this.offchain
|
|
138
|
+
.getPriceHelper()
|
|
139
|
+
.getDebankTokenPrice(reward.rewardsToken.id);
|
|
132
140
|
rewards.push({
|
|
133
|
-
APR: (0, utils_1.toAPR)((rewardPrice * rewardRate) /
|
|
141
|
+
APR: (0, utils_1.toAPR)(((rewardPrice * rewardRate) /
|
|
142
|
+
(stakedTotalSupply * underlyingLPPrice)) *
|
|
143
|
+
multiplier),
|
|
134
144
|
symbol: reward.rewardsToken.symbol,
|
|
135
145
|
});
|
|
136
146
|
}
|
|
@@ -197,16 +207,17 @@ class OffchainLendingPool {
|
|
|
197
207
|
getCollateralPrice(fast = true) {
|
|
198
208
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
209
|
const lendingPoolData = yield this.getLendingPoolData();
|
|
200
|
-
return this.calculateCollateralPrice(parseFloat(lendingPoolData.pair.reserve0), parseFloat(lendingPoolData.pair.reserve1), parseFloat(lendingPoolData.pair.totalSupply), fast
|
|
201
|
-
yield this.getBorrowableA().getTokenPriceFast()
|
|
202
|
-
yield this.getBorrowableA().getTokenPriceAccurate(), fast
|
|
203
|
-
yield this.getBorrowableB().getTokenPriceFast()
|
|
204
|
-
yield this.getBorrowableB().getTokenPriceAccurate());
|
|
210
|
+
return this.calculateCollateralPrice(parseFloat(lendingPoolData.pair.reserve0), parseFloat(lendingPoolData.pair.reserve1), parseFloat(lendingPoolData.pair.totalSupply), fast
|
|
211
|
+
? yield this.getBorrowableA().getTokenPriceFast()
|
|
212
|
+
: yield this.getBorrowableA().getTokenPriceAccurate(), fast
|
|
213
|
+
? yield this.getBorrowableB().getTokenPriceFast()
|
|
214
|
+
: yield this.getBorrowableB().getTokenPriceAccurate());
|
|
205
215
|
});
|
|
206
216
|
}
|
|
207
217
|
getUnderlyingLPPrice(fast = true) {
|
|
208
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
return (yield this.getCollateralPrice(fast)) /
|
|
219
|
+
return ((yield this.getCollateralPrice(fast)) /
|
|
220
|
+
(yield this.getStakedLPExchangeRate()));
|
|
210
221
|
});
|
|
211
222
|
}
|
|
212
223
|
// Kink Multiplier
|
|
@@ -215,29 +226,33 @@ class OffchainLendingPool {
|
|
|
215
226
|
return 5;
|
|
216
227
|
return 2;
|
|
217
228
|
}
|
|
218
|
-
// Stats
|
|
219
|
-
getTotalBorrowsUSD() {
|
|
220
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
-
const totalBorrowsUSDA = yield this.getBorrowableA().getTotalBorrowsUSD();
|
|
222
|
-
const totalBorrowsUSDB = yield this.getBorrowableB().getTotalBorrowsUSD();
|
|
223
|
-
return totalBorrowsUSDA + totalBorrowsUSDB;
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
229
|
getTotalAPR() {
|
|
227
230
|
return __awaiter(this, void 0, void 0, function* () {
|
|
228
|
-
const uniswapV2Pair = (yield this.getLendingPoolData()).pair
|
|
231
|
+
const uniswapV2Pair = (yield this.getLendingPoolData()).pair
|
|
232
|
+
.uniswapV2PairAddress;
|
|
229
233
|
// If llama fails/apr is 0 we get the uniswapAPR and stakingAPR through subgraph
|
|
230
|
-
const apr = yield this.offchain
|
|
234
|
+
const apr = yield this.offchain
|
|
235
|
+
.getAPRHelper()
|
|
236
|
+
.getLlamaAPR(uniswapV2Pair, this.offchain.network);
|
|
231
237
|
if (apr > 0)
|
|
232
238
|
return apr;
|
|
233
|
-
const [uniswapAPR, stakingAPR] = yield Promise.all([
|
|
239
|
+
const [uniswapAPR, stakingAPR] = yield Promise.all([
|
|
240
|
+
this.getUniswapAPR(),
|
|
241
|
+
this.getStakingAPR(),
|
|
242
|
+
]);
|
|
234
243
|
return uniswapAPR + stakingAPR;
|
|
235
244
|
});
|
|
236
245
|
}
|
|
246
|
+
// NOTE: Should this also include collateral totalBalanceUSD ?
|
|
237
247
|
getTVL() {
|
|
238
248
|
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
-
|
|
240
|
-
|
|
249
|
+
const [supply0USD, supply1USD] = yield Promise.all([
|
|
250
|
+
this.getBorrowableA().getSupplyUSD(),
|
|
251
|
+
this.getBorrowableB().getSupplyUSD(),
|
|
252
|
+
]);
|
|
253
|
+
if (supply0USD && supply1USD)
|
|
254
|
+
return supply0USD + supply1USD;
|
|
255
|
+
return 0;
|
|
241
256
|
});
|
|
242
257
|
}
|
|
243
258
|
// Flags
|
|
@@ -251,11 +266,6 @@ class OffchainLendingPool {
|
|
|
251
266
|
return false;
|
|
252
267
|
});
|
|
253
268
|
}
|
|
254
|
-
isStable() {
|
|
255
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
-
return false;
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
269
|
isLowTVL() {
|
|
260
270
|
return __awaiter(this, void 0, void 0, function* () {
|
|
261
271
|
return false;
|
|
@@ -266,11 +276,31 @@ class OffchainLendingPool {
|
|
|
266
276
|
return false;
|
|
267
277
|
});
|
|
268
278
|
}
|
|
279
|
+
// WARN: If V3 supports multiple pool types, then need more robust way to check if is stable or not
|
|
280
|
+
isStable() {
|
|
281
|
+
const factoryType = Number(this.factory);
|
|
282
|
+
if (factoryType === 7)
|
|
283
|
+
return true;
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
269
286
|
// Versions Specfics
|
|
270
287
|
getLendingPoolVersion() {
|
|
271
|
-
|
|
272
|
-
|
|
288
|
+
const factoryType = Number(this.factory);
|
|
289
|
+
if (factoryType < 4)
|
|
290
|
+
return LendingPoolVersion.V1;
|
|
291
|
+
if (factoryType < 8)
|
|
273
292
|
return LendingPoolVersion.V2;
|
|
293
|
+
return LendingPoolVersion.V3;
|
|
294
|
+
}
|
|
295
|
+
getTotalBorrowsUSD() {
|
|
296
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
297
|
+
const [borrows0USD, borrows1USD] = yield Promise.all([
|
|
298
|
+
this.getBorrowableA().getTotalBorrowsUSD(),
|
|
299
|
+
this.getBorrowableB().getTotalBorrowsUSD(),
|
|
300
|
+
]);
|
|
301
|
+
if (borrows0USD && borrows1USD)
|
|
302
|
+
return borrows0USD + borrows1USD;
|
|
303
|
+
return 0;
|
|
274
304
|
});
|
|
275
305
|
}
|
|
276
306
|
}
|
|
@@ -167,18 +167,23 @@ class OffchainAPRHelper {
|
|
|
167
167
|
getLlamaAPR(pool, chain) {
|
|
168
168
|
var _a;
|
|
169
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
try {
|
|
171
|
+
// Get or initialize the pools
|
|
172
|
+
const llamaAllPools = yield this.getLlamaYields();
|
|
173
|
+
// Map to llama chain names, if not supported, then fetch native way
|
|
174
|
+
const llamaChain = LlamaChains[chain];
|
|
175
|
+
if (!llamaChain)
|
|
176
|
+
return 0;
|
|
177
|
+
// Make pool unique ({poolAddress}-{chain})
|
|
178
|
+
const llamaId = pool.concat("-", llamaChain).toLowerCase();
|
|
179
|
+
// Convert to decimals to match `getUniswapAPR` and `getStakingAPR`
|
|
180
|
+
const apy = ((_a = llamaAllPools[llamaId]) === null || _a === void 0 ? void 0 : _a.apy) / 100;
|
|
181
|
+
// If 0 then should fetch native way to make sure
|
|
182
|
+
return apy || 0;
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
175
185
|
return 0;
|
|
176
|
-
|
|
177
|
-
const llamaId = pool.concat("-", llamaChain).toLowerCase();
|
|
178
|
-
// Convert to decimals to match `getUniswapAPR` and `getStakingAPR`
|
|
179
|
-
const apy = ((_a = llamaAllPools[llamaId]) === null || _a === void 0 ? void 0 : _a.apy) / 100;
|
|
180
|
-
// If 0 then should fetch native way to make sure
|
|
181
|
-
return apy || 0;
|
|
186
|
+
}
|
|
182
187
|
});
|
|
183
188
|
}
|
|
184
189
|
getLlamaTvlAndBorrows(chain) {
|
|
@@ -65,26 +65,32 @@ exports.fetchBlockByTimestamp = fetchBlockByTimestamp;
|
|
|
65
65
|
function fetchVaults() {
|
|
66
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
67
|
const calls = [];
|
|
68
|
+
const vaultTypes = [];
|
|
68
69
|
let vaultType;
|
|
69
70
|
for (vaultType in subgraphs_1.VAULT_SUBGRAPH_URL[this.network]) {
|
|
70
71
|
const subgraphs = subgraphs_1.VAULT_SUBGRAPH_URL[this.network][vaultType];
|
|
71
72
|
if (!subgraphs || subgraphs.length === 0)
|
|
72
73
|
continue;
|
|
73
74
|
calls.push(this.endpointManager.fetch(subgraphs, this.network, (queryBuilder) => queryBuilder.vaultsQuery(vaultType, [])));
|
|
75
|
+
vaultTypes.push(vaultType);
|
|
74
76
|
}
|
|
75
77
|
const results = yield Promise.all(calls);
|
|
76
78
|
const vaults = {};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (!
|
|
81
|
-
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
results.forEach((result, index) => {
|
|
80
|
+
var _a;
|
|
81
|
+
// `offchainEndpointManager` returns null when using filters and cant find subgraph with filter
|
|
82
|
+
if (!result)
|
|
83
|
+
return;
|
|
84
|
+
// Get the vault type for this result
|
|
85
|
+
const vaultType = vaultTypes[index];
|
|
86
|
+
// WARN: data.lendingVaults will be wrong for different vaults! We should rename it to just vaults
|
|
87
|
+
const vaultsForType = (_a = result.data) === null || _a === void 0 ? void 0 : _a.lendingVaults;
|
|
88
|
+
if (!vaultsForType)
|
|
89
|
+
return;
|
|
90
|
+
// Add all vaults for this vault type
|
|
85
91
|
const typedVaults = vaultsForType.map((vault) => (Object.assign(Object.assign({}, vault), { vaultType })));
|
|
86
92
|
vaults[vaultType] = typedVaults;
|
|
87
|
-
}
|
|
93
|
+
});
|
|
88
94
|
return vaults;
|
|
89
95
|
});
|
|
90
96
|
}
|
|
@@ -278,6 +284,7 @@ function fetchUniswapAPR(lendingPoolsByAmm, seconds = 60 * 60 * 24 * 7) {
|
|
|
278
284
|
exports.fetchUniswapAPR = fetchUniswapAPR;
|
|
279
285
|
// OffchainLendingPool Data
|
|
280
286
|
function initializeLendingPoolsData() {
|
|
287
|
+
var _a, _b, _c;
|
|
281
288
|
return __awaiter(this, void 0, void 0, function* () {
|
|
282
289
|
const lendingPoolsData = {};
|
|
283
290
|
// Get raw data
|
|
@@ -291,7 +298,9 @@ function initializeLendingPoolsData() {
|
|
|
291
298
|
const lendingPoolsByAmm = {};
|
|
292
299
|
for (const factory in lendingPools) {
|
|
293
300
|
for (const lendingPool of lendingPools[factory]) {
|
|
294
|
-
const amm = (0, amms_1.getAmmByFactory)(this.network,
|
|
301
|
+
const amm = (0, amms_1.getAmmByFactory)(this.network,
|
|
302
|
+
// WARN: Quick temporary fix, to be removed after
|
|
303
|
+
(_b = (_a = lendingPool === null || lendingPool === void 0 ? void 0 : lendingPool.pair) === null || _a === void 0 ? void 0 : _a.uniswapV2Factory) !== null && _b !== void 0 ? _b : (_c = lendingPool === null || lendingPool === void 0 ? void 0 : lendingPool.nftlp) === null || _c === void 0 ? void 0 : _c.dexFactory);
|
|
295
304
|
if (!amm)
|
|
296
305
|
continue;
|
|
297
306
|
if (!lendingPoolsByAmm[amm])
|
|
@@ -304,6 +313,9 @@ function initializeLendingPoolsData() {
|
|
|
304
313
|
// Organize lending pools data
|
|
305
314
|
for (const factory in lendingPools) {
|
|
306
315
|
for (const lendingPool of lendingPools[factory]) {
|
|
316
|
+
// WARN: Quick temporary fix, to be removed after
|
|
317
|
+
if (factory === "8")
|
|
318
|
+
lendingPool['pair'] = lendingPool['nftlp'];
|
|
307
319
|
lendingPool.pair.uniswapAPR = uniswapAPR[lendingPool.id] || 0;
|
|
308
320
|
if (impermaxChefRewardRates) {
|
|
309
321
|
lendingPool.borrowable0.rewards =
|
|
@@ -10,7 +10,7 @@ export declare enum SortDirection {
|
|
|
10
10
|
ASC = "asc",
|
|
11
11
|
DESC = "desc"
|
|
12
12
|
}
|
|
13
|
-
export declare enum
|
|
13
|
+
export declare enum VaultListOrderBy {
|
|
14
14
|
TVL = 0,
|
|
15
15
|
APR = 1,
|
|
16
16
|
DEPOSITED = 2
|
|
@@ -51,5 +51,5 @@ export default class OffchainMultichain {
|
|
|
51
51
|
getOffchain(network: Networks): Offchain;
|
|
52
52
|
getVaultList(params?: VaultListParams): Promise<Array<OffchainVault>>;
|
|
53
53
|
networkHasVault(network: Networks): boolean;
|
|
54
|
-
getLendingPoolList(params?: LendingPoolListParams
|
|
54
|
+
getLendingPoolList(params?: LendingPoolListParams): Promise<Array<OffchainLendingPool>>;
|
|
55
55
|
}
|
|
@@ -24,7 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
var _a, _OffchainMultichain_instance;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.LendingPoolListOrderBy = exports.
|
|
27
|
+
exports.LendingPoolListOrderBy = exports.VaultListOrderBy = exports.SortDirection = void 0;
|
|
28
28
|
const types_1 = require("../config/types");
|
|
29
29
|
const offchain_1 = __importDefault(require("./offchain"));
|
|
30
30
|
const subgraphs_1 = require("../config/subgraphs");
|
|
@@ -34,12 +34,12 @@ var SortDirection;
|
|
|
34
34
|
SortDirection["ASC"] = "asc";
|
|
35
35
|
SortDirection["DESC"] = "desc";
|
|
36
36
|
})(SortDirection = exports.SortDirection || (exports.SortDirection = {}));
|
|
37
|
-
var
|
|
38
|
-
(function (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
})(
|
|
37
|
+
var VaultListOrderBy;
|
|
38
|
+
(function (VaultListOrderBy) {
|
|
39
|
+
VaultListOrderBy[VaultListOrderBy["TVL"] = 0] = "TVL";
|
|
40
|
+
VaultListOrderBy[VaultListOrderBy["APR"] = 1] = "APR";
|
|
41
|
+
VaultListOrderBy[VaultListOrderBy["DEPOSITED"] = 2] = "DEPOSITED";
|
|
42
|
+
})(VaultListOrderBy = exports.VaultListOrderBy || (exports.VaultListOrderBy = {}));
|
|
43
43
|
// Pools //
|
|
44
44
|
var LendingPoolListOrderBy;
|
|
45
45
|
(function (LendingPoolListOrderBy) {
|
|
@@ -71,24 +71,24 @@ class OffchainMultichain {
|
|
|
71
71
|
*--------------------------------------------------------*/
|
|
72
72
|
getVaultList(params = {}) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
|
|
74
|
+
console.time("Vaults");
|
|
75
75
|
const allNetworks = params.networks || Object.values(types_1.Networks);
|
|
76
76
|
// Filter out networks without vaults
|
|
77
77
|
const networksWithVaults = allNetworks.filter((network) => this.networkHasVault(network));
|
|
78
|
-
//
|
|
79
|
-
const
|
|
80
|
-
for (const network of networksWithVaults) {
|
|
78
|
+
// Networks
|
|
79
|
+
const networkPromises = networksWithVaults.map((network) => __awaiter(this, void 0, void 0, function* () {
|
|
81
80
|
const offchain = this.getOffchain(network);
|
|
82
81
|
const vaultsData = yield offchain.getVaultsData();
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
const vaultPromises = Object.keys(vaultsData).map((address) => offchain.getVault(address));
|
|
83
|
+
const vaults = yield Promise.all(vaultPromises);
|
|
84
|
+
// TODO: Reomve this? Types
|
|
85
|
+
return params.type
|
|
86
|
+
? vaults.filter((vault) => vault.getVaultType() === params.type)
|
|
87
|
+
: vaults;
|
|
88
|
+
}));
|
|
89
|
+
const results = yield Promise.all(networkPromises);
|
|
90
|
+
console.timeEnd("Vaults");
|
|
91
|
+
return results.flat();
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
// Helpful for frontend UI thing
|
|
@@ -99,10 +99,25 @@ class OffchainMultichain {
|
|
|
99
99
|
* Lending Pools
|
|
100
100
|
*--------------------------------------------------------*/
|
|
101
101
|
// private async getVaultSortValue( vault: OffchainVault, orderBy: VaultOrderBy,): Promise<number> { }
|
|
102
|
-
getLendingPoolList(params = {}
|
|
102
|
+
getLendingPoolList(params = {}) {
|
|
103
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
console.time("Lending Pools");
|
|
105
|
+
const allNetworks = params.networks || Object.values(types_1.Networks);
|
|
106
|
+
// Networks
|
|
107
|
+
const networkPromises = allNetworks.map((network) => __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const offchain = this.getOffchain(network);
|
|
109
|
+
const lendingPoolsData = yield offchain.getLendingPoolsData();
|
|
110
|
+
// Factories
|
|
111
|
+
const factoryPromises = Object.entries(lendingPoolsData).map(([factory, pools]) => __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const poolPromises = Object.keys(pools).map((poolId) => offchain.getLendingPool(factory, poolId));
|
|
113
|
+
return Promise.all(poolPromises);
|
|
114
|
+
}));
|
|
115
|
+
const factoryResults = yield Promise.all(factoryPromises);
|
|
116
|
+
return factoryResults.flat();
|
|
117
|
+
}));
|
|
118
|
+
const results = yield Promise.all(networkPromises);
|
|
119
|
+
console.timeEnd("Lending Pools");
|
|
120
|
+
return results.flat();
|
|
106
121
|
});
|
|
107
122
|
}
|
|
108
123
|
}
|
|
@@ -3,6 +3,7 @@ import { IQueryBuilder } from "../../interfaces/query-builder";
|
|
|
3
3
|
export declare class PonderQueryBuilder implements IQueryBuilder {
|
|
4
4
|
blockQuery(): import("graphql").DocumentNode;
|
|
5
5
|
getBlockNumber(response: any, network: Networks): number;
|
|
6
|
+
lendingPoolsV3Query(factory: Factory, addressesFilter: Address[], network: Networks): import("graphql").DocumentNode;
|
|
6
7
|
lendingPoolsQuery(factory: Factory, addressesFilter: Address[], network: Networks): import("graphql").DocumentNode;
|
|
7
8
|
userQuery(account: Address, network: Networks, factory: Factory): import("graphql").DocumentNode;
|
|
8
9
|
tvlQuery(): import("graphql").DocumentNode;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PonderQueryBuilder = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
const types_1 = require("../../../../config/types");
|
|
8
9
|
const factories_1 = require("../../../../config/factories");
|
|
9
10
|
const impermax_factories_1 = require("../../../../config/contracts/impermax-factories");
|
|
10
11
|
// TODO: Might need to separate Vaults query based on vault type, maybe not.
|
|
@@ -23,10 +24,90 @@ class PonderQueryBuilder {
|
|
|
23
24
|
getBlockNumber(response, network) {
|
|
24
25
|
return response.data._meta.status[network].block.number || 0;
|
|
25
26
|
}
|
|
27
|
+
/*-----------------------------*
|
|
28
|
+
* 2. Lending pools V3
|
|
29
|
+
*-----------------------------*/
|
|
30
|
+
lendingPoolsV3Query(factory, addressesFilter, network) {
|
|
31
|
+
const tokenStr = `{
|
|
32
|
+
id
|
|
33
|
+
symbol
|
|
34
|
+
name
|
|
35
|
+
decimals
|
|
36
|
+
derivedUSD
|
|
37
|
+
}`;
|
|
38
|
+
const distributorStr = `{
|
|
39
|
+
id
|
|
40
|
+
}`;
|
|
41
|
+
const farmingPoolStr = `{
|
|
42
|
+
epochAmount
|
|
43
|
+
epochBegin
|
|
44
|
+
segmentLength
|
|
45
|
+
vestingBegin
|
|
46
|
+
sharePercentage
|
|
47
|
+
distributor ${distributorStr}
|
|
48
|
+
}`;
|
|
49
|
+
const borrowableStr = `{
|
|
50
|
+
id
|
|
51
|
+
underlying ${tokenStr}
|
|
52
|
+
totalBalance
|
|
53
|
+
totalBorrows
|
|
54
|
+
borrowRate
|
|
55
|
+
reserveFactor
|
|
56
|
+
kinkBorrowRate
|
|
57
|
+
kinkUtilizationRate
|
|
58
|
+
adjustSpeed
|
|
59
|
+
borrowIndex
|
|
60
|
+
accrualTimestamp
|
|
61
|
+
exchangeRate
|
|
62
|
+
borrowTracker
|
|
63
|
+
farmingPool ${farmingPoolStr}
|
|
64
|
+
}`;
|
|
65
|
+
const collateralStr = `{
|
|
66
|
+
id
|
|
67
|
+
safetyMargin
|
|
68
|
+
liquidationIncentive
|
|
69
|
+
liquidationFee
|
|
70
|
+
}`;
|
|
71
|
+
const nftlpStr = `{
|
|
72
|
+
id
|
|
73
|
+
factory
|
|
74
|
+
dexFactory
|
|
75
|
+
token1Price
|
|
76
|
+
token0Price
|
|
77
|
+
rewards {
|
|
78
|
+
items {
|
|
79
|
+
id
|
|
80
|
+
rewardRate
|
|
81
|
+
rewardsToken ${tokenStr}
|
|
82
|
+
periodFinish
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}`;
|
|
86
|
+
const id_in_string = addressesFilter.length > 0 ? `id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
|
|
87
|
+
return (0, graphql_tag_1.default) `{
|
|
88
|
+
lendingPools(
|
|
89
|
+
limit: 1000
|
|
90
|
+
where: { factoryId: "${impermax_factories_1.IMPERMAX_FACTORY[network][factory]}", ${id_in_string}}
|
|
91
|
+
) {
|
|
92
|
+
items {
|
|
93
|
+
id
|
|
94
|
+
borrowable0 ${borrowableStr}
|
|
95
|
+
borrowable1 ${borrowableStr}
|
|
96
|
+
collateral ${collateralStr}
|
|
97
|
+
nftlp ${nftlpStr}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
_meta {
|
|
101
|
+
status
|
|
102
|
+
}
|
|
103
|
+
}`;
|
|
104
|
+
}
|
|
26
105
|
/*-----------------------------*
|
|
27
106
|
* 2. Lending pools
|
|
28
107
|
*-----------------------------*/
|
|
29
108
|
lendingPoolsQuery(factory, addressesFilter, network) {
|
|
109
|
+
if (factory == types_1.Factory.V3)
|
|
110
|
+
return this.lendingPoolsV3Query(factory, addressesFilter, network);
|
|
30
111
|
const tokenStr = `{
|
|
31
112
|
id
|
|
32
113
|
symbol
|
|
@@ -3,6 +3,7 @@ import { IQueryBuilder } from "../../interfaces/query-builder";
|
|
|
3
3
|
export declare class TheGraphQueryBuilder implements IQueryBuilder {
|
|
4
4
|
blockQuery(timestamp: number): import("graphql").DocumentNode;
|
|
5
5
|
getBlockNumber(response: any, network: Networks): number;
|
|
6
|
+
lendingPoolsV3Query(factory: Factory, addressesFilter: Address[]): import("graphql").DocumentNode;
|
|
6
7
|
lendingPoolsQuery(factory: Factory, addressesFilter: Address[]): import("graphql").DocumentNode;
|
|
7
8
|
userQuery(account: Address, network: Networks, factory: Factory): import("graphql").DocumentNode;
|
|
8
9
|
tvlQuery(): import("graphql").DocumentNode;
|
|
@@ -33,6 +33,9 @@ class TheGraphQueryBuilder {
|
|
|
33
33
|
/*-----------------------------*
|
|
34
34
|
* 2. Lending pools
|
|
35
35
|
*-----------------------------*/
|
|
36
|
+
lendingPoolsV3Query(factory, addressesFilter) {
|
|
37
|
+
return (0, graphql_tag_1.default) `{}`;
|
|
38
|
+
}
|
|
36
39
|
lendingPoolsQuery(factory, addressesFilter) {
|
|
37
40
|
const tokenStr = `{
|
|
38
41
|
id
|
|
@@ -3,6 +3,7 @@ import { Address, Factory, Networks, VaultType } from '../../../config/types';
|
|
|
3
3
|
export interface IQueryBuilder {
|
|
4
4
|
blockQuery(timestamp: number): DocumentNode;
|
|
5
5
|
getBlockNumber: (response: any, network: Networks) => number;
|
|
6
|
+
lendingPoolsV3Query(factory: Factory, addressesFilter: Address[], network: Networks): DocumentNode;
|
|
6
7
|
lendingPoolsQuery(factory: Factory, addressesFilter: Address[], network: Networks): DocumentNode;
|
|
7
8
|
userQuery(account: Address, network: Networks, factory: Factory): DocumentNode;
|
|
8
9
|
tvlQuery(): DocumentNode;
|