impermax-sdk 2.1.79 → 2.1.80
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.
|
@@ -92,7 +92,7 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
92
92
|
else {
|
|
93
93
|
approveB += amountBUser;
|
|
94
94
|
}
|
|
95
|
-
actions.push(yield actionsGetter.methods.getBorrowAndMintUniV3Action(borrowableA.toBigNumber(amountAUser), borrowableB.toBigNumber(amountBUser), borrowableA.toBigNumber(depositADelta), borrowableB.toBigNumber(depositBDelta), borrowableA.toBigNumber(depositADelta / this.getUiMargin()), borrowableB.toBigNumber(depositBDelta / this.getUiMargin())).call());
|
|
95
|
+
actions.push(yield actionsGetter.methods.getBorrowAndMintUniV3Action(yield borrowableA.toBigNumber(amountAUser), yield borrowableB.toBigNumber(amountBUser), yield borrowableA.toBigNumber(depositADelta), yield borrowableB.toBigNumber(depositBDelta), yield borrowableA.toBigNumber(depositADelta / this.getUiMargin()), yield borrowableB.toBigNumber(depositBDelta / this.getUiMargin())).call());
|
|
96
96
|
depositADelta = 0;
|
|
97
97
|
depositBDelta = 0;
|
|
98
98
|
borrowADelta = Math.min(borrowADelta, 0);
|
|
@@ -100,20 +100,20 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
100
100
|
}
|
|
101
101
|
// Borrow
|
|
102
102
|
if (borrowADelta > 0) {
|
|
103
|
-
actions.push(yield actionsGetter.methods.getBorrowAction(0, borrowableA.toBigNumber(borrowADelta), isEthA ? router._address : this.getAccountAddress()).call());
|
|
103
|
+
actions.push(yield actionsGetter.methods.getBorrowAction(0, yield borrowableA.toBigNumber(borrowADelta), isEthA ? router._address : this.getAccountAddress()).call());
|
|
104
104
|
borrowADelta = 0;
|
|
105
105
|
if (isEthA)
|
|
106
106
|
doWithdrawEth = true;
|
|
107
107
|
}
|
|
108
108
|
if (borrowBDelta > 0) {
|
|
109
|
-
actions.push(yield actionsGetter.methods.getBorrowAction(1, borrowableB.toBigNumber(borrowBDelta), isEthB ? router._address : this.getAccountAddress()).call());
|
|
109
|
+
actions.push(yield actionsGetter.methods.getBorrowAction(1, yield borrowableB.toBigNumber(borrowBDelta), isEthB ? router._address : this.getAccountAddress()).call());
|
|
110
110
|
borrowBDelta = 0;
|
|
111
111
|
if (isEthB)
|
|
112
112
|
doWithdrawEth = true;
|
|
113
113
|
}
|
|
114
114
|
// Mint
|
|
115
115
|
if (depositADelta > 0 || depositBDelta > 0) {
|
|
116
|
-
actions.push(yield actionsGetter.methods.getMintUniV3Action(borrowableA.toBigNumber(depositADelta), borrowableB.toBigNumber(depositBDelta), borrowableA.toBigNumber(depositADelta / this.getUiMargin()), borrowableB.toBigNumber(depositBDelta / this.getUiMargin())).call());
|
|
116
|
+
actions.push(yield actionsGetter.methods.getMintUniV3Action(yield borrowableA.toBigNumber(depositADelta), yield borrowableB.toBigNumber(depositBDelta), yield borrowableA.toBigNumber(depositADelta / this.getUiMargin()), yield borrowableB.toBigNumber(depositBDelta / this.getUiMargin())).call());
|
|
117
117
|
if (isEthA) {
|
|
118
118
|
ethValue += depositADelta;
|
|
119
119
|
}
|
|
@@ -134,7 +134,7 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
134
134
|
// remove LP and send liquidity to the router
|
|
135
135
|
const liquidityToRemove = -optimalLiquidity.liquidity * this.getDust();
|
|
136
136
|
const currentLiquidity = yield this.getAccountNftlp().getLiquidity(tokenId);
|
|
137
|
-
actions.push(yield actionsGetter.methods.getRedeemUniV3Action((0, ether_utils_1.decimalToBalance)(Math.max(liquidityToRemove / currentLiquidity,
|
|
137
|
+
actions.push(yield actionsGetter.methods.getRedeemUniV3Action((0, ether_utils_1.decimalToBalance)(Math.max(liquidityToRemove / currentLiquidity, 18)), yield borrowableA.toBigNumber(-depositADelta / this.getUiMargin()), yield borrowableB.toBigNumber(-depositBDelta / this.getUiMargin()), router._address).call());
|
|
138
138
|
if (isEthA || isEthB)
|
|
139
139
|
doWithdrawEth = true;
|
|
140
140
|
// withdraw or repay tokenA
|
|
@@ -142,7 +142,7 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
142
142
|
// if repay >= redeem, we can repay MAX_UINT in order to use every redeemed fund for repaying
|
|
143
143
|
// otherwise we can set a repay limit in order to withdraw the funds not used to repay
|
|
144
144
|
const maximizeRepay = (-borrowADelta) > (-depositADelta) / this.getDust();
|
|
145
|
-
actions.push(yield actionsGetter.methods.getRepayRouterAction(0, maximizeRepay ? general_1.MAX_UINT : borrowableA.toBigNumber(-borrowADelta), isEthA ? router._address : this.getAccountAddress()).call());
|
|
145
|
+
actions.push(yield actionsGetter.methods.getRepayRouterAction(0, maximizeRepay ? general_1.MAX_UINT : yield borrowableA.toBigNumber(-borrowADelta), isEthA ? router._address : this.getAccountAddress()).call());
|
|
146
146
|
// after repayRouter, we need to call repayUser only if repay > redeem and the token is not ETH
|
|
147
147
|
// (for ETH we've already repaid since repayETH is done through repayRouter)
|
|
148
148
|
if (!maximizeRepay)
|
|
@@ -161,7 +161,7 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
161
161
|
// withdraw or repay tokenB (same logic as tokenA)
|
|
162
162
|
if (borrowBDelta < 0) {
|
|
163
163
|
const maximizeRepay = (-borrowBDelta) > (-depositBDelta) / this.getDust();
|
|
164
|
-
actions.push(yield actionsGetter.methods.getRepayRouterAction(1, maximizeRepay ? general_1.MAX_UINT : borrowableB.toBigNumber(-borrowBDelta), isEthB ? router._address : this.getAccountAddress()).call());
|
|
164
|
+
actions.push(yield actionsGetter.methods.getRepayRouterAction(1, maximizeRepay ? general_1.MAX_UINT : yield borrowableB.toBigNumber(-borrowBDelta), isEthB ? router._address : this.getAccountAddress()).call());
|
|
165
165
|
if (!maximizeRepay)
|
|
166
166
|
borrowBDelta = 0;
|
|
167
167
|
else if (isEthB) {
|
|
@@ -184,7 +184,7 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
184
184
|
doWithdrawEth = true;
|
|
185
185
|
}
|
|
186
186
|
else {
|
|
187
|
-
actions.push(yield actionsGetter.methods.getRepayUserAction(0, borrowableA.toBigNumber(-borrowADelta)).call());
|
|
187
|
+
actions.push(yield actionsGetter.methods.getRepayUserAction(0, yield borrowableA.toBigNumber(-borrowADelta)).call());
|
|
188
188
|
approveA -= borrowADelta;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
@@ -195,7 +195,7 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
195
195
|
doWithdrawEth = true;
|
|
196
196
|
}
|
|
197
197
|
else {
|
|
198
|
-
actions.push(yield actionsGetter.methods.getRepayUserAction(1, borrowableB.toBigNumber(-borrowBDelta)).call());
|
|
198
|
+
actions.push(yield actionsGetter.methods.getRepayUserAction(1, yield borrowableB.toBigNumber(-borrowBDelta)).call());
|
|
199
199
|
approveB -= borrowBDelta;
|
|
200
200
|
}
|
|
201
201
|
}
|