-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor to make contracts and tests strategy-centric
- Loading branch information
Showing
25 changed files
with
996 additions
and
3,566 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
202 changes: 142 additions & 60 deletions
202
contracts/Strategy.sol โ contracts/EverlongStrategy.sol
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,58 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity ^0.8.18; | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.20; | ||
|
||
import { IStrategy } from "tokenized-strategy/interfaces/IStrategy.sol"; | ||
import { IEverlong } from "./IEverlong.sol"; | ||
|
||
interface IEverlongStrategy is IStrategy { | ||
// โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ | ||
// โ VIEW FUNCTIONS โ | ||
// โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ | ||
|
||
/// @notice Gets the number of positions managed by the Everlong instance. | ||
/// @return The number of positions. | ||
function positionCount() external view returns (uint256); | ||
|
||
/// @notice Gets the position at an index. | ||
/// Position `maturityTime` increases with each index. | ||
/// @param _index The index of the position. | ||
/// @return The position. | ||
function positionAt( | ||
uint256 _index | ||
) external view returns (IEverlong.Position memory); | ||
import { IEverlongEvents } from "./IEverlongEvents.sol"; | ||
import { IEverlongPortfolio } from "./IEverlongPortfolio.sol"; | ||
|
||
interface IEverlongStrategy is IStrategy, IEverlongEvents, IEverlongPortfolio { | ||
// โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ | ||
// โ Structs โ | ||
// โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ | ||
|
||
/// @notice Contains the information needed to identify an open Hyperdrive position. | ||
struct Position { | ||
/// @notice Time when the position matures. | ||
uint128 maturityTime; | ||
/// @notice Amount of bonds in the position. | ||
uint128 bondAmount; | ||
} | ||
|
||
// TODO: Revisit position closure limit to see what POSITION_DURATION would | ||
// be needed to run out of gas. | ||
// | ||
/// @notice Parameters to specify how a rebalance will be performed. | ||
struct RebalanceOptions { | ||
/// @notice Limit on the amount of idle to spend on a new position. | ||
/// @dev A value of zero indicates no limit. | ||
uint256 spendingLimit; | ||
/// @notice Minimum amount of bonds to receive when opening a position. | ||
uint256 minOutput; | ||
/// @notice Minimum vault share price when opening a position. | ||
uint256 minVaultSharePrice; | ||
/// @notice Maximum amount of mature positions that can be closed. | ||
/// @dev A value of zero indicates no limit. | ||
uint256 positionClosureLimit; | ||
/// @notice Passed to hyperdrive `openLong()` and `closeLong()`. | ||
bytes extraData; | ||
} | ||
|
||
// โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ | ||
// โ Views โ | ||
// โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ | ||
|
||
/// @notice Gets the address of the underlying Hyperdrive Instance | ||
function hyperdrive() external view returns (address); | ||
|
||
/// @notice Gets the Everlong instance's kind. | ||
/// @return The Everlong instance's kind. | ||
function kind() external pure returns (string memory); | ||
|
||
/// @notice Gets the Everlong instance's version. | ||
/// @return The Everlong instance's version. | ||
function version() external pure returns (string memory); | ||
|
||
/// @notice Gets whether Everlong uses hyperdrive's base token. | ||
/// @return True if using hyperdrive's base token, false otherwise. | ||
function asBase() external view returns (bool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.20; | ||
|
||
/// @author DELV | ||
/// @title IEverlongStrategyFactory | ||
/// @notice Interface for an EverlongStrategyFactory. | ||
/// @custom:disclaimer The language used in this code is for coding convenience | ||
/// only, and is not intended to, and does not, have any | ||
/// particular legal or regulatory significance. | ||
interface IEverlongStrategyFactory { | ||
// โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ | ||
// โ Stateful โ | ||
// โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ | ||
|
||
/** | ||
* @notice Deploy a new Strategy. | ||
* @param _asset The underlying asset for the strategy to use. | ||
* @param _hyperdrive The underlying hyperdrive pool for the strategy to use. | ||
* @param _asBase Whether to use hyperdrive's base asset. | ||
* @return . The address of the new strategy. | ||
*/ | ||
function newStrategy( | ||
address _asset, | ||
string calldata _name, | ||
address _hyperdrive, | ||
bool _asBase | ||
) external returns (address); | ||
|
||
// โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ | ||
// โ Views โ | ||
// โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ | ||
|
||
/// @notice Gets the Everlong factory's name. | ||
/// @return The Everlong instance's kind. | ||
function name() external pure returns (string memory); | ||
|
||
/// @notice Gets the Everlong factory's kind. | ||
/// @return The Everlong factory's kind. | ||
function kind() external pure returns (string memory); | ||
|
||
/// @notice Gets the Everlong factory's version. | ||
/// @return The Everlong factory's version. | ||
function version() external pure returns (string memory); | ||
|
||
// โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ | ||
// โ Events โ | ||
// โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ | ||
|
||
/// @notice Emitted when a new EverlongStrategy is created. | ||
event NewStrategy(address indexed strategy, address indexed asset); | ||
} |
Oops, something went wrong.