RipeToken
Overview
RipeToken (RIPE) is the governance token powering the Ripe DAO, granting holders voting rights over protocol parameters, treasury allocation, and strategic direction. Distributed through rewards, bonding, and initial allocations, RIPE aligns stakeholder incentives with long-term protocol success.
Governance Powers:
Protocol Parameters: Vote on collateral ratios, fee structures, and risk parameters
Treasury Management: Direct allocation of protocol revenues and strategic reserves
Contract Upgrades: Approve new modules and protocol improvements through governance
Reward Distribution: Control emission rates and allocation across protocol activities
RIPE implements controlled minting through RipeHq authorization, ensuring transparent distribution according to DAO-approved rules. The token features EIP-2612 permits, emergency controls, and time-locked transitions for secure decentralized governance. RIPE is distributed via Lootbox rewards, BondRoom purchases, and can be locked in RipeGov for enhanced governance power.
Architecture & Modules
RipeToken is built using a modular architecture that inherits comprehensive ERC20 functionality:
Erc20Token Module
Location:
contracts/tokens/modules/Erc20Token.vyPurpose: Provides complete ERC20 token functionality with advanced features
Key Features:
Standard ERC20 operations (transfer, approve, allowance)
EIP-2612 permit functionality for gasless approvals
Blacklist system for compliance
Pause mechanism for emergency stops
Time-locked governance transitions
Secure minting and burning capabilities
Exported Interface: Complete token interface via
token.__interface__
Module Initialization
System Architecture Diagram
Data Structures
PendingHq Struct
Tracks pending RipeHq address changes:
State Variables
Token Information (Immutable)
TOKEN_NAME: String[64]- "Ripe DAO Governance Token"TOKEN_SYMBOL: String[32]- "RIPE"TOKEN_DECIMALS: uint8- 18 decimalsVERSION: String[8]- "v1.0.0"
Core ERC20 State
balanceOf: HashMap[address, uint256]- Token balancesallowance: HashMap[address, HashMap[address, uint256]]- Spending approvalstotalSupply: uint256- Total token supply
Security and Governance
ripeHq: address- Current RipeHq contract addressblacklisted: HashMap[address, bool]- Blacklisted addressesisPaused: bool- Token pause statependingHq: PendingHq- Pending RipeHq change datahqChangeTimeLock: uint256- Time lock for RipeHq changes
EIP-712 Support
nonces: HashMap[address, uint256]- Permit nonces for each addressDomain separator components for signature validation
Constants and Immutable
MIN_HQ_TIME_LOCK: uint256- Minimum time lock for RipeHq changesMAX_HQ_TIME_LOCK: uint256- Maximum time lock for RipeHq changesVarious EIP-712 and cryptographic constants
Constructor
__init__
Initializes the RipeToken with comprehensive configuration parameters.
Parameters
_ripeHq
address
RipeHq contract address (empty for initial deployment)
_initialGov
address
Initial governance address (for setup phase)
_minHqTimeLock
uint256
Minimum time lock for RipeHq changes
_maxHqTimeLock
uint256
Maximum time lock for RipeHq changes
_initialSupply
uint256
Initial token supply to mint
_initialSupplyRecipient
address
Recipient of initial supply
Returns
Constructor does not return any values
Access
Called only during deployment
Example Usage
Example Output: Token deployed with name "Ripe DAO Governance Token", symbol "RIPE", 18 decimals, initial supply minted to recipient
Core ERC20 Functions
name
Returns the token name.
Returns
String[64]
"Ripe DAO Governance Token"
Access
Public view function
symbol
Returns the token symbol.
Returns
String[32]
"RIPE"
Access
Public view function
decimals
Returns the number of decimal places.
Returns
uint8
18 decimals
Access
Public view function
totalSupply
Returns the total token supply.
Returns
uint256
Total supply of Ripe tokens
Access
Public view function
balanceOf
Returns the token balance of an account.
Parameters
_account
address
Account to check
Returns
uint256
Token balance of the account
Access
Public view function
Transfer Functions
transfer
Transfers tokens from caller to recipient.
Parameters
_recipient
address
Address to receive tokens
_amount
uint256
Amount to transfer
Returns
bool
True if transfer successful
Access
Public function (requires caller not blacklisted, token not paused)
Events Emitted
Transfer- Contains sender, recipient, and amount
Example Usage
transferFrom
Transfers tokens from one address to another using allowance.
Parameters
_sender
address
Address to send from
_recipient
address
Address to receive tokens
_amount
uint256
Amount to transfer
Returns
bool
True if transfer successful
Access
Public function (requires sufficient allowance, parties not blacklisted)
Events Emitted
Transfer- Contains sender, recipient, and amountApproval- If allowance is updated
Example Usage
Approval Functions
approve
Sets spending allowance for a spender.
Parameters
_spender
address
Address authorized to spend
_amount
uint256
Amount approved for spending
Returns
bool
True if approval successful
Access
Public function (requires parties not blacklisted, token not paused)
Events Emitted
Approval- Contains owner, spender, and amount
Example Usage
allowance
Returns the spending allowance.
Parameters
_owner
address
Token owner
_spender
address
Authorized spender
Returns
uint256
Current allowance amount
Access
Public view function
increaseAllowance
Increases the spending allowance.
Parameters
_spender
address
Address to increase allowance for
_amount
uint256
Amount to increase by
Returns
bool
True if increase successful
Access
Public function (requires parties not blacklisted, token not paused)
decreaseAllowance
Decreases the spending allowance.
Parameters
_spender
address
Address to decrease allowance for
_amount
uint256
Amount to decrease by
Returns
bool
True if decrease successful
Access
Public function (requires parties not blacklisted, token not paused)
Minting and Burning Functions
mint
Mints new Ripe tokens (RipeToken-specific function).
Parameters
_recipient
address
Address to receive new tokens
_amount
uint256
Amount of tokens to mint
Returns
bool
True if mint successful
Access
Only callable by addresses authorized through RipeHq's canMintRipe validation
Events Emitted
Transfer- Contains zero address as sender, recipient, and amount
Example Usage
Example Output: Mints 500 RIPE to user, increases total supply
burn
Burns tokens from caller's balance.
Parameters
_amount
uint256
Amount of tokens to burn
Returns
bool
True if burn successful
Access
Public function (requires token not paused, sufficient balance)
Events Emitted
Transfer- Contains sender, zero address as recipient, and amount
Example Usage
EIP-2612 Permit Functions
DOMAIN_SEPARATOR
Returns the EIP-712 domain separator.
Returns
bytes32
Current domain separator hash
Access
Public view function
nonces
Returns the current permit nonce for an address.
Parameters
_owner
address
Address to check nonce for
Returns
uint256
Current nonce value
Access
Public view function
permit
Sets approval using a signed message (gasless approval).
Parameters
_owner
address
Token owner granting approval
_spender
address
Address authorized to spend
_value
uint256
Approval amount
_deadline
uint256
Signature expiration timestamp
_signature
Bytes[65]
EIP-712 signature
Returns
bool
True if permit successful
Access
Public function (signature must be valid and not expired)
Events Emitted
Approval- Contains owner, spender, and value
Example Usage
Blacklist Functions
blacklisted
Checks if an address is blacklisted.
Parameters
_addr
address
Address to check
Returns
bool
True if address is blacklisted
Access
Public view function
setBlacklist
Adds or removes an address from the blacklist.
Parameters
_addr
address
Address to blacklist/unblacklist
_shouldBlacklist
bool
True to blacklist, False to remove
Returns
bool
True if operation successful
Access
Only callable by addresses authorized through RipeHq's canSetTokenBlacklist
Events Emitted
BlacklistModified- Contains address and blacklist status
Example Usage
burnBlacklistTokens
Burns tokens from a blacklisted address.
Parameters
_addr
address
Blacklisted address to burn from
_amount
uint256
Amount to burn (default: entire balance)
Returns
bool
True if burn successful
Access
Only callable by RipeHq governance
Events Emitted
Transfer- Contains address, zero address, and amount burned
RipeHq Management Functions
ripeHq
Returns the current RipeHq contract address.
Returns
address
Current RipeHq contract address
Access
Public view function
hasPendingHqChange
Checks if there's a pending RipeHq address change.
Returns
bool
True if RipeHq change is pending
Access
Public view function
initiateHqChange
Initiates a time-locked change of RipeHq address.
Parameters
_newHq
address
New RipeHq contract address
Returns
Function does not return any values
Access
Only callable by RipeHq governance
Events Emitted
HqChangeInitiated- Contains previous HQ, new HQ, and confirmation block
Example Usage
confirmHqChange
Confirms a pending RipeHq change after time lock.
Returns
bool
True if change confirmed, False if validation failed
Access
Only callable by RipeHq governance
Events Emitted
HqChangeConfirmed- Contains previous HQ, new HQ, initiation block, and confirmation block
Example Usage
cancelHqChange
Cancels a pending RipeHq change.
Access
Only callable by RipeHq governance
Events Emitted
HqChangeCancelled- Contains cancelled HQ, initiation block, and confirmation block
isValidNewRipeHq
Validates if an address can be set as the new RipeHq.
Parameters
_newHq
address
Address to validate
Returns
bool
True if address is valid RipeHq
Access
Public view function
Time Lock Configuration Functions
hqChangeTimeLock
Returns the current time lock for RipeHq changes.
Returns
uint256
Current time lock in blocks
Access
Public view function
setHqChangeTimeLock
Updates the RipeHq change time lock.
Parameters
_newTimeLock
uint256
New time lock period in blocks
Returns
bool
True if update successful
Access
Only callable by RipeHq governance (when no pending governance changes)
Events Emitted
HqChangeTimeLockModified- Contains previous and new time lock values
isValidHqChangeTimeLock
Validates a proposed time lock value.
Parameters
_newTimeLock
uint256
Proposed time lock value
Returns
bool
True if time lock is valid
Access
Public view function
minHqTimeLock
Returns the minimum allowed time lock.
Returns
uint256
Minimum time lock in blocks
Access
Public view function
maxHqTimeLock
Returns the maximum allowed time lock.
Returns
uint256
Maximum time lock in blocks
Access
Public view function
Pause Functions
isPaused
Returns the token's pause state.
Returns
bool
True if token is paused
Access
Public view function
pause
Pauses or unpauses all token operations.
Parameters
_shouldPause
bool
True to pause, False to unpause
Access
Only callable by RipeHq governance
Events Emitted
TokenPauseModified- Contains new pause state
Example Usage
Setup Functions
finishTokenSetup
Completes initial token setup by setting RipeHq (one-time use).
Parameters
_newHq
address
RipeHq contract address
_timeLock
uint256
Time lock duration (0 uses minimum)
Returns
bool
True if setup successful
Access
Only callable by initial governance (one-time use during deployment)
Events Emitted
InitialRipeHqSet- Contains HQ address and time lock value
Example Usage
Last updated