Skip to content

Commit

Permalink
feat: update asset pool to interact with new xToken design
Browse files Browse the repository at this point in the history
  • Loading branch information
bhargavaparoksham committed Jan 15, 2025
1 parent 22197c0 commit 204b591
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 92 deletions.
58 changes: 41 additions & 17 deletions src/interfaces/IAssetPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ pragma solidity ^0.8.20;
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {IXToken} from "./IXToken.sol";
import {ILPRegistry} from "./ILPRegistry.sol";
import {IAssetOracle} from "./IAssetOracle.sol";

interface IAssetPool {
enum CycleState {
ACTIVE, // Normal operation
REBALANCING // LPs rebalancing reserves
REBALANCING // LPs rebalancing reserves
}

// --------------------------------------------------------------------------------
// EVENTS
// --------------------------------------------------------------------------------
event DepositRequested(address indexed user, uint256 amount, uint256 indexed cycleIndex);
event DepositCancelled(address indexed user, uint256 amount, uint256 indexed cycleIndex);
event AssetClaimed(address indexed user, uint256 amount, uint256 indexed cycleIndex);
event BurnRequested(address indexed user, uint256 xTokenAmount, uint256 indexed cycleIndex);
event BurnCancelled(address indexed user, uint256 amount, uint256 indexed cycleIndex);
event ReserveWithdrawn(address indexed user, uint256 amount, uint256 indexed cycleIndex);
event Rebalanced(address indexed lp, uint256 amount, bool isDeficit, uint256 indexed cycleIndex);
event Rebalanced(address indexed lp, uint256 amount, bool isDeposit, uint256 indexed cycleIndex);
event CycleStarted(uint256 indexed cycleIndex, uint256 timestamp);
event CycleTimeUpdated(uint256 newCycleTime);
event RebalanceTimeUpdated(uint256 newRebalanceTime);
Expand All @@ -30,6 +34,9 @@ interface IAssetPool {
int256 rebalanceAmount
);

// --------------------------------------------------------------------------------
// ERRORS
// --------------------------------------------------------------------------------
error InvalidAmount();
error InsufficientBalance();
error NotLP();
Expand All @@ -39,28 +46,36 @@ interface IAssetPool {
error ZeroAddress();
error NothingToClaim();
error NothingToCancel();
error MintOrBurnPending();

// User actions
// --------------------------------------------------------------------------------
// USER ACTIONS
// --------------------------------------------------------------------------------
function depositReserve(uint256 amount) external;
function cancelDeposit() external;
function mintAsset(address user) external;
function burnAsset(uint256 xTokenAmount) external;
function burnAsset(uint256 assetAmount) external;
function cancelBurn() external;
function withdrawReserve(address user) external;

// LP actions
// --------------------------------------------------------------------------------
// LP ACTIONS
// --------------------------------------------------------------------------------
function initiateRebalance() external;
function rebalancePool(address lp, uint256 amount, bool isDeposit) external;

// Governance actions
// --------------------------------------------------------------------------------
// GOVERNANCE ACTIONS
// --------------------------------------------------------------------------------
function updateCycleTime(uint256 newCycleTime) external;
function updateRebalanceTime(uint256 newRebalanceTime) external;
function pausePool() external;
function unpausePool() external;

// View functions
// --------------------------------------------------------------------------------
// VIEW FUNCTIONS
// --------------------------------------------------------------------------------
function getGeneralInfo() external view returns (
uint256 _reserveBalance,
uint256 _xTokenSupply,
CycleState _cycleState,
uint256 _cycleIndex,
Expand All @@ -76,25 +91,34 @@ interface IAssetPool {
int256 _rebalanceAmount
);

// State getters
// --------------------------------------------------------------------------------
// STATE GETTERS
// --------------------------------------------------------------------------------
function reserveToken() external view returns (IERC20);
function assetToken() external view returns (IXToken);
function lpRegistry() external view returns (ILPRegistry);
function assetOracle() external view returns (IAssetOracle);

function cycleIndex() external view returns (uint256);
function cycleState() external view returns (CycleState);
function nextRebalanceStartDate() external view returns (uint256);
function nextRebalanceEndDate() external view returns (uint256);
function cycleTime() external view returns (uint256);
function rebalanceTime() external view returns (uint256);
function reserveBalance() external view returns (uint256);
function totalDepositRequests() external view returns (uint256);
function totalRedemptionRequests() external view returns (uint256);
function totalRedemptionScaledRequests() external view returns (uint256);

function totalReserveBalance() external view returns (uint256);
function newReserveSupply() external view returns (uint256);
function newAssetSupply() external view returns (uint256);
function netReserveDelta() external view returns (int256);
function rebalanceAmount() external view returns (int256);

function rebalancedLPs() external view returns (uint256);
function hasRebalanced(address lp) external view returns (bool);
function depositRequests(address user) external view returns (uint256);
function redemptionScaledRequests(address user) external view returns (uint256);

function cycleTotalDepositRequests(uint256 cycle) external view returns (uint256);
function cycleTotalRedemptionRequests(uint256 cycle) external view returns (uint256);
function cycleDepositRequests(uint256 cycle, address user) external view returns (uint256);
function cycleRedemptionRequests(uint256 cycle, address user) external view returns (uint256);
function lastActionCycle(address user) external view returns (uint256);
function cycleRebalancePrice(uint256 _cycleIndex) external view returns (uint256);
}
function cycleRebalancePrice(uint256 cycle) external view returns (uint256);
}
Loading

0 comments on commit 204b591

Please sign in to comment.