Skip to content
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

Closed
wants to merge 10 commits into from
Closed

Token Staking #4

wants to merge 10 commits into from

Conversation

r-czajkowski
Copy link
Contributor

@r-czajkowski r-czajkowski commented Oct 26, 2023

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.

nkuba and others added 3 commits October 6, 2023 14:44
- 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
@r-czajkowski r-czajkowski requested review from dimpar and nkuba October 26, 2023 16:22
@r-czajkowski r-czajkowski changed the base branch from main to core-init October 26, 2023 16:22
@r-czajkowski r-czajkowski self-assigned this Oct 26, 2023
Copy link
Member

@dimpar dimpar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass.

Copy link
Member

@dimpar dimpar Oct 27, 2023

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:

  1. Do we allow a BTC staker to increase its stake?
  2. Do we allow a BTC staker to decrease its stake?
  3. Set min staking amount. Might be pulled to a different "parameters" contract.
  4. Set max staking amount. Might be pulled to a different "parameters" contract.
  5. 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.
  6. unauthorizeStakingRouter()
  7. A function that disables/pausing moving funds from this staking contract to a anywhere else.
  8. Unstake (covered in a different PR).

}

function _stake(address account, uint256 amount) private {
require(amount > 0, "Amount is less than minimum");
Copy link
Member

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.

Copy link
Contributor Author

@r-czajkowski r-czajkowski Oct 30, 2023

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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about account -> staker?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@r-czajkowski r-czajkowski force-pushed the staking branch 3 times, most recently from 037bd19 to ae6c079 Compare October 30, 2023 09:54
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.
@r-czajkowski
Copy link
Contributor Author

Continued in #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants