generated from sushiswap/hardhat-foundation
/
IBentoBoxMinimal.sol
98 lines (84 loc) · 3.53 KB
/
IBentoBoxMinimal.sol
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
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.7;
/// @notice Minimal interface for BentoBox token vault interactions - `token` is aliased as `address` from `IERC20` for code simplicity.
interface IBentoBoxMinimal {
struct Rebase {
uint128 elastic;
uint128 base;
}
struct StrategyData {
uint64 strategyStartDate;
uint64 targetPercentage;
uint128 balance; // the balance of the strategy that BentoBox thinks is in there
}
function strategyData(address token) external view returns (StrategyData memory);
/// @notice Balance per ERC-20 token per account in shares.
function balanceOf(address, address) external view returns (uint256);
/// @notice Deposit an amount of `token` represented in either `amount` or `share`.
/// @param token_ The ERC-20 token to deposit.
/// @param from which account to pull the tokens.
/// @param to which account to push the tokens.
/// @param amount Token amount in native representation to deposit.
/// @param share Token amount represented in shares to deposit. Takes precedence over `amount`.
/// @return amountOut The amount deposited.
/// @return shareOut The deposited amount repesented in shares.
function deposit(
address token_,
address from,
address to,
uint256 amount,
uint256 share
) external payable returns (uint256 amountOut, uint256 shareOut);
/// @notice Withdraws an amount of `token` from a user account.
/// @param token_ The ERC-20 token to withdraw.
/// @param from which user to pull the tokens.
/// @param to which user to push the tokens.
/// @param amount of tokens. Either one of `amount` or `share` needs to be supplied.
/// @param share Like above, but `share` takes precedence over `amount`.
function withdraw(
address token_,
address from,
address to,
uint256 amount,
uint256 share
) external returns (uint256 amountOut, uint256 shareOut);
/// @notice Transfer shares from a user account to another one.
/// @param token The ERC-20 token to transfer.
/// @param from which user to pull the tokens.
/// @param to which user to push the tokens.
/// @param share The amount of `token` in shares.
function transfer(
address token,
address from,
address to,
uint256 share
) external;
/// @dev Helper function to represent an `amount` of `token` in shares.
/// @param token The ERC-20 token.
/// @param amount The `token` amount.
/// @param roundUp If the result `share` should be rounded up.
/// @return share The token amount represented in shares.
function toShare(
address token,
uint256 amount,
bool roundUp
) external view returns (uint256 share);
/// @dev Helper function to represent shares back into the `token` amount.
/// @param token The ERC-20 token.
/// @param share The amount of shares.
/// @param roundUp If the result should be rounded up.
/// @return amount The share amount back into native representation.
function toAmount(
address token,
uint256 share,
bool roundUp
) external view returns (uint256 amount);
/// @notice Registers this contract so that users can approve it for the BentoBox.
function registerProtocol() external;
function totals(address token) external view returns (Rebase memory);
function harvest(
address token,
bool balance,
uint256 maxChangeAmount
) external;
}