omgnetwork / plasma-contracts

Root chain contracts for Plasma
Apache License 2.0
114 stars 66 forks source link

quasar: Add fee and returns to quasar pool #747

Closed souradeep-das closed 3 years ago

souradeep-das commented 3 years ago

Key

output_value:

actual size of output that has to be fast exited

reserved_amount:

amount that can be withdrawn from the pool with the above output ( output_value - fees)

token_usable_capacity:

--> addCapacity() increases capacity by supplied_funds ----> obtainTicket() decreases capacity by reserved_amount ------> flushTicket() increases capacity back by reserved_amount ------> challengeClaim() can increase capacity back by reserved_amount else, withdrawal successful, capacity reduced --> repayPool() increases capacity by output_value of claimed outputs ( fee + reserved_amount)

--> withdrawFunds() decreases capacity by supplied_funds + fee(accumulated), [up till value of usable_capacity]

unclaimed_bond_reserve:

--> obtainTicket() adds bond value to contract ----> flushExpiredTicket() adds bond to unclaimed_bond reserve (stays in the contract) ------> withdrawUnclaimedBonds() returns this store to quasar maintainer ----> challengeClaim() returns bond to challenger ----> claim (or) processClaim() returns bond to output owner

pool_supply:

for the calculation of exchange rate --> addCapacity() increases supply by supplied_funds --> Claim (or) processClaim() increases supply by fee --> withdrawFunds() decrease supply by supplied_funds + fee(accumulated)

owed_amount:

--> claim (or) processClaim() increases owed by output_value of claimed output ( fee + reserved_amount) --> repayPool() decreases owed by amount supplied

souradeep-das commented 3 years ago

Just writing down something that came to mind for feedback-

In regards to the very small residue in the pool, in case all qTokens have been withdrawn, assume residue = usableCapacity = 10 wei if someone acts funny and claims ticket to reserve 5 wei from the residue in the pool, but will not able to claim since, utilize() would fail with a totalQTokenSupply of 0, also losing the ticket. This should be okay right? The residue shouldn’t also build up and remain minimal since, the entire pool supply is distributed for each round of utilize()

kevsul commented 3 years ago

Just writing down something that came to mind for feedback-

In regards to the very small residue in the pool, in case all qTokens have been withdrawn, assume residue = usableCapacity = 10 wei if someone acts funny and claims ticket to reserve 5 wei from the residue in the pool, but will not able to claim since, utilize() would fail with a totalQTokenSupply of 0, also losing the ticket. This should be okay right? The residue shouldn’t also build up and remain minimal since, the entire pool supply is distributed for each round of utilize()

I think that's fine. 10 wei is dust - nobody is going to pay the gas + fee to claim that