Skip to content

Commit

Permalink
WIP fully async vault
Browse files Browse the repository at this point in the history
  • Loading branch information
hieronx committed Aug 21, 2024
1 parent dfa51af commit caece4b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/ControlledAsyncDeposits.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {ERC20} from "solmate/tokens/ERC20.sol";
* To allow partial claims, the deposit and mint functions would need to allow for pro rata claims.
* Conversions between claimable assets/shares should be checked for rounding safety.
*/
contract ControlledAsyncDeposits is BaseERC7540, IERC7540Deposit {
abstract contract BaseControlledAsyncDeposits is BaseERC7540, IERC7540Deposit {
uint256 internal _totalPendingAssets;
mapping(address => PendingDeposit) internal _pendingDeposit;
mapping(address => ClaimableDeposit) internal _claimableDeposit;
Expand All @@ -32,8 +32,6 @@ contract ControlledAsyncDeposits is BaseERC7540, IERC7540Deposit {
uint256 shares;
}

constructor(ERC20 _asset, string memory _name, string memory _symbol) BaseERC7540(_asset, _name, _symbol) {}

function totalAssets() public view override returns (uint256) {
// total assets pending redemption must be removed from the reported total assets
// otherwise pending assets would be treated as yield for outstanding shares
Expand Down Expand Up @@ -142,3 +140,7 @@ contract ControlledAsyncDeposits is BaseERC7540, IERC7540Deposit {
return interfaceId == type(IERC7540Deposit).interfaceId || super.supportsInterface(interfaceId);
}
}

contract ControlledAsyncDeposits is BaseControlledAsyncDeposits {
constructor(ERC20 _asset, string memory _name, string memory _symbol) BaseERC7540(_asset, _name, _symbol) {}
}
15 changes: 15 additions & 0 deletions src/FullyAsyncVault.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import {BaseERC7540} from "src/BaseERC7540.sol";
import {BaseControlledAsyncDeposits} from "src/ControlledAsyncDeposits.sol";
import {BaseTimelockedAsyncWithdrawals} from "src/TimelockedAsyncWithdrawals.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";

contract FullyAsyncVault is BaseControlledAsyncDeposits, BaseTimelockedAsyncWithdrawals {
constructor(ERC20 _asset, string memory _name, string memory _symbol)
BaseControlledAsyncDeposits()
BaseTimelockedAsyncWithdrawals()
BaseERC7540(_asset, _name, _symbol)
{}
}
8 changes: 5 additions & 3 deletions src/TimelockedAsyncWithdrawals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {ERC20} from "solmate/tokens/ERC20.sol";
* To allow partial claims, the redeem and withdraw functions would need to allow for pro rata claims.
* Conversions between claimable assets/shares should be checked for rounding safety.
*/
contract TimelockedAsyncWithdrawals is BaseERC7540, IERC7540Redeem {
abstract contract BaseTimelockedAsyncWithdrawals is BaseERC7540, IERC7540Redeem {
uint32 public constant TIMELOCK = 3 days;

uint256 internal _totalPendingApproxAssets;
Expand All @@ -33,8 +33,6 @@ contract TimelockedAsyncWithdrawals is BaseERC7540, IERC7540Redeem {
uint32 claimableTimestamp;
}

constructor(ERC20 _asset, string memory _name, string memory _symbol) BaseERC7540(_asset, _name, _symbol) {}

function totalAssets() public view override returns (uint256) {
return ERC20(asset).balanceOf(address(this)) - _totalPendingApproxAssets;
}
Expand Down Expand Up @@ -149,3 +147,7 @@ contract TimelockedAsyncWithdrawals is BaseERC7540, IERC7540Redeem {
return interfaceId == type(IERC7540Redeem).interfaceId || super.supportsInterface(interfaceId);
}
}

contract TimelockedAsyncWithdrawals is BaseTimelockedAsyncWithdrawals {
constructor(ERC20 _asset, string memory _name, string memory _symbol) BaseERC7540(_asset, _name, _symbol) {}
}

0 comments on commit caece4b

Please sign in to comment.