Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Themis V2 contract is divided into two main parts.
The first part is the M0 Pool contract, which mainly provides deposit, debit, clearing, and flash credit for mainstream tokens, and issues corresponding t/s/v tokens for deposit and debit. The related contract mainly contains modules for the configuration of the pool each pool price calculation and interest rate, clearing, and other configuration functions. The auxiliary contract mainly contains rewards, ui data provider, incentive data provider, wallet balance provider and WETH gateway.
The second part is the M1 Pool contract, which mainly provides Uniswap V2/V3, and other third-party LP lending functions, and issues corresponding s/v tokens for the corresponding lending behavior. The relevant contract mainly contains modules for the configuration of the pools each pool price calculation and interest rate, clearing, and other configuration functions.
The available M1Pool borrow cap is from the M0 Pool, and the corresponding assets and s/v token borrowed by the user are minted from the M0 Pool.
Core protocol contracts fall in following 4 categories:
Configuration
Pool logic
Tokenization
Misc
Themis Protocol V2 implements an access control list to segregate powers and/or benefits that can be allocated to different entities on the protocol. The roles and holders are managed in the ACLManager.sol, which keeps track of the individual roles and its holders.
The main addresses register of the protocol, containing address of *core protocol contracts *and ACL admin. It acts as factory of proxies and admin of those. The owner of this contract has the right to set/update implementation of the upgradable contracts. The latest contract addresses should be retrieved from this contract by making the appropriate calls.
Contains a list of active
PoolAddressProvider addresses, for different markets. It is used for indexing all Themis protocol’s markets.
Oracle Sentinel validates if operations are allowed depending on the PriceOracle health. Once the PriceOracle gets up after an outage/downtime, users can make their positions healthy during a grace period.
Implements the calculation of the interest rates depending on the reserve state. This contract holds the information needed to calculate and update the yield relating to specific liquidity pools. Each contract stores the optimised base curves using the corresponding parameters of each asset. This means that there is a mathematical function which determines the yield of each liquidity pool, with the yield changing based on the amount of borrowed funds and the total liquidity (i.e. utilisation) of the pool.
The main entry point into the Themis Protocol. Most user interactions with the Themis Protocol occur via the Pool contract. Pool is owned by the PoolAddressesProvider of the specific market. All admin functions are callable by the PoolConfigurator contract, which is defined in PoolAddressesProvider.
Provider configuration methods for the Pool contract. The write methods of this contract can only be called by addresses with corresponding permission-ed system roles that are managed by ACLManager.
Yield-generating tokens that are minted and burnt upon supply and withdraw of assets to Themis Pool
The special type of aToken that are minted and burnt upon supply and withdraw of assets that has voting power associated (which can be delegated) with them.
The non-transferable interest accruing, stable rate tokenised borrows.
The non-transferable interest accruing, variable rate tokenised borrows.
Contract to get asset prices, manage price sources and update the fallback oracle.
Peripheral contract to collect and pre-process information from the Pool.
This contract is responsible for configuring the different rewards and the claim process.
These are isolated contracts that manages the procedure of the rewards transfer at claim. This allows the RewardsController to support any custom rewards like Staked Themis, common ERC20 or even NFT.
Helper contract to fetch Incentives Data. It is used by Themis UI for reward balance info.
Helper contract, used by Themis UI, to fetch Pool Data such reserves list, all reserves data like liquidity, token addresses, rate strategy etc.
Only ERC20 tokens can be supplied & borrowed from the Themis Protocol V2 pools. To facilitate using token native to the chain (such ETH on Ethereum or Matic on polygon) a helper contract is used to support single tx supply, borrow, repay and withdraw.
Used for getting multiple tokens balance for one user address. This contract is used by Themis backend to reduce the number of blockchain calls for fetching user balance.
Core protocol contracts fall in following 4 categories:
Configuration
M1Pool logic
Tokenization
Misc
M1 Configuration is similar to M0
The main entry point into the Themis Protocol. Most user interactions with the Themis Protocol occur via the Pool contract. Pool is owned by the PoolAddressesProvider of the specific market. All admin functions are callable by the PoolConfigurator contract, which is defined in PoolAddressesProvider.
Provider configuration methods for the M1 Pool contract. The write methods of this contract can only be called by addresses with corresponding permission-ed system roles that are managed by ACLManager.
M1 tokenization configuration is Similar to M0
Helper contract, used by Themis UI, to fetch Pool Data such reserves list, all reserves data like liquidity, token addresses, rate strategy etc.
M1CollateralValueCalculator
M1 asset-specific calculation price contract, mainly used for Uniswap v2/v3 LP, Balancer BPT, Arrakis Vault, Curve LP etc. value calculation
The M1Pool.sol
contract is the main user facing contract of the protocol. It exposes the liquidity management methods that can be invoked using either Solidity or Web3 libraries.
User can borrow the amount
of asset
by collateral the collateralAddress
asset to M1Pool
When borrowM1
, the M1Pool contract must have** allowance()
to spend funds on behalf of msg.sender ** for at-least** amount ** for the** asset **being supplied. This can be done via the standard ERC20/ERC721 approve()
method on the underlying token contract.
Referral program is currently inactive, you can pass 0 as referralCode
. This program may be activated in the future through an Aave governance proposal.
collateralAddress
address
Contract address of collateral assets
collateralAmount
uint256
The number of collateral, send in the tokenId when it is uniswapV3, and send in the number of collateral to be deposit for the others
asset
address
address of the underlying asset
amount
uint256
amount to be borrowed, expressed in wei units
interestRateMode
uint256
the type of borrow debt. Stable: 1, Variable: 2
referralCode
uint16
referral code for our referral program. Use 0 for no referral code.
onBehalfOf
address
address of user who will incur the asset. Use msg.sender when not calling on behalf of a different user.
userRecordId
uint256
Record ID generated after collateralizing assets
collateralAmount
uint256
Increase in the amount of collateral assets
userRecordId
uint256
Record ID generated after collateralizing assets
collateralAmount
uint256
Reducing the amount of collateral assets
userRecordId
uint256
Record ID generated after collateralizing assets
amount
uint256
The amount of new borrow needs
onBehalfOf
address
address of user who will incur the asset.
collateralAddress
address
contract address of the collateral asset
userRecordId
uint256
Record ID generated after collateralizing assets
asset
address
The contract address of the borrowing asset
amount
uint256
the amount of reapy
onBehalfOf
address
the receiver of the collateral, when fully repaid
Liquidation operation based on the record ID generated by the collateral, anyone can call this interface when the collateral record triggers the liquidation.
recordId
uint256
Record ID generated after collateralizing assets
Check if the collateral record has been liquidated against the record ID
currentCollateralValueInBaseCurrency
uint256
Current value of the collateral
collateralDebt
uint256
current debt of the collateral
collateralDebtInBaseCurrency
uint256
current debt value of the collateral
liquidationThreshold
uint256
Liquidation threshold
collateralCurrentRatio
uint256
Current Loan risk, when its bigger than Liquidation threshold, the liquidation method can be call.
Get information about how many collateral records the user has based on the user's address
user
address
user address
uint256[]
current collateral record of user
Get the collateral details based on the collateral record ID.
Get the total number of debts for which the user borrowed a certain asset
Access Control List Manager is the main registry of system roles and permissions. ACLManager allows a Role Admin to manage roles. Role Admin is itself a role that is managed by the DEFAULT_ADMIN_ROLE.
DEFAULT_ADMIN_ROLE is held by the*ACLAdmin,*which is initialized in PoolAddressesProvider .
On Ethereum chain PoolAddressesProvider , is owned by Aave Governance. In networks other than Ethereum, either theCrosschain Governance BridgesorCommunity Multisigsare used to manage the PoolAddressesProvider .
Below we outline the powers/responsibilities of the roles and the specific methods that are only accessible to the holders of these roles.
FLASH_BORROWER
Flash loan premium is waived for the holders of this role. ⛔ Does not include flashLoanSimple
flashLoan
BRIDGE
Can leverage the Portal feature
mintUnbacked backUnbacked
ASSET_LISTING_ADMIN
Can update
asset oracle sources
fallback oracle
add new assets to the Aave market
setAssetSources
setFallbackOracle
initReserves
RISK_ADMIN
Can update
grace period of Oracle Sentinels
reserve params
unbacked mint cap
liquidation protocol fee
existing eMode categories and create new. (not category 0)
add/remove asset in silo mode
setGracePeriod
setReserveBorrowing
configureReserveAsCollateral
setReserveStableRateBorrowing
setReserveFreeze
setBorrowableInIsolation
setReserveFactor
setDebtCeiling
setBorrowCap
setSupplyCap
setLiquidationProtocolFee
setEModeCategory
setAssetEModeCategory
setUnbackedMintCap
setReserveInterestRateStrategyAddress
setSiloedBorrowing
ACL_ADMIN
Manage the role admins in the ACLManager
setRoleAdmin
addPoolAdmin
removePoolAdmin
addEmergencyAdmin
removeEmergencyAdmin
addRiskAdmin
removeRiskAdmin
addFlashBorrower
removeFlashBorrower
addBridge
removeBridge
addAssetListingAdmin
removeAssetListingAdmin
EMERGENCY_ADMIN
Can pause/unpause the pool or individual reserve
setPoolPause
POOL_ADMIN
Can
update token implementations
drop reserves
pause/unpause reserves
activate/deactivate reserves
update premiums
do all the things available to RISK_ADMIN & ASSET_LISTING_ADMIN
all methods available to RISK_ADMIN
all methods available to ASSET_LISTING_ADMIN
dropReserve
updateAToken
updateStableDebtToken
updateVariableDebtToken
setReserveActive
updateBridgeProtocolFee
updateFlashloanPremiumTotal
updateFlashloanPremiumToProtocol
Returns true if the address has POOL_ADMIN role.
Returns true if the address has EMERGENCY_ADMIN role.
Returns true if the address has RISK_ADMIN role.
Returns true if the address has FLASH_BORROWER role.
Returns true if the address has BRIDGE role.
Returns true if the address has ASSET_LISTING_ADMIN role.
setRoleAdmin(bytes32 role, bytes32 adminRole)
Setup admin to manage Roles.
This method can only be called by address with DEFAULT_ADMIN_ROLE .
role
bytes32
keccak256 hash of one of the following:
POOL_ADMIN
EMERGENCY_ADMIN
RISK_ADMIN
FLASH_BORROWER
BRIDGE
ASSET_LISTING_ADMIN
adminRole
bytes32
adminRole responsible for role. 0x00 is reserved for DEFAULT_ADMIN_ROLE
Add address to the list of members in POOL_ADMIN role. Holders of this role can update token implementations, drop, (un) pause and (de)activate reserves, update premiums and do everything the ASSET_LISTING_ADMIN and RISK_ADMIN can do.
Can be called only byRole Admin, specified byAave Governance, responsible for managing POOL_ADMIN role.
admin
address
address which will be granted POOL_ADMIN role.
Remove given address from the list of members in POOL_ADMIN role.
Can be called only byRole Admin, specified byAave Governance, responsible for managing POOL_ADMIN role.
admin
address
address for which POOL_ADMIN role permissions must be revoked.
Add address to the list of members in EMERGENCY_ADMIN role. Holders of this role can pause and unpause the pool or an individual reserve.
Can be called only byRole Admin, specified byAave Governance, responsible for managing EMERGENCY_ADMIN role.
admin
address
address which will be granted EMERGENCY_ADMIN role.
Remove given address from the list of members in EMERGENCY_ADMIN role.
Can be called only byRole Admin, specified byAave Governance, responsible for managing EMERGENCY_ADMIN role.
admin
address
address for which EMERGENCY_ADMIN role permissions must be revoked.
Add address to the list of members in RISK_ADMIN role. Holders of this role can update grace period of Oracle Sentinels, reserve params, unbacked mint cap,liquidation fee and eMode categories.
admin
address
address which will be granted RISK_ADMIN role.
Remove given address from the list of members in RISK_ADMIN role.
admin
address
address for which RISK_ADMIN role permissions must be revoked.
Add address to the list of members in FLASH_BORROWER role. Holders of this role do not pay premium for flash loan (Does not apply to flashLonaSimple).
Remove given address from the list of members in FLASH_BORROWER role.
admin
address
address for which FLASH_BORROWER role permissions must be revoked.
Add contract address to the list ofbridges. Holders of this role can leverage the Portal feature to seamlessly move supplied assets across Aave V3 markets on different networks.
Can be called only byRole Admin, specified byAave Governance, responsible for managing BRIDGE role.
bridge
address
address which will be granted BRIDGE role.
Remove contract address from the list of bridges.
Can be called only byRole Admin, specified byAave Governance, responsible for managing BRIDGE role.
bridge
address
address for which BRIDGE role permissions must be revoked.
Add address to the list of member in ASSET_LISTING_ADMIN role. Holder of this role can update oracles & add new asset to the Aave market. ``
admin
address
address which will be granted ASSET_LISTING_ADMIN role.
Remove address from the list of members in ASSET_LISTING_ADMIN role.
admin
address
address for which ASSET_LISTING_ADMIN role permissions must be revoked.
This contract validates if the operations are allowed depending on the PriceOracle health.
The PriceOracle
is considered healthy once its completely up and the grace period has passed.
function isBorrowAllowed()
function isLiquidationAllowed()
function getSequencerOracle()
function getGracePeriod()
function setSequencerOracle(address newSequencerOracle)
Can be called only by PoolAdmin.
function setGracePeriod(uint256 newGracePeriod)
Can be called only by PoolAdmin or RiskAdmin.