How It Works
- Minting/Burning:
The owner (protocol governance or AI agent) mints or burns tokens based on inflation data fetched from the oracle.
- Dynamic Reserves:
Reserves can be adjusted manually (later replaced with AI-managed contracts).
Transaction fees can be redirected to the treasury.
- Oracle Integration:
The oracle contract allows updates to the inflation rate (mocked here; can be replaced with Chainlink oracles).
Lending Protocol:
Features in the Contract
- Collateralization Ratio:
Ensures users deposit sufficient collateral (e.g., 150% of the loan amount).
- Inflation Adjustment:
Debt is adjusted dynamically based on inflation using the oracle's data.
- Repayment:
Borrowers can repay their loans partially or fully.
- Collateral Withdrawal:
Borrowers can withdraw collateral as long as the collateralization ratio is maintained.
- Liquidation:
Positions are liquidated if collateral falls below the liquidation threshold (e.g., 110%).
Examples:
- Deposit Collateral and Borrow:
const tx = await lendingContract.depositAndBorrow(debtAmount, { value: collateralAmount });
- Repay Loan:
await flatcoin.approve(lendingContract.address, repaymentAmount); const tx = await lendingContract.repayLoan(repaymentAmount);
- Withdraw Collateral:
const tx = await lendingContract.withdrawCollateral(collateralAmount);
- Liquidate a Position:
const tx = await lendingContract.liquidate(borrowerAddress);