@@ -154,29 +154,20 @@ const LpSettings: React.FC<{ onComplete: () => void; squeethToMint: string }> =
154
154
return
155
155
}
156
156
157
- const minPriceBN = new bn ( minPrice )
158
- const maxPriceBN = new bn ( maxPrice )
159
- if ( minPriceBN . isLessThanOrEqualTo ( 0 ) || maxPriceBN . isLessThanOrEqualTo ( 0 ) ) {
160
- return
161
- }
162
-
163
- // still not sure about this
164
- // but basically the thought is that lowerPrice is derived from maxPrice since that's in denominator
165
- const lowerPrice = ethPrice . div ( maxPrice ) . integerValue ( bn . ROUND_FLOOR ) . toNumber ( )
166
- const upperPrice = ethPrice . div ( minPrice ) . integerValue ( bn . ROUND_FLOOR ) . toNumber ( )
167
-
168
- const ticks = getTicksFromPriceRange ( lowerPrice , upperPrice )
169
-
157
+ const ticks = getTicksFromPriceRange ( minPrice , maxPrice )
170
158
setLowerTick ( ticks . lowerTick )
171
159
setUpperTick ( ticks . upperTick )
172
160
} , [ usingDefaultPriceRange , minPrice , maxPrice , ethPrice , getTicksFromPriceRange ] )
173
161
174
162
useAppEffect ( ( ) => {
175
- getDepositAmounts ( new bn ( squeethToMint ) , lowerTick , upperTick , 0 , collatRatioVal , 0 ) . then ( ( deposits ) => {
163
+ async function calcDepositAmounts ( ) {
164
+ const deposits = await getDepositAmounts ( new bn ( squeethToMint ) , lowerTick , upperTick , 0 , collatRatioVal , 0 )
176
165
if ( deposits ) {
177
166
setDepositAmounts ( deposits )
178
167
}
179
- } )
168
+ }
169
+
170
+ calcDepositAmounts ( )
180
171
} , [ squeethToMint , lowerTick , upperTick , collatRatioVal , getDepositAmounts ] )
181
172
182
173
const openPosition = useAppCallback ( async ( ) => {
@@ -189,7 +180,7 @@ const LpSettings: React.FC<{ onComplete: () => void; squeethToMint: string }> =
189
180
console . log ( 'transaction failed' )
190
181
console . log ( e )
191
182
}
192
- } , [ squeethToMint , lowerTick , upperTick , collatRatio , slippageAmount , openLpPosition ] )
183
+ } , [ squeethToMint , lowerTick , upperTick , collatRatioVal , slippageAmountVal , openLpPosition , onComplete ] )
193
184
194
185
return (
195
186
< >
0 commit comments