How to use the globals.AuctionStatus.ACTIVE function in globals

To help you get started, we’ve selected a few globals examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gnosis / dx-react / src / components / AuctionStateHOC / index.tsx View on Github external
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 }
}
github gnosis / dx-react / src / utils / timings.ts View on Github external
//     The auction will start in approx 6h:45min and run for approx. 6 hours
    //     <br>
    //     <br>
    //     {userParticipates &amp;&amp; `You may claim your ${bToken} in approx. 12h:45min`}
    //   <p></p>
    // )
  }

  const auctionStartMs = auctionStart.mul(1000)

  // auctionStart time is always in the past for Status.ACTIVE auctions
  // except for whenthe auction only starts and
  // auctionStart is set 10min in the future (WAITING_PERIOD)

  // index corresponds to an active auction
  if (status === Status.ACTIVE) {
    if (auctionStartMs.lt(now)) {
      const timeSinceStart = now - auctionStartMs.toNumber()
      const { h: hoursSinceStart } = getHhMm(timeSinceStart)

      if (hoursSinceStart &gt; 6) {
        const willEnd = 'soon'
        return { willEnd, claim: willEnd }
      }
      // Produces in AuctionStatus(
      //   <p>This auction will end soon</p>
      // )

      const timeTillEnd = AUCTION_RUN_TIME - timeSinceStart
      const willEnd = `in approx ${formatHours(getHhMm(timeTillEnd))}`

      return { willEnd, claim: willEnd }
github gnosis / dx-react / src / api / index.ts View on Github external
])

  const outstandingVolumeNormal = await getOutstandingVolume(pair, {
    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 &lt;= 0 === THEORETICALLY CLOSED
    // TODO: ask why num here and not den
    if (closingPriceDir[0].equals(0) &amp;&amp; outstandingVolumeNormal.eq(0)) {
      statusDir.status = AuctionStatus.ENDED
      statusDir.theoreticallyClosed = true
    }
    if (closingPriceOpp[0].equals(0) &amp;&amp; outstandingVolumeInverse.eq(0)) {
      statusOpp.status = AuctionStatus.ENDED
      statusOpp.theoreticallyClosed = true
    }
  }
github gnosis / dx-react / src / containers / AuctionProgress / index.ts View on Github external
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)
github gnosis / dx-react / src / api / index.ts View on Github external
const outstandingVolumeNormal = await getOutstandingVolume(pair, {
    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 &lt;= 0 === THEORETICALLY CLOSED
    // TODO: ask why num here and not den
    if (closingPriceDir[0].equals(0) &amp;&amp; outstandingVolumeNormal.eq(0)) {
      statusDir.status = AuctionStatus.ENDED
      statusDir.theoreticallyClosed = true
    }
    if (closingPriceOpp[0].equals(0) &amp;&amp; outstandingVolumeInverse.eq(0)) {
      statusOpp.status = AuctionStatus.ENDED
      statusOpp.theoreticallyClosed = true
    }
  }

  return {
github gnosis / dx-react / src / components / AuctionStatus / index.tsx View on Github external
completed: boolean,
  theoreticallyCompleted: boolean,
  claimSellerFunds: () =&gt; any,
}

// const getTimeStr = (timestamp: number) =&gt; {
//   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) =&gt; statusText[str] || str

const ShowStatus: React.SFC {} }&gt; = ({
  // timeLeft,
  sellAmount,
  buyAmount,
  buyToken,
  status,
  claimTokens,
github gnosis / dx-react / src / components / AuctionPanel / index.tsx View on Github external
buyToken={buy}
            sellAmount={userSelling}
            buyAmount={userCanClaim}
            auctionStart={auctionStart}
            timeLeft={timeToCompletion}
            now={now}
            status={status}
            completed={completed}
            theoreticallyCompleted={theoreticallyCompleted}
            claimSellerFunds={claimSellerFunds}
          /&gt;
          
          
        
      } /&gt;
github gnosis / dx-react / src / components / AuctionStateHOC / index.tsx View on Github external
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
}
github gnosis / dx-react / src / components / AuctionFooter / index.tsx View on Github external
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>
          <big>Take part in the {status === Status.ACTIVE ? 'next' : ''} auction</big>
        </span>
      </div>
    )
  }

  if (status === Status.ENDED &amp;&amp; sellAmount.gt(0)) { return (
    <div>
      <span>
        <small>AMOUNT SOLD</small>
        <big>{sellAmount.div(10 ** sellDecimal).toString()} {sellTokenSymbol}</big>
      </span>
    </div>
  )
  }