Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Mellow LRT Vault price feed contract #54

Merged
merged 7 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ ASSET_LIMIT=5
PRICE_FEED_DECIMALS=9
PRICE_FEED_DESCRIPTIONS=["steakLRT", "Re7LRT", "amphrETH", "rstETH"]
QUOTED_PRICE_FEEDS=["WETH/ETH", "WETH/USDC"]
MELLOW_PRICE_FEEDS=["amphrETH/wstETH"]
MELLOW_VAULTS=["0x5fD13359Ba15A84B76f7F87568309040176167cd"]
403 changes: 403 additions & 0 deletions contracts/mellow-lrt/interfaces/IVault.sol

Large diffs are not rendered by default.

395 changes: 395 additions & 0 deletions contracts/mellow-lrt/interfaces/IVaultConfigurator.sol

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IAggregatorV3 {
function decimals() external view returns (uint8);

function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IDepositContract {
function get_deposit_root() external view returns (bytes32 rootHash);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IDepositSecurityModule {
struct Signature {
bytes32 r;
bytes32 vs;
}

function depositBufferedEther(
uint256 blockNumber,
bytes32 blockHash,
bytes32 depositRoot,
uint256 stakingModuleId,
uint256 nonce,
bytes calldata depositCalldata,
Signature[] calldata sortedGuardianSignatures
) external;

function addGuardian(address addr, uint256 newQuorum) external;

function getOwner() external view returns (address);

function setMinDepositBlockDistance(uint256 newValue) external;

function getGuardianIndex(address) external view returns (int256);

function STAKING_ROUTER() external view returns (address);

function DEPOSIT_CONTRACT() external view returns (address);

function getMaxDeposits() external view returns (uint256);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface ILidoLocator {
function depositSecurityModule() external view returns (address);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IStakingRouter {
function pauseStakingModule(uint256 _stakingModuleId) external;
function resumeStakingModule(uint256 _stakingModuleId) external;
function getStakingModuleIsDepositPaused(
uint256 _stakingModuleId
) external view returns (bool);
function getStakingModuleIsActive(
uint256 _stakingModuleId
) external view returns (bool);
function getStakingModuleNonce(
uint256 _stakingModuleId
) external view returns (uint256);
function getStakingModuleLastDepositBlock(
uint256 _stakingModuleId
) external view returns (uint256);
function hasStakingModule(
uint256 _stakingModuleId
) external view returns (bool);
function getStakingModuleMaxDepositsCount(
uint256 _stakingModuleId,
uint256 depositableEther
) external view returns (uint256);
}
10 changes: 10 additions & 0 deletions contracts/mellow-lrt/interfaces/external/lido/ISteth.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface ISteth {
function submit(address _referral) external payable returns (uint256);

function getBufferedEther() external view returns (uint256);

function DEPOSIT_SIZE() external view returns (uint256);
}
12 changes: 12 additions & 0 deletions contracts/mellow-lrt/interfaces/external/lido/IWSteth.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IWSteth {
function wrap(uint256 stethAmount) external payable returns (uint256);

function unwrap(uint256 wstethAmount) external returns (uint256);

function getStETHByWstETH(
uint256 wstethAmount
) external view returns (uint256);
}
7 changes: 7 additions & 0 deletions contracts/mellow-lrt/interfaces/external/lido/IWeth.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IWeth {
function deposit() external payable;
function withdraw(uint256 amount) external;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: BSL-1.1
pragma solidity ^0.8.20;

interface IWithdrawalQueue {
function unfinalizedStETH() external view returns (uint256);
}
107 changes: 107 additions & 0 deletions contracts/mellow-lrt/interfaces/external/symbiotic/IBond.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IBond is IERC20 {
/**
* @notice Emitted when debt is issued.
* @param issuer address of the debt's issuer
* @param recipient address that should receive the underlying asset
* @param debtIssued amount of the debt issued
*/
event IssueDebt(
address indexed issuer,
address indexed recipient,
uint256 debtIssued
);

/**
* @notice Emitted when debt is repaid.
* @param issuer address of the debt's issuer
* @param recipient address that received the underlying asset
* @param debtRepaid amount of the debt repaid
*/
event RepayDebt(
address indexed issuer,
address indexed recipient,
uint256 debtRepaid
);

/**
* @notice Get the bond's underlying asset.
* @return asset address of the underlying asset
*/
function asset() external view returns (address);

/**
* @notice Get a total amount of repaid debt.
* @return total repaid debt
*/
function totalRepaidDebt() external view returns (uint256);

/**
* @notice Get an amount of repaid debt created by a particular issuer.
* @param issuer address of the debt's issuer
* @return particular issuer's repaid debt
*/
function issuerRepaidDebt(address issuer) external view returns (uint256);

/**
* @notice Get an amount of repaid debt to a particular recipient.
* @param recipient address that received the underlying asset
* @return particular recipient's repaid debt
*/
function recipientRepaidDebt(
address recipient
) external view returns (uint256);

/**
* @notice Get an amount of repaid debt for a particular issuer-recipient pair.
* @param issuer address of the debt's issuer
* @param recipient address that received the underlying asset
* @return particular pair's repaid debt
*/
function repaidDebt(
address issuer,
address recipient
) external view returns (uint256);

/**
* @notice Get a total amount of debt.
* @return total debt
*/
function totalDebt() external view returns (uint256);

/**
* @notice Get a current debt created by a particular issuer.
* @param issuer address of the debt's issuer
* @return particular issuer's debt
*/
function issuerDebt(address issuer) external view returns (uint256);

/**
* @notice Get a current debt to a particular recipient.
* @param recipient address that should receive the underlying asset
* @return particular recipient's debt
*/
function recipientDebt(address recipient) external view returns (uint256);

/**
* @notice Get a current debt for a particular issuer-recipient pair.
* @param issuer address of the debt's issuer
* @param recipient address that should receive the underlying asset
* @return particular pair's debt
*/
function debt(
address issuer,
address recipient
) external view returns (uint256);

/**
* @notice Burn a given amount of the bond, and increase a debt of the underlying asset for the caller.
* @param recipient address that should receive the underlying asset
* @param amount amount of the bond
*/
function issueDebt(address recipient, uint256 amount) external;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IBond} from "./IBond.sol";

interface IDefaultBond is IBond {
error InsufficientDeposit();
error InsufficientWithdraw();
error InsufficientIssueDebt();

/**
* @notice Deposit a given amount of the underlying asset, and mint the bond to a particular recipient.
* @param recipient address of the bond's recipient
* @param amount amount of the underlying asset
* @return amount of the bond minted
*/
function deposit(
address recipient,
uint256 amount
) external returns (uint256);

/**
* @notice Deposit a given amount of the underlying asset using a permit functionality, and mint the bond to a particular recipient.
* @param recipient address of the bond's recipient
* @param amount amount of the underlying asset
* @param deadline timestamp of the signature's deadline
* @param v v component of the signature
* @param r r component of the signature
* @param s s component of the signature
* @return amount of the bond minted
*/
function deposit(
address recipient,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256);

/**
* @notice Withdraw a given amount of the underlying asset, and transfer it to a particular recipient.
* @param recipient address of the underlying asset's recipient
* @param amount amount of the underlying asset
*/
function withdraw(address recipient, uint256 amount) external;

function limit() external view returns (uint256);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.20;

/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface ISwapRouter {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}

/// @notice Swaps `amountIn` of one token for as much as possible of another token
/// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
/// @return amountOut The amount of the received token
function exactInputSingle(
ExactInputSingleParams calldata params
) external payable returns (uint256 amountOut);

struct ExactInputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
}

/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
/// @return amountOut The amount of the received token
function exactInput(
ExactInputParams calldata params
) external payable returns (uint256 amountOut);

struct ExactOutputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
uint160 sqrtPriceLimitX96;
}

/// @notice Swaps as little as possible of one token for `amountOut` of another token
/// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
/// @return amountIn The amount of the input token
function exactOutputSingle(
ExactOutputSingleParams calldata params
) external payable returns (uint256 amountIn);

struct ExactOutputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
}

/// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
/// @return amountIn The amount of the input token
function exactOutput(
ExactOutputParams calldata params
) external payable returns (uint256 amountIn);
}
13 changes: 13 additions & 0 deletions contracts/mellow-lrt/interfaces/modules/IDefaultModule.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: BSL-1.1

// Solidity version pragma
pragma solidity ^0.8.20;

/**
* @title IDefaultModule
* @notice Interface defining methods and errors for the DefaultModule contract.
*/
interface IDefaultModule {
/// @dev Error indicating that an operation is not allowed
error Forbidden();
}
Loading
Loading