Skip to content

Commit

Permalink
feat: support min_assets in lp withdrawa
Browse files Browse the repository at this point in the history
  • Loading branch information
jhlee-young committed Jun 19, 2023
1 parent 59f6424 commit f37b65b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/forms/SwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ import { TooltipIcon } from "components/Tooltip"
import Tooltip from "lang/Tooltip.json"
import useGasPrice from "rest/useGasPrice"
import { hasTaxToken } from "helpers/token"
import { Coins, CreateTxOptions, Fee, SignerInfo } from "@terra-money/terra.js"
import {
Coins,
CreateTxOptions,
Fee,
Numeric,
SignerInfo,
} from "@terra-money/terra.js"
import { Type } from "pages/Swap"
import usePool from "rest/usePool"
import { insertIf } from "libs/utils"
Expand Down Expand Up @@ -899,6 +905,19 @@ const SwapForm = ({ type, tabs }: { type: Type; tabs: TabViewProps }) => {
sender: `${walletAddress}`,
amount: `${value1}`,
lpAddr: `${lpContract}`,
minAssets: poolResult?.estimated
.split("-")
.map(
(val, idx) =>
Numeric.parse(val)
.mul(
Numeric.parse(
(1 - Number(slippageTolerance)).toString()
)
)
.toFixed(0) + (idx ? poolContract2 : poolContract1)
)
.join(","),
deadline: Number(txDeadlineMinute),
},
}[type] as any
Expand Down Expand Up @@ -961,6 +980,7 @@ const SwapForm = ({ type, tabs }: { type: Type; tabs: TabViewProps }) => {
generateContractMessages,
to,
lpContract,
poolResult?.estimated,
]
)

Expand Down
1 change: 1 addition & 0 deletions src/rest/useAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ const useAPI = (version: ApiVersion = "v2") => {
lpAddr: string
amount: number | string
sender: string
minAssets?: string
deadline?: number
}
) => {
Expand Down

0 comments on commit f37b65b

Please sign in to comment.