Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
index,
currentAuctionIndex,
auctionStart,
price,
outstandingVolume,
}: AuctionStatusArgs) => {
console.log('closingPrice: ', closingPrice.map(n => n.toNumber()))
console.log('index: ', index)
console.log('currentAuctionIndex: ', currentAuctionIndex.toNumber())
console.log('auctionStart: ', auctionStart.toNumber())
console.log('price: ', price.map(n => n.toNumber()))
if (closingPrice[1].gt(0) || currentAuctionIndex.gt(index)) return { status: AuctionStatus.ENDED }
// this should show theoretically auctions as ENDED and allow to claim,
// which internally closes the auction with a 0 buy order
// TODO: consider if (currentAuctionIndex < index && auction has sell volume) return AuctionStatus.PLANNED
if (currentAuctionIndex.lt(index)) return { status: AuctionStatus.PLANNED }
if (auctionStart.equals(1)) return { status: AuctionStatus.INIT }
if (currentAuctionIndex.equals(index) && closingPrice[0].equals(0) && outstandingVolume.eq(0)) {
console.log('Theoretically closed')
return { status: AuctionStatus.ENDED, theoretically: true }
}
if (!price[1].equals(0)) return { status: AuctionStatus.ACTIVE }
return { status: AuctionStatus.INACTIVE }
}
const AuctionFooter: React.SFC = ({
// auctionEnded,
sellTokenSymbol,
// buyTokenSymbol,
sellAmount,
// buyAmount,
sellDecimal,
// buyDecimal,
status,
}) => {
if (status === Status.PLANNED || status === Status.INIT || status === Status.ACTIVE) {
if (sellAmount.gt(0)) { return (
<div>
<span>
<small>AMOUNT DEPOSITED</small>
<big>{sellAmount.div(10 ** sellDecimal).toString()} {sellTokenSymbol}</big>
</span>
</div>
)
}
return (
<div>
<span>
<small>
{status === Status.ACTIVE ? 'You are not taking part in this auction' : 'You have no deposit in this auction'}
</small></span></div>
import { connect } from 'react-redux'
import AuctionProgress from 'components/AuctionProgress'
// import { State } from 'types'
import { AuctionStatus as Status } from 'globals'
const status2progress = {
[Status.INIT]: 1,
[Status.PLANNED]: 2,
[Status.ACTIVE]: 3,
[Status.ENDED]: 4,
}
const getAuctionProgress = (status: Status) => status2progress[status] || 0
const mapStateToProps = () => ({
// TODO: populate AuctionStatus in store by querying DutchX regularly or listening for Events
progress: getAuctionProgress(Status.INIT),
})
export default connect(mapStateToProps)(AuctionProgress)
<big>No funds to claim</big>
)
}
return (
<span>
<button disabled="{isClaiming" id="claimToken">
<i>CLAIM</i>
<strong>{(buyAmount.div(10 ** buyToken.decimals)).toFixed()} {buyToken.symbol || buyToken.name || buyToken.address}</strong>
<span><img src="{claim}"></span>
</button>
</span>
)
case Status.ACTIVE:
case Status.PLANNED:
case Status.INIT:
// no deposit -- no button
if (sellAmount.eq(0)) return null
return (
<>
<span>
<button disabled="" id="claimToken">
<i>CLAIM</i>
<strong>{buyToken.symbol || buyToken.name || buyToken.address}</strong>
<span><img src="{claim}"></span>
</button>
</span>
)
default:
return null
participatesInverse: balanceInverse.gt(0),
claimableNormal: currAuctionEndedDir && balanceNormal.gt(0),
claimableInverse: currAuctionEndedOpp && balanceInverse.gt(0),
claimableBalanceNormal: currentClaimableBalanceNormal.div(10 ** decimalsBuy).toFixed(FIXED_DECIMALS),
claimableBalanceInverse: currentClaimableBalanceInverse.div(10 ** decimalsSell).toFixed(FIXED_DECIMALS),
statusDir,
statusOpp,
}
const next = {
index: lastIndex.add(1).toString(),
balanceNormal: balanceNext.normal.div(10 ** decimalsSell).toFixed(FIXED_DECIMALS),
balanceInverse: balanceNext.inverse.div(10 ** decimalsBuy).toFixed(FIXED_DECIMALS),
participatesNormal: balanceNext.normal.gt(0),
participatesInverse: balanceNext.inverse.gt(0),
status: { status: AuctionStatus.PLANNED },
}
let latestIndicesNormal: BigNumber[] = indicesWithSellerBalance,
latestIndicesReverse: BigNumber[] = indicesWithSellerBalanceInverse
if (committedToNextNormal && currAuctionNeverRanDir) {
// if (currAuctionNeverRanDir)
latestIndicesNormal = [...indicesWithSellerBalance, lastIndex.add(1)]
balancePerIndex.push(balanceNext.normal)
}
if (committedToNextInverse && currAuctionNeverRanOpp) {
latestIndicesReverse = [...indicesWithSellerBalanceInverse, lastIndex.add(1)]
balancePerIndexInverse.push(balanceNext.inverse)
}
ongoingAuction = {
if (auctionStart.eq(1)) {
if (status === Status.INIT) { return {
willStart: 'soon',
runFor: 'approx. 6h',
claim: 'in approx. 6h',
}}
// Produces in AuctionStatus(
// <p>
// The auction will start soon and run for approx. 6 hours
// <br>
// <br>
// {userParticipates && `You may claim your ${bToken} in approx. 6 hours`}
// </p>
// )
if (status === Status.PLANNED) { return {
willStart: 'in approx 6h:45min',
runFor: 'approx. 6h',
claim: 'in approx. 12h:45min',
}}
// Produces in AuctionStatus(
// <p>
// The auction will start in approx 6h:45min and run for approx. 6 hours
// <br>
// <br>
// {userParticipates && `You may claim your ${bToken} in approx. 12h:45min`}
// </p>
// )
}
const auctionStartMs = auctionStart.mul(1000)
const getProgressStep = ({ status, sellerBalance }: ProgressStepArgs) => {
if (sellerBalance.lte(0) || status === AuctionStatus.INACTIVE) return 0
if (status === AuctionStatus.INIT || status === AuctionStatus.PLANNED) return 1
if (status === AuctionStatus.ACTIVE) return 2
if (status === AuctionStatus.ENDED) return 3
return 0
}