OriginProtocol / ousd-governance

OUSD Governance Portal and Contracts
11 stars 4 forks source link

Add Migrator #410

Closed shahthepro closed 6 months ago

shahthepro commented 6 months ago

If you made a contract change, make sure to complete the checklist below before merging it in master.

Contract change checklist:

DanielVF commented 6 months ago

Code Review - Migrator

Requirements

We wish to provide one transaction + approval of OGV and veOGV stakes to OGN and xOGN stakes.

This contract collects ogv to the user's address, and then burns it there using an approval. OGN is then sent to a new stake for the user's address and/or sent directly to the user.

A simple migrate method can just burn and transfers without touching the staking system.

Authentication

Ethereum

Cryptographic code

No crypto

Gas problems

Black magic

Overflow

Proxy

Events

Medium Checks

Rounding

Dependencies

External calls

Tests

Deploy

Deploy file not yet written

Logic

Logic looks correct.

Deployment Considerations

No deploy yet

Internal State

Attack

This code will hold and then distribute 40%ish of the circulating supply of OGN. An exploit could have major financial consequences for token holders.

Although OGV is the current governance token and xOGN will be the future governance token, this migration contract should not be able to directly cause a loss of governance, since during the migration period, a multisig will temporary control governance.

We will be topping off the code with excess OGN tokens, since we don't know precisely when the migration will start. If the deployer still had governance, they could skim off excess tokens. We plan to move tokens to this contract and start() it from the same governance transaction, which means the governance action would fail if the migration contract was not owned by governance.

A concern would be if a user could take OGV tokens from someone else. This does not appear to be possible since all funds pulls are from msg.sender.

Another concern would be getting too many tokens for a conversion. The conversion rate matches the governance proposal. We will have another sanity check in that the amount of OGN initially transferred to the contract will be checked. Finally, the isSolvent modifier should revert if we give out too many tokens.

Flavor

Flavor is good.

DanielVF commented 6 months ago

Code Review - veOGV

Requirements

Authentication

Ethereum

Cryptographic code

no crypto

Gas problems

Black magic

Overflow

Proxy

Events

Rounding

Dependencies

External calls

Deploy

No deploy code written

When deploy code is written, a collect call should be made just before this upgrade.

Logic

Logic appears correct.

Internal State

Attack

This contract holds 3.7 billion OGV, which will soon be convertible to OGN - 40 something million at today's prices.

An attack would attempt to gain access to another user's tokens, get more tokens than owed, or double withdraw.

Flavor

The code is slightly awkward because of the tension between keeping backwards compatibility versus most functionality no longer being needed. However there is not any anticipated future work on this contract, and it's okay as is.

DanielVF commented 6 months ago

Noting that we should do some fork testing of this during the audit.