Skip to content

Commit

Permalink
Attempt to fix burn
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHartnell committed Nov 9, 2023
1 parent ed1d9f6 commit 8b0aea4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
21 changes: 11 additions & 10 deletions contracts/external/cw-abc/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::{
coins, ensure, to_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal as StdDecimal, DepsMut, Env,
MessageInfo, QuerierWrapper, Response, StdError, StdResult, Storage, Uint128, WasmMsg,
ensure, to_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal as StdDecimal, DepsMut, Env,
MessageInfo, QuerierWrapper, Response, StdError, StdResult, Storage, SubMsg, Uint128, WasmMsg,
};
use cw_tokenfactory_issuer::msg::ExecuteMsg as IssuerExecuteMsg;
use cw_utils::must_pay;
Expand Down Expand Up @@ -120,8 +120,6 @@ pub fn execute_sell(
info: MessageInfo,
curve_fn: CurveFn,
) -> CwAbcResult {
let burner = info.sender.clone();

let supply_denom = SUPPLY_DENOM.load(deps.storage)?;
let burn_amount = must_pay(&info, &supply_denom)?;

Expand Down Expand Up @@ -172,16 +170,19 @@ pub fn execute_sell(
.map_err(StdError::overflow)?;

// Now send the tokens to the sender
let msg_send = BankMsg::Send {
to_address: burner.to_string(),
amount: coins(released_reserve.u128(), curve_state.reserve_denom),
};
let msg_send = SubMsg::new(CosmosMsg::Bank(BankMsg::Send {
to_address: info.sender.to_string(),
amount: vec![Coin {
amount: released_reserve,
denom: curve_state.reserve_denom,
}],
}));

Ok(Response::<TokenFactoryMsg>::new()
.add_message(msg_send)
.add_messages(burn_msgs)
.add_submessage(msg_send)
.add_attribute("action", "burn")
.add_attribute("from", burner)
.add_attribute("from", info.sender)
.add_attribute("amount", burn_amount)
.add_attribute("burned", released_reserve)
.add_attribute("funded", taxed_amount))
Expand Down
11 changes: 10 additions & 1 deletion contracts/external/cw-abc/src/test_tube/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,17 @@ fn test_happy_path() {
let phase: CommonsPhaseConfigResponse = abc.query(&QueryMsg::PhaseConfig {}).unwrap();
println!("Phase {:?}", phase);

// Contract balances
let balances = env.bank().query_all_balances(
&osmosis_test_tube::osmosis_std::types::cosmos::bank::v1beta1::QueryAllBalancesRequest {
address: abc.contract_addr.to_string(),
pagination: None,
},
).unwrap();
println!("{:?}", balances);

// Burn
abc.execute(&ExecuteMsg::Burn {}, &coins(900000, denom), &accounts[0])
abc.execute(&ExecuteMsg::Burn {}, &coins(10000, denom), &accounts[0])
.unwrap();

let curve_info: CurveInfoResponse = abc.query(&QueryMsg::CurveInfo {}).unwrap();
Expand Down

0 comments on commit 8b0aea4

Please sign in to comment.