-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Token Staking #4
Conversation
- Added new hh toolbox - Added deployemnt plugin - Added helper scripts - Added linters - Added placeholder dirs for contracts and tests
There are a lot of minor changes to include each in seperate commits. This is a part of the overall project structure. Changes include: - established pattern for the deployment scripts and testing files - cleanup in the package.json and hardhat.config.js - cleanup in prettier, eslint, slither and mocha config files - cleanup in gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more of a high level functionality that I think we need to decide upon:
- Do we allow a BTC staker to increase its stake?
- Do we allow a BTC staker to decrease its stake?
- Set min staking amount. Might be pulled to a different "parameters" contract.
- Set max staking amount. Might be pulled to a different "parameters" contract.
- We might consider adding a
address StakingRouter
+authorizeStakingRouter(address) by multisig
and wrap it with a modifier which verifies if a caller that request for funds to a Strategy is a indeed a StakingRouter. unauthorizeStakingRouter()
- A function that disables/pausing moving funds from this staking contract to a anywhere else.
- Unstake (covered in a different PR).
} | ||
|
||
function _stake(address account, uint256 amount) private { | ||
require(amount > 0, "Amount is less than minimum"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably set min and max amounts vars and use it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_stake(msg.sender, amount); | ||
} | ||
|
||
function _stake(address account, uint256 amount) private { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about account
-> staker
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
037bd19
to
ae6c079
Compare
A token staking contract for a specified standard ERC20 token. A holder of the specified token can stake its tokens to this contract and recover the stake after undelegation period is over.
Use ERC20 contracts and libraries to interact with staking token in staking contract.
Add function that stakes owner's tokens in the staking contract - tracks user's staked funds and emit `Staked` event. The minimum amount is required.
Add support for `approveAndCall`/`receiveApproval` pattern. The tBTC token contract that will be a staking token supports this pattern. To be able to stake in one transaction (instead of 2: approve + stake) we must implement the `RecieveApproval` interface. The token staking contract receives approval to spend tokens and create a stake for a given account.
Add min and max staking amount. Currently, functions that return these values have hardcoded values, but in the future we want to pull this param from "parameters" contract that stores governable params.
`account` -> `staker`
We should mint staking token eg. `stBTC` that represents staked token staked with Litmus. It will probably be a rebaseable ERC-20 token.
Continued in #11 |
Depends on: #1
Ref: #2
This PR creates the Token Staking contract - a contract for a specified standard ERC20 token. A holder of the specified token can stake its tokens to this contract and recover the stake after undelegation period is over. This contract also supports
approveAndCall
/receiveApproval
pattern so users can stake in one transaction (instead of 2:Token.approve
+TokenStaking.stake
). The initial implementation of staking tracks the staked balance and transfers the staked amount to the staking contract.