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

MP-2547 burn contract #434

Open
wants to merge 5 commits into
base: mp-2425_burn_fee_collector_rewards
Choose a base branch
from

Conversation

dancreee
Copy link
Contributor

@dancreee dancreee commented Aug 30, 2024

Contract to be deployed on Neutron for burning the token.

I've added some state/queries so for now we can easily keep track of total burn amounts.

Originally I was going to just use this contract from Osmosis to do the native burn, but I think it makes sense to also route the burns from Neutron through this contract so we have 1 central place that does the accounting for the total burn amounts.

Eventually when a mature indexing solution is in place to account for the burns and show historical data we could simplify the contract removing the state/queries

@dancreee dancreee changed the title burn contract MP-2547 burn contract Sep 2, 2024
Copy link
Contributor

@piobab piobab left a comment

Choose a reason for hiding this comment

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

LGTM. Left some comments

@@ -0,0 +1,30 @@
[package]
name = "mars-burn-contract"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove the suffix? Maybe mars-burner?

backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please fix aligment? One space from biggest horizontal name

thiserror = { workspace = true }

[dev-dependencies]
cw-multi-test = { workspace = true }
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::GetBurntAmount {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe without Get prefix

let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize;
let start = start_after.map(|denom| Bound::ExclusiveRaw(denom.into_bytes()));

let burnt_amounts: StdResult<Vec<BurntAmountResponse>> = BURNT_AMOUNTS
Copy link
Contributor

Choose a reason for hiding this comment

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

use mars_types::burn::{BurntAmountResponse, ExecuteMsg, QueryMsg};

#[test]
fn burn_funds() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have multitest way of test to double check burned amount in the contract but this type of test should be fine as well.

Copy link
Contributor

@markonmars markonmars left a comment

Choose a reason for hiding this comment

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

LGTM! Left a couple minor comments for consideration, but no strong opinion so feel free to disregard.


pub fn execute_burn_funds(deps: DepsMut, env: Env, denom: String) -> ContractResult<Response> {
let contract_address = env.contract.address;
let balance = deps.querier.query_balance(contract_address, denom.clone())?;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should check that no other funds were mistakenly sent with the msg?

For instance if I send [100uosmo, 100uatom] and pass uosmo as a denom, I will lose the uatom right?

Might be an over optimisation given that this is a burn address so you should expect to lose funds you send to it, but could prevent accidental mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Another nit: I think in general using must_pay is probably best practice here but I don't actually see any issue with the way it is implemented. It might actually be desirable that we just burn the balance of the contract for that denom

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't necessarily want to tie into the same tx a bank send with a wasm burn always, imo keep it flexible so you can do these separately (e.g. if there is an issue with IBC hooks, we can separate out the IBC send with the wasm execute to burn)

We could be more defensive here and set a burn denom and reject any other denom sent to the contract, although imo this contract could be useful for others so I think it could be an over-optimisation in this case, but i'm pretty 50:50 on that so could be swayed

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