Skip to content

Commit

Permalink
pass liquidity detla to burn handler
Browse files Browse the repository at this point in the history
  • Loading branch information
p6te committed Aug 22, 2024
1 parent 85cfbba commit f6ffb69
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
9 changes: 5 additions & 4 deletions frontend/src/containers/LiquidityWrapper/LiquidityWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,14 @@ export const LiquidityWrapper: React.FC<IProps> = ({
removeLiquidityHandler={() => {
if (tokenAIndex !== null && tokenBIndex !== null) {
dispatch(
poolsActions.burn(
new Pair(
poolsActions.burn({
pair: new Pair(
tokens[tokenAIndex].address,
tokens[tokenBIndex].address,
FEE_TIERS[feeIndex]
)
)
),
liquidityDelta: new BN(10000)
})
)
}
}}
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/store/reducers/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ export interface MintData {
lpPoolExists: boolean
}

export interface BurnData {
pair: Pair
liquidityDelta: BN
}

export const poolsSliceName = 'pools'
const poolsSlice = createSlice({
name: poolsSliceName,
Expand Down Expand Up @@ -152,7 +157,7 @@ const poolsSlice = createSlice({
mint(state, _action: PayloadAction<MintData>) {
return state
},
burn(state, _action: PayloadAction<Pair>) {
burn(state, _action: PayloadAction<BurnData>) {
return state
}
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/store/sagas/pools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { actions, MintData, PairTokens, PoolWithAddress } from '@store/reducers/pools'
import { actions, BurnData, MintData, PairTokens, PoolWithAddress } from '@store/reducers/pools'
import { network, rpcAddress } from '@store/selectors/connection'
import { all, call, put, select, spawn, takeLatest } from 'typed-redux-saga'
import { PayloadAction } from '@reduxjs/toolkit'
Expand Down Expand Up @@ -189,7 +189,7 @@ export function* handleMint(action: PayloadAction<MintData>) {
yield* call([connection, connection.confirmTransaction], confirmStrategy)
}

export function* handleBurn(action: PayloadAction<Pair>) {
export function* handleBurn(action: PayloadAction<BurnData>) {
const loaderHandleBurn = createLoaderKey()
const loaderSigningTx = createLoaderKey()

Expand All @@ -203,7 +203,7 @@ export function* handleBurn(action: PayloadAction<Pair>) {
})
)

const pair = action.payload
const { liquidityDelta, pair } = action.payload

const networkType = yield* select(network)
const rpc = yield* select(rpcAddress)
Expand Down Expand Up @@ -248,7 +248,7 @@ export function* handleBurn(action: PayloadAction<Pair>) {
const burnIx = yield* call([protocolProgram, protocolProgram.burnLpTokenIx], {
pair,
index: 0,
liquidityDelta: new BN(10000),
liquidityDelta,
invProgram: marketProgram.program.programId,
invState: stateAddress,
position: positionAddress,
Expand Down

0 comments on commit f6ffb69

Please sign in to comment.