-
Notifications
You must be signed in to change notification settings - Fork 261
Expand file tree
/
Copy pathIYieldBackend.sol
More file actions
48 lines (42 loc) · 2.34 KB
/
IYieldBackend.sol
File metadata and controls
48 lines (42 loc) · 2.34 KB
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
/**
* A yield backend acts as interface between an ERC20 wrapper SuperToken and a yield generating protocol.
* The underlying token can be deposited on upgrade and withdrawn on downgrade.
*
* It is possible to transition from no/one yield backend to another/no yield backend.
* one -> another could be seen as a composition of one -> no -> another
*
* one -> no means withdraw not in the context of a downgrade.
*
* Contracts implementing this act as a kind of hot-pluggable library,
* using delegatecall to execute its logic on the SuperToken contract.
* This means that underlying tokens are transferred directly between the SuperToken contract and the yield protocol,
* as are yield protocol tokens representing positions in that protocol.
* If an implementation requires to hold state, it shall do so using a namespaced storage layout (EIP-7201).
*/
interface IYieldBackend {
/// Invoked by `SuperToken` as delegatecall.
/// Sets up the SuperToken as needed, e.g. by giving required approvals.
function enable() external;
/// Invoked by `SuperToken` as delegatecall.
/// Restores the prior state, e.g. by revoking given approvals
function disable() external;
/// Invoked by `SuperToken` as delegatecall.
/// Deposits the given amount of the underlying asset into the yield backend.
function deposit(uint256 amount) external;
/// Invoked by `SuperToken` as delegatecall.
/// Deposits the maximum amount of the underlying asset into the yield backend.
/// Maximum is defined by the underlying asset balance of the SuperToken and the yield backend capacity.
function depositMax() external;
/// Invoked by `SuperToken` as delegatecall.
/// Withdraws the given amount of the underlying asset from the yield backend.
function withdraw(uint256 amount) external;
/// Invoked by `SuperToken` as delegatecall.
/// Withdraws the maximum amount of the underlying asset from the yield backend.
/// Maximum is defined by how much can be withdrawn from the yield backend at that point in time.
function withdrawMax() external;
/// Invoked by `SuperToken` as delegatecall.
/// tranfers the deposited asset exceeding totalSupply of the SuperToken to the preset receiver account
function withdrawSurplus(uint256 totalSupply) external;
}