impermax-sdk 2.1.241 → 2.1.246
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/index.d.ts +2 -1
- package/lib/offchain/account/lendingPool/offchainAccountLendingPool.d.ts +1 -0
- package/lib/offchain/account/lendingPool/offchainAccountLendingPoolV2.d.ts +1 -0
- package/lib/offchain/account/lendingPool/offchainAccountLendingPoolV2.js +11 -0
- package/lib/offchain/account/lendingPool/offchainAccountLendingPoolV3.d.ts +1 -0
- package/lib/offchain/account/lendingPool/offchainAccountLendingPoolV3.js +8 -0
- package/lib/offchain/lendingPool/offchainLendingPool.js +2 -0
- package/lib/utils/position/interface.d.ts +1 -1
- package/lib/utils/position/uniswapV2/index.d.ts +1 -1
- package/lib/utils/position/uniswapV3/index.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -47,4 +47,5 @@ import OffchainAccountNftlpUniswapV3 from './offchain/account/lendingPool/nftlp/
|
|
|
47
47
|
import { MAX_TICK, MIN_TICK, formatPriceSqrtX96, uniV3TickToPrice } from "./utils/nftlpMath/uniswapV3General";
|
|
48
48
|
import UniswapV3Position from './utils/position/uniswapV3';
|
|
49
49
|
import UniswapV2Position from './utils/position/uniswapV2';
|
|
50
|
-
|
|
50
|
+
import Position from './utils/position/interface';
|
|
51
|
+
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, OnchainAccountLendingPoolV2, OnchainAccountLendingPoolV3, OnchainAccountNftlpUniswapV3, OnchainAccountPoolToken, OnchainAccountBorrowable, OnchainAccountCollateral, OnchainAccountLendingVault, OnchainContractsHelper, OnchainImpermaxFactory, OnchainInteractions, OnchainInteractionsLendingPool, OnchainInteractionsPoolToken, OnchainInteractionsCollateral, OnchainInteractionsBorrowable, 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, XIMX_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, OnchainInteractionsLendingPoolV3, OnchainInteractionsNftlpUniswapV3, decimalToBalance, OffchainAccountLendingPoolV3, OffchainAccountNftlpUniswapV3, MAX_TICK, MIN_TICK, formatPriceSqrtX96, uniV3TickToPrice, isV3Factory, UniswapV3Position, UniswapV2Position, Position, OffchainAccountCollateralV2 };
|
|
@@ -17,6 +17,7 @@ export default abstract class OffchainAccountLendingPool {
|
|
|
17
17
|
protected abstract getNewBorrowableObject(borrowable: Borrowable): OffchainAccountBorrowable;
|
|
18
18
|
constructor(account: OffchainAccount, lendingPool: OffchainLendingPool);
|
|
19
19
|
abstract getLendingPoolPosition(): Promise<LendingPoolPosition | undefined>;
|
|
20
|
+
abstract getLeveragedAPR(tokenId?: number): Promise<number>;
|
|
20
21
|
getAccount: () => OffchainAccount;
|
|
21
22
|
getLendingPool: () => OffchainLendingPool;
|
|
22
23
|
getBorrowable: (borrowable: Borrowable) => OffchainAccountBorrowable;
|
|
@@ -37,6 +37,7 @@ export default class OffchainAccountLendingPoolV2 extends OffchainAccountLending
|
|
|
37
37
|
borrowable1: import("../../offchainTypes").BorrowPosition | undefined;
|
|
38
38
|
};
|
|
39
39
|
} | undefined>;
|
|
40
|
+
getLeveragedAPR(): Promise<number>;
|
|
40
41
|
getLeveragedPositions(): Promise<Array<OffchainLeveragedPosition>>;
|
|
41
42
|
getLeveragedPositionsTotalBalanceUSD(): Promise<number>;
|
|
42
43
|
getLeveragedPositionsNetAPR(): Promise<number>;
|
|
@@ -57,6 +57,17 @@ class OffchainAccountLendingPoolV2 extends offchainAccountLendingPool_1.default
|
|
|
57
57
|
},
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
+
/*--------------------------------------------------------------------------*
|
|
61
|
+
* Position APR *
|
|
62
|
+
*--------------------------------------------------------------------------*/
|
|
63
|
+
// NOTE: Should this be moved directly to position object?
|
|
64
|
+
async getLeveragedAPR() {
|
|
65
|
+
const baseAPR = await this.getLendingPool().getTotalAPR();
|
|
66
|
+
const leverage = (await this.getCollateral().getPositionObject()).getLeverage();
|
|
67
|
+
const borrowApr0 = await this.getLendingPool().getBorrowableA().getBorrowAPR();
|
|
68
|
+
const borrowApr1 = await this.getLendingPool().getBorrowableB().getBorrowAPR();
|
|
69
|
+
return baseAPR * leverage - (borrowApr0 + borrowApr1) / 2 * (leverage - 1);
|
|
70
|
+
}
|
|
60
71
|
async getLeveragedPositions() {
|
|
61
72
|
return [];
|
|
62
73
|
}
|
|
@@ -35,6 +35,7 @@ export default class OffchainAccountLendingPoolV3 extends OffchainAccountLending
|
|
|
35
35
|
positions: Record<string, NftlpPosition> | undefined;
|
|
36
36
|
} | undefined>;
|
|
37
37
|
getTokenIds(): Promise<(string | undefined)[]>;
|
|
38
|
+
getLeveragedAPR(tokenId: number): Promise<number>;
|
|
38
39
|
getLeveragedPositions(): Promise<Array<OffchainLeveragedPosition>>;
|
|
39
40
|
getLeveragedPositionsTotalBalanceUSD(): Promise<number>;
|
|
40
41
|
getLeveragedPositionsNetAPR(): Promise<number>;
|
|
@@ -64,6 +64,14 @@ class OffchainAccountLendingPoolV3 extends offchainAccountLendingPool_1.default
|
|
|
64
64
|
const positions = userData[factory]?.positions?.[pairAddress] || [];
|
|
65
65
|
return positions.map(pos => pos.tokenId);
|
|
66
66
|
}
|
|
67
|
+
/*--------------------------------------------------------------------------*
|
|
68
|
+
* Position APR *
|
|
69
|
+
*--------------------------------------------------------------------------*/
|
|
70
|
+
// TODO: CL APR
|
|
71
|
+
// NOTE: Should this be moved directly to position object?
|
|
72
|
+
async getLeveragedAPR(tokenId) {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
67
75
|
async getLeveragedPositions() {
|
|
68
76
|
return [];
|
|
69
77
|
}
|
|
@@ -69,6 +69,8 @@ class OffchainLendingPool {
|
|
|
69
69
|
this.getBorrowableA().getTokenPriceAccurate(),
|
|
70
70
|
this.getBorrowableB().getTokenPriceAccurate()
|
|
71
71
|
]);
|
|
72
|
+
console.log("Offchain priceA: %s", priceA);
|
|
73
|
+
console.log("Offchain priceB: %s", priceB);
|
|
72
74
|
return priceA / priceB;
|
|
73
75
|
}
|
|
74
76
|
async getMarketPrice() {
|