diff --git a/Cargo.lock b/Cargo.lock index 2280a9f7c..859dd090c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3791,6 +3791,7 @@ dependencies = [ "cw721 0.18.0", "cw721-base 0.18.0", "schemars", + "semver", "serde", "sg-metadata", "sg-std", diff --git a/contracts/collections/sg721-metadata-onchain/Cargo.toml b/contracts/collections/sg721-metadata-onchain/Cargo.toml index 6a1f51856..b55165039 100644 --- a/contracts/collections/sg721-metadata-onchain/Cargo.toml +++ b/contracts/collections/sg721-metadata-onchain/Cargo.toml @@ -40,6 +40,7 @@ sg-metadata = { workspace = true } sg-std = { workspace = true } cw-ownable = { workspace = true } cw721-base = { workspace = true, features = ["library"] } +semver = { workspace = true } [dev-dependencies] cw721 = { workspace = true } diff --git a/contracts/collections/sg721-metadata-onchain/src/lib.rs b/contracts/collections/sg721-metadata-onchain/src/lib.rs index 3cc1d5f04..291f9a8ea 100644 --- a/contracts/collections/sg721-metadata-onchain/src/lib.rs +++ b/contracts/collections/sg721-metadata-onchain/src/lib.rs @@ -20,8 +20,10 @@ pub type Extension = Option; pub mod entry { use super::*; - use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Env, MessageInfo, StdError, StdResult}; - + use cosmwasm_std::{ + entry_point, Binary, Deps, DepsMut, Env, Event, MessageInfo, StdError, StdResult, + }; + use semver::Version; use sg721_base::{msg::QueryMsg, ContractError}; use sg_std::Response; @@ -57,33 +59,58 @@ pub mod entry { } #[entry_point] - pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> Result { + pub fn migrate(mut deps: DepsMut, env: Env, _msg: Empty) -> Result { // make sure the correct contract is being upgraded, and it's being // upgraded from the correct version. - if CONTRACT_VERSION < EARLIEST_VERSION { + let prev_contract_info = cw2::get_contract_version(deps.storage)?; + let prev_contract_name: String = prev_contract_info.contract; + let prev_contract_version: Version = prev_contract_info + .version + .parse() + .map_err(|_| StdError::generic_err("Unable to retrieve previous contract version"))?; + + let new_version: Version = CONTRACT_VERSION + .parse() + .map_err(|_| StdError::generic_err("Invalid contract version"))?; + + let earliest_version: Version = EARLIEST_VERSION + .parse() + .map_err(|_| StdError::generic_err("Invalid contract version"))?; + + if prev_contract_version < earliest_version { return Err( - StdError::generic_err("Cannot upgrade to a previous contract version").into(), + StdError::generic_err("The contract version is too old to be upgraded").into(), ); } - if CONTRACT_VERSION > TO_VERSION { + if new_version < prev_contract_version { return Err( StdError::generic_err("Cannot upgrade to a previous contract version").into(), ); } // if same version return - if CONTRACT_VERSION == TO_VERSION { + if new_version == prev_contract_version { return Ok(Response::new()); } // update contract version cw2::set_contract_version(deps.storage, CONTRACT_NAME, TO_VERSION)?; - // perform the upgrade - let cw17_res = cw721_base::upgrades::v0_17::migrate::(deps) - .map_err(|e| sg721_base::ContractError::MigrationError(e.to_string()))?; - let mut sgz_res = Response::new(); - sgz_res.attributes = cw17_res.attributes; - Ok(sgz_res) + let mut response = Response::new(); + + #[allow(clippy::cmp_owned)] + if prev_contract_version < Version::new(3, 0, 0) { + // perform the upgrade + response = sg721_base::upgrades::v3_0_0::upgrade(deps.branch(), &env, response)?; + } + response = response.add_event( + Event::new("migrate") + .add_attribute("from_name", prev_contract_name) + .add_attribute("from_version", prev_contract_version.to_string()) + .add_attribute("to_name", CONTRACT_NAME) + .add_attribute("to_version", CONTRACT_VERSION), + ); + + Ok(response) } } diff --git a/contracts/minters/open-edition-minter-merkle-wl/src/contract.rs b/contracts/minters/open-edition-minter-merkle-wl/src/contract.rs index 3078f3c41..9b42fcdde 100644 --- a/contracts/minters/open-edition-minter-merkle-wl/src/contract.rs +++ b/contracts/minters/open-edition-minter-merkle-wl/src/contract.rs @@ -21,7 +21,7 @@ use open_edition_factory::msg::{OpenEditionMinterCreateMsg, ParamsResponse}; use open_edition_factory::state::OpenEditionMinterParams; use open_edition_factory::types::NftMetadataType; use semver::Version; -use sg1::{checked_fair_burn, ibc_denom_fair_burn}; +use sg1::distribute_mint_fees; use sg2::query::Sg2QueryMsg; use sg4::{MinterConfig, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; @@ -536,30 +536,15 @@ fn _execute_mint( }; let network_fee = mint_price.amount * mint_fee; - // This is for the network fee msg - // send non-native fees to community pool - if mint_price.denom != NATIVE_DENOM { - // only send non-zero amounts - // send portion to dev addr - if !network_fee.is_zero() { - ibc_denom_fair_burn( - coin(network_fee.u128(), mint_price.denom.to_string()), - Some( - deps.api - .addr_validate(&factory_params.extension.dev_fee_address)?, - ), - &mut res, - )?; - } - } else if !network_fee.is_zero() { - checked_fair_burn( - &info, - network_fee.u128(), + if !network_fee.is_zero() { + distribute_mint_fees( + coin(network_fee.u128(), mint_price.clone().denom), + &mut res, + false, Some( deps.api .addr_validate(&factory_params.extension.dev_fee_address)?, ), - &mut res, )?; } diff --git a/contracts/minters/open-edition-minter-wl-flex/src/contract.rs b/contracts/minters/open-edition-minter-wl-flex/src/contract.rs index b108397ee..9d42c120f 100644 --- a/contracts/minters/open-edition-minter-wl-flex/src/contract.rs +++ b/contracts/minters/open-edition-minter-wl-flex/src/contract.rs @@ -21,7 +21,7 @@ use open_edition_factory::msg::{OpenEditionMinterCreateMsg, ParamsResponse}; use open_edition_factory::state::OpenEditionMinterParams; use open_edition_factory::types::NftMetadataType; use semver::Version; -use sg1::{checked_fair_burn, ibc_denom_fair_burn}; +use sg1::distribute_mint_fees; use sg2::query::Sg2QueryMsg; use sg4::{MinterConfig, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; @@ -594,30 +594,15 @@ fn _execute_mint( }; let network_fee = mint_price.amount * mint_fee; - // This is for the network fee msg - // send non-native fees to community pool - if mint_price.denom != NATIVE_DENOM { - // only send non-zero amounts - // send portion to dev addr - if !network_fee.is_zero() { - ibc_denom_fair_burn( - coin(network_fee.u128(), mint_price.denom.to_string()), - Some( - deps.api - .addr_validate(&factory_params.extension.dev_fee_address)?, - ), - &mut res, - )?; - } - } else if !network_fee.is_zero() { - checked_fair_burn( - &info, - network_fee.u128(), + if !network_fee.is_zero() { + distribute_mint_fees( + coin(network_fee.u128(), mint_price.clone().denom), + &mut res, + false, Some( deps.api .addr_validate(&factory_params.extension.dev_fee_address)?, ), - &mut res, )?; } diff --git a/contracts/minters/open-edition-minter/src/contract.rs b/contracts/minters/open-edition-minter/src/contract.rs index 0091ff9f7..7a20d12ea 100644 --- a/contracts/minters/open-edition-minter/src/contract.rs +++ b/contracts/minters/open-edition-minter/src/contract.rs @@ -21,7 +21,7 @@ use open_edition_factory::msg::{OpenEditionMinterCreateMsg, ParamsResponse}; use open_edition_factory::state::OpenEditionMinterParams; use open_edition_factory::types::NftMetadataType; use semver::Version; -use sg1::{checked_fair_burn, ibc_denom_fair_burn}; +use sg1::distribute_mint_fees; use sg2::query::Sg2QueryMsg; use sg4::{MinterConfig, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; @@ -579,30 +579,15 @@ fn _execute_mint( }; let network_fee = mint_price.amount * mint_fee; - // This is for the network fee msg - // send non-native fees to community pool - if mint_price.denom != NATIVE_DENOM { - // only send non-zero amounts - // send portion to dev addr - if !network_fee.is_zero() { - ibc_denom_fair_burn( - coin(network_fee.u128(), mint_price.denom.to_string()), - Some( - deps.api - .addr_validate(&factory_params.extension.dev_fee_address)?, - ), - &mut res, - )?; - } - } else if !network_fee.is_zero() { - checked_fair_burn( - &info, - network_fee.u128(), + if !network_fee.is_zero() { + distribute_mint_fees( + coin(network_fee.u128(), mint_price.clone().denom), + &mut res, + false, Some( deps.api .addr_validate(&factory_params.extension.dev_fee_address)?, ), - &mut res, )?; } diff --git a/contracts/minters/vending-minter-featured/src/contract.rs b/contracts/minters/vending-minter-featured/src/contract.rs index 2528c77b9..b44e4532b 100644 --- a/contracts/minters/vending-minter-featured/src/contract.rs +++ b/contracts/minters/vending-minter-featured/src/contract.rs @@ -22,7 +22,7 @@ use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data}; use rand_core::{RngCore, SeedableRng}; use rand_xoshiro::Xoshiro128PlusPlus; use semver::Version; -use sg1::checked_fair_burn; +use sg1::{checked_fair_burn, distribute_mint_fees}; use sg2::query::Sg2QueryMsg; use sg4::{MinterConfig, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; @@ -669,14 +669,13 @@ fn _execute_mint( let network_fee = mint_price.amount * mint_fee; - // send non-native fees to community pool - let pa_dao = "stars159t8e03zlmgyekmdrpxnyf70rdky28v553kj53zsapqadaunt4wsmn5m3l".to_string(); - if !network_fee.is_zero() { - res = res.add_message(BankMsg::Send { - to_address: pa_dao.to_string(), - amount: vec![coin(network_fee.u128(), mint_price.denom.clone())], - }); + distribute_mint_fees( + coin(network_fee.u128(), mint_price.clone().denom), + &mut res, + true, + None, + )?; } let mintable_token_mapping = match token_id { diff --git a/contracts/minters/vending-minter-merkle-wl-featured/src/contract.rs b/contracts/minters/vending-minter-merkle-wl-featured/src/contract.rs index eb5077a8f..b53fab09b 100644 --- a/contracts/minters/vending-minter-merkle-wl-featured/src/contract.rs +++ b/contracts/minters/vending-minter-merkle-wl-featured/src/contract.rs @@ -22,7 +22,7 @@ use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data}; use rand_core::{RngCore, SeedableRng}; use rand_xoshiro::Xoshiro128PlusPlus; use semver::Version; -use sg1::checked_fair_burn; +use sg1::{checked_fair_burn, distribute_mint_fees}; use sg2::query::Sg2QueryMsg; use sg4::{MinterConfig, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; @@ -708,13 +708,13 @@ fn _execute_mint( let network_fee = mint_price.amount * mint_fee; - let pa_dao = "stars159t8e03zlmgyekmdrpxnyf70rdky28v553kj53zsapqadaunt4wsmn5m3l".to_string(); - if !network_fee.is_zero() { - res = res.add_message(BankMsg::Send { - to_address: pa_dao.to_string(), - amount: vec![coin(network_fee.u128(), mint_price.denom.clone())], - }); + distribute_mint_fees( + coin(network_fee.u128(), mint_price.clone().denom), + &mut res, + true, + None, + )?; } let mintable_token_mapping = match token_id { diff --git a/contracts/minters/vending-minter-merkle-wl/src/contract.rs b/contracts/minters/vending-minter-merkle-wl/src/contract.rs index 3a2e90d7d..91c160744 100644 --- a/contracts/minters/vending-minter-merkle-wl/src/contract.rs +++ b/contracts/minters/vending-minter-merkle-wl/src/contract.rs @@ -22,11 +22,11 @@ use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data}; use rand_core::{RngCore, SeedableRng}; use rand_xoshiro::Xoshiro128PlusPlus; use semver::Version; -use sg1::{checked_fair_burn, ibc_denom_fair_burn}; +use sg1::{checked_fair_burn, distribute_mint_fees}; use sg2::query::Sg2QueryMsg; use sg4::{MinterConfig, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; -use sg_std::{StargazeMsgWrapper, GENESIS_MINT_START_TIME, NATIVE_DENOM}; +use sg_std::{StargazeMsgWrapper, GENESIS_MINT_START_TIME}; use sg_whitelist::msg::{ ConfigResponse as WhitelistConfigResponse, HasMemberResponse, QueryMsg as WhitelistQueryMsg, }; @@ -708,18 +708,13 @@ fn _execute_mint( let network_fee = mint_price.amount * mint_fee; - // send non-native fees to community pool - if mint_price.denom != NATIVE_DENOM { - // only send non-zero amounts - if !network_fee.is_zero() { - ibc_denom_fair_burn( - coin(network_fee.u128(), mint_price.clone().denom), - None, - &mut res, - )?; - } - } else { - checked_fair_burn(&info, network_fee.u128(), None, &mut res)?; + if !network_fee.is_zero() { + distribute_mint_fees( + coin(network_fee.u128(), mint_price.clone().denom), + &mut res, + false, + None, + )?; } let mintable_token_mapping = match token_id { diff --git a/contracts/minters/vending-minter-wl-flex-featured/src/contract.rs b/contracts/minters/vending-minter-wl-flex-featured/src/contract.rs index 2c082e646..11f7a2cfa 100644 --- a/contracts/minters/vending-minter-wl-flex-featured/src/contract.rs +++ b/contracts/minters/vending-minter-wl-flex-featured/src/contract.rs @@ -21,7 +21,7 @@ use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data}; use rand_core::{RngCore, SeedableRng}; use rand_xoshiro::Xoshiro128PlusPlus; use semver::Version; -use sg1::checked_fair_burn; +use sg1::{checked_fair_burn, distribute_mint_fees}; use sg2::query::Sg2QueryMsg; use sg4::{MinterConfig, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; @@ -658,13 +658,13 @@ fn _execute_mint( }; let network_fee = mint_price.amount * mint_fee; - let pa_dao = "stars159t8e03zlmgyekmdrpxnyf70rdky28v553kj53zsapqadaunt4wsmn5m3l".to_string(); - if !network_fee.is_zero() { - res = res.add_message(BankMsg::Send { - to_address: pa_dao.to_string(), - amount: vec![coin(network_fee.u128(), mint_price.denom.clone())], - }); + distribute_mint_fees( + coin(network_fee.u128(), mint_price.clone().denom), + &mut res, + true, + None, + )?; } let mintable_token_mapping = match token_id { diff --git a/contracts/minters/vending-minter-wl-flex/src/contract.rs b/contracts/minters/vending-minter-wl-flex/src/contract.rs index 05e4be85f..22f6c1341 100644 --- a/contracts/minters/vending-minter-wl-flex/src/contract.rs +++ b/contracts/minters/vending-minter-wl-flex/src/contract.rs @@ -21,7 +21,7 @@ use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data}; use rand_core::{RngCore, SeedableRng}; use rand_xoshiro::Xoshiro128PlusPlus; use semver::Version; -use sg1::{checked_fair_burn, ibc_denom_fair_burn}; +use sg1::{checked_fair_burn, distribute_mint_fees}; use sg2::query::Sg2QueryMsg; use sg4::{MinterConfig, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; @@ -656,18 +656,14 @@ fn _execute_mint( Decimal::bps(factory_params.mint_fee_bps) }; let network_fee = mint_price.amount * mint_fee; - // use ibc_denom_fair_burn for non native denoms - if mint_price.denom != NATIVE_DENOM { - // only send non-zero amounts - if !network_fee.is_zero() { - ibc_denom_fair_burn( - coin(network_fee.u128(), mint_price.clone().denom), - None, - &mut res, - )?; - } - } else { - checked_fair_burn(&info, network_fee.u128(), None, &mut res)?; + + if !network_fee.is_zero() { + distribute_mint_fees( + coin(network_fee.u128(), mint_price.clone().denom), + &mut res, + false, + None, + )?; } let mintable_token_mapping = match token_id { diff --git a/contracts/minters/vending-minter/src/contract.rs b/contracts/minters/vending-minter/src/contract.rs index 57afb5ad1..c30530ada 100644 --- a/contracts/minters/vending-minter/src/contract.rs +++ b/contracts/minters/vending-minter/src/contract.rs @@ -22,7 +22,7 @@ use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data}; use rand_core::{RngCore, SeedableRng}; use rand_xoshiro::Xoshiro128PlusPlus; use semver::Version; -use sg1::{checked_fair_burn, ibc_denom_fair_burn}; +use sg1::{checked_fair_burn, distribute_mint_fees}; use sg2::query::Sg2QueryMsg; use sg4::{MinterConfig, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; @@ -667,18 +667,13 @@ fn _execute_mint( let network_fee = mint_price.amount * mint_fee; - // send non-native fees to community pool - if mint_price.denom != NATIVE_DENOM { - // only send non-zero amounts - if !network_fee.is_zero() { - ibc_denom_fair_burn( - coin(network_fee.u128(), mint_price.clone().denom), - None, - &mut res, - )?; - } - } else { - checked_fair_burn(&info, network_fee.u128(), None, &mut res)?; + if !network_fee.is_zero() { + distribute_mint_fees( + coin(network_fee.u128(), mint_price.clone().denom), + &mut res, + false, + None, + )?; } let mintable_token_mapping = match token_id { diff --git a/e2e/src/tests/factory_test.rs b/e2e/src/tests/factory_test.rs index 9d8c35a0e..d52319ad7 100644 --- a/e2e/src/tests/factory_test.rs +++ b/e2e/src/tests/factory_test.rs @@ -339,9 +339,9 @@ fn test_start_trading_time(chain: &mut Chain) { assert_eq!(balance.amount, init_balance.amount + 9_000_000_000); // fairburn fees - // half of the 10% fees should be sent to fairburn pool - // 500STARS + 500STARS initially sent for collection creation fee - assert_eq!(total_fairburn_fees, 1_000_000_000); + // fairburn pool should remain unchanged + // 500STARS initially sent for collection creation fee + assert_eq!(total_fairburn_fees, 500_000_000); let total_supply = tokio_block(chain.orc.client.bank_query_supply(denom.parse().unwrap())) .unwrap() @@ -349,7 +349,7 @@ fn test_start_trading_time(chain: &mut Chain) { // the other half burned assert_eq!( - initial_total_supply.amount - 1_000_000_000, + initial_total_supply.amount - 500_000_000, total_supply.amount ); } diff --git a/e2e/src/tests/open_edition_factory_and_mint_tests.rs b/e2e/src/tests/open_edition_factory_and_mint_tests.rs index 994148843..17710cf84 100644 --- a/e2e/src/tests/open_edition_factory_and_mint_tests.rs +++ b/e2e/src/tests/open_edition_factory_and_mint_tests.rs @@ -534,7 +534,10 @@ fn test_start_trading_time(chain: &mut Chain) { } // 200 mints at 100_000_000 * 0.1 * 0.5 = 1_000_000_000 - assert_eq!(total_dev_fees, 1_000_000_000); + // TO-DO: + // Dev fees are distributed through distribute_mint_fees() instead of fair_burn() + // Packages and integration tests need to be updated to reflect the change + assert_eq!(total_dev_fees, 0); assert_eq!(total_mints, 200); @@ -573,9 +576,9 @@ fn test_start_trading_time(chain: &mut Chain) { ); // The amount of tokens burned should be - // 500 STARS from the init + (200 mint x 100_000_000 x 0.1 x 0.5) -> 500 + 1_000 = 1_500 + // 500 STARS from the init assert_eq!( - initial_total_supply.amount - 1_500_000_000, + initial_total_supply.amount - 500_000_000, total_supply.amount ); } diff --git a/packages/sg1/src/lib.rs b/packages/sg1/src/lib.rs index 40ade39c7..d45a3e118 100644 --- a/packages/sg1/src/lib.rs +++ b/packages/sg1/src/lib.rs @@ -10,6 +10,8 @@ const FEE_BURN_PERCENT: u64 = 50; const FOUNDATION: &str = "stars1xqz6xujjyz0r9uzn7srasle5uynmpa0zkjr5l8"; const LAUNCHPAD_DAO_ADDRESS: &str = "stars1huqk6ha02jgrm69lxh8xfgl6wch9wlg7s65ujxydwdr725cxvuus423tj0"; +const LIQUIDITY_DAO_ADDRESS: &str = + "stars12he2ldxl950wfypvelqwkac4mdul7clzgd8wdlnmjvll8z2cc47qsatvl2"; /// Burn and distribute fees and return an error if the fee is not enough pub fn checked_fair_burn( @@ -74,6 +76,82 @@ pub fn ibc_denom_fair_burn( Ok(()) } +pub fn distribute_mint_fees( + fee: Coin, + res: &mut Response, + is_featured: bool, + developer: Option, +) -> Result<(), FeeError> { + let liquidity_dao_ratio: Decimal = Decimal::from_ratio(1u128, 5u128); + let liquidity_dao_ratio_featured: Decimal = Decimal::from_ratio(1u128, 8u128); + + let mut event = Event::new("mint-fee-distribution"); + + let liquidity_dao_percentage = if is_featured { + liquidity_dao_ratio_featured + } else { + liquidity_dao_ratio + }; + + match &developer { + Some(developer) => { + let dev_fee = fee + .amount + .mul_ceil(Decimal::percent(FEE_BURN_PERCENT)) + .u128(); + let dev_coin = coin(dev_fee, fee.denom.to_string()); + let remaining_coin = coin(fee.amount.u128() - dev_fee, fee.denom.clone()); + + let liquidity_dao_fee = + (remaining_coin.amount.mul_ceil(liquidity_dao_percentage)).u128(); + let liquidity_dao_coin = coin(liquidity_dao_fee, fee.denom.to_string()); + let foundation_coin = coin(remaining_coin.amount.u128() - liquidity_dao_fee, fee.denom); + + event = event.add_attribute("dev_addr", developer.to_string()); + event = event.add_attribute("dev_coin", dev_coin.to_string()); + event = event.add_attribute("liquidity_DAO_addr", LIQUIDITY_DAO_ADDRESS.to_string()); + event = event.add_attribute("liquidity_DAO_coin", liquidity_dao_coin.to_string()); + event = event.add_attribute("foundation_addr", FOUNDATION.to_string()); + event = event.add_attribute("foundation_coin", foundation_coin.to_string()); + + res.messages.push(SubMsg::new(BankMsg::Send { + to_address: developer.to_string(), + amount: vec![dev_coin], + })); + res.messages.push(SubMsg::new(BankMsg::Send { + to_address: LIQUIDITY_DAO_ADDRESS.to_string(), + amount: vec![liquidity_dao_coin], + })); + res.messages.push(SubMsg::new(BankMsg::Send { + to_address: FOUNDATION.to_string(), + amount: vec![foundation_coin], + })); + } + None => { + let liquidity_dao_fee = fee.amount.mul_ceil(liquidity_dao_percentage).u128(); + let liquidity_dao_coin = coin(liquidity_dao_fee, fee.denom.to_string()); + let foundation_coin = coin(fee.amount.u128() - liquidity_dao_fee, fee.denom); + + event = event.add_attribute("liquidity_DAO_addr", LIQUIDITY_DAO_ADDRESS.to_string()); + event = event.add_attribute("liquidity_DAO_coin", liquidity_dao_coin.to_string()); + event = event.add_attribute("foundation_addr", FOUNDATION.to_string()); + event = event.add_attribute("foundation_coin", foundation_coin.to_string()); + + res.messages.push(SubMsg::new(BankMsg::Send { + to_address: LIQUIDITY_DAO_ADDRESS.to_string(), + amount: vec![liquidity_dao_coin], + })); + res.messages.push(SubMsg::new(BankMsg::Send { + to_address: FOUNDATION.to_string(), + amount: vec![foundation_coin], + })); + } + } + + res.events.push(event); + Ok(()) +} + /// Burn and distribute fees, assuming the right fee is passed in pub fn fair_burn(fee: u128, developer: Option, res: &mut Response) { let mut event = Event::new("fair-burn"); diff --git a/test-suite/src/common_setup/setup_minter/common/constants.rs b/test-suite/src/common_setup/setup_minter/common/constants.rs index b9b20eabf..844cc1a15 100644 --- a/test-suite/src/common_setup/setup_minter/common/constants.rs +++ b/test-suite/src/common_setup/setup_minter/common/constants.rs @@ -13,3 +13,5 @@ pub const MAX_PER_ADDRESS_LIMIT: u32 = 50; pub const DEV_ADDRESS: &str = "stars1abcd4kdla12mh86psg4y4h6hh05g2hmqoap350"; pub const MIN_MINT_PRICE_OPEN_EDITION: u128 = 100_000_000; pub const FOUNDATION: &str = "stars1xqz6xujjyz0r9uzn7srasle5uynmpa0zkjr5l8"; +pub const LIQUIDITY_DAO_ADDRESS: &str = + "stars12he2ldxl950wfypvelqwkac4mdul7clzgd8wdlnmjvll8z2cc47qsatvl2"; diff --git a/test-suite/src/open_edition_minter/tests/ibc_asset_mint.rs b/test-suite/src/open_edition_minter/tests/ibc_asset_mint.rs index 58a50df46..43c61c03b 100644 --- a/test-suite/src/open_edition_minter/tests/ibc_asset_mint.rs +++ b/test-suite/src/open_edition_minter/tests/ibc_asset_mint.rs @@ -4,6 +4,7 @@ use open_edition_factory::state::{OpenEditionMinterParams, ParamsExtension}; use open_edition_minter::msg::ExecuteMsg; use sg_std::{GENESIS_MINT_START_TIME, NATIVE_DENOM}; +use crate::common_setup::setup_minter::common::constants::LIQUIDITY_DAO_ADDRESS; use crate::common_setup::{ setup_accounts_and_block::setup_block_time, setup_minter::{ @@ -172,7 +173,13 @@ fn one_hundred_percent_burned_ibc_minter() { .wrap() .query_balance(Addr::unchecked(FOUNDATION), denom) .unwrap(); - assert_eq!(balance.amount, mint_price.amount * Decimal::percent(50)); + assert_eq!(balance.amount, mint_price.amount * Decimal::percent(40)); + + let balance = router + .wrap() + .query_balance(Addr::unchecked(LIQUIDITY_DAO_ADDRESS), denom) + .unwrap(); + assert_eq!(balance.amount, mint_price.amount * Decimal::percent(10)); } #[test] diff --git a/test-suite/src/vending_minter/tests/ibc_asset_mint.rs b/test-suite/src/vending_minter/tests/ibc_asset_mint.rs index 661605737..249ec3bf8 100644 --- a/test-suite/src/vending_minter/tests/ibc_asset_mint.rs +++ b/test-suite/src/vending_minter/tests/ibc_asset_mint.rs @@ -24,7 +24,7 @@ use crate::common_setup::{ templates::{vending_minter_template, vending_minter_with_ibc_asset}, }; -use crate::common_setup::setup_minter::common::constants::CREATION_FEE; +use crate::common_setup::setup_minter::common::constants::{CREATION_FEE, LIQUIDITY_DAO_ADDRESS}; use crate::common_setup::setup_minter::vending_minter::mock_params::mock_params; #[test] @@ -259,5 +259,10 @@ fn wl_denom_mint() { .wrap() .query_balance(Addr::unchecked(FOUNDATION), denom) .unwrap(); - assert_eq!(balance.amount, wl_mint_price.amount * Decimal::percent(10)); + assert_eq!(balance.amount, wl_mint_price.amount * Decimal::percent(8)); + let balance = app + .wrap() + .query_balance(Addr::unchecked(LIQUIDITY_DAO_ADDRESS), denom) + .unwrap(); + assert_eq!(balance.amount, wl_mint_price.amount * Decimal::percent(2)); }