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

feat: Add contract astroport-pair-xyk-sale-tax #381

Merged
merged 22 commits into from
Jan 12, 2024

Conversation

apollo-sturdy
Copy link
Contributor

@apollo-sturdy apollo-sturdy commented Oct 18, 2023

This contract is a copy of the standard XYK pair but adds a configurable tax on swaps.

After launching the APOLLO token, Apollo DAO will be submitting a proposal to migrate standard xyk pair to this contract. If the proposal passes, perhaps it makes sense to merge it into the main astroport-core repo.

contracts/pair_xyk_sale_tax/src/contract.rs Outdated Show resolved Hide resolved
@epanchee
Copy link
Collaborator

Hi @apollo-sturdy

Isn't this recently added feature does the same thing?

// If this pool is configured to share fees, calculate the amount to send
// to the receiver and add the transfer message
// The calculation works as follows: We take the share percentage first,
// and the remainder is then split between LPs and maker
let mut fees_commission_amount = commission_amount;
let mut fee_share_amount = Uint128::zero();
if let Some(fee_share) = config.fee_share.clone() {
// Calculate the fee share amount from the full commission amount
let share_fee_rate = Decimal::from_ratio(fee_share.bps, 10000u16);
fee_share_amount = fees_commission_amount * share_fee_rate;
if !fee_share_amount.is_zero() {
// Subtract the fee share amount from the commission
fees_commission_amount = fees_commission_amount.saturating_sub(fee_share_amount);
// Build send message for the shared amount
let fee_share_msg = Asset {
info: ask_pool.info.clone(),
amount: fee_share_amount,
}
.into_msg(fee_share.recipient)?;
messages.push(fee_share_msg);
}
}

@apollo-sturdy
Copy link
Contributor Author

Hi @apollo-sturdy

Isn't this recently added feature does the same thing?

Thanks for mentioning this, I wasn't aware of this change. However, this doesn't seem to allow us to accomplish what we want. There are a few differences:

  • It charges the fee share / tax on the return asset rather than the offer asset.
  • It charges the fee rate on top of the commission amount which is set the same for all pairs of the same type, which means we at most would be able to take 100% of the total_fee_rate.

@donovansolms
Copy link
Collaborator

Looks good - I have nothing to add.

I hope that tax_config_admin would be some governance address and not a multisig that would allow silent rugging of everyone that swaps via this pool. If it is, I'd much rather have stricter limits on what the tax can be set to.

contracts/pair_xyk_sale_tax/Cargo.toml Show resolved Hide resolved
contracts/pair_xyk_sale_tax/src/contract.rs Show resolved Hide resolved
contracts/pair_xyk_sale_tax/src/contract.rs Outdated Show resolved Hide resolved
contracts/pair_xyk_sale_tax/src/contract.rs Show resolved Hide resolved
contracts/pair_xyk_sale_tax/src/contract.rs Outdated Show resolved Hide resolved
contracts/pair_xyk_sale_tax/Cargo.toml Outdated Show resolved Hide resolved
contracts/pair_xyk_sale_tax/Cargo.toml Show resolved Hide resolved
contracts/pair_xyk_sale_tax/src/contract.rs Show resolved Hide resolved
Copy link
Collaborator

@epanchee epanchee left a comment

Choose a reason for hiding this comment

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

LGTM

@epanchee epanchee merged commit b08b4d8 into astroport-fi:main Jan 12, 2024
4 checks passed
@apollo-sturdy apollo-sturdy deleted the dev/xyk-sale-tax branch January 12, 2024 14:02
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.

4 participants