File size: 38,516 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
  "language": "Solidity",
  "sources": {
    "contracts/TreasuryBondDepository.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./BaseBondDepository.sol\";\n\nimport \"./interfaces/ITreasuryBondDepository.sol\";\nimport \"./interfaces/IBondGovernor.sol\";\nimport \"./interfaces/ITreasury.sol\";\n\n/// @title TreasuryBondDepository\n/// @author Bluejay Core Team\n/// @notice TreasuryBondDepository allows the protocol to raise funds into the Treasury by selling bonds.\n/// These bonds allow users to claim governance token vested over a period of time.\n/// The bonds are priced based on outstanding debt ratio and a bond control variable.\n/// @dev This contract is only suitable for assets with 18 decimals.\ncontract TreasuryBondDepository is\n  Ownable,\n  BaseBondDepository,\n  ITreasuryBondDepository\n{\n  using SafeERC20 for IERC20;\n\n  uint256 private constant WAD = 10**18;\n  uint256 private constant RAY = 10**27;\n  uint256 private constant RAD = 10**45;\n\n  /// @notice Contract address of the BLU Token\n  IERC20 public immutable BLU;\n\n  /// @notice Contract address of the asset used to pay for the bonds\n  IERC20 public immutable override reserve;\n\n  /// @notice Contract address of the Treasury where the reserve assets are sent and BLU minted\n  ITreasury public immutable treasury;\n\n  /// @notice Vesting period of bonds, in seconds\n  uint256 public immutable vestingPeriod;\n\n  /// @notice Contract address of the BondGovernor where bond parameters are defined\n  IBondGovernor public bondGovernor;\n\n  /// @notice Address where fees collected from bond sales are sent\n  address public feeCollector;\n\n  /// @notice Flag to pause purchase of bonds\n  bool public isPurchasePaused;\n\n  /// @notice Flag to pause redemption of bonds\n  bool public isRedeemPaused;\n\n  /// @notice Governance token debt outstanding, decaying over the vesting period, in WAD\n  uint256 public totalDebt;\n\n  /// @notice Timestamp of last debt decay, in unix timestamp\n  uint256 public lastDecay;\n\n  /// @notice Constructor to initialize the contract\n  /// @dev Bond parameters should be initialized in the bond governor.\n  /// @param _bondGovernor Address of bond governor which defines bond parameters\n  /// @param _reserve Address of the asset accepted for payment of the bonds\n  /// @param _BLU Address of the BLU token\n  /// @param _treasury Address of the Treasury for minting BLU tokens and storing proceeds\n  /// @param _feeCollector Address to send fees collected from bond sales\n  /// @param _vestingPeriod Vesting period of bonds, in seconds\n  constructor(\n    address _bondGovernor,\n    address _reserve,\n    address _BLU,\n    address _treasury,\n    address _feeCollector,\n    uint256 _vestingPeriod\n  ) {\n    bondGovernor = IBondGovernor(_bondGovernor);\n    reserve = IERC20(_reserve);\n    BLU = IERC20(_BLU);\n    treasury = ITreasury(_treasury);\n    feeCollector = _feeCollector;\n    vestingPeriod = _vestingPeriod;\n    isPurchasePaused = true;\n  }\n\n  // =============================== INTERNAL FUNCTIONS =================================\n\n  /// @notice Decrease total debt by removing amount of debt decayed during the period elapsed\n  function _decayDebt() internal {\n    totalDebt = totalDebt - debtDecay();\n    lastDecay = block.timestamp;\n  }\n\n  // =============================== PUBLIC FUNCTIONS =================================\n\n  /// @notice Purchase treasury bond paid with reserve assets\n  /// @dev Approval of reserve asset to this address is required\n  /// @param amount Amount of reserve asset to spend, in WAD\n  /// @param maxPrice Maximum price to pay for the bond to prevent slippages, in WAD\n  /// @param recipient Address to issue the bond to\n  /// @return bondId ID of bond that was issued\n  function purchase(\n    uint256 amount,\n    uint256 maxPrice,\n    address recipient\n  ) public override returns (uint256 bondId) {\n    require(!isPurchasePaused, \"Purchase paused\");\n    (\n      uint256 controlVariable,\n      uint256 minimumPrice,\n      uint256 minimumSize,\n      uint256 maximumSize,\n      uint256 fees\n    ) = bondGovernor.getPolicy(address(reserve));\n    require(recipient != address(0), \"Invalid address\");\n\n    _decayDebt();\n\n    uint256 price = calculateBondPrice(\n      controlVariable,\n      minimumPrice,\n      debtRatio()\n    );\n    require(price <= maxPrice, \"Price too high\");\n\n    uint256 payout = (amount * WAD) / price;\n    require(payout >= minimumSize, \"Bond size too small\");\n    require(payout <= maximumSize, \"Bond size too big\");\n\n    uint256 feeCollected = (amount * fees) / price;\n    reserve.safeTransferFrom(msg.sender, address(treasury), amount);\n    treasury.mint(address(this), payout + feeCollected);\n\n    if (feeCollected > 0) {\n      BLU.safeTransfer(feeCollector, feeCollected);\n    }\n\n    bondId = _mint(recipient, payout, vestingPeriod);\n    totalDebt += payout;\n\n    emit BondPurchased(bondId, recipient, amount, payout, price);\n  }\n\n  /// @notice Redeem BLU tokens from previously purchased bond.\n  /// BLU is linearly vested over the vesting period and user can redeem vested tokens at any time.\n  /// @dev Bond will be deleted after the bond is fully vested and redeemed\n  /// @param bondId ID of bond to redeem, caller must the bond owner\n  /// @param recipient Address to send vested BLU tokens to\n  /// @return payout Amount of BLU tokens sent to recipient, in WAD\n  /// @return principal Amount of BLU tokens left to be vested on the bond, in WAD\n  function redeem(uint256 bondId, address recipient)\n    public\n    override\n    returns (uint256 payout, uint256 principal)\n  {\n    require(!isRedeemPaused, \"Redeem paused\");\n    require(bondOwners[bondId] == msg.sender, \"Not bond owner\");\n    Bond memory bond = bonds[bondId];\n    if (bond.lastRedeemed + bond.vestingPeriod <= block.timestamp) {\n      _burn(bondId);\n      payout = bond.principal;\n      BLU.safeTransfer(recipient, bond.principal);\n      emit BondRedeemed(bondId, recipient, true, payout, 0);\n    } else {\n      payout =\n        (bond.principal * (block.timestamp - bond.lastRedeemed)) /\n        bond.vestingPeriod;\n      principal = bond.principal - payout;\n      bonds[bondId] = Bond({\n        principal: principal,\n        vestingPeriod: bond.vestingPeriod -\n          (block.timestamp - bond.lastRedeemed),\n        purchased: bond.purchased,\n        lastRedeemed: block.timestamp\n      });\n      BLU.safeTransfer(recipient, payout);\n      emit BondRedeemed(bondId, recipient, false, payout, principal);\n    }\n  }\n\n  // =============================== ADMIN FUNCTIONS =================================\n\n  /// @notice Set the address where fees are sent to\n  /// @param _feeCollector Address of fee collector\n  function setFeeCollector(address _feeCollector) public override onlyOwner {\n    feeCollector = _feeCollector;\n    emit UpdatedFeeCollector(_feeCollector);\n  }\n\n  /// @notice Pause or unpause redemption of bonds\n  /// @param pause True to pause redemption, false to unpause redemption\n  function setIsRedeemPaused(bool pause) public override onlyOwner {\n    isRedeemPaused = pause;\n    emit RedeemPaused(pause);\n  }\n\n  /// @notice Pause or unpause purchase of bonds\n  /// @param pause True to pause purchase, false to unpause purchase\n  function setIsPurchasePaused(bool pause) public override onlyOwner {\n    isPurchasePaused = pause;\n    emit PurchasePaused(pause);\n  }\n\n  // =============================== VIEW FUNCTIONS =================================\n\n  /// @notice Calculate current debt after debt decay\n  /// @return debt Amount of current debt, in WAD\n  function currentDebt() public view override returns (uint256 debt) {\n    debt = totalDebt - debtDecay();\n  }\n\n  /// @notice Calculate amount of debt decayed during the period elapsed\n  /// @return decay Amount of debt to decay by, in WAD\n  function debtDecay() public view override returns (uint256 decay) {\n    uint256 timeSinceLast = block.timestamp - lastDecay;\n    decay = (totalDebt * timeSinceLast) / vestingPeriod;\n    if (decay > totalDebt) {\n      decay = totalDebt;\n    }\n  }\n\n  /// @notice Calculate ratio of debt against the total supply of BLU tokens\n  /// @return ratio Debt ratio, in WAD\n  function debtRatio() public view override returns (uint256 ratio) {\n    ratio = (currentDebt() * WAD) / BLU.totalSupply();\n  }\n\n  /// @notice Calculate current price of bond\n  /// @return price Price of bond, in WAD\n  function bondPrice() public view override returns (uint256 price) {\n    (uint256 controlVariable, uint256 minimumPrice, , , ) = bondGovernor\n      .getPolicy(address(reserve));\n    return calculateBondPrice(controlVariable, minimumPrice, debtRatio());\n  }\n\n  /// @notice Calculate price of bond using the control variable, debt ratio and min price\n  /// @param controlVariable Control variable of bond, in RAY\n  /// @param minimumPrice Minimum price of bond, in WAD\n  /// @param ratio Debt ratio, in WAD\n  /// @return price Price of bond, in WAD\n  function calculateBondPrice(\n    uint256 controlVariable,\n    uint256 minimumPrice,\n    uint256 ratio\n  ) public pure override returns (uint256 price) {\n    price = (controlVariable * ratio + RAD) / RAY;\n    if (price < minimumPrice) {\n      price = minimumPrice;\n    }\n  }\n}\n"
    },
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
    },
    "@openzeppelin/contracts/interfaces/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\n"
    },
    "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    function safeTransfer(\n        IERC20 token,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(\n        IERC20 token,\n        address from,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    function safeIncreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        uint256 newAllowance = token.allowance(address(this), spender) + value;\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    function safeDecreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            uint256 newAllowance = oldAllowance - value;\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n        }\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        if (returndata.length > 0) {\n            // Return data is optional\n            require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n        }\n    }\n}\n"
    },
    "contracts/BaseBondDepository.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./interfaces/IBaseBondDepository.sol\";\n\n/// @title BaseBondDepository\n/// @author Bluejay Core Team\n/// @notice BaseBondDepository provides logic for minting, burning and storing bond info.\n/// The contract is to be inherited by treasury bond depository and stabilizing bond depository.\nabstract contract BaseBondDepository is IBaseBondDepository {\n  /// @notice Number of bonds minted, monotonic increasing from 0\n  uint256 public bondsCount;\n\n  /// @notice Map of bond ID to the bond information\n  mapping(uint256 => Bond) public override bonds;\n\n  /// @notice Map of bond ID to the address of the bond owner\n  mapping(uint256 => address) public bondOwners;\n\n  /// @notice Map of bond owner address to array of bonds owned\n  mapping(address => uint256[]) public ownedBonds;\n\n  /// @notice Map of bond owner and bond ID to the index location of `ownedBonds`\n  mapping(address => mapping(uint256 => uint256)) public ownedBondsIndex;\n\n  // =============================== INTERNAL FUNCTIONS =================================\n\n  /// @notice Internal function for child contract to mint a bond with fixed vesting period to an address\n  /// @param to Address to mint the bond to\n  /// @param payout Amount of assets to payout across the entire vesting period\n  /// @param vestingPeriod Vesting period of the bond\n  function _mint(\n    address to,\n    uint256 payout,\n    uint256 vestingPeriod\n  ) internal returns (uint256 bondId) {\n    bondId = ++bondsCount;\n    bonds[bondId] = Bond({\n      principal: payout,\n      vestingPeriod: vestingPeriod,\n      purchased: block.timestamp,\n      lastRedeemed: block.timestamp\n    });\n    bondOwners[bondId] = to;\n    uint256[] storage userBonds = ownedBonds[to];\n    ownedBondsIndex[to][bondId] = userBonds.length;\n    userBonds.push(bondId);\n  }\n\n  /// @notice Internal function for child contract to burn a bond, usually after it fully vest\n  /// This recover gas as well as delete the bond from the view functions\n  /// @param bondId Bond ID of the bond to burn\n  /// @dev Perform required sanity check on the bond before burning it\n  function _burn(uint256 bondId) internal {\n    address bondOwner = bondOwners[bondId];\n    require(bondOwner != address(0), \"Invalid bond\");\n    uint256[] storage userBonds = ownedBonds[bondOwner];\n    mapping(uint256 => uint256) storage userBondIndices = ownedBondsIndex[\n      bondOwner\n    ];\n    uint256 lastBondIndex = userBonds.length - 1;\n    uint256 bondIndex = userBondIndices[bondId];\n    if (bondIndex != lastBondIndex) {\n      uint256 lastBondId = userBonds[lastBondIndex];\n      userBonds[bondIndex] = lastBondId;\n      userBondIndices[lastBondId] = bondIndex;\n    }\n    userBonds.pop();\n    delete userBondIndices[bondId];\n    delete bonds[bondId];\n    delete bondOwners[bondId];\n  }\n\n  // =============================== INTERNAL FUNCTIONS =================================\n\n  /// @notice List all bond IDs owned by an address\n  /// @param owner Address of the owner of the bonds\n  /// @return bondIds List of bond IDs owned by the address\n  function listBondIds(address owner)\n    public\n    view\n    override\n    returns (uint256[] memory bondIds)\n  {\n    bondIds = ownedBonds[owner];\n  }\n\n  /// @notice List all bond info owned by an address\n  /// @param owner Address of the owner of the bonds\n  /// @return Bond List of bond info owned by the address\n  function listBonds(address owner)\n    public\n    view\n    override\n    returns (Bond[] memory)\n  {\n    uint256[] memory bondIds = ownedBonds[owner];\n    Bond[] memory bondsOwned = new Bond[](bondIds.length);\n    for (uint256 i = 0; i < bondIds.length; i++) {\n      bondsOwned[i] = bonds[bondIds[i]];\n    }\n    return bondsOwned;\n  }\n}\n"
    },
    "contracts/interfaces/ITreasuryBondDepository.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./IBondDepositoryCommon.sol\";\n\ninterface ITreasuryBondDepository is IBondDepositoryCommon {\n  function purchase(\n    uint256 amount,\n    uint256 maxPrice,\n    address recipient\n  ) external returns (uint256 bondId);\n\n  function currentDebt() external view returns (uint256 debt);\n\n  function debtDecay() external view returns (uint256 decay);\n\n  function debtRatio() external view returns (uint256 ratio);\n\n  function setFeeCollector(address dao) external;\n\n  function calculateBondPrice(\n    uint256 controlVariable,\n    uint256 minimumPrice,\n    uint256 ratio\n  ) external view returns (uint256 price);\n\n  event UpdatedFeeCollector(address dao);\n  event RedeemPaused(bool indexed isPaused);\n  event PurchasePaused(bool indexed isPaused);\n}\n"
    },
    "contracts/interfaces/IBondGovernor.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IBondGovernor {\n  struct Policy {\n    uint256 controlVariable; // [ray]\n    uint256 lastControlVariableUpdate; // [unix timestamp]\n    uint256 targetControlVariable; // [ray]\n    uint256 timeToTargetControlVariable; // [seconds]\n    uint256 minimumPrice; // [wad]\n  }\n\n  function initializePolicy(\n    address asset,\n    uint256 controlVariable,\n    uint256 minimumPrice\n  ) external;\n\n  function adjustPolicy(\n    address asset,\n    uint256 targetControlVariable,\n    uint256 timeToTargetControlVariable,\n    uint256 minimumPrice\n  ) external;\n\n  function updateControlVariable(address asset) external;\n\n  function setFees(uint256 _fees) external;\n\n  function setMinimumSize(uint256 _minimumSize) external;\n\n  function setMaximumRatio(uint256 _maximumRatio) external;\n\n  function getControlVariable(address asset)\n    external\n    view\n    returns (uint256 controlVariable);\n\n  function maximumBondSize() external view returns (uint256 maxBondSize);\n\n  function getPolicy(address asset)\n    external\n    view\n    returns (\n      uint256 currentControlVariable,\n      uint256 minPrice,\n      uint256 minSize,\n      uint256 maxBondSize,\n      uint256 fees\n    );\n\n  event UpdatedFees(uint256 fees);\n  event UpdatedMinimumSize(uint256 fees);\n  event UpdatedMaximumRatio(uint256 fees);\n  event CreatedPolicy(\n    address indexed asset,\n    uint256 controlVariable,\n    uint256 minPrice\n  );\n  event UpdatedPolicy(\n    address indexed asset,\n    uint256 targetControlVariable,\n    uint256 minPrice,\n    uint256 timeToTargetControlVariable\n  );\n}\n"
    },
    "contracts/interfaces/ITreasury.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface ITreasury {\n  function mint(address to, uint256 amount) external;\n\n  function withdraw(\n    address token,\n    address to,\n    uint256 amount\n  ) external;\n\n  function increaseMintLimit(address minter, uint256 amount) external;\n\n  function decreaseMintLimit(address minter, uint256 amount) external;\n\n  function increaseWithdrawalLimit(\n    address asset,\n    address spender,\n    uint256 amount\n  ) external;\n\n  function decreaseWithdrawalLimit(\n    address asset,\n    address spender,\n    uint256 amount\n  ) external;\n\n  event Mint(address indexed to, uint256 amount);\n  event Withdraw(address indexed token, address indexed to, uint256 amount);\n  event MintLimitUpdate(address indexed minter, uint256 amount);\n  event WithdrawLimitUpdate(\n    address indexed token,\n    address indexed minter,\n    uint256 amount\n  );\n}\n"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address recipient, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `sender` to `recipient` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) external returns (bool);\n\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"
    },
    "@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize, which returns 0 for contracts in\n        // construction, since the code is only stored at the end of the\n        // constructor execution.\n\n        uint256 size;\n        assembly {\n            size := extcodesize(account)\n        }\n        return size > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
    },
    "contracts/interfaces/IBaseBondDepository.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IBaseBondDepository {\n  struct Bond {\n    uint256 principal; // [wad]\n    uint256 vestingPeriod; // [seconds]\n    uint256 purchased; // [unix timestamp]\n    uint256 lastRedeemed; // [unix timestamp]\n  }\n\n  function bonds(uint256 _id)\n    external\n    view\n    returns (\n      uint256 principal,\n      uint256 vestingPeriod,\n      uint256 purchased,\n      uint256 lastRedeemed\n    );\n\n  function listBondIds(address owner)\n    external\n    view\n    returns (uint256[] memory bondIds);\n\n  function listBonds(address owner) external view returns (Bond[] memory);\n}\n"
    },
    "contracts/interfaces/IBondDepositoryCommon.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/interfaces/IERC20.sol\";\nimport \"./IBaseBondDepository.sol\";\n\ninterface IBondDepositoryCommon is IBaseBondDepository {\n  function reserve() external view returns (IERC20);\n\n  function bondPrice() external view returns (uint256 price);\n\n  function redeem(uint256 bondId, address recipient)\n    external\n    returns (uint256 payout, uint256 principal);\n\n  function setIsRedeemPaused(bool pause) external;\n\n  function setIsPurchasePaused(bool pause) external;\n\n  event BondPurchased(\n    uint256 indexed bondId,\n    address indexed recipient,\n    uint256 amount,\n    uint256 principal,\n    uint256 price\n  );\n  event BondRedeemed(\n    uint256 indexed bondId,\n    address indexed recipient,\n    bool indexed fullyRedeemed,\n    uint256 payout,\n    uint256 principal\n  );\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 1000000
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    },
    "libraries": {}
  }
}