Brokerage Smart Contracts
Every OpenDAX v4 brokerage functioning relies upon a custody smart contract that serves as an exchange vault. It locks users' funds when they deposit to the exchange and unlocks them to users' blockchain addresses at withdrawals. Along with the vault contract, OpenDAX v4 is powered by dedicated smart contracts that implement all needed operations.
Each OpenDAX v4 instance has a VaultProxy contract created on deployment.
This smart contract provides funds custody by storing hashed withdraw/deposit requests so that they can not be used again (e.g. to prevent double withdrawal).
It also serves as a proxy: navigates requests to the globally defined VaultImpl contract.
VaultImpl (Vault Implementation) provides all needed operational logic for VaultProxy. It's a common contract for all OpenDAX v4 instances. It contains custody logic: performs all operations on VaultProxy contracts' requests:
- migrate to a new VaultImpl version
For example, VaultImpl performs an operation and stores the hash of it in VaultProxy storage.
The new VaultProxy already has a hardcoded address of a VaultImpl contract.
VaultProxy is responsible for the assets' custody, VaultImpl for the logic of the operations, and Finex is the entity that navigates users’ requests.
VaultProxy only contains custody and delegation logic and remains unchanging.
VaultImpl contract that provides operations logic can be upgraded when needed.
If an update is available, each broker receives the notification and may choose to migrate their VaultProxy connection to a new, updated VaultImpl contract (or choose to stay with the previous VaultImpl version).
A new version of VaultImpl essentially makes a hardfork of the Yellow Network.
Previous versions of VaultImpl remain functional since some brokers may prefer to use them and not apply new features of a new VaultImpl contract. But if the broker uses Yellow Network, they need to upgrade.