Skip to content

Commit

Permalink
Correct close market modal threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
WRadoslaw committed Mar 27, 2024
1 parent d49e4a3 commit 4ab02dd
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type CloseMarketModalProps = {
// Assuming x - supply of tokens beside AMM, y - AMM tokens supply (minted - burned) and at the same time the threshold
// we get following formula (for this scenario it's enough if it just equals)
// 1% * (x + y) = y --> x / 99 = y
const TRESHOLD_RATIO = 99
const TRESHOLD_RATIO = 100

export const CloseMarketModal = ({ onClose, show, channelId, tokenId }: CloseMarketModalProps) => {
const { memberId } = useUser()
Expand All @@ -50,9 +50,12 @@ export const CloseMarketModal = ({ onClose, show, channelId, tokenId }: CloseMar
const ammBalance = data?.creatorTokenById?.currentAmmSale
? +data.creatorTokenById.currentAmmSale.mintedByAmm - +data.creatorTokenById.currentAmmSale.burnedByAmm
: 0
const thresholdAmount = data?.creatorTokenById
? Math.floor((+data.creatorTokenById.totalSupply - ammBalance) / TRESHOLD_RATIO)
: 0
const thresholdAmount =
TRESHOLD_RATIO < 100
? data?.creatorTokenById
? Math.floor((+data.creatorTokenById.totalSupply - ammBalance) / TRESHOLD_RATIO)
: 0
: 0
const hasSufficientTokens = tokenBalance >= ammBalance - thresholdAmount
const amountToSell = Math.max(0, Math.floor(ammBalance - thresholdAmount))

Expand Down

0 comments on commit 4ab02dd

Please sign in to comment.