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 altcoin buy & renew support #22

Merged
merged 10 commits into from
Mar 8, 2024
Merged

feat: add altcoin buy & renew support #22

merged 10 commits into from
Mar 8, 2024

Conversation

irisdv
Copy link
Collaborator

@irisdv irisdv commented Mar 4, 2024

Close #21

@irisdv irisdv requested a review from Th0rgal March 4, 2024 15:39
@irisdv irisdv added the 🔥 Ready for review Pull Request needs a label Mar 4, 2024
discount_id: felt252,
metadata: felt252,
altcoin_addr: ContractAddress,
quote: u128,
Copy link
Member

Choose a reason for hiding this comment

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

quote could be a Wad directly since you will cast it after anyway

fn get_altcoin_price(
self: @Naming::ContractState, altcoin_quote: Wad, domain_price_eth: Wad
) -> u256 {
(domain_price_eth / altcoin_quote).into()
Copy link
Member

Choose a reason for hiding this comment

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

It should be a multiplication here. The base currency is ETH, the quoted currency is something like USDC. In that context a quote means the price of 1 ETH in the quoted currency, so for example 3500 USDC. It means you should just have to do a multiplication. If the API called by the backend returns the other way (the altcoin is the base currency), we should modify the backend to return 1/result, this will help keep this code less confusing. Also a multiplication should be significantly cheaper.


// User wants to buy a domain in STRK for one year
let domain_price_eth = Wad { val: 8999999999999875 };
// 1 STRK = 0,00522180500429277 ETH
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense with the current get_altcoin_price but should be updated so altcoin is the quoted token in base currency: ETH

);
self.emit(Event::SaleMetadata(SaleMetadata { domain, metadata }));
// find new domain expiry
let new_expiry = if domain_data.expiry <= now {
Copy link
Member

Choose a reason for hiding this comment

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

I think we could drop these two expiry check because the auto renew contract already ensures you can't do something abusive (your domain should expire soon and we can renew only for one year)

@irisdv irisdv requested a review from Th0rgal March 7, 2024 09:16
Copy link
Member

@Th0rgal Th0rgal left a comment

Choose a reason for hiding this comment

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

lgtm

@Th0rgal Th0rgal merged commit 6a922ce into master Mar 8, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔥 Ready for review Pull Request needs a
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add STRK payment support
2 participants