Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 }
}
export const getTimingApproximations = ({ auctionStart, status, now }: TimingApprox) => {
if (status === Status.ENDED || status === Status.INACTIVE) return null
now = now * 1000
// auction is in 10 min waiting period
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',
const mapStateToProps = ({ tokenPair: { sell, buy } }: State) => ({
sellToken: sell,
buyToken: buy,
// TODO: get buyAmount based on what can be claimed, i.e. at the end of auction
buyAmount: toBigNumber(2.5520300),
// TODO: make sure time and status are populated in the store by DutchX
timeLeft: 73414,
status: Status.INIT,
})
price: priceNormal,
sellVolume: sellVolumesCurrentDir,
buyVolume: buyVolumesDir,
auctionIndex: lastIndex,
})
const outstandingVolumeInverse = await getOutstandingVolume(pair, {
price: priceInverse,
sellVolume: sellVolumesCurrentOpp,
buyVolume: buyVolumesOpp,
auctionIndex: lastIndex,
})
const statusDir: StatusOppDir = { status: AuctionStatus.ACTIVE }
const statusOpp: StatusOppDir = { status: AuctionStatus.ACTIVE }
if (auctionStart.eq(1)) statusDir.status = statusOpp.status = AuctionStatus.INIT
else {
// outstandingVolume <= 0 === THEORETICALLY CLOSED
// TODO: ask why num here and not den
if (closingPriceDir[0].equals(0) && outstandingVolumeNormal.eq(0)) {
statusDir.status = AuctionStatus.ENDED
statusDir.theoreticallyClosed = true
}
if (closingPriceOpp[0].equals(0) && outstandingVolumeInverse.eq(0)) {
statusOpp.status = AuctionStatus.ENDED
statusOpp.theoreticallyClosed = true
}
}
return {
lastIndex,
closingPrices: {
const mapStateToProps = () => ({
// TODO: populate AuctionStatus in store by querying DutchX regularly or listening for Events
progress: getAuctionProgress(Status.INIT),
})
// const getTimeStr = (timestamp: number) => {
// const date = new Date(timestamp)
// const hh = date.getUTCHours()
// const mm = date.getUTCMinutes()
// const ss = date.getUTCSeconds()
// return `${hh ? `${hh} hour(s) ` : ''}${mm ? `${mm} minute(s) ` : ''}${ss ? `${ss} second(s) ` : ''}`
// }
const statusText: { [T in Status]: string } = {
[Status.ACTIVE]: 'Ongoing',
[Status.ENDED]: 'Ended',
// WHAT should Status.INACTIVE be?
[Status.INACTIVE]: 'Inactive ',
[Status.INIT]: 'Not Started',
[Status.PLANNED]: 'Not Started',
}
const translateStatus2Text = (str: string) => statusText[str] || str
const ShowStatus: React.SFC {} }> = ({
// timeLeft,
sellAmount,
buyAmount,
buyToken,
status,
claimTokens,
isClaiming,
}) => {
switch (status) {
case Status.ENDED:
(auction, i) => {
return (
{auction.current && auction.current.dirRunning && auction.current.participatesNormal && (
push(`/auction/${auction.sell.symbol}-${auction.buy.symbol}-${auction.current.index}`)}
>
{auction.sell.symbol}/{auction.buy.symbol}
{auction.current.statusDir.status === AuctionStatus.INIT ? 'NOT STARTED' : 'ONGOING'}
<p>{auction.current.balanceNormal.toString()} {auction.sell.symbol}</p>
claim {getTimingApproximations({
auctionStart: auction.auctionStart,
now: auction.now,
status: auction.current.statusDir.status,
}).claim}
)}
{auction.next && auction.next.participatesNormal && (
push(`/auction/${auction.sell.symbol}-${auction.buy.symbol}-${auction.next.index}`)}
>
(claimAndWithdrawSellerFundsFromSeveral(auction.sell, auction.buy))}>
{auction.past.claimableBalanceNormal} {auction.buy.symbol} <img src="{require('assets/claim.svg')}">
}
)}
{auction.current && auction.current.oppRunning && auction.current.participatesInverse && (
push(`/auction/${auction.buy.symbol}-${auction.sell.symbol}-${auction.current.index}`)}
>
{auction.buy.symbol}/{auction.sell.symbol}
{auction.current.statusOpp.status === AuctionStatus.INIT ? 'NOT STARTED' : 'ONGOING'}
<p>{auction.current.balanceInverse.toString()} {auction.buy.symbol}</p>
claim {getTimingApproximations({
auctionStart: auction.auctionStart,
now: auction.now,
status: auction.current.statusOpp.status,
}).claim}
)}
{auction.next && auction.next.participatesInverse && (
push(`/auction/${auction.buy.symbol}-${auction.sell.symbol}-${auction.next.index}`)}
>