diff --git a/docs/LidoARMPublicSquashed.svg b/docs/LidoARMPublicSquashed.svg index 9b0c980..db25cb9 100644 --- a/docs/LidoARMPublicSquashed.svg +++ b/docs/LidoARMPublicSquashed.svg @@ -4,24 +4,25 @@ - - + + UmlClassDiagram - - + + -13 - -LidoARM -../src/contracts/LidoARM.sol - -Public: -   operator: address <<OwnableOperable>> -   MAX_PRICE_DEVIATION: uint256 <<AbstractARM>> -   PRICE_SCALE: uint256 <<AbstractARM>> -   CLAIM_DELAY: uint256 <<AbstractARM>> -   FEE_SCALE: uint256 <<AbstractARM>> +14 + +LidoARM +../src/contracts/LidoARM.sol + +Public: +   operator: address <<OwnableOperable>> +   MAX_PRICE_DEVIATION: uint256 <<AbstractARM>> +   PRICE_SCALE: uint256 <<AbstractARM>> +   CLAIM_DELAY: uint256 <<AbstractARM>> +   FEE_SCALE: uint256 <<AbstractARM>> +   liquidityAsset: address <<AbstractARM>>   token0: IERC20 <<AbstractARM>>   token1: IERC20 <<AbstractARM>>   traderate0: uint256 <<AbstractARM>> @@ -34,7 +35,7 @@   feeCollector: address <<AbstractARM>>   fee: uint16 <<AbstractARM>>   feesAccrued: uint112 <<AbstractARM>> -   lastTotalAssets: uint128 <<AbstractARM>> +   lastAvailableAssets: uint128 <<AbstractARM>>   liquidityProviderController: address <<AbstractARM>>   steth: IERC20 <<LidoLiquidityManager>>   weth: IWETH <<LidoLiquidityManager>> @@ -56,18 +57,18 @@    previewRedeem(shares: uint256): (assets: uint256) <<AbstractARM>>    requestRedeem(shares: uint256): (requestId: uint256, assets: uint256) <<AbstractARM>>    claimRedeem(requestId: uint256): (assets: uint256) <<AbstractARM>> -    setFee(_fee: uint256) <<onlyOwner>> <<AbstractARM>> -    setFeeCollector(_feeCollector: address) <<onlyOwner>> <<AbstractARM>> -    collectFees(): (fees: uint256) <<AbstractARM>> -    setLiquidityProviderController(_liquidityProviderController: address) <<onlyOwner>> <<AbstractARM>> -    approveStETH() <<onlyOperatorOrOwner>> <<LidoLiquidityManager>> -    requestStETHWithdrawalForETH(amounts: uint256[]): (requestIds: uint256[]) <<onlyOperatorOrOwner>> <<LidoLiquidityManager>> -    claimStETHWithdrawalForWETH(requestIds: uint256[]) <<onlyOperatorOrOwner>> <<LidoLiquidityManager>> -    initialize(_name: string, _symbol: string, _operator: address, _fee: uint256, _feeCollector: address, _liquidityProviderController: address) <<initializer>> <<LidoARM>> -Public: -    <<event>> AdminChanged(previousAdmin: address, newAdmin: address) <<Ownable>> -    <<event>> OperatorChanged(newAdmin: address) <<OwnableOperable>> -    <<event>> TraderateChanged(traderate0: uint256, traderate1: uint256) <<AbstractARM>> +    setLiquidityProviderController(_liquidityProviderController: address) <<onlyOwner>> <<AbstractARM>> +    setFee(_fee: uint256) <<onlyOwner>> <<AbstractARM>> +    setFeeCollector(_feeCollector: address) <<onlyOwner>> <<AbstractARM>> +    collectFees(): (fees: uint256) <<AbstractARM>> +    requestStETHWithdrawalForETH(amounts: uint256[]): (requestIds: uint256[]) <<onlyOperatorOrOwner>> <<LidoLiquidityManager>> +    claimStETHWithdrawalForWETH(requestIds: uint256[]) <<onlyOperatorOrOwner>> <<LidoLiquidityManager>> +    initialize(_name: string, _symbol: string, _operator: address, _fee: uint256, _feeCollector: address, _liquidityProviderController: address) <<initializer>> <<LidoARM>> +Public: +    <<event>> AdminChanged(previousAdmin: address, newAdmin: address) <<Ownable>> +    <<event>> OperatorChanged(newAdmin: address) <<OwnableOperable>> +    <<event>> TraderateChanged(traderate0: uint256, traderate1: uint256) <<AbstractARM>> +    <<event>> Deposit(owner: address, assets: uint256, shares: uint256) <<AbstractARM>>    <<event>> RedeemRequested(withdrawer: address, requestId: uint256, assets: uint256, queued: uint256, claimTimestamp: uint256) <<AbstractARM>>    <<event>> RedeemClaimed(withdrawer: address, requestId: uint256, assets: uint256) <<AbstractARM>>    <<event>> FeeCalculated(newFeesAccrued: uint256, assetIncrease: uint256) <<AbstractARM>> diff --git a/docs/LidoARMSquashed.svg b/docs/LidoARMSquashed.svg index 7d4280a..1a2c8bf 100644 --- a/docs/LidoARMSquashed.svg +++ b/docs/LidoARMSquashed.svg @@ -4,93 +4,92 @@ - - + + UmlClassDiagram - + 14 - -LidoARM -../src/contracts/LidoARM.sol - -Private: -   _gap: uint256[49] <<OwnableOperable>> -   _gap: uint256[42] <<AbstractARM>> -   _gap: uint256[49] <<LidoLiquidityManager>> -Internal: -   OWNER_SLOT: bytes32 <<Ownable>> -   MIN_TOTAL_SUPPLY: uint256 <<AbstractARM>> -   DEAD_ACCOUNT: address <<AbstractARM>> -Public: -   operator: address <<OwnableOperable>> -   MAX_PRICE_DEVIATION: uint256 <<AbstractARM>> -   PRICE_SCALE: uint256 <<AbstractARM>> -   CLAIM_DELAY: uint256 <<AbstractARM>> -   FEE_SCALE: uint256 <<AbstractARM>> -   liquidityAsset: address <<AbstractARM>> -   token0: IERC20 <<AbstractARM>> -   token1: IERC20 <<AbstractARM>> -   traderate0: uint256 <<AbstractARM>> -   traderate1: uint256 <<AbstractARM>> -   withdrawsQueued: uint128 <<AbstractARM>> -   withdrawsClaimed: uint128 <<AbstractARM>> -   withdrawsClaimable: uint128 <<AbstractARM>> -   nextWithdrawalIndex: uint128 <<AbstractARM>> -   withdrawalRequests: mapping(uint256=>WithdrawalRequest) <<AbstractARM>> -   feeCollector: address <<AbstractARM>> -   fee: uint16 <<AbstractARM>> -   feesAccrued: uint112 <<AbstractARM>> -   lastTotalAssets: uint128 <<AbstractARM>> -   liquidityProviderController: address <<AbstractARM>> -   steth: IERC20 <<LidoLiquidityManager>> -   weth: IWETH <<LidoLiquidityManager>> -   withdrawalQueue: IStETHWithdrawal <<LidoLiquidityManager>> -   outstandingEther: uint256 <<LidoLiquidityManager>> - -Internal: -    _owner(): (ownerOut: address) <<Ownable>> -    _setOwner(newOwner: address) <<Ownable>> -    _onlyOwner() <<Ownable>> -    _initOwnableOperable(_operator: address) <<OwnableOperable>> -    _setOperator(newOperator: address) <<OwnableOperable>> -    _initARM(_operator: address, _name: string, _symbol: string, _fee: uint256, _feeCollector: address, _liquidityProviderController: address) <<AbstractARM>> -    _inDeadline(deadline: uint256) <<AbstractARM>> -    _transferAsset(asset: address, to: address, amount: uint256) <<LidoARM>> -    _transferAssetFrom(asset: address, from: address, to: address, amount: uint256) <<AbstractARM>> -    _swapExactTokensForTokens(inToken: IERC20, outToken: IERC20, amountIn: uint256, to: address): (amountOut: uint256) <<AbstractARM>> -    _swapTokensForExactTokens(inToken: IERC20, outToken: IERC20, amountOut: uint256, to: address): (amountIn: uint256) <<AbstractARM>> -    _setTraderates(_traderate0: uint256, _traderate1: uint256) <<AbstractARM>> -    _updateWithdrawalQueueLiquidity() <<AbstractARM>> -    _liquidityAvailable(): uint256 <<AbstractARM>> -    _rawTotalAssets(): uint256 <<AbstractARM>> -    _externalWithdrawQueue(): uint256 <<LidoARM>> -    _accruePerformanceFee() <<AbstractARM>> -    _setFee(_fee: uint256) <<AbstractARM>> -    _setFeeCollector(_feeCollector: address) <<AbstractARM>> -    _initLidoLiquidityManager() <<LidoLiquidityManager>> -External: -    <<payable>> null() <<LidoLiquidityManager>> -    owner(): address <<Ownable>> -    setOwner(newOwner: address) <<onlyOwner>> <<Ownable>> -    setOperator(newOperator: address) <<onlyOwner>> <<OwnableOperable>> -    swapExactTokensForTokens(inToken: IERC20, outToken: IERC20, amountIn: uint256, amountOutMin: uint256, to: address) <<AbstractARM>> -    swapExactTokensForTokens(amountIn: uint256, amountOutMin: uint256, path: address[], to: address, deadline: uint256): (amounts: uint256[]) <<AbstractARM>> -    swapTokensForExactTokens(inToken: IERC20, outToken: IERC20, amountOut: uint256, amountInMax: uint256, to: address) <<AbstractARM>> -    swapTokensForExactTokens(amountOut: uint256, amountInMax: uint256, path: address[], to: address, deadline: uint256): (amounts: uint256[]) <<AbstractARM>> -    setPrices(buyT1: uint256, sellT1: uint256) <<onlyOperatorOrOwner>> <<AbstractARM>> -    previewDeposit(assets: uint256): (shares: uint256) <<AbstractARM>> -    deposit(assets: uint256): (shares: uint256) <<AbstractARM>> -    previewRedeem(shares: uint256): (assets: uint256) <<AbstractARM>> -    requestRedeem(shares: uint256): (requestId: uint256, assets: uint256) <<AbstractARM>> -    claimRedeem(requestId: uint256): (assets: uint256) <<AbstractARM>> -    setLiquidityProviderController(_liquidityProviderController: address) <<onlyOwner>> <<AbstractARM>> -    setFee(_fee: uint256) <<onlyOwner>> <<AbstractARM>> -    setFeeCollector(_feeCollector: address) <<onlyOwner>> <<AbstractARM>> -    collectFees(): (fees: uint256) <<AbstractARM>> -    approveStETH() <<onlyOperatorOrOwner>> <<LidoLiquidityManager>> + +LidoARM +../src/contracts/LidoARM.sol + +Private: +   _gap: uint256[49] <<OwnableOperable>> +   _gap: uint256[42] <<AbstractARM>> +   _gap: uint256[49] <<LidoLiquidityManager>> +Internal: +   OWNER_SLOT: bytes32 <<Ownable>> +   MIN_TOTAL_SUPPLY: uint256 <<AbstractARM>> +   DEAD_ACCOUNT: address <<AbstractARM>> +Public: +   operator: address <<OwnableOperable>> +   MAX_PRICE_DEVIATION: uint256 <<AbstractARM>> +   PRICE_SCALE: uint256 <<AbstractARM>> +   CLAIM_DELAY: uint256 <<AbstractARM>> +   FEE_SCALE: uint256 <<AbstractARM>> +   liquidityAsset: address <<AbstractARM>> +   token0: IERC20 <<AbstractARM>> +   token1: IERC20 <<AbstractARM>> +   traderate0: uint256 <<AbstractARM>> +   traderate1: uint256 <<AbstractARM>> +   withdrawsQueued: uint128 <<AbstractARM>> +   withdrawsClaimed: uint128 <<AbstractARM>> +   withdrawsClaimable: uint128 <<AbstractARM>> +   nextWithdrawalIndex: uint128 <<AbstractARM>> +   withdrawalRequests: mapping(uint256=>WithdrawalRequest) <<AbstractARM>> +   feeCollector: address <<AbstractARM>> +   fee: uint16 <<AbstractARM>> +   feesAccrued: uint112 <<AbstractARM>> +   lastAvailableAssets: uint128 <<AbstractARM>> +   liquidityProviderController: address <<AbstractARM>> +   steth: IERC20 <<LidoLiquidityManager>> +   weth: IWETH <<LidoLiquidityManager>> +   withdrawalQueue: IStETHWithdrawal <<LidoLiquidityManager>> +   outstandingEther: uint256 <<LidoLiquidityManager>> + +Internal: +    _owner(): (ownerOut: address) <<Ownable>> +    _setOwner(newOwner: address) <<Ownable>> +    _onlyOwner() <<Ownable>> +    _initOwnableOperable(_operator: address) <<OwnableOperable>> +    _setOperator(newOperator: address) <<OwnableOperable>> +    _initARM(_operator: address, _name: string, _symbol: string, _fee: uint256, _feeCollector: address, _liquidityProviderController: address) <<AbstractARM>> +    _inDeadline(deadline: uint256) <<AbstractARM>> +    _transferAsset(asset: address, to: address, amount: uint256) <<LidoARM>> +    _transferAssetFrom(asset: address, from: address, to: address, amount: uint256) <<AbstractARM>> +    _swapExactTokensForTokens(inToken: IERC20, outToken: IERC20, amountIn: uint256, to: address): (amountOut: uint256) <<AbstractARM>> +    _swapTokensForExactTokens(inToken: IERC20, outToken: IERC20, amountOut: uint256, to: address): (amountIn: uint256) <<AbstractARM>> +    _setTraderates(_baseToTokenRate: uint256, _tokenToBaseRate: uint256) <<AbstractARM>> +    _updateWithdrawalQueueLiquidity() <<AbstractARM>> +    _liquidityAvailable(): uint256 <<AbstractARM>> +    _availableAssets(): uint256 <<AbstractARM>> +    _externalWithdrawQueue(): uint256 <<LidoARM>> +    _accruePerformanceFee() <<AbstractARM>> +    _setFee(_fee: uint256) <<AbstractARM>> +    _setFeeCollector(_feeCollector: address) <<AbstractARM>> +    _initLidoLiquidityManager() <<LidoLiquidityManager>> +External: +    <<payable>> null() <<LidoLiquidityManager>> +    owner(): address <<Ownable>> +    setOwner(newOwner: address) <<onlyOwner>> <<Ownable>> +    setOperator(newOperator: address) <<onlyOwner>> <<OwnableOperable>> +    swapExactTokensForTokens(inToken: IERC20, outToken: IERC20, amountIn: uint256, amountOutMin: uint256, to: address) <<AbstractARM>> +    swapExactTokensForTokens(amountIn: uint256, amountOutMin: uint256, path: address[], to: address, deadline: uint256): (amounts: uint256[]) <<AbstractARM>> +    swapTokensForExactTokens(inToken: IERC20, outToken: IERC20, amountOut: uint256, amountInMax: uint256, to: address) <<AbstractARM>> +    swapTokensForExactTokens(amountOut: uint256, amountInMax: uint256, path: address[], to: address, deadline: uint256): (amounts: uint256[]) <<AbstractARM>> +    setPrices(buyT1: uint256, sellT1: uint256) <<onlyOperatorOrOwner>> <<AbstractARM>> +    previewDeposit(assets: uint256): (shares: uint256) <<AbstractARM>> +    deposit(assets: uint256): (shares: uint256) <<AbstractARM>> +    previewRedeem(shares: uint256): (assets: uint256) <<AbstractARM>> +    requestRedeem(shares: uint256): (requestId: uint256, assets: uint256) <<AbstractARM>> +    claimRedeem(requestId: uint256): (assets: uint256) <<AbstractARM>> +    setLiquidityProviderController(_liquidityProviderController: address) <<onlyOwner>> <<AbstractARM>> +    setFee(_fee: uint256) <<onlyOwner>> <<AbstractARM>> +    setFeeCollector(_feeCollector: address) <<onlyOwner>> <<AbstractARM>> +    collectFees(): (fees: uint256) <<AbstractARM>>    requestStETHWithdrawalForETH(amounts: uint256[]): (requestIds: uint256[]) <<onlyOperatorOrOwner>> <<LidoLiquidityManager>>    claimStETHWithdrawalForWETH(requestIds: uint256[]) <<onlyOperatorOrOwner>> <<LidoLiquidityManager>>    initialize(_name: string, _symbol: string, _operator: address, _fee: uint256, _feeCollector: address, _liquidityProviderController: address) <<initializer>> <<LidoARM>> diff --git a/src/contracts/AbstractARM.sol b/src/contracts/AbstractARM.sol index b1098ea..632129b 100644 --- a/src/contracts/AbstractARM.sol +++ b/src/contracts/AbstractARM.sol @@ -98,11 +98,11 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { /// 500 = 5% performance fee uint16 public fee; /// @notice The performance fees accrued but not collected. - /// This is removed from the total assets. + /// This is removed from the available assets. uint112 public feesAccrued; - /// @notice The total assets at the last time performance fees were calculated. + /// @notice The available assets at the last time performance fees were calculated. /// This can only go up so is a high watermark. - uint128 public lastTotalAssets; + uint128 public lastAvailableAssets; address public liquidityProviderController; @@ -166,9 +166,9 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { // This avoids donation attacks when there are no assets in the ARM contract _mint(DEAD_ACCOUNT, MIN_TOTAL_SUPPLY); - // Initialize the last total assets to the current total assets + // Initialize the last available assets to the current available assets // This ensures no performance fee is accrued when the performance fee is calculated when the fee is set - lastTotalAssets = SafeCast.toUint128(_rawTotalAssets()); + lastAvailableAssets = SafeCast.toUint128(_availableAssets()); _setFee(_fee); _setFeeCollector(_feeCollector); @@ -406,12 +406,12 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { /// @param assets The amount of liquidity assets to deposit /// @return shares The amount of shares that were minted function deposit(uint256 assets) external returns (uint256 shares) { - // Accrue any performance fees based on the increase in total assets before + // Accrue any performance fees based on the increase in available assets before // the liquidity asset from the deposit is transferred into the ARM _accruePerformanceFee(); // Calculate the amount of shares to mint after the performance fees have been accrued - // which reduces the total assets and before new assets are deposited. + // which reduces the available assets, and before new assets are deposited. shares = convertToShares(assets); // Transfer the liquidity asset from the sender to this contract @@ -420,8 +420,8 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { // mint shares _mint(msg.sender, shares); - // Save the new total assets after the performance fee accrued and new assets deposited - lastTotalAssets = SafeCast.toUint128(_rawTotalAssets()); + // Save the new available assets after the performance fee accrued and new assets deposited + lastAvailableAssets = SafeCast.toUint128(_availableAssets()); // Check the liquidity provider caps after the new assets have been deposited if (liquidityProviderController != address(0)) { @@ -443,7 +443,7 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { /// @return requestId The index of the withdrawal request /// @return assets The amount of liquidity assets that will be claimable by the redeemer function requestRedeem(uint256 shares) external returns (uint256 requestId, uint256 assets) { - // Accrue any performance fees based on the increase in total assets before + // Accrue any performance fees based on the increase in available assets before // the liquidity asset from the redeem is reserved for the ARM withdrawal queue _accruePerformanceFee(); @@ -470,8 +470,8 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { // burn redeemer's shares _burn(msg.sender, shares); - // Save the new total assets after performance fee accrued and withdrawal queue updated - lastTotalAssets = SafeCast.toUint128(_rawTotalAssets()); + // Save the new available assets after performance fee accrued and withdrawal queue updated + lastAvailableAssets = SafeCast.toUint128(_availableAssets()); emit RedeemRequested(msg.sender, requestId, assets, queued, claimTimestamp); } @@ -559,22 +559,22 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { /// @notice The total amount of assets in the ARM and external withdrawal queue, /// less the liquidity assets reserved for the ARM's withdrawal queue and accrued fees. function totalAssets() public view virtual returns (uint256) { - uint256 totalAssetsBeforeFees = _rawTotalAssets(); + uint256 availableAssetsBeforeFees = _availableAssets(); - // If the total assets have decreased, then we don't charge a performance fee - if (totalAssetsBeforeFees <= lastTotalAssets) return totalAssetsBeforeFees; + // If the available assets have decreased, then we don't charge a performance fee + if (availableAssetsBeforeFees <= lastAvailableAssets) return availableAssetsBeforeFees; // Calculate the increase in assets since the last time fees were calculated - uint256 assetIncrease = totalAssetsBeforeFees - lastTotalAssets; + uint256 assetIncrease = availableAssetsBeforeFees - lastAvailableAssets; - // Calculate the performance fee and remove from the total assets before new fees are removed - return totalAssetsBeforeFees - ((assetIncrease * fee) / FEE_SCALE); + // Calculate the performance fee and remove from the available assets before new fees are removed + return availableAssetsBeforeFees - ((assetIncrease * fee) / FEE_SCALE); } - /// @dev Calculate the total assets in the ARM, external withdrawal queue, - /// less liquidity assets reserved for the ARM's withdrawal queue and past accrued fees. + /// @dev Calculate the available assets which is the assets in the ARM, external withdrawal queue, + /// less liquidity assets reserved for the ARM's withdrawal queue and accrued fees. /// The accrued fees are from the last time fees were calculated. - function _rawTotalAssets() internal view returns (uint256) { + function _availableAssets() internal view returns (uint256) { // Get the assets in the ARM and external withdrawal queue uint256 assets = token0.balanceOf(address(this)) + token1.balanceOf(address(this)) + _externalWithdrawQueue(); @@ -582,7 +582,7 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { uint256 queuedMem = withdrawsQueued; uint256 claimedMem = withdrawsClaimed; - // If the ARM becomes insolvent enough that the total value in the ARM and external withdrawal queue + // If the ARM becomes insolvent enough that the available assets in the ARM and external withdrawal queue // is less than the outstanding withdrawals and accrued fees. if (assets + claimedMem < queuedMem + feesAccrued) { return 0; @@ -620,23 +620,23 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { /// Performance Fee Functions //////////////////////////////////////////////////// - /// @dev Accrues the performance fee based on the increase in total assets + /// @dev Accrues the performance fee based on the increase in available assets /// Needs to be called before any action that changes the liquidity provider shares. eg deposit and redeem function _accruePerformanceFee() internal { - uint256 newTotalAssets = _rawTotalAssets(); + uint256 newAvailableAssets = _availableAssets(); - // Do not accrued a performance fee if the total assets has decreased - if (newTotalAssets <= lastTotalAssets) return; + // Do not accrued a performance fee if the available assets has decreased + if (newAvailableAssets <= lastAvailableAssets) return; - uint256 assetIncrease = newTotalAssets - lastTotalAssets; + uint256 assetIncrease = newAvailableAssets - lastAvailableAssets; uint256 newFeesAccrued = (assetIncrease * fee) / FEE_SCALE; // Save the new accrued fees back to storage feesAccrued = SafeCast.toUint112(feesAccrued + newFeesAccrued); - // Save the new total assets back to storage less the new accrued fees. + // Save the new available assets back to storage less the new accrued fees. // This is be updated again in the post deposit and post withdraw hooks to include // the assets deposited or withdrawn - lastTotalAssets = SafeCast.toUint128(newTotalAssets - newFeesAccrued); + lastAvailableAssets = SafeCast.toUint128(newAvailableAssets - newFeesAccrued); emit FeeCalculated(newFeesAccrued, assetIncrease); } diff --git a/test/fork/LidoFixedPriceMultiLpARM/ClaimRedeem.t.sol b/test/fork/LidoFixedPriceMultiLpARM/ClaimRedeem.t.sol index fc738f4..de65cff 100644 --- a/test/fork/LidoFixedPriceMultiLpARM/ClaimRedeem.t.sol +++ b/test/fork/LidoFixedPriceMultiLpARM/ClaimRedeem.t.sol @@ -121,7 +121,7 @@ contract Fork_Concrete_LidoARM_ClaimRedeem_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY); assertEq(lidoARM.balanceOf(address(this)), 0); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); @@ -142,7 +142,7 @@ contract Fork_Concrete_LidoARM_ClaimRedeem_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY); assertEq(lidoARM.balanceOf(address(this)), 0); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); @@ -186,7 +186,7 @@ contract Fork_Concrete_LidoARM_ClaimRedeem_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), 0); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY); assertEq(lidoARM.balanceOf(address(this)), 0); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); @@ -210,7 +210,7 @@ contract Fork_Concrete_LidoARM_ClaimRedeem_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT / 2); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY); assertEq(lidoARM.balanceOf(address(this)), 0); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); @@ -233,7 +233,7 @@ contract Fork_Concrete_LidoARM_ClaimRedeem_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY); assertEq(lidoARM.balanceOf(address(this)), 0); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); diff --git a/test/fork/LidoFixedPriceMultiLpARM/Constructor.t.sol b/test/fork/LidoFixedPriceMultiLpARM/Constructor.t.sol index debd3a3..7f050d0 100644 --- a/test/fork/LidoFixedPriceMultiLpARM/Constructor.t.sol +++ b/test/fork/LidoFixedPriceMultiLpARM/Constructor.t.sol @@ -22,7 +22,7 @@ contract Fork_Concrete_LidoARM_Constructor_Test is Fork_Shared_Test_ { assertEq(lidoARM.operator(), operator); assertEq(lidoARM.feeCollector(), feeCollector); assertEq(lidoARM.fee(), 2000); - assertEq(lidoARM.lastTotalAssets(), 1e12); + assertEq(lidoARM.lastAvailableAssets(), 1e12); assertEq(lidoARM.feesAccrued(), 0); // the 20% performance fee is removed on initialization assertEq(lidoARM.totalAssets(), 1e12); diff --git a/test/fork/LidoFixedPriceMultiLpARM/Deposit.t.sol b/test/fork/LidoFixedPriceMultiLpARM/Deposit.t.sol index 90aa0eb..943570c 100644 --- a/test/fork/LidoFixedPriceMultiLpARM/Deposit.t.sol +++ b/test/fork/LidoFixedPriceMultiLpARM/Deposit.t.sol @@ -108,7 +108,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY); assertEq(lidoARM.balanceOf(address(this)), 0); // Ensure no shares before assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY, "total supply before"); // Minted to dead on deploy assertEq(lidoARM.totalAssets(), MIN_TOTAL_SUPPLY, "total assets before"); @@ -131,7 +131,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + amount); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY + amount); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + amount); assertEq(lidoARM.balanceOf(address(this)), shares); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY + amount, "total supply after"); assertEq(lidoARM.totalAssets(), MIN_TOTAL_SUPPLY + amount, "total assets after"); @@ -154,7 +154,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + amount); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY + amount); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + amount); assertEq(lidoARM.balanceOf(address(this)), amount); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY + amount); // Minted to dead on deploy assertEq(lidoARM.totalAssets(), MIN_TOTAL_SUPPLY + amount); @@ -177,7 +177,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + amount * 2); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY + amount * 2); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + amount * 2); assertEq(lidoARM.balanceOf(address(this)), shares * 2); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY + amount * 2); assertEq(lidoARM.totalAssets(), MIN_TOTAL_SUPPLY + amount * 2); @@ -201,7 +201,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + amount); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY + amount); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + amount); assertEq(lidoARM.balanceOf(alice), 0); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY + amount); // Minted to dead on deploy assertEq(lidoARM.totalAssets(), MIN_TOTAL_SUPPLY + amount); @@ -225,7 +225,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + amount * 2); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY + amount * 2); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + amount * 2); assertEq(lidoARM.balanceOf(alice), shares); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY + amount * 2); assertEq(lidoARM.totalAssets(), MIN_TOTAL_SUPPLY + amount * 2); @@ -251,7 +251,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + assetGain); assertEq(lidoARM.outstandingEther(), 0, "Outstanding ether before"); assertEq(lidoARM.feesAccrued(), 0, "fee accrued before"); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY, "last total assets before"); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY, "last available assets before"); assertEq(lidoARM.balanceOf(address(this)), 0, "user shares before"); // Ensure no shares before assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY, "Total supply before"); // Minted to dead on deploy // 80% of the asset gain goes to the total assets @@ -285,7 +285,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(lidoARM.outstandingEther(), 0, "Outstanding ether after"); assertEq(lidoARM.feesAccrued(), feesAccrued, "fees accrued after"); // No perfs so no fees assertEq( - lidoARM.lastTotalAssets(), + lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + (assetGain * 80 / 100) + depositedAssets, "last total assets after" ); @@ -324,7 +324,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), wethBalanceBefore, "WETH ARM balance before"); assertEq(lidoARM.outstandingEther(), 0, "Outstanding ether before"); assertEq(lidoARM.feesAccrued(), 0, "Fees accrued before"); - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY, "last total assets before"); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY, "last available assets before"); assertEq(lidoARM.balanceOf(alice), 0, "alice shares before"); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY, "total supply before"); assertEq(lidoARM.totalAssets(), MIN_TOTAL_SUPPLY, "total assets before"); @@ -353,7 +353,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), wethBalanceBefore + amount, "WETH ARM balance after"); assertEq(lidoARM.outstandingEther(), 0, "Outstanding ether after"); assertEq(lidoARM.feesAccrued(), 0, "Fees accrued after"); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY + amount, "last total assets after"); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + amount, "last available assets after"); assertEq(lidoARM.balanceOf(alice), shares, "alice shares after"); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY + amount, "total supply after"); assertEq(lidoARM.totalAssets(), MIN_TOTAL_SUPPLY + amount, "total assets after"); @@ -381,7 +381,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY); assertEq(lidoARM.outstandingEther(), DEFAULT_AMOUNT); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY); assertEq(lidoARM.balanceOf(address(this)), 0); // Ensure no shares before assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); // Minted to dead on deploy assertEq(lidoARM.totalAssets(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 80 / 100); @@ -419,7 +419,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 2); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), DEFAULT_AMOUNT * 20 / 100); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 80 / 100 + excessLeftover); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 80 / 100 + excessLeftover); assertEq(lidoARM.balanceOf(address(this)), 0); // Ensure no shares after assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); // Minted to dead on deploy assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); // All the caps are used @@ -465,7 +465,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY); assertEq(lidoARM.balanceOf(address(this)), 0); // Ensure no shares after assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); // Minted to dead on deploy assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); // All the caps are used @@ -511,7 +511,7 @@ contract Fork_Concrete_LidoARM_Deposit_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 2); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), DEFAULT_AMOUNT * 20 / 100); // No perfs so no fees - assertApproxEqAbs(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY + deadAddressBenef, STETH_ERROR_ROUNDING); + assertApproxEqAbs(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + deadAddressBenef, STETH_ERROR_ROUNDING); assertEq(lidoARM.balanceOf(address(this)), 0); // Ensure no shares after assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); // Minted to dead on deploy assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); // All the caps are used diff --git a/test/fork/LidoFixedPriceMultiLpARM/RequestRedeem.t.sol b/test/fork/LidoFixedPriceMultiLpARM/RequestRedeem.t.sol index dc5b949..053e085 100644 --- a/test/fork/LidoFixedPriceMultiLpARM/RequestRedeem.t.sol +++ b/test/fork/LidoFixedPriceMultiLpARM/RequestRedeem.t.sol @@ -33,7 +33,7 @@ contract Fork_Concrete_LidoARM_RequestRedeem_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT); assertEq(lidoARM.balanceOf(address(this)), DEFAULT_AMOUNT); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT); assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); @@ -57,7 +57,7 @@ contract Fork_Concrete_LidoARM_RequestRedeem_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY); assertEq(lidoARM.balanceOf(address(this)), 0); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); @@ -76,7 +76,7 @@ contract Fork_Concrete_LidoARM_RequestRedeem_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 3 / 4); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 3 / 4); assertEq(lidoARM.balanceOf(address(this)), DEFAULT_AMOUNT * 3 / 4); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 3 / 4); assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); // Down only @@ -104,7 +104,7 @@ contract Fork_Concrete_LidoARM_RequestRedeem_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), 0); // No perfs so no fees - assertEq(lidoARM.lastTotalAssets(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 1 / 4); + assertEq(lidoARM.lastAvailableAssets(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 1 / 4); assertEq(lidoARM.balanceOf(address(this)), DEFAULT_AMOUNT * 1 / 4); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 1 / 4); assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); // Down only @@ -143,7 +143,7 @@ contract Fork_Concrete_LidoARM_RequestRedeem_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT * 2); // +perfs assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), feeAccrued); - assertApproxEqAbs(lidoARM.lastTotalAssets(), expectedAssetsDead, 1); // 1 wei of error + assertApproxEqAbs(lidoARM.lastAvailableAssets(), expectedAssetsDead, 1); // 1 wei of error assertEq(lidoARM.balanceOf(address(this)), 0); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0); @@ -182,7 +182,7 @@ contract Fork_Concrete_LidoARM_RequestRedeem_Test_ is Fork_Shared_Test_ { assertEq(weth.balanceOf(address(lidoARM)), MIN_TOTAL_SUPPLY + DEFAULT_AMOUNT - assetsLoss); assertEq(lidoARM.outstandingEther(), 0); assertEq(lidoARM.feesAccrued(), feeAccrued); - assertApproxEqAbs(lidoARM.lastTotalAssets(), expectedAssetsDead, 1); // 1 wei of error + assertApproxEqAbs(lidoARM.lastAvailableAssets(), expectedAssetsDead, 1); // 1 wei of error assertEq(lidoARM.balanceOf(address(this)), 0); assertEq(lidoARM.totalSupply(), MIN_TOTAL_SUPPLY); assertEq(liquidityProviderController.liquidityProviderCaps(address(this)), 0);