diff --git a/apps/dapp/src/components/Pages/Ramos/admin/helpers.ts b/apps/dapp/src/components/Pages/Ramos/admin/helpers.ts index 45f42eb82..42ce33de3 100644 --- a/apps/dapp/src/components/Pages/Ramos/admin/helpers.ts +++ b/apps/dapp/src/components/Pages/Ramos/admin/helpers.ts @@ -21,20 +21,20 @@ export const handleBlur = (value: number | '', minValue: number, maxValue: numbe return value; }; -export const formatJoinRequestTuple = (request?: IBalancerVault.JoinPoolRequestStruct): string => { +export const formatJoinRequestTuple = (request?: IBalancerVault.JoinPoolRequestStructOutput): string => { if (request) { return `[[${request.assets.map((asset) => `"${asset}"`).join(',')}],[${request.maxAmountsIn .map((amount) => `"${amount}"`) - .join(',')}],"${request.userData}",false]`; + .join(',')}],"${request.userData}",${request.fromInternalBalance}]`; } return ''; }; -export const formatExitRequestTuple = (request?: IBalancerVault.ExitPoolRequestStruct): string => { +export const formatExitRequestTuple = (request?: IBalancerVault.ExitPoolRequestStructOutput): string => { if (request) { return `[[${request?.assets.map((asset) => `"${asset}"`).join(',')}],[${request?.minAmountsOut .map((amount) => `"${amount}"`) - .join(',')}],"${request?.userData}",false]`; + .join(',')}],"${request.userData}",${request.toInternalBalance}]`; } return ''; }; @@ -84,6 +84,15 @@ export const calculateTargetPriceUp = async ( return currentPrice.add(currentPrice.mul(adjustedBps)); }; +export const decodeUserData = (userData: string) => { + const [joinType,amountsIn,bptOut] = ethers.utils.defaultAbiCoder.decode(['uint256', 'uint256[]', 'uint256'], userData); + return { + joinType, + amountsIn, + bptOut, + } +} + export const makeJoinRequest = (tokens: string[], amountsIn: BigNumber[]): IBalancerVault.JoinPoolRequestStruct => { // 1 === WeightedJoinPoolKind.EXACT_TOKENS_IN_FOR_BPT_OUT // https://dev.balancer.fi/resources/joins-and-exits/pool-joins diff --git a/apps/dapp/src/components/Pages/Ramos/admin/useRamosAdmin.ts b/apps/dapp/src/components/Pages/Ramos/admin/useRamosAdmin.ts index aa1a06d90..38fe8e09e 100644 --- a/apps/dapp/src/components/Pages/Ramos/admin/useRamosAdmin.ts +++ b/apps/dapp/src/components/Pages/Ramos/admin/useRamosAdmin.ts @@ -24,6 +24,7 @@ import { applySlippage, calculateTargetPriceDown, calculateTargetPriceUp, + decodeUserData, formatExitRequestTuple, formatJoinRequestTuple, getBpsPercentageFromTpf, @@ -326,14 +327,10 @@ export function useRamosAdmin() { slippageTolerance * 100 ); const reqDataQuote = proportionalAddLiquidityQuote.requestData; - const tokenAddrs = reqDataQuote.assets; - - const initJoinReq = makeJoinRequest(tokenAddrs, reqDataQuote.maxAmountsIn); - const { amountsIn, bptOut } = await balancerHelpers.queryJoin(poolId, ramos.address, ramos.address, initJoinReq); - const joinPoolRequest = makeJoinRequest(tokenAddrs, amountsIn); + const { bptOut } = decodeUserData(reqDataQuote.userData); return { - joinPoolRequest: formatJoinRequestTuple(joinPoolRequest), - minBptOut: applySlippage(bptOut, slippageTolerance).toString(), + joinPoolRequest: formatJoinRequestTuple(reqDataQuote), + minBptOut: bptOut, }; } }; @@ -345,14 +342,7 @@ export function useRamosAdmin() { slippageTolerance * 100 ); const reqDataQuote = proportionalRemoveLiquidityQuote.requestData; - - const exitRequest = makeExitRequest( - balPooltokensOrdered, - reqDataQuote.minAmountsOut, - exitAmountBpt, - WeightedPoolExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT - ); - return formatExitRequestTuple(exitRequest); + return formatExitRequestTuple(reqDataQuote); }; const createDepositAndStakeRequest = async (bptAmountIn: DecimalBigNumber) => {