impermax-sdk 2.1.569 → 2.1.571
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/whitelist.js +2 -0
- package/lib/offchain/account/lendingPool/nftlp/offchainAccountNftlpGenericCL.d.ts +2 -2
- package/lib/offchain/account/lendingPool/nftlp/offchainAccountNftlpGenericCL.js +4 -4
- package/lib/onchain/account/onchainAccountPoolToken.d.ts +1 -0
- package/lib/onchain/account/onchainAccountPoolToken.js +4 -3
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpGenericCL.d.ts +1 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpGenericCL.js +11 -4
- package/lib/onchain/onchainLendingVault.d.ts +1 -0
- package/lib/onchain/onchainLendingVault.js +2 -1
- package/package.json +1 -1
package/lib/config/whitelist.js
CHANGED
|
@@ -117,6 +117,8 @@ exports.WHITELISTED_PAIRS = {
|
|
|
117
117
|
"0xFd6b42A3da0e755d647D1eBF522E7D4368D7fEf7",
|
|
118
118
|
"0xB8e831D4eb4Ce93ffca9Ff4A8fe2c3f9bF99628A",
|
|
119
119
|
"0xb5E2500f93Bc2DD3163E191EBc6F3B2f5B1E8b7f",
|
|
120
|
+
"0xc612250083ad9a3b1b07616f7832d0ba11cef227",
|
|
121
|
+
"0xe2a738197977c3135796ae45b3b847f1126489e0",
|
|
120
122
|
// Scale
|
|
121
123
|
"0x4Cafce8b0Ca0Ba9d3490Ce9b67048139f698a5f8",
|
|
122
124
|
"0x965c3f8Dc3aa446b268aB3Bca4d7E82b788FfE96",
|
|
@@ -25,6 +25,6 @@ export default abstract class OffchainAccountNftlpGenericCL extends OffchainAcco
|
|
|
25
25
|
getUnclaimedFees(tokenId: number): Promise<FeeAmounts>;
|
|
26
26
|
getCumulativeDeposit0(tokenId: number): Promise<number>;
|
|
27
27
|
getCumulativeDeposit1(tokenId: number): Promise<number>;
|
|
28
|
-
createPositionObject(tokenId: number): Promise<GenericCLPosition>;
|
|
29
|
-
getPositionObject(tokenId: number): Promise<GenericCLPosition>;
|
|
28
|
+
createPositionObject(tokenId: number, onchainPrice?: number): Promise<GenericCLPosition>;
|
|
29
|
+
getPositionObject(tokenId: number, onchainPrice?: number): Promise<GenericCLPosition>;
|
|
30
30
|
}
|
|
@@ -67,7 +67,7 @@ class OffchainAccountNftlpGenericCL extends offchainAccountNftlp_1.default {
|
|
|
67
67
|
const positionData = await this.getPositionData(tokenId);
|
|
68
68
|
return parseFloat(positionData.cumulativeDeposit1);
|
|
69
69
|
}
|
|
70
|
-
async createPositionObject(tokenId) {
|
|
70
|
+
async createPositionObject(tokenId, onchainPrice) {
|
|
71
71
|
const unclaimedFees = await this.getUnclaimedFees(tokenId);
|
|
72
72
|
return new cl_1.default({
|
|
73
73
|
liquidity: await this.getLiquidity(tokenId),
|
|
@@ -75,7 +75,7 @@ class OffchainAccountNftlpGenericCL extends offchainAccountNftlp_1.default {
|
|
|
75
75
|
unclaimedFeesY: unclaimedFees.amountY,
|
|
76
76
|
debtX: await this.getLendingPool().getBorrowableA().getBorrowedAmount(tokenId),
|
|
77
77
|
debtY: await this.getLendingPool().getBorrowableB().getBorrowedAmount(tokenId),
|
|
78
|
-
marketPrice: await this.getNftlp().getMarketPrice(),
|
|
78
|
+
marketPrice: onchainPrice ?? await this.getNftlp().getMarketPrice(),
|
|
79
79
|
oraclePrice: await this.getNftlp().getOraclePrice(),
|
|
80
80
|
priceA: await this.getPriceA(tokenId),
|
|
81
81
|
priceB: await this.getPriceB(tokenId),
|
|
@@ -90,11 +90,11 @@ class OffchainAccountNftlpGenericCL extends offchainAccountNftlp_1.default {
|
|
|
90
90
|
cumulativeBorrowY: await this.getLendingPool().getBorrowableB().getCumulativeBorrows(tokenId),
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
async getPositionObject(tokenId) {
|
|
93
|
+
async getPositionObject(tokenId, onchainPrice) {
|
|
94
94
|
if (!this.cache.positionsObject)
|
|
95
95
|
this.cache.positionsObject = {};
|
|
96
96
|
if (!this.cache.positionsObject[tokenId])
|
|
97
|
-
this.cache.positionsObject[tokenId] = this.createPositionObject(tokenId);
|
|
97
|
+
this.cache.positionsObject[tokenId] = this.createPositionObject(tokenId, onchainPrice);
|
|
98
98
|
return this.cache.positionsObject[tokenId];
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -20,6 +20,7 @@ export default abstract class OnchainAccountPoolToken {
|
|
|
20
20
|
getLiquidityBuffer: () => number;
|
|
21
21
|
getUiMargin: () => number;
|
|
22
22
|
getTokenPriceAccurate: () => Promise<number>;
|
|
23
|
+
getMulticall: () => import("../onchainMulticall").default;
|
|
23
24
|
private initializeAvailableBalance;
|
|
24
25
|
getAvailableBalance(): Promise<number>;
|
|
25
26
|
getAvailableBalanceUSD(): Promise<number>;
|
|
@@ -13,6 +13,7 @@ class OnchainAccountPoolToken {
|
|
|
13
13
|
this.getLiquidityBuffer = () => this.getAccount().getOnchain().liquidityBuffer;
|
|
14
14
|
this.getUiMargin = () => this.getAccount().getOnchain().uiMargin;
|
|
15
15
|
this.getTokenPriceAccurate = async () => (await this.poolToken.getOffchainPoolToken()).getTokenPriceAccurate();
|
|
16
|
+
this.getMulticall = () => this.getAccount().getOnchain().multicall;
|
|
16
17
|
this.getDeposited = this.getAmount;
|
|
17
18
|
}
|
|
18
19
|
cleanCache() {
|
|
@@ -22,9 +23,9 @@ class OnchainAccountPoolToken {
|
|
|
22
23
|
async initializeAvailableBalance() {
|
|
23
24
|
const token = await this.poolToken.getToken();
|
|
24
25
|
if (token._address.toLowerCase() == weths_1.WETH[this.getNetwork()].toLowerCase()) {
|
|
25
|
-
return (await this.
|
|
26
|
+
return (await this.getMulticall().call(this.getMulticall().getEthBalance(this.getAccountAddress()))) / 1e18;
|
|
26
27
|
}
|
|
27
|
-
const balance = await token.methods.balanceOf(this.getAccountAddress())
|
|
28
|
+
const balance = await this.getMulticall().call(token.methods.balanceOf(this.getAccountAddress()));
|
|
28
29
|
return (await this.poolToken.normalize(balance));
|
|
29
30
|
}
|
|
30
31
|
async getAvailableBalance() {
|
|
@@ -40,7 +41,7 @@ class OnchainAccountPoolToken {
|
|
|
40
41
|
// Tokens
|
|
41
42
|
async initializeTokens() {
|
|
42
43
|
const poolToken = await this.poolToken.getPoolToken();
|
|
43
|
-
const balance = await poolToken.methods.balanceOf(this.getAccountAddress())
|
|
44
|
+
const balance = await this.getMulticall().call(poolToken.methods.balanceOf(this.getAccountAddress()));
|
|
44
45
|
return (await this.poolToken.normalize(balance));
|
|
45
46
|
}
|
|
46
47
|
async getTokens() {
|
|
@@ -12,6 +12,7 @@ export default abstract class OnchainNftlpGenericCL extends OnchainNftlp {
|
|
|
12
12
|
oraclePrice?: Promise<number>;
|
|
13
13
|
};
|
|
14
14
|
getOffchainNftlp: () => Promise<OffchainNftlpGenericCL>;
|
|
15
|
+
getMulticall: () => import("../../../onchainMulticall").default;
|
|
15
16
|
protected tickSpacings(): Promise<Array<number>>;
|
|
16
17
|
protected abstract initializeCLPool(tickSpacing: number): Promise<Contract | null>;
|
|
17
18
|
getCLPool(tickSpacing: number): Promise<any>;
|
|
@@ -10,6 +10,7 @@ class OnchainNftlpGenericCL extends onchainNftlp_1.default {
|
|
|
10
10
|
super(...arguments);
|
|
11
11
|
this.cache = {};
|
|
12
12
|
this.getOffchainNftlp = async () => (await this.getLendingPool().getOffchainLendingPool()).getNftlp();
|
|
13
|
+
this.getMulticall = () => this.getLendingPool().getImpermaxFactory().getOnchain().multicall;
|
|
13
14
|
}
|
|
14
15
|
async tickSpacings() {
|
|
15
16
|
return (await this.getOffchainNftlp()).tickSpacings();
|
|
@@ -34,9 +35,15 @@ class OnchainNftlpGenericCL extends onchainNftlp_1.default {
|
|
|
34
35
|
const pool = await this.getCLPool(tickSpacing);
|
|
35
36
|
if (!pool)
|
|
36
37
|
return;
|
|
37
|
-
const priceSqrtX96 = (await pool.methods.slot0().call()).sqrtPriceX96;
|
|
38
|
-
const price =
|
|
39
|
-
const liquidity = await pool.methods.liquidity().call() * 1;
|
|
38
|
+
// const priceSqrtX96 = (await pool.methods.slot0().call()).sqrtPriceX96;
|
|
39
|
+
// const price = formatPriceSqrtX96(priceSqrtX96, priceAdjustment);
|
|
40
|
+
// const liquidity = await pool.methods.liquidity().call() * 1;
|
|
41
|
+
const [slot0, _liquidity] = await Promise.all([
|
|
42
|
+
this.getMulticall().call(pool.methods.slot0()),
|
|
43
|
+
this.getMulticall().call(pool.methods.liquidity())
|
|
44
|
+
]);
|
|
45
|
+
const liquidity = _liquidity * 1;
|
|
46
|
+
const price = (0, CLGeneral_1.formatPriceSqrtX96)(slot0[0], priceAdjustment);
|
|
40
47
|
priceCumulative += price * liquidity;
|
|
41
48
|
liquidityCumulative += liquidity;
|
|
42
49
|
}));
|
|
@@ -45,7 +52,7 @@ class OnchainNftlpGenericCL extends onchainNftlp_1.default {
|
|
|
45
52
|
async initializeOraclePrice() {
|
|
46
53
|
const nftlp = await this.getNftlp();
|
|
47
54
|
const priceAdjustment = await this.priceAdjustment();
|
|
48
|
-
const priceSqrtX96 = await nftlp.methods.oraclePriceSqrtX96()
|
|
55
|
+
const priceSqrtX96 = await this.getMulticall().call(nftlp.methods.oraclePriceSqrtX96());
|
|
49
56
|
return (0, CLGeneral_1.formatPriceSqrtX96)(priceSqrtX96, priceAdjustment);
|
|
50
57
|
}
|
|
51
58
|
async tickToPrice(tick) {
|
|
@@ -13,6 +13,7 @@ export default class OnchainLendingVault extends OnchainPoolToken {
|
|
|
13
13
|
getOnchain: () => Onchain;
|
|
14
14
|
getVaultAddress: () => string;
|
|
15
15
|
getContractHelper: () => import("./onchainContractsHelper").default;
|
|
16
|
+
getMulticall: () => import("./onchainMulticall").default;
|
|
16
17
|
getPoolTokenAddress(): Promise<Address>;
|
|
17
18
|
getOffchainPoolToken(): Promise<OffchainLendingVault>;
|
|
18
19
|
getOffchainLendingVault: () => Promise<OffchainLendingVault>;
|
|
@@ -11,6 +11,7 @@ class OnchainLendingVault extends onchainPoolToken_1.default {
|
|
|
11
11
|
this.getOnchain = () => this.onchain;
|
|
12
12
|
this.getVaultAddress = () => this.vaultAddress;
|
|
13
13
|
this.getContractHelper = () => this.onchain.getContractHelper();
|
|
14
|
+
this.getMulticall = () => this.onchain.multicall;
|
|
14
15
|
this.getOffchainLendingVault = this.getOffchainPoolToken;
|
|
15
16
|
this.onchain = onchain;
|
|
16
17
|
this.vaultAddress = vaultAddress;
|
|
@@ -30,7 +31,7 @@ class OnchainLendingVault extends onchainPoolToken_1.default {
|
|
|
30
31
|
}
|
|
31
32
|
async initializeToken() {
|
|
32
33
|
const poolToken = await this.getPoolToken();
|
|
33
|
-
return this.getContractHelper().newERC20(await poolToken.methods.underlying()
|
|
34
|
+
return this.getContractHelper().newERC20(await this.getMulticall().call(poolToken.methods.underlying()));
|
|
34
35
|
}
|
|
35
36
|
// Available Liquidity
|
|
36
37
|
/*private async initializeAvailableLiquidity() : Promise<number> {
|