Coder Social home page Coder Social logo

stakingpool-v2's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

stakingpool-v2's Issues

A checklist for April 18th launch

  • #7
  • #8
  • Is durationmodifiable? Currently,poolData.endTimestamp = poolData.endTimestamp + poolData.duration;`.
  • migrate
  • Test
    • when the pool is closed, the staking reward should not be extended.

`getTimestamp` does not return the timestmap of the block which includes the tx

Problem

getTimestamp returns the latest block timestamp, rather than the timestamp of the block which includes the input transaction.

it('success', async () => {
    const poolDataBefore = await getPoolData(testEnv);
    const userDataBefore = await getUserData(testEnv, alice);

    const claimTx = await testEnv.stakingPool.connect(alice).claim();
    const claimTx2 =  await testEnv.stakingPool.connect(alice).claim();

    console.log(await getTimestamp(claimTx)); // '0x62c6aeac'
    console.log(await getTimestamp(claimTx2)); // '0x62c6aeac'

Underflow error in StakingPoolV2.getUserReward(alice, 1)

Problem

StakingPoolV2.getUserReward(alice, 1) raises an underflow error after alice migrates all from round 1 to round 2 and totalPrincipal of round 1 goes down to 0.

I added a failing test here: https://github.com/elysia-dev/elyfi-stakingpool-v2/tree/fix/last-migrate-all.

$ yarn hardhat test test/migrate.test.ts

1) StakingPool.migrate
       second round initiated
         success when the last user migrate all:
     Error: VM Exception while processing transaction: reverted with panic code 0x11 (Arithmetic operation underflowed or overflowed outside of an unchecked block)
      at StakingPoolV2.getUserReward (contracts/logic/StakingPoolLogicV2.sol:45)
      at StakingPoolV2.getUserReward (contracts/StakingPoolV2.sol:59)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at runNextTicks (internal/process/task_queues.js:64:3)
      at listOnTimeout (internal/timers.js:526:9)
      at processTimers (internal/timers.js:500:7)
      at HardhatNode.runCall (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:503:20)
      at EthModule._callAction (node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:353:9)
      at HardhatNetworkProvider.request (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:108:18)

Cause

This is because migrate does not update the pool index which the user migrates from, namely round 1 in this case.
https://github.com/elysia-dev/elyfi-stakingpool-v2/blob/5922029b4d719e8aaba90c05b70b8b484fe576c2/contracts/StakingPoolV2.sol#L177

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.