forked from superform-xyz/superform-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIBaseForm.sol
140 lines (113 loc) · 6.26 KB
/
IBaseForm.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
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
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;
import { IERC165 } from "openzeppelin-contracts/contracts/utils/introspection/IERC165.sol";
import { InitSingleVaultData } from "../types/DataTypes.sol";
import { IERC4626 } from "openzeppelin-contracts/contracts/interfaces/IERC4626.sol";
/// @title IBaseForm
/// @author ZeroPoint Labs
/// @notice Interface for Base Form
interface IBaseForm is IERC165 {
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
/// @dev is emitted when a new vault is added by the admin.
event VaultAdded(uint256 id, IERC4626 vault);
/// @dev is emitted when a payload is processed by the destination contract.
event Processed(uint64 srcChainID, uint64 dstChainId, uint256 srcPayloadId, uint256 amount, address vault);
/// @dev is emitted when an emergency withdrawal is processed
event EmergencyWithdrawalProcessed(address refundAddress, uint256 amount);
/*///////////////////////////////////////////////////////////////
EXTERNAL WRITE FUNCTONS
//////////////////////////////////////////////////////////////*/
/// @dev process same chain id deposits
/// @param singleVaultData_ A bytes representation containing all the data required to make a form action
/// @param srcSender_ The address of the sender of the transaction
/// @return dstAmount The amount of tokens deposited in same chain action
function directDepositIntoVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_
)
external
payable
returns (uint256 dstAmount);
/// @dev process withdrawal of collateral from a vault
/// @param singleVaultData_ A bytes representation containing all the data required to make a form action
/// @param srcSender_ The address of the sender of the transaction
/// @return dstAmount The amount of tokens withdrawn in same chain action
function directWithdrawFromVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_
)
external
returns (uint256 dstAmount);
/// @dev process same chain id deposits
/// @param singleVaultData_ A bytes representation containing all the data required to make a form action
/// @param srcSender_ The address of the sender of the transaction
/// @param srcChainId_ The chain id of the source chain
/// @return dstAmount The amount of tokens deposited in same chain action
/// @dev is dstAmoutn is `0` then no further action/acknowledgement needs to be sent
function xChainDepositIntoVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_,
uint64 srcChainId_
)
external
returns (uint256 dstAmount);
/// @dev process withdrawal of collateral from a vault
/// @param singleVaultData_ A bytes representation containing all the data required to make a form action
/// @param srcSender_ The address of the sender of the transaction
/// @param srcChainId_ The chain id of the source chain
/// @return dstAmount The amount of tokens withdrawn
function xChainWithdrawFromVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_,
uint64 srcChainId_
)
external
returns (uint256 dstAmount);
/// @dev process withdrawal of shares if form is paused
/// @param refundAddress_ The address to refund the shares to
/// @param amount_ The amount of vault shares to refund
function emergencyWithdraw(address refundAddress_, uint256 amount_) external;
/// @notice get Superform name of the ERC20 vault representation
/// @return The ERC20 name
function superformYieldTokenName() external view returns (string memory);
/// @notice get Superform symbol of the ERC20 vault representation
/// @return The ERC20 symbol
function superformYieldTokenSymbol() external view returns (string memory);
/// @notice Returns the underlying token of a vault.
/// @return The asset being deposited into the vault used for accounting, depositing, and withdrawing
function getVaultAsset() external view returns (address);
/// @notice Returns the name of the vault.
/// @return The name of the vault
function getVaultName() external view returns (string memory);
/// @notice Returns the symbol of a vault.
/// @return The symbol associated with a vault
function getVaultSymbol() external view returns (string memory);
/// @notice Returns the number of decimals in a vault for accounting purposes
/// @return The number of decimals in the vault balance
function getVaultDecimals() external view returns (uint256);
/// @dev returns the vault address
function getVaultAddress() external view returns (address);
/// @notice Returns the amount of underlying tokens each share of a vault is worth.
/// @return The pricePerVaultShare value
function getPricePerVaultShare() external view returns (uint256);
/// @notice Returns the amount of vault shares owned by the form.
/// @return The form's vault share balance
function getVaultShareBalance() external view returns (uint256);
/// @notice get the total amount of underlying managed in the ERC4626 vault
function getTotalAssets() external view returns (uint256);
/// @notice get the total amount of assets received if shares are actually redeemed
/// @notice https://eips.ethereum.org/EIPS/eip-4626
function getPreviewPricePerVaultShare() external view returns (uint256);
/// @notice get the state registry id
function getStateRegistryId() external view returns (uint256);
/// @dev API may need to know state of funds deployed
function previewDepositTo(uint256 assets_) external view returns (uint256);
/// @notice positionBalance() -> .vaultIds&destAmounts
/// @return how much of an asset + interest (accrued) is to withdraw from the Vault
function previewWithdrawFrom(uint256 assets_) external view returns (uint256);
/// @dev API may need to know state of funds deployed
function previewRedeemFrom(uint256 shares_) external view returns (uint256);
function formImplementationId() external view returns (uint32);
}