-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add OFDA, OSDA, and SDA v1.1 contracts
- Loading branch information
Showing
15 changed files
with
1,804 additions
and
285 deletions.
There are no files selected for viewing
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,67 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity 0.8.15; | ||
|
||
import {BondBaseOFDA, IBondAggregator, Authority} from "./bases/BondBaseOFDA.sol"; | ||
import {IBondTeller} from "./interfaces/IBondTeller.sol"; | ||
import {IBondFixedExpiryTeller} from "./interfaces/IBondFixedExpiryTeller.sol"; | ||
|
||
/// @title Bond Fixed-Expiry Fixed Discount Auctioneer | ||
/// @notice Bond Fixed-Expiry Fixed Discount Auctioneer Contract | ||
/// @dev Bond Protocol is a permissionless system to create bond markets | ||
/// for any token pair. Bond issuers create BondMarkets that pay out | ||
/// a Payout Token in exchange for deposited Quote Tokens. Users can purchase | ||
/// future-dated Payout Tokens with Quote Tokens at the current market price and | ||
/// receive Bond Tokens to represent their position while their bond vests. | ||
/// Once the Bond Tokens vest, they can redeem it for the Quote Tokens. | ||
/// | ||
/// @dev An Auctioneer contract allows users to create and manage bond markets. | ||
/// All bond pricing logic and market data is stored in the Auctioneer. | ||
/// An Auctioneer is dependent on a Teller to serve external users and | ||
/// an Aggregator to register new markets. The Fixed Discount Auctioneer | ||
/// lets issuers set a Fixed Discount to an oracle price to buy a | ||
/// target amount of quote tokens or sell a target amount of payout tokens | ||
/// over the duration of a market. | ||
/// See IBondOFDA.sol for price format details. | ||
/// | ||
/// @dev The Fixed-Expiry Fixed Discount Auctioneer is an implementation of the | ||
/// Bond Base Fixed Discount Auctioneer contract specific to creating bond markets where | ||
/// all purchases on that market vest at a certain timestamp. | ||
/// | ||
/// @author Oighty | ||
contract BondFixedExpiryOFDA is BondBaseOFDA { | ||
/* ========== CONSTRUCTOR ========== */ | ||
constructor( | ||
IBondTeller teller_, | ||
IBondAggregator aggregator_, | ||
address guardian_, | ||
Authority authority_ | ||
) BondBaseOFDA(teller_, aggregator_, guardian_, authority_) {} | ||
|
||
/// @inheritdoc BondBaseOFDA | ||
function createMarket(bytes calldata params_) external override returns (uint256) { | ||
// Decode params into the struct type expected by this auctioneer | ||
MarketParams memory params = abi.decode(params_, (MarketParams)); | ||
|
||
// Vesting is rounded to the nearest day at 0000 UTC (in seconds) since bond tokens | ||
// are only unique to a day, not a specific timestamp. | ||
params.vesting = (params.vesting / 1 days) * 1 days; | ||
|
||
// Get conclusion from start time and duration | ||
// Don't need to check valid start time or duration here since it will be checked in _createMarket | ||
uint48 start = params.start == 0 ? uint48(block.timestamp) : params.start; | ||
uint48 conclusion = start + params.duration; | ||
|
||
// Check that the vesting parameter is valid for a fixed-expiry market | ||
if (params.vesting != 0 && params.vesting < conclusion) revert Auctioneer_InvalidParams(); | ||
|
||
// Create market with provided params | ||
uint256 marketId = _createMarket(params); | ||
|
||
// Create bond token (ERC20 for fixed expiry) if not instant swap | ||
if (params.vesting != 0) | ||
IBondFixedExpiryTeller(address(_teller)).deploy(params.payoutToken, params.vesting); | ||
|
||
// Return market ID | ||
return marketId; | ||
} | ||
} |
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,60 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity ^0.8.15; | ||
|
||
import {BondBaseOSDA, IBondAggregator, Authority} from "./bases/BondBaseOSDA.sol"; | ||
import {IBondTeller} from "./interfaces/IBondTeller.sol"; | ||
import {IBondFixedExpiryTeller} from "./interfaces/IBondFixedExpiryTeller.sol"; | ||
|
||
/// @title Bond Fixed-Expiry Oracle-based Sequential Dutch Auctioneer | ||
/// @notice Bond Fixed-Expiry Oracle-based Sequential Dutch Auctioneer Contract | ||
/// @dev Bond Protocol is a permissionless system to create Olympus-style bond markets | ||
/// for any token pair. The markets do not require maintenance and will manage | ||
/// bond prices based on activity. Bond issuers create BondMarkets that pay out | ||
/// a Payout Token in exchange for deposited Quote Tokens. Users can purchase | ||
/// future-dated Payout Tokens with Quote Tokens at the current market price and | ||
/// receive Bond Tokens to represent their position while their bond vests. | ||
/// Once the Bond Tokens vest, they can redeem it for the Quote Tokens. | ||
/// | ||
/// @dev The Fixed-Expiry Oracle-based SDA is an implementation of the | ||
/// Bond Base Oracle-based SDA contract specific to creating bond markets where | ||
/// all purchases on that market vest at a certain timestamp. | ||
/// | ||
/// @author Oighty, Zeus, Potted Meat, indigo | ||
contract BondFixedExpiryOSDA is BondBaseOSDA { | ||
/* ========== CONSTRUCTOR ========== */ | ||
constructor( | ||
IBondTeller teller_, | ||
IBondAggregator aggregator_, | ||
address guardian_, | ||
Authority authority_ | ||
) BondBaseOSDA(teller_, aggregator_, guardian_, authority_) {} | ||
|
||
/// @inheritdoc BondBaseOSDA | ||
function createMarket(bytes calldata params_) external override returns (uint256) { | ||
// Decode params into the struct type expected by this auctioneer | ||
MarketParams memory params = abi.decode(params_, (MarketParams)); | ||
|
||
// Vesting is rounded to the nearest day at 0000 UTC (in seconds) since bond tokens | ||
// are only unique to a day, not a specific timestamp. | ||
params.vesting = (params.vesting / 1 days) * 1 days; | ||
|
||
// Get conclusion from start time and duration | ||
// Don't need to check valid start time or duration here since it will be checked in _createMarket | ||
uint48 start = params.start == 0 ? uint48(block.timestamp) : params.start; | ||
uint48 conclusion = start + params.duration; | ||
|
||
// Check that the vesting parameter is valid for a fixed-expiry market | ||
if (params.vesting != 0 && params.vesting < conclusion) revert Auctioneer_InvalidParams(); | ||
|
||
// Create market with provided params | ||
uint256 marketId = _createMarket(params); | ||
|
||
// Create bond token (ERC20 for fixed expiry) if not instant swap | ||
if (params.vesting != 0) { | ||
IBondFixedExpiryTeller(address(_teller)).deploy(params.payoutToken, params.vesting); | ||
} | ||
|
||
// Return market ID | ||
return marketId; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity 0.8.15; | ||
|
||
import {BondBaseOFDA, IBondAggregator, Authority} from "./bases/BondBaseOFDA.sol"; | ||
import {IBondTeller} from "./interfaces/IBondTeller.sol"; | ||
|
||
/// @title Bond Fixed-Term Fixed Discount Auctioneer | ||
/// @notice Bond Fixed-Term Fixed Discount Auctioneer Contract | ||
/// @dev Bond Protocol is a permissionless system to create bond markets | ||
/// for any token pair. Bond issuers create BondMarkets that pay out | ||
/// a Payout Token in exchange for deposited Quote Tokens. Users can purchase | ||
/// future-dated Payout Tokens with Quote Tokens at the current market price and | ||
/// receive Bond Tokens to represent their position while their bond vests. | ||
/// Once the Bond Tokens vest, they can redeem it for the Quote Tokens. | ||
/// | ||
/// @dev An Auctioneer contract allows users to create and manage bond markets. | ||
/// All bond pricing logic and market data is stored in the Auctioneer. | ||
/// An Auctioneer is dependent on a Teller to serve external users and | ||
/// an Aggregator to register new markets. The Fixed Discount Auctioneer | ||
/// lets issuers set a Fixed Discount to an oracle price to buy a | ||
/// target amount of quote tokens or sell a target amount of payout tokens | ||
/// over the duration of a market. | ||
/// See IBondOFDA.sol for price format details. | ||
/// | ||
/// @dev The Fixed-Term Fixed Discount Auctioneer is an implementation of the | ||
/// Bond Bas Fixed Discount Auctioneer contract specific to creating bond markets where | ||
/// purchases vest in a fixed amount of time after purchased (rounded to the day). | ||
/// | ||
/// @author Oighty | ||
contract BondFixedTermOFDA is BondBaseOFDA { | ||
/* ========== CONSTRUCTOR ========== */ | ||
constructor( | ||
IBondTeller teller_, | ||
IBondAggregator aggregator_, | ||
address guardian_, | ||
Authority authority_ | ||
) BondBaseOFDA(teller_, aggregator_, guardian_, authority_) {} | ||
|
||
/* ========== MARKET FUNCTIONS ========== */ | ||
/// @inheritdoc BondBaseOFDA | ||
function createMarket(bytes calldata params_) external override returns (uint256) { | ||
// Decode params into the struct type expected by this auctioneer | ||
MarketParams memory params = abi.decode(params_, (MarketParams)); | ||
|
||
// Check that the vesting parameter is valid for a fixed-term market | ||
if (params.vesting != 0 && (params.vesting < 1 days || params.vesting > MAX_FIXED_TERM)) | ||
revert Auctioneer_InvalidParams(); | ||
|
||
// Create market and return market ID | ||
return _createMarket(params); | ||
} | ||
} |
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,44 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity ^0.8.15; | ||
|
||
import {BondBaseOSDA, IBondAggregator, Authority} from "./bases/BondBaseOSDA.sol"; | ||
import {IBondTeller} from "./interfaces/IBondTeller.sol"; | ||
|
||
/// @title Bond Fixed-Term Oracle-based Sequential Dutch Auctioneer | ||
/// @notice Bond Fixed-Term Oracle-based Sequential Dutch Auctioneer Contract | ||
/// @dev Bond Protocol is a permissionless system to create Olympus-style bond markets | ||
/// for any token pair. The markets do not require maintenance and will manage | ||
/// bond prices based on activity. Bond issuers create BondMarkets that pay out | ||
/// a Payout Token in exchange for deposited Quote Tokens. Users can purchase | ||
/// future-dated Payout Tokens with Quote Tokens at the current market price and | ||
/// receive Bond Tokens to represent their position while their bond vests. | ||
/// Once the Bond Tokens vest, they can redeem it for the Quote Tokens. | ||
/// | ||
/// @dev The Fixed-Term Oracle-based SDA is an implementation of the | ||
/// Bond Base OSDA contract specific to creating bond markets where | ||
/// purchases vest in a fixed amount of time after purchased (rounded to the day). | ||
/// | ||
/// @author Oighty, Zeus, Potted Meat, indigo | ||
contract BondFixedTermOSDA is BondBaseOSDA { | ||
/* ========== CONSTRUCTOR ========== */ | ||
constructor( | ||
IBondTeller teller_, | ||
IBondAggregator aggregator_, | ||
address guardian_, | ||
Authority authority_ | ||
) BondBaseOSDA(teller_, aggregator_, guardian_, authority_) {} | ||
|
||
/* ========== MARKET FUNCTIONS ========== */ | ||
/// @inheritdoc BondBaseOSDA | ||
function createMarket(bytes calldata params_) external override returns (uint256) { | ||
// Decode params into the struct type expected by this auctioneer | ||
MarketParams memory params = abi.decode(params_, (MarketParams)); | ||
|
||
// Check that the vesting parameter is valid for a fixed-term market | ||
if (params.vesting != 0 && (params.vesting < 1 days || params.vesting > MAX_FIXED_TERM)) | ||
revert Auctioneer_InvalidParams(); | ||
|
||
// Create market and return market ID | ||
return _createMarket(params); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.