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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.6; /** * @title IBondTellerMatic * @author solace.fi * @notice A bond teller that accepts **MATIC** and **WMATIC** as payment. * * Bond tellers allow users to buy bonds. Payments are made in **MATIC** or **WMATIC** which is sent to the underwriting pool and used to back risk. Users will receive [**SOLACE**](./../../SOLACE) but it must be bonded or staked. If bonded, the [**SOLACE**](./../../SOLACE) will be vested linearly and redeemed over time. If staked, the [**SOLACE**](./../../SOLACE) only be withdrawable after the lock expires but will give the user extra [**SOLACE**](./../../SOLACE) rewards and voting rights. * * Bonds can be purchased via [`depositMatic()`](#depositeth), [`depositWmatic()`](#depositwmatic), or [`depositWmaticSigned()`](#depositwmaticsigned). Bonds are represented as ERC721s, can be viewed with [`bonds()`](#bonds), and redeemed with [`claimRewards()`](#claimrewards). If staked, an [`xsLocker`](./../../staking/xsLocker) lock is created instead of a bond. */ interface IBondTellerMatic { /*************************************** EVENTS ***************************************/ /// @notice Emitted when a bond is created. event CreateBond(uint256 indexed lockID, uint256 principalAmount, uint256 payoutAmount, uint40 vestingStart, uint40 vestingTime); /// @notice Emitted when a bond is redeemed. event RedeemBond(uint256 indexed bondID, address recipient, uint256 payoutAmount); /// @notice Emitted when deposits are paused. event Paused(); /// @notice Emitted when deposits are unpaused. event Unpaused(); /// @notice Emitted when terms are set. event TermsSet(); /// @notice Emitted when fees are set. event FeesSet(); /// @notice Emitted when fees are set. event AddressesSet(); /*************************************** INITIALIZER ***************************************/ /** * @notice Initializes the teller. * @param name_ The name of the bond token. * @param governance_ The address of the [governor](/docs/protocol/governance). * @param solace_ The [**SOLACE**](./../../SOLACE) token. * @param xsLocker_ The [**xsLocker**](./../../staking/xsLocker) contract. * @param pool_ The underwriting pool. * @param dao_ The DAO. * @param principal_ The ERC20 token that users deposit. * @param isPermittable_ True if `principal` supports `EIP2612`. * @param bondDepo_ The bond depository. */ function initialize( string memory name_, address governance_, address solace_, address xsLocker_, address pool_, address dao_, address principal_, bool isPermittable_, address bondDepo_ ) external; /*************************************** VIEW FUNCTIONS ***************************************/ // BOND PRICE /** * @notice Calculate the current price of a bond. * Assumes 1 [**SOLACE**](./../../SOLACE) payout. * @return price_ The price of the bond measured in `principal`. */ function bondPrice() external view returns (uint256 price_); /** * @notice Calculate the amount of [**SOLACE**](./../../SOLACE) out for an amount of `principal`. * @param amountIn Amount of principal to deposit. * @param stake True to stake, false to not stake. * @return amountOut Amount of [**SOLACE**](./../../SOLACE) out. */ function calculateAmountOut(uint256 amountIn, bool stake) external view returns (uint256 amountOut); /** * @notice Calculate the amount of `principal` in for an amount of [**SOLACE**](./../../SOLACE) out. * @param amountOut Amount of [**SOLACE**](./../../SOLACE) out. * @param stake True to stake, false to not stake. * @return amountIn Amount of principal to deposit. */ function calculateAmountIn(uint256 amountOut, bool stake) external view returns (uint256 amountIn); /*************************************** BONDER FUNCTIONS ***************************************/ /** * @notice Create a bond by depositing **MATIC**. * Principal will be transferred from `msg.sender` using `allowance`. * @param minAmountOut The minimum [**SOLACE**](./../../SOLACE) out. * @param depositor The bond recipient, default msg.sender. * @param stake True to stake, false to not stake. * @return payout The amount of [**SOLACE**](./../../SOLACE) in the bond. * @return tokenID The ID of the newly created bond or lock. */ function depositMatic( uint256 minAmountOut, address depositor, bool stake ) external payable returns (uint256 payout, uint256 tokenID); /** * @notice Create a bond by depositing `amount` **WMATIC**. * **WMATIC** will be transferred from `msg.sender` using `allowance`. * @param amount Amount of **WMATIC** to deposit. * @param minAmountOut The minimum [**SOLACE**](./../../SOLACE) out. * @param depositor The bond recipient, default msg.sender. * @param stake True to stake, false to not stake. * @return payout The amount of [**SOLACE**](./../../SOLACE) in the bond. * @return tokenID The ID of the newly created bond or lock. */ function depositWmatic( uint256 amount, uint256 minAmountOut, address depositor, bool stake ) external returns (uint256 payout, uint256 tokenID); /** * @notice Create a bond by depositing `amount` **WMATIC**. * **WMATIC** will be transferred from `depositor` using `permit`. * Note that not all **WMATIC**s have a permit function, in which case this function will revert. * @param amount Amount of **WMATIC** to deposit. * @param minAmountOut The minimum [**SOLACE**](./../../SOLACE) out. * @param depositor The bond recipient, default msg.sender. * @param stake True to stake, false to not stake. * @param deadline Time the transaction must go through before. * @param v secp256k1 signature * @param r secp256k1 signature * @param s secp256k1 signature * @return payout The amount of [**SOLACE**](./../../SOLACE) in the bond. * @return tokenID The ID of the newly created bond or lock. */ function depositWmaticSigned( uint256 amount, uint256 minAmountOut, address depositor, bool stake, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 payout, uint256 tokenID); /** * @notice Claim payout for a bond that the user holds. * User calling `claimPayout()` must be either the owner or approved for the entered bondID. * @param bondID The ID of the bond to redeem. */ function claimPayout(uint256 bondID) external; /*************************************** GOVERNANCE FUNCTIONS ***************************************/ /** * @notice Pauses deposits. * Can only be called by the current [**governor**](/docs/protocol/governance). */ function pause() external; /** * @notice Unpauses deposits. * Can only be called by the current [**governor**](/docs/protocol/governance). */ function unpause() external; /** * @notice Sets the addresses to call out. * Can only be called by the current [**governor**](/docs/protocol/governance). * @param solace_ The [**SOLACE**](./../../SOLACE) token. * @param xsLocker_ The [**xsLocker**](./../../staking/xsLocker) contract. * @param pool_ The underwriting pool. * @param dao_ The DAO. * @param principal_ The ERC20 token that users deposit. * @param isPermittable_ True if `principal` supports `EIP2612`. * @param bondDepo_ The bond depository. */ function setAddresses( address solace_, address xsLocker_, address pool_, address dao_, address principal_, bool isPermittable_, address bondDepo_ ) external; /*************************************** FALLBACK FUNCTIONS ***************************************/ /** * @notice Fallback function to allow contract to receive *MATIC*. * Deposits **MATIC** and creates bond. */ receive () external payable; /** * @notice Fallback function to allow contract to receive **MATIC**. * Deposits **MATIC** and creates bond. */ fallback () external payable; } |