elysia-dev / stakingpool-v2 Goto Github PK
View Code? Open in Web Editor NEWElyfi stakingpool
Elyfi stakingpool
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'
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)
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.