weweswap / contracts

smart contracts
MIT License
1 stars 4 forks source link

ADD: Merge Contracts #2

Closed jpthor closed 3 months ago

jpthor commented 3 months ago

Overview

There is a 30 day period to deposit CHAOS coins. There is a 30 day period to switch and withdraw WEWE coins.

The killswitch allows users to deposit, then withdraw (after Cliff) at 100% conversion (1:1) ratio. Linear, so after 15 days, it's only 50% conversion (1:0.5). After 30 days, 0% conversion (1:0)

Implementation

Owner

Users

Logic

Count the allocate coins when a user deposits in a mapping

mapping availableCoins -> 256 // the original deposit of WEWE
mapping userAllocation address -> uint256 // map the allocated WEWE per user
mapping totalAllocatedCoins -> uint256 // add up the total allocated, each time user deposits
mapping userLastClaimSecondsAgo address -> uint256 // when the user last claimed

When users deposit, the coins will be allocated, as per killswitch. If not all users deposit in time, there will forever be "un-allocated coins".

the difference between (totalAllocatedCoins - availableCoins) is thus the un-allocated coins, that can be "shared" with the users remains in the contract.

Each time a users claims the unallocated coins, the availableCoins should decrement. But, the last time they claimed, should be factored in, so they don't double-claim other's coins.