Protocol Module
Overview
The satay::protocol
module manages the protocol-level configuration, governance, and fee structure in the Satay ecosystem. It provides functionality for setting and managing the protocol's governance, protocol fees, and protocol fee recipients.
Structs
Protocol
The Protocol
struct represents the protocol-level configuration. It stores governance-related information, including the current governance address, pending governance, protocol fees, and the recipient of protocol fees.
ProtocolController
The ProtocolController
struct provides the control and signing capabilities for the protocol, storing the ExtendRef
used for extending the protocol's object.
FeeConfig
The FeeConfig
struct stores information about the protocol's management and performance fees.
Events
GovernanceChanged
Emitted when the governance of the protocol is changed.
Constants
MAX_PROTOCOL_FEE:
u64 = 5000
– Maximum protocol fee allowed (in BPS).DEFAULT_PROTOCOL_FEE:
u64 = 1000
– Default protocol fee (in BPS).PROTOCOL_SEED:
vector<u8> = b"00000000Protocol"
– Seed used to create the protocol object.
Error Codes
ECONFIG_NOT_INITIALIZED: Configuration has not been initialized.
ENOT_GOVERNANCE: Caller is not the governance account.
ENOT_PENDING_GOVERNANCE: Caller is not the pending governance account.
EINVALID_PROTOCOL_FEE: Protocol fee exceeds the maximum allowed value.
EZERO_ADDRESS_ERROR: Zero address is invalid for certain actions (e.g., fee recipient).
Public Functions
Module Initialization
init_module(signer: &signer)
: Initializes the protocol module by creating the protocol and protocol controller objects.
Governance Management
set_governance(account: &signer, governance: address)
: Sets the pending governance account. Only the current governance account can call this function.accept_governance(account: &signer)
: Accepts the pending governance address, promoting it to the current governance address. Only the pending governance account can call this function.
Fee Management
set_protocol_fee(account: &signer, protocol_fee: u64)
: Sets the protocol fee. The fee must not exceed the maximum allowed (MAX_PROTOCOL_FEE
).set_protocol_fee_recipient(account: &signer, recipient: address)
: Sets the recipient of the protocol fee. The recipient address must not be zero.
Friend Functions
get_signer(): signer acquires ProtocolController
: Returns the signer for extending the protocol, used by friend modules to interact with the protocol.
View Functions
is_governance(account: address): bool acquires Protocol
: Checks if the provided account is the current governance account.is_pending_governance(account: address): bool acquires Protocol
: Checks if the provided account is the pending governance account.get_governance(): address acquires Protocol
: Returns the current governance address.get_pending_governance(): Option<address> acquires Protocol
: Returns the pending governance address, if any.get_address(): address
: Returns the address of the protocol.get_protocol_fee(): u64 acquires Protocol
: Returns the current protocol fee.get_protocol_fee_recipient(): address acquires Protocol
: Returns the address that receives the protocol fee.get_deployer(): address
: Returns the address of the deployer (the account that deployed the protocol).get_performance_fee(): u64 acquires Protocol
: Returns the performance fee for the protocol.get_management_fee(): u64 acquires Protocol
: Returns the management fee for the protocol.
Access Control
Governance Account: The account designated as the governance account has full control over the protocol's configuration, including changing fees and governance.
Pending Governance: When a governance transition is in progress, the pending governance account must accept its role to finalize the change.
Friend Functions: The
satay::wrapper
,satay::strategy
, andsatay::vault
modules are friends ofsatay::protocol
, giving them access to certain internal protocol functions.
Last updated