diff --git a/src/contracts/AbstractARM.sol b/src/contracts/AbstractARM.sol index 1398410..039c521 100644 --- a/src/contracts/AbstractARM.sol +++ b/src/contracts/AbstractARM.sol @@ -7,6 +7,10 @@ import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {OwnableOperable} from "./OwnableOperable.sol"; import {IERC20, ICapManager} from "./Interfaces.sol"; +/** + * @title Generic Automated Redemption Manager (ARM) + * @author Origin Protocol Inc + */ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { //////////////////////////////////////////////////// /// Constants @@ -140,7 +144,7 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { require(_liquidityAsset == address(token0) || _liquidityAsset == address(token1), "invalid liquidity asset"); liquidityAsset = _liquidityAsset; // The base asset, eg stETH, is not the liquidity asset, eg WETH - baseAsset = _liquidityAsset == address(token0) ? address(token1) : address(token0); + baseAsset = _liquidityAsset == _token0 ? _token1 : _token0; } /// @notice Initialize the contract. @@ -404,7 +408,9 @@ abstract contract AbstractARM is OwnableOperable, ERC20Upgradeable { * If the cross price is being lowered, there can not be a significant amount of base assets in the ARM. eg stETH. * This prevents the ARM making a loss when the base asset is sold at a lower price than it was bought * before the cross price was lowered. - * The base assets should be sent to the withdrawal queue before the cross price can be lowered. + * The base assets should be sent to the withdrawal queue before the cross price can be lowered. For example, the + * `Owner` should construct a tx that calls `requestLidoWithdrawals` before `setCrossPrice` for the Lido ARM + * when the cross price is being lowered. * The cross price can be increased with assets in the ARM. * @param newCrossPrice The new cross price scaled to 36 decimals. */ diff --git a/src/contracts/LidoARM.sol b/src/contracts/LidoARM.sol index 9c39889..c519ac4 100644 --- a/src/contracts/LidoARM.sol +++ b/src/contracts/LidoARM.sol @@ -42,10 +42,12 @@ contract LidoARM is Initializable, AbstractARM { steth = IERC20(_steth); weth = IWETH(_weth); lidoWithdrawalQueue = IStETHWithdrawal(_lidoWithdrawalQueue); + + _disableInitializers(); } /// @notice Initialize the storage variables stored in the proxy contract. - /// The deployer that calls initialize has to approve the this ARM's proxy contract to transfer 1e12 WETH. + /// The deployer that calls initialize has to approve the ARM's proxy contract to transfer 1e12 WETH. /// @param _name The name of the liquidity provider (LP) token. /// @param _symbol The symbol of the liquidity provider (LP) token. /// @param _operator The address of the account that can request and claim Lido withdrawals. @@ -73,7 +75,7 @@ contract LidoARM is Initializable, AbstractARM { * Reference: https://docs.lido.fi/contracts/withdrawal-queue-erc721/ * Note: There is a 1k amount limit. Caller should split large withdrawals in chunks of less or equal to 1k each.) */ - function requestLidoWithdrawals(uint256[] memory amounts) + function requestLidoWithdrawals(uint256[] calldata amounts) external onlyOperatorOrOwner returns (uint256[] memory requestIds) @@ -99,7 +101,7 @@ contract LidoARM is Initializable, AbstractARM { * @notice Claim the ETH owed from the redemption requests and convert it to WETH. * Before calling this method, caller should check on the request NFTs to ensure the withdrawal was processed. */ - function claimLidoWithdrawals(uint256[] memory requestIds) external { + function claimLidoWithdrawals(uint256[] calldata requestIds) external { // Claim the NFTs for ETH. uint256 lastIndex = lidoWithdrawalQueue.getLastCheckpointIndex(); uint256[] memory hintIds = lidoWithdrawalQueue.findCheckpointHints(requestIds, 1, lastIndex); diff --git a/src/contracts/Ownable.sol b/src/contracts/Ownable.sol index 7e9b13f..5497637 100644 --- a/src/contracts/Ownable.sol +++ b/src/contracts/Ownable.sol @@ -1,6 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.23; +/** + * @title Base contract that provides ownership control + * @author Origin Protocol Inc + */ contract Ownable { /// @notice The slot used to store the owner of the contract. /// This is also used as the proxy admin. diff --git a/src/contracts/OwnableOperable.sol b/src/contracts/OwnableOperable.sol index e2e0363..1fa43c1 100644 --- a/src/contracts/OwnableOperable.sol +++ b/src/contracts/OwnableOperable.sol @@ -3,6 +3,10 @@ pragma solidity ^0.8.23; import {Ownable} from "./Ownable.sol"; +/** + * @title Base contract that provides ownership and operational control + * @author Origin Protocol Inc + */ contract OwnableOperable is Ownable { /// @notice The account that can request and claim withdrawals. address public operator;