@@ -233,124 +233,26 @@ export class CreditAccountServiceV300
233233 } : PreviewWithdrawLlamathenaProportionallyProps ) : Promise < PreviewWithdrawLlamathenaProportionallyResult > {
234234 const LLAMATHENA_CURVE_POOL : Address =
235235 "0xd29f8980852c2c76fc3f6e96a7aa06e0bedcc1b1" . toLowerCase ( ) as Address ;
236- const SCRVUSD : Address =
237- "0x0655977FEb2f289A4aB78af67BAB0d17aAb84367" . toLowerCase ( ) as Address ;
238- const SUSDE : Address =
239- "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497" . toLowerCase ( ) as Address ;
240236
241237 const llamathenaBalance = llamathena . balance ;
242- if ( llamathenaBalance === 0n )
238+ if ( llamathenaBalance === 0n ) {
243239 return {
244- scrvusdDelta : 0n ,
245- scrvusdAddress : SCRVUSD ,
246-
247- susdeDelta : 0n ,
248- susdeAddress : SUSDE ,
249-
250- llamathena : [ llamathena ] ,
251-
252- assets : [
253- {
254- token : SCRVUSD ,
255- balance : 0n ,
256- } ,
257- {
258- token : SUSDE ,
259- balance : 0n ,
260- } ,
261- ] ,
262- } ;
263-
264- const llamathenaAbi = [
265- {
266- type : "function" ,
267- inputs : [ ] ,
268- name : "get_balances" ,
269- outputs : [
270- {
271- name : "" ,
272- internalType : "uint256[]" ,
273- type : "uint256[]" ,
274- } ,
275- ] ,
276- stateMutability : "view" ,
277- } ,
278- {
279- type : "function" ,
280- inputs : [ ] ,
281- name : "totalSupply" ,
282- outputs : [
283- {
284- name : "" ,
285- internalType : "uint256" ,
286- type : "uint256" ,
287- } ,
288- ] ,
289- stateMutability : "view" ,
290- } ,
291- ] as const ;
292-
293- const [ poolBalances , totalSupply ] = await this . client . multicall ( {
294- batchSize : 0 ,
295- allowFailure : false ,
296- contracts : [
297- {
298- address : LLAMATHENA_CURVE_POOL ,
299- abi : llamathenaAbi ,
300- functionName : "get_balances" ,
301- } ,
302- {
303- address : LLAMATHENA_CURVE_POOL ,
304- abi : llamathenaAbi ,
305- functionName : "totalSupply" ,
306- } ,
307- ] ,
308- } ) ;
309-
310- if ( totalSupply === 0n )
311- return {
312- scrvusdDelta : 0n ,
313- scrvusdAddress : SCRVUSD ,
314-
315- susdeDelta : 0n ,
316- susdeAddress : SUSDE ,
317-
318- llamathena : [ llamathena ] ,
319-
240+ stkLlamathena : [ llamathena ] ,
320241 assets : [
321242 {
322- token : SCRVUSD ,
323- balance : 0n ,
324- } ,
325- {
326- token : SUSDE ,
243+ token : LLAMATHENA_CURVE_POOL ,
327244 balance : 0n ,
328245 } ,
329246 ] ,
330247 } ;
331-
332- const [ scrvusdBalance = 0n , susdeBalance = 0n ] = poolBalances ;
333-
334- const scrvusdDelta = ( scrvusdBalance * llamathenaBalance ) / totalSupply ;
335- const susdeDelta = ( susdeBalance * llamathenaBalance ) / totalSupply ;
248+ }
336249
337250 return {
338- scrvusdDelta,
339- scrvusdAddress : SCRVUSD ,
340-
341- susdeDelta,
342- susdeAddress : SUSDE ,
343-
344- llamathena : [ llamathena ] ,
345-
251+ stkLlamathena : [ llamathena ] ,
346252 assets : [
347253 {
348- token : SCRVUSD ,
349- balance : scrvusdDelta ,
350- } ,
351- {
352- token : SUSDE ,
353- balance : susdeDelta ,
254+ token : LLAMATHENA_CURVE_POOL ,
255+ balance : llamathenaBalance ,
354256 } ,
355257 ] ,
356258 } ;
@@ -363,8 +265,6 @@ export class CreditAccountServiceV300
363265 } : LlamathenaProportionalWithdrawProps ) {
364266 const LLAMATHENA_BASE_REWARD_POOL : Address =
365267 "0x11fd8801a051b296e337a3e1168839fb346d5940" ;
366- const LLAMATHENA_POOL : Address =
367- "0xd29f8980852c2c76fc3f6e96a7aa06e0bedcc1b1" ;
368268
369269 const cm = this . sdk . marketRegister . findCreditManager ( ca . creditManager ) ;
370270 const priceUpdatesCalls = await this . getPriceUpdatesForFacade ( {
@@ -380,20 +280,17 @@ export class CreditAccountServiceV300
380280 throw new Error ( "BaseRewardPool adapter for llamathena is missing" ) ;
381281 }
382282
383- const curvePoolAdapter = cm . creditManager . adapters . get ( LLAMATHENA_POOL ) ;
384- if ( ! curvePoolAdapter ) {
385- throw new Error ( "Curve pool adapter for llamathena is missing" ) ;
386- }
387-
388283 const storeExpectedBalances : MultiCall = {
389284 target : cm . creditFacade . address ,
390285 callData : encodeFunctionData ( {
391286 abi : cm . creditFacade . abi ,
392287 functionName : "storeExpectedBalances" ,
393288 args : [
394289 [
395- { token : preview . scrvusdAddress , amount : preview . scrvusdDelta } ,
396- { token : preview . susdeAddress , amount : preview . susdeDelta } ,
290+ {
291+ token : preview . assets [ 0 ] . token ,
292+ amount : preview . assets [ 0 ] . balance ,
293+ } ,
397294 ] ,
398295 ] ,
399296 } ) ,
@@ -404,16 +301,7 @@ export class CreditAccountServiceV300
404301 callData : encodeFunctionData ( {
405302 abi : iBaseRewardPoolAbi ,
406303 functionName : "withdrawAndUnwrap" ,
407- args : [ preview . llamathena [ 0 ] . balance , false ] ,
408- } ) ,
409- } ;
410-
411- const removeLiquidityCall : MultiCall = {
412- target : curvePoolAdapter . address ,
413- callData : encodeFunctionData ( {
414- abi : iCurveV1_2AssetsAdapterAbi ,
415- functionName : "remove_liquidity" ,
416- args : [ preview . llamathena [ 0 ] . balance , [ 0n , 0n ] ] ,
304+ args : [ preview . stkLlamathena [ 0 ] . balance , false ] ,
417305 } ) ,
418306 } ;
419307
@@ -429,7 +317,6 @@ export class CreditAccountServiceV300
429317 const swapCalls : Array < MultiCall > = [
430318 storeExpectedBalances ,
431319 withdrawAndUnwrapCall ,
432- removeLiquidityCall ,
433320 compareBalances ,
434321 ] ;
435322
0 commit comments