Atlax
This is a full-stack, fully on-chain DeFi app that enables users to supply tokens and be rewarded, or borrow tokens against their collateral. The motivation stemmed from AAVE, but all code and architecture are original. The platform is deployed on the Polygon Mumbai testnet.
A full walkthrough of the platform, from supplying collateral to repaying a loan.
Key Features
The platform supports a core loop of supplying, earning, borrowing, and repaying, all governed by on-chain logic.
Supply & Earn Collateral
Users can supply 5 different test tokens (DAI, LINK, WMATIC, USDC, JEUR) to the platform as collateral. Upon depositing, you receive LAR tokens based on the USD value of your contribution.
Borrowing Logic
To borrow, your collateral value must be greater than the loan value, influenced by the LTV (Loan To Value) ratio of your collateral. This ensures the protocol remains solvent.
Repayment & Interest
The platform maintains a stable, constant APY rate for all borrowable tokens, so interest due does not fluctuate. When repaying, the user returns the borrowed tokens plus the accrued interest.
Withdraw Collateral
After settling a debt, users can retrieve their collateral. When a user withdraws, the platform burns a corresponding value of the LAR tokens that were awarded, completing the cycle.
Architecture & Key Concepts
The contract architecture is designed to be modular, secure, and connected to real-world data.
1. The Diamond Standard (EIP-2535)
The core logic uses the Diamond Standard, which partitions functionalities into distinct segments called 'facets'. This enhances adaptability and allows the contract to scale beyond the typical 24kb size limit, making future upgrades seamless.
2. Chainlink Oracles
To determine the value of collateral and loans, the contract employs Chainlink's AggregatorV3Interface. This provides up-to-date, real-time price feeds, which are critical for the platform's solvency.
3. Security & Standards
The contract utilizes OpenZeppelin's battle-tested libraries, including the IERC20 interface for all token interactions and theOwnable contract to establish secure contract ownership measures.