3 ms·
You might be confused. The "price > 0" refers to the price of TITAN. TITAN isn't backed by USDC at all. IRON is (ideally) backed by 75% USDC and 25% TITAN.
by Thorrez 5y ago
You might be confused. The "price > 0" refers to the price of TITAN. TITAN isn't backed by USDC at all. IRON is (ideally) backed by 75% USDC and 25% TITAN.
- rank0 5y agoOh you're right I am confused. I actually don't even understand the point of the price check in the first place. Why does the USDC portion of IRON tokens need to be locked in the smart contract based on TITAN price anyways?
- Thorrez 5y ago>Why does the USDC portion of IRON tokens need to be locked in the smart contract based on TITAN price anyways? It doesn't need to be. It's basically a bug in the code. They didn't consider TITAN price being 0 to be possible, so they didn't write their code in a way to handle it correctly. A random guess for why they had the price > 0 check. They might have had code like this: // Returns (usdc_to_withdraw, titan_to_withdraw) def GetWithdrawalAmounts(iron_to_withdraw): usdc_price = 1 // guaranteed: USDC price in USD (aka USD/USDC) titan_price = GetTitanPrice() // TITAN price in USD (aka USD/TITAN) iron_price = GetIronPrice() // IRON price in USD (aka USD/IRON) usdc_to_withdraw = iron_to_withdraw * iron_price * 0.75 / usdc_price assert titan_price > 0 titan_to_withdraw = iron_to_withdraw * iron_price * 0.25 / titan_price return (usdc_to_withdraw, titan_to_withdraw) If you look at it like that, it's pretty obvious why they have the assertion that titan_price > 0. Without that assertion there's a divide by 0. If you want to handle the ability to withdraw USDC even if the TITAN price is 0, you have to make the code more complicated. Likely not just this function, but the system as a whole, because it'll mess up all the accounting.