Skip to content

Commit

Permalink
Add liquidity slippage and IBC max button (#133) (#134)
Browse files Browse the repository at this point in the history
* add 1% slippage to add liquidity

* fix typo

* subtract fee from max IBC
  • Loading branch information
ben2x4 authored Jan 14, 2022
1 parent 422a196 commit 20c5919
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const WalletCardWithInput = ({
walletAddress = 'No address found',
}: WalletCardWithInputProps) => {
const tokenInfo = useIBCAssetInfo(tokenSymbol)
// TODO: Configure max fee per chain
const maxFee = 0.05
return (
<CardWithSeparator
contents={[
Expand Down Expand Up @@ -58,7 +60,7 @@ export const WalletCardWithInput = ({
<TokenAmountInput
amount={value}
onAmountChange={onChange}
maxAmount={maxValue}
maxAmount={Math.max(maxValue - maxFee, 0)}
tokenSymbol={tokenInfo.symbol}
/>
</>,
Expand Down
2 changes: 1 addition & 1 deletion features/assets/components/TransferDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const TransferDialog = ({
<StyledContent>
<Text variant="header">{capitalizedTransactionType}</Text>
<Text css={{ paddingTop: '$12', paddingBottom: '$9' }} variant="body">
How many {tokenInfo.name} would you like to {transactionKind}?
How much {tokenInfo.name} would you like to {transactionKind}?
</Text>
<StyledDivForCards>
{transactionKind === 'deposit' && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export const usePoolDialogController = ({
})

function calculateMaxApplicableBalances() {
const tokenAToTokenBRatio = reserve?.[0] / reserve?.[1]
// TODO: Make slippage configurable
const slippage = 0.99
const tokenAToTokenBRatio = (reserve?.[0] * slippage) / reserve?.[1]
const tokenABalanceMinusGasFee = Math.max(tokenABalance - 0.1, 0)

const isTokenALimitingFactor =
Expand Down

0 comments on commit 20c5919

Please sign in to comment.