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

SPOT Appraiser update #223

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
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
192 changes: 85 additions & 107 deletions spot-vaults/contracts/BillBroker.sol

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions spot-vaults/contracts/_interfaces/IMetaOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: BUSL-1.1

/// @notice Oracle adapter for AMPL and its family of assets.
// solhint-disable-next-line compiler-version
interface IMetaOracle {
/// @return Number of decimals representing the prices returned.
function decimals() external pure returns (uint8);

/// @notice Computes the deviation between SPOT's market price and FMV price.
/// @return deviation The computed deviation factor.
/// @return isValid True if the returned deviation is valid.
function spotPriceDeviation() external returns (uint256 deviation, bool isValid);

/// @notice Computes the deviation between AMPL's market price and price target.
/// @return deviation The computed deviation factor.
/// @return isValid True if the returned deviation is valid.
function amplPriceDeviation() external returns (uint256 deviation, bool isValid);

/// @return price The price of SPOT in dollars.
/// @return isValid True if the returned price is valid.
function spotUsdPrice() external returns (uint256 price, bool isValid);

/// @return price The price of AMPL in dollars.
/// @return isValid True if the returned price is valid.
function amplUsdPrice() external returns (uint256 price, bool isValid);

/// @return price The SPOT FMV price in dollars.
/// @return isValid True if the returned price is valid.
function spotFmvUsdPrice() external returns (uint256 price, bool isValid);

/// @return price The AMPL target price in dollars.
/// @return isValid True if the returned price is valid.
function amplTargetUsdPrice() external returns (uint256 price, bool isValid);

/// @return price The WAMPL price in dollars.
/// @return isValid True if the returned price is valid.
function wamplUsdPrice() external returns (uint256 price, bool isValid);

/// @return price The ETH price in dollars.
/// @return isValid True if the returned price is valid.
function ethUsdPrice() external returns (uint256 price, bool isValid);

/// @return price The price of USDC tokens in dollars.
/// @return isValid True if the returned price is valid.
function usdcUsdPrice() external returns (uint256 price, bool isValid);
}
28 changes: 28 additions & 0 deletions spot-vaults/contracts/_interfaces/IPerpPricer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: BUSL-1.1

/// @notice Oracle contract to price perps and its underlying token.
// solhint-disable-next-line compiler-version
interface IPerpPricer {
/// @return Number of decimals representing the prices returned.
function decimals() external pure returns (uint8);

/// @return price The price of reference USD tokens in dollars.
/// @return isValid True if the returned price is valid.
function usdPrice() external returns (uint256 price, bool isValid);

/// @return price The price of perp tokens in dollars.
/// @return isValid True if the returned price is valid.
function perpUsdPrice() external returns (uint256 price, bool isValid);

/// @return price The price of underlying tokens (which back perp) in dollars.
/// @return isValid True if the returned price is valid.
function underlyingUsdPrice() external returns (uint256 price, bool isValid);

/// @return price Perp's fmv price in dollars.
/// @return isValid True if the returned price is valid.
function perpFmvUsdPrice() external returns (uint256 price, bool isValid);

/// @return beta Perp's volatility measure.
/// @return isValid True if the returned measure is valid.
function perpBeta() external returns (uint256, bool);
}
22 changes: 0 additions & 22 deletions spot-vaults/contracts/_interfaces/ISpotPricingStrategy.sol

This file was deleted.

8 changes: 8 additions & 0 deletions spot-vaults/contracts/_interfaces/errors/BillBrokerErrors.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;

/// @notice Expect AR lower bound to be under the upper bound.
error InvalidARBound();

/// @notice Expected pre and post swap AR delta to be non-increasing or non-decreasing.
error UnexpectedARDelta();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: BUSL-1.1
/// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;

/// @notice Expected contract call to be triggered by authorized caller.
Expand All @@ -10,15 +10,6 @@ error UnexpectedDecimals();
/// @notice Expected perc value to be at most (1 * 10**DECIMALS), i.e) 1.0 or 100%.
error InvalidPerc();

/// @notice Expected Senior CDR bound to be more than 1.0 or 100%.
error InvalidSeniorCDRBound();

/// @notice Expect AR lower bound to be under the upper bound.
error InvalidARBound();

/// @notice Expected pre and post swap AR delta to be non-increasing or non-decreasing.
error UnexpectedARDelta();

/// @notice Slippage higher than tolerance requested by user.
error SlippageTooHigh();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// solhint-disable-next-line compiler-version
interface IBondController {
function collateralBalance() external view returns (uint256);
}
14 changes: 14 additions & 0 deletions spot-vaults/contracts/_interfaces/external/IERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// solhint-disable-next-line compiler-version
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
}
7 changes: 7 additions & 0 deletions spot-vaults/contracts/_interfaces/external/IPerpFeePolicy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// solhint-disable-next-line compiler-version
interface IPerpFeePolicy {
function decimals() external returns (uint8);
function deviationRatio() external returns (uint256);
function computePerpRolloverFeePerc(uint256 dr) external returns (int256);
}
13 changes: 13 additions & 0 deletions spot-vaults/contracts/_interfaces/external/IPerpetualTranche.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// solhint-disable-next-line compiler-version
interface IPerpetualTranche {
function underlying() external view returns (address);
function getTVL() external returns (uint256);
function totalSupply() external returns (uint256);
function getReserveCount() external returns (uint256);
function getReserveAt(uint256 index) external returns (address);
function deviationRatio() external returns (uint256);
function getReserveTokenValue(address t) external returns (uint256);
function getReserveTokenBalance(address t) external returns (uint256);
function feePolicy() external returns (address);
}
6 changes: 6 additions & 0 deletions spot-vaults/contracts/_interfaces/external/ITranche.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// solhint-disable-next-line compiler-version
interface ITranche {
function bond() external view returns (address);
function totalSupply() external view returns (uint256);
}
2 changes: 0 additions & 2 deletions spot-vaults/contracts/_interfaces/external/IWAMPL.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// solhint-disable-next-line compiler-version
pragma solidity ^0.7.6;

interface IWAMPL {
function wrapperToUnderlying(uint256 wamples) external view returns (uint256);
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;

/// @notice A data structure to define a geometric Line with two points.
struct Line {
/// @notice x-coordinate of the first point.
uint256 x1;
/// @notice y-coordinate of the first point.
uint256 y1;
/// @notice x-coordinate of the second point.
uint256 x2;
/// @notice y-coordinate of the second point.
uint256 y2;
}

/// @notice A data structure to define a numeric Range.
struct Range {
/// @notice Lower bound of the range.
uint256 lower;
/// @notice Upper bound of the range.
uint256 upper;
}
import { Range } from "./CommonTypes.sol";

/// @notice A data structure to store various fees associated with BillBroker operations.
struct BillBrokerFees {
Expand Down
22 changes: 22 additions & 0 deletions spot-vaults/contracts/_interfaces/types/CommonTypes.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;

/// @notice A data structure to define a geometric Line with two points.
struct Line {
// @dev x-coordinate of the first point.
uint256 x1;
// @dev y-coordinate of the first point.
uint256 y1;
// @dev x-coordinate of the second point.
uint256 x2;
// @dev y-coordinate of the second point.
uint256 y2;
}

/// @notice A data structure to define a numeric Range.
struct Range {
// @dev Lower bound of the range.
uint256 lower;
// @dev Upper bound of the range.
uint256 upper;
}
Loading
Loading