impermax-sdk 2.1.367 → 2.1.369
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/ibexes.js +11 -11
- package/lib/config/subgraphs.d.ts +1 -1
- package/lib/config/subgraphs.js +3 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/lib/offchain/account/index.d.ts +2 -1
- package/lib/offchain/account/index.js +3 -1
- package/lib/offchain/account/offchainAccount.d.ts +4 -1
- package/lib/offchain/account/offchainAccount.js +8 -0
- package/lib/offchain/account/staking/index.d.ts +2 -0
- package/lib/offchain/account/staking/index.js +7 -0
- package/lib/offchain/account/staking/offchainAccountStakingModule.d.ts +15 -0
- package/lib/offchain/account/staking/offchainAccountStakingModule.js +44 -0
- package/lib/offchain/initializer/staking.d.ts +2 -2
- package/lib/offchain/initializer/staking.js +5 -5
- package/lib/offchain/initializer/user/index.d.ts +1 -0
- package/lib/offchain/initializer/user/index.js +1 -0
- package/lib/offchain/initializer/user/userStaking/index.d.ts +5 -0
- package/lib/offchain/initializer/user/userStaking/index.js +27 -0
- package/lib/offchain/offchain.d.ts +7 -2
- package/lib/offchain/offchain.js +3 -1
- package/lib/offchain/offchainAPRHelper.js +4 -1
- package/lib/offchain/offchainTypes.d.ts +12 -7
- package/lib/offchain/queries/apis/ponder/index.d.ts +18 -16
- package/lib/offchain/queries/apis/ponder/index.js +3 -0
- package/lib/offchain/queries/apis/thegraph/index.d.ts +1 -0
- package/lib/offchain/queries/apis/thegraph/index.js +10 -0
- package/lib/offchain/queries/interfaces/query-builder.d.ts +1 -0
- package/lib/offchain/staking/offchainStakingModule.d.ts +8 -7
- package/lib/offchain/staking/offchainStakingModule.js +26 -16
- package/package.json +1 -1
|
@@ -4,10 +4,10 @@ exports.XIBEX = exports.IBEX = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
exports.IBEX = {
|
|
6
6
|
[types_1.Networks.Ropsten]: '',
|
|
7
|
-
[types_1.Networks.Mainnet]: '
|
|
8
|
-
[types_1.Networks.Polygon]: '
|
|
9
|
-
[types_1.Networks.Arbitrum]: '
|
|
10
|
-
[types_1.Networks.Avalanche]: '
|
|
7
|
+
[types_1.Networks.Mainnet]: '0xf655c8567e0f213e6c634cd2a68d992152161dc6',
|
|
8
|
+
[types_1.Networks.Polygon]: '0xf972daced7c6b03223710c11413036d17eb298f6',
|
|
9
|
+
[types_1.Networks.Arbitrum]: '0x56659245931cb6920e39c189d2a0e7dd0da2d57b',
|
|
10
|
+
[types_1.Networks.Avalanche]: '0x089d3daf549f99553c2182db24bc4336a4f0c824',
|
|
11
11
|
[types_1.Networks.Moonriver]: '',
|
|
12
12
|
[types_1.Networks.Aurora]: '',
|
|
13
13
|
[types_1.Networks.Cronos]: '',
|
|
@@ -16,15 +16,15 @@ exports.IBEX = {
|
|
|
16
16
|
[types_1.Networks.Moonbeam]: '',
|
|
17
17
|
[types_1.Networks.Sxnetwork]: '',
|
|
18
18
|
[types_1.Networks.Canto]: '',
|
|
19
|
-
[types_1.Networks.ZksyncEra]: '
|
|
20
|
-
[types_1.Networks.Blast]: '
|
|
21
|
-
[types_1.Networks.Base]: '
|
|
19
|
+
[types_1.Networks.ZksyncEra]: '0xbe9f8c0d6f0fd7e46cdacca340747ea2f247991d',
|
|
20
|
+
[types_1.Networks.Blast]: '0x9f04b6cefd5bcd67d76ab708f17553ce40188e6a',
|
|
21
|
+
[types_1.Networks.Base]: '0xb8a9a92dfe1303728394dd0f8362a09962dec24f',
|
|
22
22
|
[types_1.Networks.Mantle]: '',
|
|
23
|
-
[types_1.Networks.Scroll]: '
|
|
24
|
-
[types_1.Networks.Optimism]: '
|
|
23
|
+
[types_1.Networks.Scroll]: '0x78ab77f7d590fb101aa18affc238cbfea31ead5b',
|
|
24
|
+
[types_1.Networks.Optimism]: '0xbb6bbaa0f6d839a00c82b10747abc3b7e2eecc82',
|
|
25
25
|
[types_1.Networks.Real]: '',
|
|
26
|
-
[types_1.Networks.Sonic]: '
|
|
27
|
-
[types_1.Networks.Linea]: '
|
|
26
|
+
[types_1.Networks.Sonic]: '0x55d1d7edbc417dce5efa0df53d9445176efd3920',
|
|
27
|
+
[types_1.Networks.Linea]: '0xcf0f95e34f25d1bb3d9cad3cbb2eb40dab7c3841'
|
|
28
28
|
};
|
|
29
29
|
// Stkaing module
|
|
30
30
|
exports.XIBEX = {
|
|
@@ -3,7 +3,7 @@ export declare const IMPERMAX_SUBGRAPH_URL: NetworkFactoryIndex<Address[]>;
|
|
|
3
3
|
export declare const VAULT_SUBGRAPH_URL: NetworkVaultTypeIndex<Address[]>;
|
|
4
4
|
export declare const IMPERMAX_CHEF_SUBGRAPH_URL: NetworkIndex<string>;
|
|
5
5
|
export declare const BLOCKS_SUBGRAPH_URL: NetworkIndex<string>;
|
|
6
|
-
export declare const XIBEX_SUBGRAPH_URL
|
|
6
|
+
export declare const XIBEX_SUBGRAPH_URL: Partial<NetworkIndex<string[]>>;
|
|
7
7
|
export declare const CONFIG_MANAGER_SUBGRAPH_URL: {
|
|
8
8
|
ropsten: string;
|
|
9
9
|
mainnet: string;
|
package/lib/config/subgraphs.js
CHANGED
|
@@ -289,7 +289,9 @@ exports.BLOCKS_SUBGRAPH_URL = {
|
|
|
289
289
|
[types_1.Networks.Sonic]: "",
|
|
290
290
|
[types_1.Networks.Linea]: "",
|
|
291
291
|
};
|
|
292
|
-
exports.XIBEX_SUBGRAPH_URL =
|
|
292
|
+
exports.XIBEX_SUBGRAPH_URL = {
|
|
293
|
+
[types_1.Networks.Arbitrum]: ["https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/Db9k9m7WLxs5YdnCSip9TwBXT2vuiufzTnnF6JgCeYYs"],
|
|
294
|
+
};
|
|
293
295
|
exports.CONFIG_MANAGER_SUBGRAPH_URL = {
|
|
294
296
|
[types_1.Networks.Ropsten]: "",
|
|
295
297
|
[types_1.Networks.Mainnet]: "",
|
package/lib/index.d.ts
CHANGED
|
@@ -72,4 +72,5 @@ import OffchainAccountBorrowableV3 from './offchain/account/lendingPool/offchain
|
|
|
72
72
|
import { PairState } from "./config/whitelist";
|
|
73
73
|
import { AccountMarketData } from './offchain/account/offchainAccount';
|
|
74
74
|
import OffchainStakingModule from './offchain/staking/offchainStakingModule';
|
|
75
|
-
|
|
75
|
+
import OffchainAccountStakingModule from './offchain/account/staking';
|
|
76
|
+
export { offchain, OffchainMultichain, Offchain, OffchainPoolToken, OffchainLendingPool, OffchainCollateral, OffchainBorrowable, OffchainLendingPoolV2, OffchainCollateralV2, OffchainBorrowableV2, OffchainLendingPoolV3, OffchainCollateralV3, OffchainBorrowableV3, OffchainNftlp, OffchainNftlpUniswapV3, OffchainVault, OffchainLeveragedVault, OffchainLendingVault, OffchainHedgedVault, OffchainConfigManager, OffchainPairConfig, OffchainProposal, OffchainMultichainAccount, OffchainAccount, OffchainAccountPoolToken, OffchainAccountLendingPool, OffchainAccountCollateral, OffchainAccountBorrowable, OffchainAccountLendingPoolV2, OffchainAccountCollateralV2, OffchainAccountBorrowableV2, OffchainAccountLendingPoolV3, OffchainAccountCollateralV3, OffchainAccountBorrowableV3, OffchainAccountNftlp, OffchainAccountNftlpUniswapV3, OffchainLeveragedPosition, OffchainAccountVault, OffchainPriceHelper, OffchainSolidexHelper, PoolTokenData, BorrowableData, CollateralData, BorrowablePastData, TokenData, RewardData, PairData, FarmingPoolData, LendingPoolPastData, LendingPoolData, CollateralPosition, SupplyPosition, BorrowPosition, UserData, TvlData, XIbexData, LendingVaultData, VaultPosition, PairConfigData, ProposalData, ProposalMetadata, VaultRisk, VaultType, onchain, Onchain, OnchainImpermaxFactory, OnchainImpermaxFactoryV2, OnchainImpermaxFactoryV3, OnchainPoolToken, OnchainLendingPool, OnchainBorrowable, OnchainCollateral, OnchainLendingPoolV2, OnchainBorrowableV2, OnchainCollateralV2, OnchainLendingPoolV3, OnchainBorrowableV3, OnchainCollateralV3, OnchainNftlp, OnchainNftlpUniswapV3, OnchainLendingVault, OnchainConfigManager, OnchainProposal, OnchainPairConfig, OnchainAccount, OnchainAccountPoolToken, OnchainAccountLendingPool, OnchainAccountBorrowable, OnchainAccountCollateral, OnchainAccountLendingPoolV2, OnchainAccountBorrowableV2, OnchainAccountCollateralV2, OnchainAccountLendingPoolV3, OnchainAccountBorrowableV3, OnchainAccountCollateralV3, OnchainAccountNftlp, OnchainAccountNftlpUniswapV3, OnchainAccountLendingVault, OnchainContractsHelper, OnchainInteractions, OnchainInteractionsPoolToken, OnchainInteractionsLendingPool, OnchainInteractionsCollateral, OnchainInteractionsBorrowable, OnchainInteractionsLendingPoolV2, OnchainInteractionsCollateralV2, OnchainInteractionsBorrowableV2, OnchainInteractionsLendingPoolV3, OnchainInteractionsCollateralV3, OnchainInteractionsBorrowableV3, OnchainInteractionsNftlp, OnchainInteractionsNftlpUniswapV3, OnchainInteractionsLendingVault, OnchainInteractionsConfigManager, Contract, ApprovalType, PermitData, OnchainConfig, Changes, NO_CHANGES, Values, AirdropData, PendingRewardUI, CollateralConfig, BorrowableV2Config, BorrowableV3Config, PairConfig, CLAIM_AGGREGATOR, IMPERMAX_CHEF, IMX, IMPERMAX_FACTORY, getNetworkFactories, getFactoryByAddress, 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, XIBEX_SUBGRAPH_URL, Networks, Factory, Extension, PoolTokenType, Amms, Address, NetworkIndex, FactoryIndex, AddressIndex, NetworkFactoryIndex, LendingPoolIndex, AmmIndex, DistributorDetails, ProposalState, WhitelistState, VaultListOrderBy, VaultListParams, LendingPoolListOrderBy, LendingPoolListParams, SortDirection, LendingPoolVersion, PositionType, AccountPosition, PermitType, Permits, Permit, Borrowable, decimalToBalance, MAX_TICK, MIN_TICK, formatPriceSqrtX96, uniV3TickToPrice, isV3Factory, UniswapV3Position, UniswapV2Position, Position, BorrowableEntity, BorrowablePosition, LendingVaultEntity, PairState, SupplyPositionsParams, BorrowPositionsParams, TopPositionsParams, VaultPositionsParams, AccountEarningsParams, AccountMarketData, OffchainStakingModule, IBEX, XIBEX, OffchainAccountStakingModule };
|
package/lib/index.js
CHANGED
|
@@ -29,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.OnchainBorrowable = exports.OnchainLendingPool = exports.OnchainPoolToken = exports.OnchainImpermaxFactoryV3 = exports.OnchainImpermaxFactoryV2 = exports.OnchainImpermaxFactory = exports.Onchain = exports.onchain = exports.VaultType = exports.VaultRisk = exports.OffchainSolidexHelper = exports.OffchainPriceHelper = exports.OffchainAccountVault = exports.OffchainLeveragedPosition = exports.OffchainAccountNftlpUniswapV3 = exports.OffchainAccountNftlp = exports.OffchainAccountBorrowableV3 = exports.OffchainAccountCollateralV3 = exports.OffchainAccountLendingPoolV3 = exports.OffchainAccountBorrowableV2 = exports.OffchainAccountCollateralV2 = exports.OffchainAccountLendingPoolV2 = exports.OffchainAccountBorrowable = exports.OffchainAccountCollateral = exports.OffchainAccountLendingPool = exports.OffchainAccountPoolToken = exports.OffchainAccount = exports.OffchainMultichainAccount = exports.OffchainProposal = exports.OffchainPairConfig = exports.OffchainConfigManager = exports.OffchainHedgedVault = exports.OffchainLendingVault = exports.OffchainLeveragedVault = exports.OffchainVault = exports.OffchainNftlpUniswapV3 = exports.OffchainNftlp = exports.OffchainBorrowableV3 = exports.OffchainCollateralV3 = exports.OffchainLendingPoolV3 = exports.OffchainBorrowableV2 = exports.OffchainCollateralV2 = exports.OffchainLendingPoolV2 = exports.OffchainBorrowable = exports.OffchainCollateral = exports.OffchainLendingPool = exports.OffchainPoolToken = exports.Offchain = exports.OffchainMultichain = exports.offchain = void 0;
|
|
30
30
|
exports.getNetworkFactories = exports.IMPERMAX_FACTORY = exports.IMX = exports.IMPERMAX_CHEF = exports.CLAIM_AGGREGATOR = exports.NO_CHANGES = exports.ApprovalType = exports.OnchainInteractionsConfigManager = exports.OnchainInteractionsLendingVault = exports.OnchainInteractionsNftlpUniswapV3 = exports.OnchainInteractionsNftlp = exports.OnchainInteractionsBorrowableV3 = exports.OnchainInteractionsCollateralV3 = exports.OnchainInteractionsLendingPoolV3 = exports.OnchainInteractionsBorrowableV2 = exports.OnchainInteractionsCollateralV2 = exports.OnchainInteractionsLendingPoolV2 = exports.OnchainInteractionsBorrowable = exports.OnchainInteractionsCollateral = exports.OnchainInteractionsLendingPool = exports.OnchainInteractionsPoolToken = exports.OnchainInteractions = exports.OnchainContractsHelper = exports.OnchainAccountLendingVault = exports.OnchainAccountNftlpUniswapV3 = exports.OnchainAccountNftlp = exports.OnchainAccountCollateralV3 = exports.OnchainAccountBorrowableV3 = exports.OnchainAccountLendingPoolV3 = exports.OnchainAccountCollateralV2 = exports.OnchainAccountBorrowableV2 = exports.OnchainAccountLendingPoolV2 = exports.OnchainAccountCollateral = exports.OnchainAccountBorrowable = exports.OnchainAccountLendingPool = exports.OnchainAccountPoolToken = exports.OnchainAccount = exports.OnchainPairConfig = exports.OnchainProposal = exports.OnchainConfigManager = exports.OnchainLendingVault = exports.OnchainNftlpUniswapV3 = exports.OnchainNftlp = exports.OnchainCollateralV3 = exports.OnchainBorrowableV3 = exports.OnchainLendingPoolV3 = exports.OnchainCollateralV2 = exports.OnchainBorrowableV2 = exports.OnchainLendingPoolV2 = exports.OnchainCollateral = void 0;
|
|
31
31
|
exports.PermitType = exports.PositionType = exports.LendingPoolVersion = exports.SortDirection = exports.LendingPoolListOrderBy = exports.VaultListOrderBy = exports.WhitelistState = exports.ProposalState = exports.Amms = exports.PoolTokenType = exports.Extension = exports.Factory = exports.Networks = exports.XIBEX_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.getFactoryByAddress = void 0;
|
|
32
|
-
exports.XIBEX = exports.IBEX = exports.OffchainStakingModule = exports.LendingVaultEntity = exports.BorrowablePosition = exports.BorrowableEntity = exports.UniswapV2Position = exports.UniswapV3Position = exports.isV3Factory = exports.uniV3TickToPrice = exports.formatPriceSqrtX96 = exports.MIN_TICK = exports.MAX_TICK = exports.decimalToBalance = exports.Borrowable = void 0;
|
|
32
|
+
exports.OffchainAccountStakingModule = exports.XIBEX = exports.IBEX = exports.OffchainStakingModule = exports.LendingVaultEntity = exports.BorrowablePosition = exports.BorrowableEntity = exports.UniswapV2Position = exports.UniswapV3Position = exports.isV3Factory = exports.uniV3TickToPrice = exports.formatPriceSqrtX96 = exports.MIN_TICK = exports.MAX_TICK = exports.decimalToBalance = exports.Borrowable = void 0;
|
|
33
33
|
const offchain_1 = __importStar(require("./offchain"));
|
|
34
34
|
exports.Offchain = offchain_1.default;
|
|
35
35
|
Object.defineProperty(exports, "OffchainAccount", { enumerable: true, get: function () { return offchain_1.OffchainAccount; } });
|
|
@@ -269,3 +269,5 @@ const offchainAccountBorrowableV3_1 = __importDefault(require("./offchain/accoun
|
|
|
269
269
|
exports.OffchainAccountBorrowableV3 = offchainAccountBorrowableV3_1.default;
|
|
270
270
|
const offchainStakingModule_1 = __importDefault(require("./offchain/staking/offchainStakingModule"));
|
|
271
271
|
exports.OffchainStakingModule = offchainStakingModule_1.default;
|
|
272
|
+
const staking_1 = __importDefault(require("./offchain/account/staking"));
|
|
273
|
+
exports.OffchainAccountStakingModule = staking_1.default;
|
|
@@ -5,5 +5,6 @@ import OffchainAccountPoolToken from "./offchainAccountPoolToken";
|
|
|
5
5
|
import OffchainAccountVault from './vault';
|
|
6
6
|
import OffchainAccount from './offchainAccount';
|
|
7
7
|
import OffchainMultichainAccount from './offchainMultichainAccount';
|
|
8
|
-
|
|
8
|
+
import OffchainAccountStakingModule from './staking';
|
|
9
|
+
export { lendingPool, vault, OffchainMultichainAccount, OffchainAccountLendingPool, OffchainAccountPoolToken, OffchainAccountVault, OffchainAccountStakingModule, };
|
|
9
10
|
export default OffchainAccount;
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.OffchainAccountVault = exports.OffchainAccountPoolToken = exports.OffchainAccountLendingPool = exports.OffchainMultichainAccount = exports.vault = exports.lendingPool = void 0;
|
|
29
|
+
exports.OffchainAccountStakingModule = exports.OffchainAccountVault = exports.OffchainAccountPoolToken = exports.OffchainAccountLendingPool = exports.OffchainMultichainAccount = exports.vault = exports.lendingPool = void 0;
|
|
30
30
|
const lendingPool = __importStar(require("./lendingPool"));
|
|
31
31
|
exports.lendingPool = lendingPool;
|
|
32
32
|
const vault = __importStar(require("./vault"));
|
|
@@ -40,4 +40,6 @@ exports.OffchainAccountVault = vault_1.default;
|
|
|
40
40
|
const offchainAccount_1 = __importDefault(require("./offchainAccount"));
|
|
41
41
|
const offchainMultichainAccount_1 = __importDefault(require("./offchainMultichainAccount"));
|
|
42
42
|
exports.OffchainMultichainAccount = offchainMultichainAccount_1.default;
|
|
43
|
+
const staking_1 = __importDefault(require("./staking"));
|
|
44
|
+
exports.OffchainAccountStakingModule = staking_1.default;
|
|
43
45
|
exports.default = offchainAccount_1.default;
|
|
@@ -2,9 +2,10 @@ import Offchain from "../index";
|
|
|
2
2
|
import { Address, AddressIndex, Factory, FactoryIndex } from "../../config/types";
|
|
3
3
|
import OffchainAccountLendingPool from "./lendingPool";
|
|
4
4
|
import OffchainAccountVault from "./vault/offchainAccountVault";
|
|
5
|
-
import { VaultPosition, UserData } from "../offchainTypes";
|
|
5
|
+
import { VaultPosition, UserData, XIbexUserData } from "../offchainTypes";
|
|
6
6
|
import { PairState } from '../../config/whitelist';
|
|
7
7
|
import { Networks } from "../../config/types";
|
|
8
|
+
import OffchainAccountStakingModule from "./staking";
|
|
8
9
|
export type AccountEarningsParams = {
|
|
9
10
|
networks?: Array<Networks>;
|
|
10
11
|
pairState?: PairState;
|
|
@@ -54,4 +55,6 @@ export default class OffchainAccount {
|
|
|
54
55
|
* 1. Filter by whitelisted/deprecated/blacklisted pairs
|
|
55
56
|
*/
|
|
56
57
|
filterPairState(offchainAccountLendingPools: Array<OffchainAccountLendingPool>, pairState: PairState): OffchainAccountLendingPool[];
|
|
58
|
+
getStakingModule(): OffchainAccountStakingModule;
|
|
59
|
+
getXIbexUserData(): Promise<XIbexUserData | null>;
|
|
57
60
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const offchainAccountVault_1 = __importDefault(require("./vault/offchainAccountVault"));
|
|
7
7
|
const offchainTypes_1 = require("../offchainTypes");
|
|
8
8
|
const offchainLendingPool_1 = require("../lendingPool/offchainLendingPool");
|
|
9
|
+
const staking_1 = __importDefault(require("./staking"));
|
|
9
10
|
class OffchainAccount {
|
|
10
11
|
constructor(offchain, account) {
|
|
11
12
|
this.getOffchain = () => this.offchain;
|
|
@@ -408,5 +409,12 @@ class OffchainAccount {
|
|
|
408
409
|
pools.push(...offchainAccountLendingPools.filter(i => i.getLendingPool().isDeprecated()));
|
|
409
410
|
return pools;
|
|
410
411
|
}
|
|
412
|
+
getStakingModule() {
|
|
413
|
+
const stakingModule = this.offchain.getStakingModule();
|
|
414
|
+
return new staking_1.default(this, stakingModule);
|
|
415
|
+
}
|
|
416
|
+
async getXIbexUserData() {
|
|
417
|
+
return this.offchain.getXIbexUserData(this.accountAddress);
|
|
418
|
+
}
|
|
411
419
|
}
|
|
412
420
|
exports.default = OffchainAccount;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const offchainAccountStakingModule_1 = __importDefault(require("./offchainAccountStakingModule"));
|
|
7
|
+
exports.default = offchainAccountStakingModule_1.default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import OffchainAccount from '../index';
|
|
2
|
+
import OffchainStakingModule from '../../staking/offchainStakingModule';
|
|
3
|
+
export default class OffchainAccountStakingModule {
|
|
4
|
+
private readonly account;
|
|
5
|
+
protected readonly stakingModule: OffchainStakingModule;
|
|
6
|
+
constructor(account: OffchainAccount, stakingModule: OffchainStakingModule);
|
|
7
|
+
getAccount: () => OffchainAccount;
|
|
8
|
+
getStakingModule: () => OffchainStakingModule;
|
|
9
|
+
private getXIbexUserData;
|
|
10
|
+
getAmount(): Promise<number>;
|
|
11
|
+
getValue(): Promise<number>;
|
|
12
|
+
getStakingYearlyYieldUSD(): Promise<number>;
|
|
13
|
+
getStakingMonthlyYieldUSD(): Promise<number>;
|
|
14
|
+
getStakingDailyYieldUSD(): Promise<number>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Follows similar implementation of offchainAccountPoolToken
|
|
4
|
+
class OffchainAccountStakingModule {
|
|
5
|
+
constructor(account, stakingModule) {
|
|
6
|
+
this.getAccount = () => this.account;
|
|
7
|
+
this.getStakingModule = () => this.stakingModule;
|
|
8
|
+
this.account = account;
|
|
9
|
+
this.stakingModule = stakingModule;
|
|
10
|
+
}
|
|
11
|
+
async getXIbexUserData() {
|
|
12
|
+
const stakingUserData = await this.account.getXIbexUserData();
|
|
13
|
+
if (!stakingUserData)
|
|
14
|
+
return undefined;
|
|
15
|
+
return stakingUserData;
|
|
16
|
+
}
|
|
17
|
+
async getAmount() {
|
|
18
|
+
const stakingUserData = await this.getXIbexUserData();
|
|
19
|
+
if (!stakingUserData)
|
|
20
|
+
return 0;
|
|
21
|
+
const exchangeRate = await this.getStakingModule().getExchangeRate();
|
|
22
|
+
const tokenBalance = stakingUserData.xibexBalance;
|
|
23
|
+
return tokenBalance * exchangeRate;
|
|
24
|
+
}
|
|
25
|
+
async getValue() {
|
|
26
|
+
const tokenPrice = await this.getStakingModule().getTokenPriceAccurate();
|
|
27
|
+
const amount = await this.getAmount();
|
|
28
|
+
return amount * tokenPrice;
|
|
29
|
+
}
|
|
30
|
+
async getStakingYearlyYieldUSD() {
|
|
31
|
+
const apr = await this.stakingModule.getStakingAPR();
|
|
32
|
+
const value = await this.getValue();
|
|
33
|
+
return apr * value;
|
|
34
|
+
}
|
|
35
|
+
async getStakingMonthlyYieldUSD() {
|
|
36
|
+
const yearlyYieldUSD = await this.getStakingYearlyYieldUSD();
|
|
37
|
+
return yearlyYieldUSD / 12;
|
|
38
|
+
}
|
|
39
|
+
async getStakingDailyYieldUSD() {
|
|
40
|
+
const yearlyYieldUSD = await this.getStakingYearlyYieldUSD();
|
|
41
|
+
return yearlyYieldUSD / 365;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = OffchainAccountStakingModule;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { XIbexData } from "../offchainTypes";
|
|
2
2
|
import Offchain from "../offchain";
|
|
3
|
-
export declare function getXIbexData(this: Offchain): Promise<XIbexData>;
|
|
4
|
-
export declare function initializeXIbexData(this: Offchain): Promise<XIbexData>;
|
|
3
|
+
export declare function getXIbexData(this: Offchain): Promise<XIbexData | null>;
|
|
4
|
+
export declare function initializeXIbexData(this: Offchain): Promise<XIbexData | null>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initializeXIbexData = exports.getXIbexData = void 0;
|
|
4
|
-
const queries_1 = require("../queries");
|
|
5
4
|
const subgraphs_1 = require("../../config/subgraphs");
|
|
6
5
|
/*--------------------------------------------------------------------------*
|
|
7
6
|
* Getters *
|
|
@@ -16,9 +15,10 @@ exports.getXIbexData = getXIbexData;
|
|
|
16
15
|
* Initializers *
|
|
17
16
|
*--------------------------------------------------------------------------*/
|
|
18
17
|
async function initializeXIbexData() {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const subgraphs = subgraphs_1.XIBEX_SUBGRAPH_URL[this.network];
|
|
19
|
+
if (!subgraphs)
|
|
20
|
+
return null;
|
|
21
|
+
const results = await this.offchainMultichain.getEndpointManager().fetch(subgraphs, this.network, (queryBuilder) => queryBuilder.xIbexQuery());
|
|
22
|
+
return results.data.xibexes[0];
|
|
23
23
|
}
|
|
24
24
|
exports.initializeXIbexData = initializeXIbexData;
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./userVault"), exports);
|
|
18
18
|
__exportStar(require("./userLendingPool"), exports);
|
|
19
|
+
__exportStar(require("./userStaking"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Address } from "../../../../config/types";
|
|
2
|
+
import { XIbexUserData } from "../../../offchainTypes";
|
|
3
|
+
import Offchain from "../../../offchain";
|
|
4
|
+
export declare function getXIbexUserData(this: Offchain, account: Address): Promise<XIbexUserData | null>;
|
|
5
|
+
export declare function initializeXIbexUserData(this: Offchain, account: Address): Promise<XIbexUserData | null>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initializeXIbexUserData = exports.getXIbexUserData = void 0;
|
|
4
|
+
const subgraphs_1 = require("../../../../config/subgraphs");
|
|
5
|
+
/*--------------------------------------------------------------------------*
|
|
6
|
+
* Getters *
|
|
7
|
+
*--------------------------------------------------------------------------*/
|
|
8
|
+
async function getXIbexUserData(account) {
|
|
9
|
+
if (!(account in this.xibexUsersData))
|
|
10
|
+
this.xibexUsersData[account] = this.initializeXIbexUserData(account);
|
|
11
|
+
const userData = await this.xibexUsersData[account];
|
|
12
|
+
return userData || null;
|
|
13
|
+
}
|
|
14
|
+
exports.getXIbexUserData = getXIbexUserData;
|
|
15
|
+
/*--------------------------------------------------------------------------*
|
|
16
|
+
* Initializers *
|
|
17
|
+
*--------------------------------------------------------------------------*/
|
|
18
|
+
async function initializeXIbexUserData(account) {
|
|
19
|
+
const subgraphs = subgraphs_1.XIBEX_SUBGRAPH_URL[this.network];
|
|
20
|
+
if (!subgraphs)
|
|
21
|
+
return null;
|
|
22
|
+
const result = await this.offchainMultichain.getEndpointManager().fetch(subgraphs, this.network, (queryBuilder) => queryBuilder.xIbexUserQuery(account));
|
|
23
|
+
if (!result)
|
|
24
|
+
return null;
|
|
25
|
+
return result.data.user;
|
|
26
|
+
}
|
|
27
|
+
exports.initializeXIbexUserData = initializeXIbexUserData;
|
|
@@ -3,7 +3,7 @@ import OffchainLendingPool from './lendingPool';
|
|
|
3
3
|
import OffchainSolidexHelper from './offchainSolidexHelper';
|
|
4
4
|
import OffchainAccount from './account';
|
|
5
5
|
import { Address, AddressIndex, Factory, FactoryIndex, LendingPoolIndex, Networks, WhitelistState, VaultType, Extension } from '../config/types';
|
|
6
|
-
import { LendingPoolData, VaultData, VaultPosition, TvlData, UserData, XIbexData, VaultBorrowable, NftlpData, PoolChart, NewlyEarnedFees, NftlpStats } from './offchainTypes';
|
|
6
|
+
import { LendingPoolData, VaultData, VaultPosition, TvlData, UserData, XIbexData, VaultBorrowable, NftlpData, PoolChart, NewlyEarnedFees, NftlpStats, XIbexUserData } from './offchainTypes';
|
|
7
7
|
import OffchainVault from './vault/offchainVault';
|
|
8
8
|
import OffchainConfigManager from './configManager';
|
|
9
9
|
import { LlamaTvlChart } from './offchainAPRHelper';
|
|
@@ -38,13 +38,16 @@ export default class Offchain {
|
|
|
38
38
|
[key in Address]?: Promise<AddressIndex<VaultPosition> | null>;
|
|
39
39
|
};
|
|
40
40
|
protected tvlData: Promise<TvlData> | null;
|
|
41
|
-
protected xIbexData: Promise<XIbexData
|
|
41
|
+
protected xIbexData: Promise<XIbexData | null>;
|
|
42
42
|
protected whitelistData: Promise<LendingPoolIndex<WhitelistState>> | null;
|
|
43
43
|
protected vaultsUsersData: {
|
|
44
44
|
[key in Address]?: Promise<AddressIndex<AddressIndex<VaultPosition>>>;
|
|
45
45
|
};
|
|
46
46
|
protected borrowersList: Promise<OffchainAccount[]> | null;
|
|
47
47
|
protected stakingModule: OffchainStakingModule;
|
|
48
|
+
protected xibexUsersData: {
|
|
49
|
+
[key in Address]?: Promise<XIbexUserData | null>;
|
|
50
|
+
};
|
|
48
51
|
protected vaultBorrowablesData: {
|
|
49
52
|
[key in VaultType]?: Promise<AddressIndex<VaultBorrowable[]>>;
|
|
50
53
|
};
|
|
@@ -88,6 +91,7 @@ export default class Offchain {
|
|
|
88
91
|
getUserData: typeof initializer.getUserData;
|
|
89
92
|
protected initializeXIbexData: typeof initializer.initializeXIbexData;
|
|
90
93
|
getXIbexData: typeof initializer.getXIbexData;
|
|
94
|
+
getXIbexUserData: typeof initializer.getXIbexUserData;
|
|
91
95
|
getVaultsUserData: typeof initializer.getVaultsUserData;
|
|
92
96
|
protected fetchWhitelist: typeof initializer.fetchWhitelist;
|
|
93
97
|
protected initializeWhitelistData: typeof initializer.initializeWhitelistData;
|
|
@@ -99,6 +103,7 @@ export default class Offchain {
|
|
|
99
103
|
getVaultData: typeof initializer.getVaultData;
|
|
100
104
|
protected fetchVaultsUserData: typeof initializer.fetchVaultsUserData;
|
|
101
105
|
protected initializeVaultsUserData: typeof initializer.initializeVaultsUserData;
|
|
106
|
+
protected initializeXIbexUserData: typeof initializer.initializeXIbexUserData;
|
|
102
107
|
protected fetchNftlpTvls: typeof initializer.fetchNftlpTvls;
|
|
103
108
|
getNftlpTvl: typeof initializer.getNftlpTvl;
|
|
104
109
|
protected fetchBorrowersList: typeof initializer.fetchBorrowersList;
|
package/lib/offchain/offchain.js
CHANGED
|
@@ -72,6 +72,7 @@ class Offchain {
|
|
|
72
72
|
this.getUserData = initializer.getUserData;
|
|
73
73
|
this.initializeXIbexData = initializer.initializeXIbexData;
|
|
74
74
|
this.getXIbexData = initializer.getXIbexData;
|
|
75
|
+
this.getXIbexUserData = initializer.getXIbexUserData;
|
|
75
76
|
// protected initializeLendingVaultsData = initializer.initializeLendingVaultsData;
|
|
76
77
|
// public getLendingVaultsData = initializer.getLendingVaultsData;
|
|
77
78
|
// public getLendingVaultData = initializer.getLendingVaultData;
|
|
@@ -89,6 +90,7 @@ class Offchain {
|
|
|
89
90
|
this.getVaultData = initializer.getVaultData;
|
|
90
91
|
this.fetchVaultsUserData = initializer.fetchVaultsUserData;
|
|
91
92
|
this.initializeVaultsUserData = initializer.initializeVaultsUserData;
|
|
93
|
+
this.initializeXIbexUserData = initializer.initializeXIbexUserData;
|
|
92
94
|
this.fetchNftlpTvls = initializer.fetchNftlpTvls;
|
|
93
95
|
this.getNftlpTvl = initializer.getNftlpTvl;
|
|
94
96
|
// NOTE: Not needed anymore since new vault subgraphs, delete?
|
|
@@ -127,6 +129,7 @@ class Offchain {
|
|
|
127
129
|
this.usersData = {};
|
|
128
130
|
this.vaultsUsersData = {};
|
|
129
131
|
this.vaultBorrowablesData = {};
|
|
132
|
+
this.xibexUsersData = {};
|
|
130
133
|
// Staking module is only available on Arbitrum atm,
|
|
131
134
|
// so we initialize it once in the offchainMultichain.
|
|
132
135
|
// this.stakingModule = new OffchainStakingModule(this);
|
|
@@ -139,7 +142,6 @@ class Offchain {
|
|
|
139
142
|
this.lendingVaultsUsersData = {};
|
|
140
143
|
this.vaultsUsersData = {};
|
|
141
144
|
this.tvlData = null;
|
|
142
|
-
this.xIbexData = null;
|
|
143
145
|
this.whitelistData = null;
|
|
144
146
|
this.solidexHelper.cleanCache();
|
|
145
147
|
this.configManager.cleanCache();
|
|
@@ -50,6 +50,8 @@ class OffchainAPRHelper {
|
|
|
50
50
|
"extra-finance",
|
|
51
51
|
"beefy",
|
|
52
52
|
"impermax-finance",
|
|
53
|
+
"impermax-v2",
|
|
54
|
+
"impermax-v3",
|
|
53
55
|
]);
|
|
54
56
|
this.offchainMultichain = offchainMultichain;
|
|
55
57
|
}
|
|
@@ -136,7 +138,8 @@ class OffchainAPRHelper {
|
|
|
136
138
|
async initializePoolsBorrow() {
|
|
137
139
|
try {
|
|
138
140
|
const response = await fetch("https://yields.llama.fi/poolsBorrow").then((i) => i.json());
|
|
139
|
-
|
|
141
|
+
// TODO: V3 yields, waiting on merge from llama
|
|
142
|
+
const impermaxPools = response.data.filter((i) => i.project === "impermax-v2");
|
|
140
143
|
this.chainsTotalSupplied = impermaxPools.reduce((acc, pool) => {
|
|
141
144
|
acc[pool.chain.toLowerCase()] =
|
|
142
145
|
(acc[pool.chain.toLowerCase()] || 0) + pool.totalSupplyUsd;
|
|
@@ -237,6 +237,18 @@ export interface VaultPosition {
|
|
|
237
237
|
id: Address;
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
|
+
export interface XIbexData {
|
|
241
|
+
id: string;
|
|
242
|
+
totalSupply: string;
|
|
243
|
+
totalBalance: string;
|
|
244
|
+
exchangeRate: string;
|
|
245
|
+
dailyAPR: string;
|
|
246
|
+
}
|
|
247
|
+
export interface XIbexUserData {
|
|
248
|
+
xibexBalance: number;
|
|
249
|
+
totalEarned: number;
|
|
250
|
+
lastExchangeRate: number;
|
|
251
|
+
}
|
|
240
252
|
export interface TvlData {
|
|
241
253
|
crossChainTVLUSD: number;
|
|
242
254
|
crossChainSupplyUSD: number;
|
|
@@ -245,13 +257,6 @@ export interface TvlData {
|
|
|
245
257
|
totalBorrowsUSD: number;
|
|
246
258
|
totalSupplyUSD: number;
|
|
247
259
|
}
|
|
248
|
-
export interface XIbexData {
|
|
249
|
-
id: string;
|
|
250
|
-
totalSupply: string;
|
|
251
|
-
totalBalance: string;
|
|
252
|
-
exchangeRate: string;
|
|
253
|
-
dailyAPR: string;
|
|
254
|
-
}
|
|
255
260
|
export interface PairConfigData {
|
|
256
261
|
factory: string;
|
|
257
262
|
pair: string;
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { Address, Extension, Factory, Networks, VaultType } from "../../../../config/types";
|
|
2
2
|
import { IQueryBuilder } from "../../interfaces/query-builder";
|
|
3
|
+
import { DocumentNode } from "graphql";
|
|
3
4
|
export declare class PonderQueryBuilder implements IQueryBuilder {
|
|
4
|
-
blockQuery():
|
|
5
|
+
blockQuery(): DocumentNode;
|
|
5
6
|
getBlockNumber(response: any, network: Networks): number;
|
|
6
|
-
lendingPoolsV3Query(factory: Factory, addressesFilter: Address[], network: Networks):
|
|
7
|
-
userQueryV3(account: Address, network: Networks, factory: Factory):
|
|
8
|
-
lendingPoolsQuery(factory: Factory, addressesFilter: Address[], network: Networks):
|
|
9
|
-
userQuery(account: Address, network: Networks, factory: Factory):
|
|
10
|
-
tvlQuery():
|
|
11
|
-
vaultsQuery(vaultType: VaultType, addressesFilter: Address[]):
|
|
12
|
-
vaultsUserQuery(account: Address):
|
|
13
|
-
proposalsMetaQuery(rangeBegin: any, rangeLength: any, descending: any):
|
|
14
|
-
proposalQuery(id: number):
|
|
15
|
-
xIbexQuery():
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
lendingPoolsV3Query(factory: Factory, addressesFilter: Address[], network: Networks): DocumentNode;
|
|
8
|
+
userQueryV3(account: Address, network: Networks, factory: Factory): DocumentNode;
|
|
9
|
+
lendingPoolsQuery(factory: Factory, addressesFilter: Address[], network: Networks): DocumentNode;
|
|
10
|
+
userQuery(account: Address, network: Networks, factory: Factory): DocumentNode;
|
|
11
|
+
tvlQuery(): DocumentNode;
|
|
12
|
+
vaultsQuery(vaultType: VaultType, addressesFilter: Address[]): DocumentNode;
|
|
13
|
+
vaultsUserQuery(account: Address): DocumentNode;
|
|
14
|
+
proposalsMetaQuery(rangeBegin: any, rangeLength: any, descending: any): DocumentNode;
|
|
15
|
+
proposalQuery(id: number): DocumentNode;
|
|
16
|
+
xIbexQuery(): DocumentNode;
|
|
17
|
+
xIbexUserQuery(account: string): DocumentNode;
|
|
18
|
+
nftlpsQuery(extension: Extension, network: Networks): DocumentNode;
|
|
19
|
+
nftlpPositionQuery(extension: Extension, positionIds: string[]): DocumentNode;
|
|
18
20
|
private nftlpUniswapV3PositionsQuery;
|
|
19
|
-
borrowersListQuery(factory: Factory):
|
|
20
|
-
borrowersListQueryV2():
|
|
21
|
-
borrowersListQueryV3():
|
|
21
|
+
borrowersListQuery(factory: Factory): DocumentNode;
|
|
22
|
+
borrowersListQueryV2(): DocumentNode;
|
|
23
|
+
borrowersListQueryV3(): DocumentNode;
|
|
22
24
|
}
|
|
@@ -407,6 +407,9 @@ class PonderQueryBuilder {
|
|
|
407
407
|
xIbexQuery() {
|
|
408
408
|
return (0, graphql_tag_1.default) `{}`;
|
|
409
409
|
}
|
|
410
|
+
xIbexUserQuery(account) {
|
|
411
|
+
return (0, graphql_tag_1.default) `{}`;
|
|
412
|
+
}
|
|
410
413
|
/*-----------------------------*
|
|
411
414
|
* NFTLP
|
|
412
415
|
*-----------------------------*/
|
|
@@ -15,6 +15,7 @@ export declare class TheGraphQueryBuilder implements IQueryBuilder {
|
|
|
15
15
|
proposalsMetaQuery(rangeBegin: any, rangeLength: any, descending: any): import("graphql").DocumentNode;
|
|
16
16
|
proposalQuery(id: number): import("graphql").DocumentNode;
|
|
17
17
|
xIbexQuery(): import("graphql").DocumentNode;
|
|
18
|
+
xIbexUserQuery(account: Address): import("graphql").DocumentNode;
|
|
18
19
|
lendingPoolsPastQuery(blockNumber: number, addressesFilter: Address[]): import("graphql").DocumentNode;
|
|
19
20
|
impermaxChefQuery(): import("graphql").DocumentNode;
|
|
20
21
|
pastVolumeQuery(blockNumber: number, addressesFilter: Address[]): import("graphql").DocumentNode;
|
|
@@ -310,6 +310,16 @@ class TheGraphQueryBuilder {
|
|
|
310
310
|
}
|
|
311
311
|
`;
|
|
312
312
|
}
|
|
313
|
+
xIbexUserQuery(account) {
|
|
314
|
+
return (0, graphql_tag_1.default) `{
|
|
315
|
+
user(id: "${account.toLowerCase()}") {
|
|
316
|
+
id
|
|
317
|
+
totalEarned
|
|
318
|
+
lastExchangeRate
|
|
319
|
+
xibexBalance
|
|
320
|
+
}
|
|
321
|
+
}`;
|
|
322
|
+
}
|
|
313
323
|
/*-----------------------------*
|
|
314
324
|
* Optionals
|
|
315
325
|
*-----------------------------*/
|
|
@@ -15,6 +15,7 @@ export interface IQueryBuilder {
|
|
|
15
15
|
proposalsMetaQuery(rangeBegin: number, rangeLength: number, descending: boolean): DocumentNode;
|
|
16
16
|
proposalQuery(id: number): DocumentNode;
|
|
17
17
|
xIbexQuery(): DocumentNode;
|
|
18
|
+
xIbexUserQuery(account: Address): DocumentNode;
|
|
18
19
|
lendingPoolsPastQuery?(blockNumber: number, addressesFilter: Address[]): DocumentNode;
|
|
19
20
|
impermaxChefQuery?(): DocumentNode;
|
|
20
21
|
whitelistQuery?(): DocumentNode;
|
|
@@ -10,12 +10,13 @@ export default class OffchainStakingModule {
|
|
|
10
10
|
constructor(offchain: Offchain);
|
|
11
11
|
getOffchain: () => Offchain;
|
|
12
12
|
getIbexAddress: () => string;
|
|
13
|
-
getXIbexData: () => Promise<XIbexData>;
|
|
13
|
+
getXIbexData: () => Promise<XIbexData | null>;
|
|
14
14
|
getXIbexAddress: () => string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
getTokenPriceAccurate(): Promise<number>;
|
|
16
|
+
getExchangeRate(): Promise<number>;
|
|
17
|
+
getTotalSupply(): Promise<number>;
|
|
18
|
+
getTotalBalance(): Promise<number>;
|
|
19
|
+
getTotalBalanceUSD(): Promise<number>;
|
|
20
|
+
getDailyStakingAPR(): Promise<number>;
|
|
21
|
+
getStakingAPR(): Promise<number>;
|
|
21
22
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ibexes_1 = require("../../config/contracts/ibexes");
|
|
4
|
+
// TODO: Rename
|
|
4
5
|
class OffchainStakingModule {
|
|
5
6
|
cleanCache() {
|
|
6
7
|
this.xIbexData = null;
|
|
@@ -20,41 +21,50 @@ class OffchainStakingModule {
|
|
|
20
21
|
this.xibex = xibex;
|
|
21
22
|
this.offchain = offchain;
|
|
22
23
|
}
|
|
23
|
-
//
|
|
24
|
-
async
|
|
24
|
+
// IBEX price
|
|
25
|
+
async getTokenPriceAccurate() {
|
|
26
|
+
return this.offchain.getPriceHelper().getTokenPrice(this.offchain.network, this.ibex);
|
|
27
|
+
}
|
|
28
|
+
// Exchange rate between 1 xibex and 1 ibex
|
|
29
|
+
async getExchangeRate() {
|
|
25
30
|
const xIbexData = await this.getXIbexData();
|
|
26
31
|
if (!xIbexData)
|
|
27
32
|
return 0;
|
|
28
|
-
return parseFloat(xIbexData.
|
|
33
|
+
return parseFloat(xIbexData.exchangeRate);
|
|
29
34
|
}
|
|
30
|
-
|
|
35
|
+
// Total supply of XIBEX
|
|
36
|
+
async getTotalSupply() {
|
|
31
37
|
const xIbexData = await this.getXIbexData();
|
|
32
38
|
if (!xIbexData)
|
|
33
39
|
return 0;
|
|
34
|
-
return parseFloat(xIbexData.
|
|
40
|
+
return parseFloat(xIbexData.totalSupply);
|
|
35
41
|
}
|
|
36
|
-
|
|
42
|
+
// Total IBEX in the vault
|
|
43
|
+
async getTotalBalance() {
|
|
37
44
|
const xIbexData = await this.getXIbexData();
|
|
38
45
|
if (!xIbexData)
|
|
39
46
|
return 0;
|
|
40
|
-
|
|
47
|
+
// Same as this.getTotalSupply * this.getExchangeRate
|
|
48
|
+
return parseFloat(xIbexData.totalBalance);
|
|
41
49
|
}
|
|
42
|
-
|
|
50
|
+
// Total IBEX in the vault in USD
|
|
51
|
+
async getTotalBalanceUSD() {
|
|
52
|
+
const totalSupply = await this.getTotalBalance();
|
|
53
|
+
const tokenPrice = await this.getTokenPriceAccurate();
|
|
54
|
+
return totalSupply * tokenPrice;
|
|
55
|
+
}
|
|
56
|
+
// APR
|
|
57
|
+
async getDailyStakingAPR() {
|
|
43
58
|
const xIbexData = await this.getXIbexData();
|
|
44
59
|
if (!xIbexData)
|
|
45
60
|
return 0;
|
|
46
|
-
return parseFloat(xIbexData.
|
|
61
|
+
return parseFloat(xIbexData.dailyAPR);
|
|
47
62
|
}
|
|
48
|
-
async
|
|
63
|
+
async getStakingAPR() {
|
|
49
64
|
const xIbexData = await this.getXIbexData();
|
|
50
65
|
if (!xIbexData)
|
|
51
66
|
return 0;
|
|
52
|
-
return parseFloat(xIbexData.
|
|
53
|
-
}
|
|
54
|
-
async getIbexTotalBalanceUSD() {
|
|
55
|
-
const totalStaked = await this.getIbexTotalBalance();
|
|
56
|
-
const tokenPrice = await this.offchain.getPriceHelper().getTokenPrice(this.offchain.network, this.ibex);
|
|
57
|
-
return totalStaked * tokenPrice;
|
|
67
|
+
return Math.pow(1 + parseFloat(xIbexData.dailyAPR), 365) - 1;
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
70
|
exports.default = OffchainStakingModule;
|