Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into nicka/track-lido-with…
Browse files Browse the repository at this point in the history
…draws
  • Loading branch information
naddison36 committed Dec 9, 2024
2 parents 5285492 + 9f64e6b commit ff69425
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/contracts/AbstractARM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*/
Expand Down
8 changes: 5 additions & 3 deletions src/contracts/LidoARM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/contracts/Ownable.sol
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 4 additions & 0 deletions src/contracts/OwnableOperable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ff69425

Please sign in to comment.