Skip to content

Update mint fee distribution logic #698

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

Merged
merged 10 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions contracts/minters/open-edition-minter-merkle-wl/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ 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};
use sg_std::{StargazeMsgWrapper, NATIVE_DENOM};
use sg_std::StargazeMsgWrapper;
use url::Url;
use whitelist_mtree::msg::{
ConfigResponse as WhitelistConfigResponse, HasMemberResponse, QueryMsg as WhitelistQueryMsg,
Expand Down Expand Up @@ -525,30 +525,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,
)?;
}

Expand Down
29 changes: 7 additions & 22 deletions contracts/minters/open-edition-minter-wl-flex/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ 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};
use sg_std::{StargazeMsgWrapper, NATIVE_DENOM};
use sg_std::StargazeMsgWrapper;
use sg_whitelist_flex::msg::{
ConfigResponse as WhitelistConfigResponse, HasMemberResponse, Member,
QueryMsg as WhitelistQueryMsg,
Expand Down Expand Up @@ -528,30 +528,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,
)?;
}

Expand Down
29 changes: 7 additions & 22 deletions contracts/minters/open-edition-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ 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};
use sg_std::{StargazeMsgWrapper, NATIVE_DENOM};
use sg_std::StargazeMsgWrapper;
use sg_whitelist::msg::{
ConfigResponse as WhitelistConfigResponse, HasMemberResponse, QueryMsg as WhitelistQueryMsg,
};
Expand Down Expand Up @@ -502,30 +502,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,
)?;
}

Expand Down
15 changes: 7 additions & 8 deletions contracts/minters/vending-minter-featured/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -664,14 +664,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -701,13 +701,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 {
Expand Down
23 changes: 9 additions & 14 deletions contracts/minters/vending-minter-merkle-wl/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,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,
};
Expand Down Expand Up @@ -701,18 +701,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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};
Expand Down Expand Up @@ -656,13 +656,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 {
Expand Down
24 changes: 10 additions & 14 deletions contracts/minters/vending-minter-wl-flex/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,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_flex::msg::{
ConfigResponse as WhitelistConfigResponse, HasMemberResponse, Member,
QueryMsg as WhitelistQueryMsg,
Expand Down Expand Up @@ -654,18 +654,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 {
Expand Down
23 changes: 9 additions & 14 deletions contracts/minters/vending-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,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,
};
Expand Down Expand Up @@ -662,18 +662,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 {
Expand Down
8 changes: 4 additions & 4 deletions e2e/src/tests/factory_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,17 @@ 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()
.balance;

// the other half burned
assert_eq!(
initial_total_supply.amount - 1_000_000_000,
initial_total_supply.amount - 500_000_000,
total_supply.amount
);
}
Expand Down
Loading
Loading