thxprotocol / modules-solidity

Default Asset Pools are connected to an ERC20 contract. The pool is controlled by a permissioned (OAuth2.0) REST API which is responsible for paying the gas costs used to manage the pool. Access to the pool is managed with a flexible role-based access mechanism. Pools can hold various reward configurations for the connected ERC20 tokent contract and will manage the distribution of those token rewards with a withdrawal system. The poll system used to govern the reward configuration and withdrawals is optional.
4 stars 3 forks source link

Research TimeLocked token distribution #31

Closed peterpolman closed 2 years ago

peterpolman commented 2 years ago

Clients let us know that they would not necessarily want beneficiaries of token rewards to be able to start transferring tokens right away

Maybe Timelocked Wallets could help out with setting up a feature that disallows beneficiaries to transfer tokens after receiving them.

peterpolman commented 2 years ago

Example implementation of timelocked wallets: https://github.com/thxprotocol/thx/pull/2

@valeriagrazzini Maybe you want to come up with an approach first and then discuss it before the implementation? Happy to jump on a call and discuss it a bit.

valeriagrazzini commented 2 years ago

Here are some basic timelock wallet contract examples, we could start with something simple and then add more features if is required.

https://github.com/jklepatch/eattheblocks/blob/master/screencast/354-timelock-contract/contracts/Timelock.sol https://github.com/radek1st/time-locked-wallets/blob/master/contracts/TimeLockedWallet.sol

Question: will the contract accept any kind of erc20 token of only one specific token address?

Also, another options different from the timelock wallet could be a timelock token with an override of the transfers function but I think it is not very transparent to the customer

peterpolman commented 2 years ago

Looking at the logic in those contracts I'm seeing a lot of overlap with our existing withdraw modules. Maybe this feature should be simplified to passing an unlockDate parameter in the proposeWithdraw() method and pass it to the _createWithdrawPoll() method over here: https://github.com/thxprotocol/modules-solidity/blob/main/contracts/05-Withdraw/Withdraw.sol#L38-L46 https://github.com/thxprotocol/modules-solidity/blob/main/contracts/05-Withdraw/Withdraw.sol#L79-L107

With that we can store the unlockDate in the withdrawPoll storage library and require now > unlockDate when withdrawPollFinalize() is called by the beneficiary of the withdrawal over here: https://github.com/thxprotocol/modules-solidity/blob/main/contracts/05-Withdraw/WithdrawPoll.sol#L129

That should timelock withdrawals in a similar manner while introducing less code.

valeriagrazzini commented 2 years ago

@peterpolman I have created a branch but I don't have push permissions I guess

peterpolman commented 2 years ago

@valeriagrazzini Should be good now!

peterpolman commented 2 years ago

@valeriagrazzini

  1. You can also run a (or multiple) local hardhat node(s) with npx hardhat node and specify its RPC in the API projects .env. 2. You can deploy the contracts on the node with sh scripts/deploy-export.sh
  2. For local usage of this package version you could use npm pack (see docs on how to reference it from package.json in the api project)