Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

chore: Update prop adds handler #1048

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('calculates and sorts proportional human amounts in', () => {
},
{
tokenAddress: daiAddress,
humanAmount: '4.678591808922701187',
humanAmount: '4.678591808922683444',
},
])
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
HumanAmount,
InputAmount,
Slippage,
calculateProportionalAmounts,
} from '@balancer/sdk'
import { Pool } from '../../../PoolProvider'
import { LiquidityActionHelpers } from '../../LiquidityActionHelpers'
Expand Down Expand Up @@ -36,17 +35,11 @@ export class ProportionalAddLiquidityHandler implements AddLiquidityHandler {
public async simulate(
humanAmountsIn: HumanTokenAmountWithAddress[]
): Promise<SdkQueryAddLiquidityOutput> {
// This is an edge-case scenario where the user only enters one humanAmount (that we always move to the first position of the humanAmountsIn array)
const humanAmountIn = this.helpers.toSdkInputAmounts(humanAmountsIn)[0]

const { bptAmount } = calculateProportionalAmounts(
this.helpers.poolStateWithBalances,
humanAmountIn
)
const referenceAmount = this.helpers.toSdkInputAmounts(humanAmountsIn)[0]

const addLiquidity = new AddLiquidity()

const addLiquidityInput = this.constructSdkInput(bptAmount)
const addLiquidityInput = this.constructSdkInput(referenceAmount)
const sdkQueryOutput = await addLiquidity.query(addLiquidityInput, this.helpers.poolState)

return { bptOut: sdkQueryOutput.bptOut, sdkQueryOutput }
Expand Down Expand Up @@ -84,11 +77,11 @@ export class ProportionalAddLiquidityHandler implements AddLiquidityHandler {
/**
* PRIVATE METHODS
*/
private constructSdkInput(bptOut: InputAmount): AddLiquidityProportionalInput {
private constructSdkInput(referenceAmount: InputAmount): AddLiquidityProportionalInput {
return {
chainId: this.helpers.chainId,
rpcUrl: getDefaultRpcUrl(this.helpers.chainId),
bptOut,
referenceAmount,
kind: AddLiquidityKind.Proportional,
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"dependencies": {
"@apollo/client": "3.8.0-rc.1",
"@balancer/sdk": "^0.23.0",
"@balancer/sdk": "^0.25.0",
"@chakra-ui/anatomy": "^2.2.2",
"@chakra-ui/hooks": "^2.2.1",
"@chakra-ui/icons": "^2.1.1",
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading