Skip to content

Commit

Permalink
feat: update pool contract
Browse files Browse the repository at this point in the history
  • Loading branch information
bhargavaparoksham committed Jan 8, 2025
1 parent de1f280 commit 76c4a96
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 195 deletions.
115 changes: 49 additions & 66 deletions src/interfaces/IAssetPool.sol
Original file line number Diff line number Diff line change
@@ -1,73 +1,56 @@
// SPDX-License-Identifier: AGPL-3.0
// author: bhargavaparoksham

pragma solidity ^0.8.20;

import {IAssetPoolAddressesProvider} from './IAssetPoolAddressesProvider.sol';
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {IXToken} from "./IXToken.sol";
import {ILPRegistry} from "./ILPRegistry.sol";

interface IAssetPool {
/**
* @dev Emitted on deposit()
* @param user The address initiating the deposit
* @param onBehalfOf The beneficiary of the deposit, receiving the aTokens
* @param amount The amount deposited
**/
event Deposit(
address user,
address indexed onBehalfOf,
uint256 amount
);

/**
* @dev Emitted on withdraw()
* @param user The address initiating the withdrawal, owner of xTokens
* @param to Address that will receive the underlying
* @param amount The amount to be withdrawn
**/
event Withdraw(address indexed user, address indexed to, uint256 amount);


/**
* @dev Emitted when the pause is triggered.
*/
event Paused();

/**
* @dev Emitted when the pause is lifted.
*/
event Unpaused();

/**
* @dev Deposits an `amount` of stable asset, receiving in return overlying xTokens.
* - E.g. User deposits 100 USDC and gets in return 100 xAsset
* @param amount The amount to be deposited
* @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
* wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
* is a different wallet
**/
function deposit(
uint256 amount,
address onBehalfOf
) external;

/**
* @dev Withdraws an `amount` of stable asset, burning the equivalent xTokens owned
* E.g. User has 100 xAsset, calls withdraw() and receives 100 USDC, burning the 100 xAsset
* @param amount The underlying amount to be withdrawn
* - Send the value type(uint256).max in order to withdraw the whole xToken balance
* @param to Address that will receive the underlying, same as msg.sender if the user
* wants to receive it on his own wallet, or a different address if the beneficiary is a
* different wallet
* @return The final amount withdrawn
**/

function withdraw(
uint256 amount,
address to
) external returns (uint256);

function getAddressesProvider() external view returns (IAssetPoolAddressesProvider);

function setPause(bool val) external;

function paused() external view returns (bool);
enum CycleState {
REBALANCING, // LPs can rebalance
IN_CYCLE // Normal cycle operation
}

event DepositReceived(address indexed user, uint256 amount, uint256 cycleNumber);
event WithdrawalRequested(address indexed user, uint256 xTokenAmount, uint256 cycleNumber);
event XTokensClaimed(address indexed user, uint256 amount, uint256 cycleNumber);
event DepositTokensClaimed(address indexed user, uint256 depositTokenAmount, uint256 cycleNumber);
event CycleStarted(uint256 cycleNumber, uint256 timestamp);
event CycleStateUpdated(CycleState newState);
event Rebalanced(address indexed lp, uint256 lpAdded, uint256 lpWithdrawn);
event RebalancingCompleted(uint256 cycleNumber);

error InvalidState();
error NotLP();
error InvalidAmount();
error InsufficientBalance();
error NotInRebalancingPeriod();
error RebalancingAlreadyDone();
error NothingToClaim();
error ZeroAddress();

function deposit(uint256 amount) external;
function requestWithdrawal(uint256 xTokenAmount) external;
function claimXTokens() external;
function claimDepositTokens() external;
function rebalance(uint256 lpAdded, uint256 lpWithdrawn) external;
function checkAndStartNewCycle() external;

function assetToken() external view returns (IXToken);
function depositToken() external view returns (IERC20);
function lpRegistry() external view returns (ILPRegistry);
function assetSymbol() external view returns (string memory);
function cycleLength() external view returns (uint256);
function rebalancingPeriod() external view returns (uint256);
function currentCycleStart() external view returns (uint256);
function currentCycleNumber() external view returns (uint256);
function currentState() external view returns (CycleState);
function unclaimedDeposits(address user) external view returns (uint256);
function unclaimedWithdrawals(address user) external view returns (uint256);
function lastDepositCycle(address user) external view returns (uint256);
function lastWithdrawalCycle(address user) external view returns (uint256);
function cycleRebalanced(address lp) external view returns (bool);
function rebalancedLPCount() external view returns (uint256);
}
61 changes: 0 additions & 61 deletions src/interfaces/IAssetPoolAddressesProvider.sol

This file was deleted.

Loading

0 comments on commit 76c4a96

Please sign in to comment.