-
Notifications
You must be signed in to change notification settings - Fork 108
Ethereum Contracts: Overview
The audited contracts code is open sourced at https://github.com/AudiusProject/audius-protocol/tree/master/eth-contracts
The Audius Ethereum contracts are meant to accomplish the following goals for the Audius protocol:
- Create the Audius token through an ERC-20
- Keep track of different service versions
- Allow service providers to stake and register services to run
- Allow delegation from users holding Audius token to service providers running services on the network
- Allow network to mint new tokens for stakers and delegators to earn staking rewards
- Enable protocol governance to carry out protocol actions such as slash, and static value updates
All contracts are built on top of OpenZeppelin's Proxy pattern through AudiusAdminUpgradeabilityProxy
which extends AdminUpgradeabilityProxy
, enabling logic upgrades to be performed through the Governance contract.
Here are some terms as they relate specifically to Audius:
Service - A traditional backend service comprised of a web server, cache and database
Stake/Staking - The act of escrowing Audius tokens to the contracts in order to run a Service. Staking can happen by either Service Providers or through Delegators on behalf of Service Providers. Good actors can Claim rewards, whereas there could be a Slashing penalty for bad actors(enforced through Governance)
Service Provider - Anyone that hosts a Service. A requirement to be a Service Provider is to meet the minimum token Stake
Delegator - Anyone that holds Audius tokens and wants to participate in the staking process but does not run a service directly like a Service Provider does. Instead Delegators directs their funds on behalf of a specified Service Provider so the provider can leverage Delegator funds to register additional Services
Slash - The act of reducing the stake of a Service Provider and all Delegators who delegated to a Service Provider
Claim - Process by which Staking rewards are generated and distributed to Stakers.
Governance - A system to enact protocol changes with community approval. Proposals for function calls on protocol contracts can be submitted, voted on, and executed by any valid Staker.
Root directory: audius-protocol/eth-contracts
AudiusToken - /contracts/erc20/AudiusToken.sol
Registry - /contracts/registry/Registry.sol
Staking - /contracts/Staking.sol
ClaimsManager - /contracts/ClaimsManager.sol
DelegateManager - /contracts/DelegateManager.sol
Governance /contracts/Governance.sol
ServiceTypeManager - /contracts/ServiceTypeManager.sol
ServiceProviderFactory /contracts/ServiceProviderFactory.sol
The AudiusToken contract is an ERC-20 token contract with initial supply of 1 billion AUDS tokens, each divisible up to 18 decimal places, and is Mintable, Pausable, and Burnable.
Contract through which external clients and Governance interact with the remaining contracts within the protocol. Each contract is registered using a key with which its address can be queried.
Contract responsible for maintaining known service types, associated versioning information and service type stake requirements within the audius protocol. Service types are used to identify services being registered within the protocol, for example 'creator-node' or 'discovery-provider'. Versioning is important in a decentralized context for client to choose the appropriate services and serve data in the latest format. Service type stake requirements enforce a minimum and maximum stake amount for each endpoint of a given type that service providers register.
Staking is the contract in which tokens are stored and account balances are managed for every service provider address (details below) within the network. Burning tokens when a slash occurs also occurs in this contract. Total stake history is tracked and each account has a full history of its stake and last claimed block. Each account value in Staking.sol represents the total sum of deployer stake + delegate stake.
Contract responsible for tracking Service Provider state within the audius network. A service provider is the account associated with a given service endpoint. Each service provider can increase/decrease stake within dynamic bounds determined by the combination of endpoints they have registered, accept delegation from other token holders, define a reward cut for delegation, and continue registering endpoints as necessary. ServiceProviderFactory forwards staking requests to the actual Staking.sol contract but tracks the amount of stake for the deployer - Staking.sol tracks the sum of delegate stake + deployer stake.
Contract responsible for allocating and minting new tokens as well as managing claim rounds. A claim round is a period of time during which service providers with valid stakes can retrieve the reward apportioned to them in the network. Claims are processed here and new value transferred to Staking.sol for the claimer, but the values in both ServiceProviderFactory and DelegateManager are updated through calls to DelegateManager.
Contract responsible for tracking delegation state, making claims, and handling slash operations. DelegateManager functionality allows any user holding Audius token to delegate to an existing provider, earning rewards by providing additional stake to a deployer while allocating a known % of their reward to said deployer. The distribution of stake between Service Provider and delegators is managed here, rewards are divided proportionally as are slashes - note that all claim and slash operations flow through this contract in order to update values tracked outside of Staking.sol appropriately and maintain consistency between total value within Staking.sol and value tracked by DelegateManager + ServiceProviderFactory.
This contract allows protocol participants to change protocol direction by submitting and voting on proposals. It is a simplified version of Compound Finance's governance system (GovernorAlpha.sol and Timelock.sol).
Each proposal represents an executable function call on a contract in the Registry. Once submitted, there is a period of time during which other participants can submit their votes - Yes or No - on the proposal. After the voting period has concluded, the proposal outcome is calculated as a the sum of the stakes of the Yes voters minus the sum of the stakes of the No voters. Any non-negative value results in a successful proposal, at which point the specified function call is executed, and the proposal is closed. Only addresses that have staked in Staking.sol
and are represented through the Registry can submit and vote on proposals.
Note that every contract within the audius protocol can be governed through evaluating proposals, making this contract very powerful. Values such as the ones enumerated below, as well as contract references to other contracts (for example, the value of Staking in DelegateManager) are all controlled by the governance contract. Initially the are two safeguard operations in governance controlled by a guardianAddress in proposal veto and guardian override. Proposal veto allows the guardianAddress to cancel any ongoing proposal, and guardian transaction override allows the guardianAddress to submit transactions to governable operations within the audius protocol. These safeguards will be slowly removed over time through contract upgrades to Governance itself.
Here we enumerate all values that can be configured through the governance process which affect the audius protocol
- fundingRoundBlockDiff (ClaimsManager.sol) - Minimum number of blocks between funding rounds
- fundingAmount (ClaimsManager.sol) - Total amount distributed to stakeholders during a given funding round
- minDelegationAmount (DelegateManager.sol) - Minimum amount of delegation allowed to a service provider
- undelegateLockupDuration (DelegateManager.sol) - Time frame required for processing a decrease in delegate stake
- votingPeriod (Governance.sol) - Period in blocks for which a governance proposal is open for voting
- votingQuorum (Governance.sol) - Required minimum number of votes to consider a proposal valid
- DEPLOYER_CUT_BASE (ServiceProviderFactory.sol) - Denominator for deployer cut calculation when distributing rewards. User values are intended to be x/DeployerCutBase.
- minDeployerStake (ServiceProviderFactory.sol) - Minimum staked by service provider account deployer. Static regardless of total number of endpoints or other configuration.
- ServiceType Values
- Note that these values are set during the initial migration, not deployed as part of the contract. Below values correspond to the required stake bounds for each endpoint a service provider registers of a given type.
- creator-node ServiceType
- Minimum stake: 200,000 AUD
- Maximum stake: 3,000,000 AUD
- discovery-provider ServiceType
- Minimum stake: 200,000 AUD
- Maximum stake: 3,000,000 AUD
- Home
- Start Here
- Content-Node
- Discovery Node
- Ethereum Smart Contracts
- Slashing
- Identity Service