-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
src/naming/main.cairo
Outdated
discount_id: felt252, | ||
metadata: felt252, | ||
altcoin_addr: ContractAddress, | ||
quote: u128, |
There was a problem hiding this comment.
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
src/naming/utils.cairo
Outdated
fn get_altcoin_price( | ||
self: @Naming::ContractState, altcoin_quote: Wad, domain_price_eth: Wad | ||
) -> u256 { | ||
(domain_price_eth / altcoin_quote).into() |
There was a problem hiding this comment.
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.
src/tests/naming/test_altcoin.cairo
Outdated
|
||
// User wants to buy a domain in STRK for one year | ||
let domain_price_eth = Wad { val: 8999999999999875 }; | ||
// 1 STRK = 0,00522180500429277 ETH |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Close #21