-
Notifications
You must be signed in to change notification settings - Fork 134
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
Dao uses Stakeable token #93
Conversation
2f7d04b
to
5886efd
Compare
How do I provide tokens to be claimed? I see the ability to query claims, but I don't see where they're set... Also, this needs a quick rebase. : ) |
My bad, I misunderstood this. Claims not rewards, its just for unbonded tokens... was thinking of how to provide rewards for staking gov tokens. Still needs rebase. : ) |
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 cool :) Nice to see how much code was removed.
@@ -40,74 +51,57 @@ pub fn execute( | |||
) -> Result<Response<Empty>, ContractError> { | |||
match msg { | |||
ExecuteMsg::Transfer { recipient, amount } => { | |||
cw20_base::contract::execute_transfer(deps, _env, info, recipient, amount) | |||
.map_err(ContractError::Cw20Error) | |||
execute_transfer(deps, _env, info, recipient, amount).map_err(ContractError::Cw20Error) |
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.
Because we use it _env
should probably be renamed to env
.
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.
Done!
contracts/cw3-dao/src/helpers.rs
Outdated
}); | ||
Ok(balance.balance) | ||
); | ||
let balance = res.map(|r| r.balance).unwrap_or_else(|_| Uint128::zero()); |
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.
Is it the case that for all types of StdError
we still want to return a balance of zero? Why not propagate the error up?
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 a great catch. The contract we are querying already handles the case that there is not data for the address and returns 0 balance as appropriate. Changed the code to propagate the error up.
@@ -53,6 +56,13 @@ pub enum ExecuteMsg { | |||
marketing: Option<String>, | |||
}, | |||
UploadLogo(Logo), | |||
Stake { |
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.
Could we add some doc comments to these?
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.
Done!
Please bump package versions. 🙏 Otherwise, LGTM. |
adfa87d
to
c4a6009
Compare
c4a6009
to
f66bd96
Compare
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 PR implements the stakeable token into the DAO. The basic architectures is as follows
CW20-Stakeable
This is a extension of cw20-base that lets the token be staked and staked balances to be queried at any arbitrary height. The contract can set an unbonding period which behaves like native cosmos sdk unbonding. The users pick an amount to unbond and then must wait the unbonding period to be able to claim the asset. While staked, assets are non-transferable.
CW20-Gov
This is an extension of CW20-Stakeable that add voting power delegation features. Staked tokens count towards voting power and stakers can delegate their voting power to an address of their choosing. Like the previous implementation, delegation is all or nothing, ie the user can designate one address to vote with all their voting power with no ability to make partial delegations.
CW-DAO
This contract uses the new CW20-Gov. This means memebers of the DAO must stake their tokens in order to be able to vote. This required updating some of the balance queries, tests, and gov token instantiation messages.
Advantages
The main advantage of this approach is enabling efficient distribution of assets to DAO stakers and quorem calculations. All tokens trading in the market will have some portion of supply locked in various defi protocols such as swaps or lending platforms. These contracts most likely will not be able to receive distributions and thus a portion of all assets distributed would in effect be burned. Under the staking method. users and contracts most actively stake their tokens in the DAO in order to be eligible for these distributions. Quorem will also be much easier to calculate as it is much safer to make the assumption that stakers are physically capable of voting on proposals. DAOs that want to make it easy to transfer assets can choose to have no unbonding period so unbonded assets instantly available for transfer.
Open Questions
Deposits are a little tricky with the new implementation. Deposits must be made with unstaked assets. I think this is a fine solution and I believe a fix for this may make the cw20-gov and cw-dao contracts too interdependent. Though curious to hear thoughts.