impermax-sdk 2.1.202 → 2.1.204
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.
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import OnchainAccountNftlp from "./onchainAccountNftlp";
|
|
2
2
|
import UniswapV3Position from "../../../../utils/position/uniswapV3";
|
|
3
3
|
interface PositionData {
|
|
4
|
-
fee:
|
|
5
|
-
tickLower:
|
|
6
|
-
tickUpper:
|
|
7
|
-
liquidity:
|
|
8
|
-
feeGrowthInside0LastX128:
|
|
9
|
-
feeGrowthInside1LastX128:
|
|
10
|
-
unclaimedFees0:
|
|
11
|
-
unclaimedFees1:
|
|
4
|
+
fee: string;
|
|
5
|
+
tickLower: string;
|
|
6
|
+
tickUpper: string;
|
|
7
|
+
liquidity: string;
|
|
8
|
+
feeGrowthInside0LastX128: string;
|
|
9
|
+
feeGrowthInside1LastX128: string;
|
|
10
|
+
unclaimedFees0: string;
|
|
11
|
+
unclaimedFees1: string;
|
|
12
12
|
}
|
|
13
13
|
export default class OnchainAccountNftlpUniswapV3 extends OnchainAccountNftlp {
|
|
14
14
|
protected cache: {
|
|
@@ -26,13 +26,13 @@ class OnchainAccountNftlpUniswapV3 extends onchainAccountNftlp_1.default {
|
|
|
26
26
|
return this.cache.positionsData[tokenId];
|
|
27
27
|
}
|
|
28
28
|
async getFee(tokenId) {
|
|
29
|
-
return (await this.getPositionData(tokenId)).fee / 10000;
|
|
29
|
+
return parseInt((await this.getPositionData(tokenId)).fee) / 10000;
|
|
30
30
|
}
|
|
31
31
|
async getTickLower(tokenId) {
|
|
32
|
-
return (await this.getPositionData(tokenId)).tickLower;
|
|
32
|
+
return parseInt((await this.getPositionData(tokenId)).tickLower);
|
|
33
33
|
}
|
|
34
34
|
async getTickUpper(tokenId) {
|
|
35
|
-
return (await this.getPositionData(tokenId)).tickUpper;
|
|
35
|
+
return parseInt((await this.getPositionData(tokenId)).tickUpper);
|
|
36
36
|
}
|
|
37
37
|
async getPriceA(tokenId) {
|
|
38
38
|
return this.getNftlp().tickToPrice(await this.getTickLower(tokenId));
|
|
@@ -43,7 +43,7 @@ class OnchainAccountNftlpUniswapV3 extends onchainAccountNftlp_1.default {
|
|
|
43
43
|
async getLiquidity(tokenId) {
|
|
44
44
|
const decimalsA = await this.getNftlp().getLendingPool().getBorrowableA().getDecimals();
|
|
45
45
|
const decimalsB = await this.getNftlp().getLendingPool().getBorrowableB().getDecimals();
|
|
46
|
-
const liquidity = (await this.getPositionData(tokenId)).liquidity;
|
|
46
|
+
const liquidity = parseInt((await this.getPositionData(tokenId)).liquidity);
|
|
47
47
|
return (0, uniswapV3General_1.formatUniV3Liquidity)(liquidity, decimalsA, decimalsB);
|
|
48
48
|
}
|
|
49
49
|
async getCurrentFeeGrowthInsideX128(tokenId) {
|
|
@@ -54,22 +54,28 @@ class OnchainAccountNftlpUniswapV3 extends onchainAccountNftlp_1.default {
|
|
|
54
54
|
nftlp.methods.positions(tokenId)
|
|
55
55
|
]);
|
|
56
56
|
return {
|
|
57
|
-
currentFeeGrowthInside0X128: position[4],
|
|
58
|
-
currentFeeGrowthInside1X128: position[5],
|
|
57
|
+
currentFeeGrowthInside0X128: parseInt(position[4]),
|
|
58
|
+
currentFeeGrowthInside1X128: parseInt(position[5]),
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
async getCurrentUnclaimedFeesRaw(tokenId) {
|
|
62
62
|
const { currentFeeGrowthInside0X128, currentFeeGrowthInside1X128 } = await this.getCurrentFeeGrowthInsideX128(tokenId);
|
|
63
63
|
const positionData = await this.getPositionData(tokenId);
|
|
64
|
-
const delta0 = currentFeeGrowthInside0X128 - positionData.feeGrowthInside0LastX128;
|
|
65
|
-
const delta1 = currentFeeGrowthInside1X128 - positionData.feeGrowthInside1LastX128;
|
|
64
|
+
const delta0 = currentFeeGrowthInside0X128 - parseInt(positionData.feeGrowthInside0LastX128);
|
|
65
|
+
const delta1 = currentFeeGrowthInside1X128 - parseInt(positionData.feeGrowthInside1LastX128);
|
|
66
|
+
console.log("DATA");
|
|
67
|
+
console.log(delta0, currentFeeGrowthInside0X128, positionData.feeGrowthInside0LastX128);
|
|
68
|
+
console.log(delta1, currentFeeGrowthInside1X128, positionData.feeGrowthInside1LastX128);
|
|
69
|
+
console.log(parseInt(positionData.unclaimedFees0), delta0 * parseInt(positionData.liquidity) / Q128, positionData.liquidity, Q128);
|
|
70
|
+
console.log(parseInt(positionData.unclaimedFees1), delta1 * parseInt(positionData.liquidity) / Q128, positionData.liquidity, Q128);
|
|
66
71
|
return {
|
|
67
|
-
unclaimedFees0: positionData.unclaimedFees0 + delta0 * positionData.liquidity / Q128,
|
|
68
|
-
unclaimedFees1: positionData.unclaimedFees1 + delta1 * positionData.liquidity / Q128,
|
|
72
|
+
unclaimedFees0: parseInt(positionData.unclaimedFees0) + delta0 * parseInt(positionData.liquidity) / Q128,
|
|
73
|
+
unclaimedFees1: parseInt(positionData.unclaimedFees1) + delta1 * parseInt(positionData.liquidity) / Q128,
|
|
69
74
|
};
|
|
70
75
|
}
|
|
71
76
|
async getCurrentUnclaimedFees(tokenId) {
|
|
72
77
|
const raw = await this.getCurrentUnclaimedFeesRaw(tokenId);
|
|
78
|
+
console.log("raw", raw);
|
|
73
79
|
return {
|
|
74
80
|
unclaimedFees0: await this.getNftlp().getLendingPool().getBorrowableA().normalize(raw.unclaimedFees0),
|
|
75
81
|
unclaimedFees1: await this.getNftlp().getLendingPool().getBorrowableB().normalize(raw.unclaimedFees1),
|