>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.