-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathIAsyncStateRegistry.sol
154 lines (127 loc) · 6.23 KB
/
IAsyncStateRegistry.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { InitSingleVaultData } from "src/types/DataTypes.sol";
import { LiqRequest } from "src/types/DataTypes.sol";
//////////////////////////////////////////////////////////////
// ERRORS //
//////////////////////////////////////////////////////////////
error NOT_READY_TO_CLAIM();
error ERC7540_AMBIDS_NOT_ENCODED();
error INVALID_AMOUNT_IN_TXDATA();
error REQUEST_CONFIG_NON_EXISTENT();
error NOT_ASYNC_SUPERFORM();
error INVALID_UPDATED_TX_DATA();
//////////////////////////////////////////////////////////////
// ENUMS //
//////////////////////////////////////////////////////////////
/// @dev all statuses of the async payload
enum AsyncStatus {
UNAVAILABLE,
PENDING,
PROCESSED
}
//////////////////////////////////////////////////////////////
// STRUCTS //
//////////////////////////////////////////////////////////////
struct RequestConfig {
uint8 isXChain;
bool retain4626;
uint64 currentSrcChainId;
uint256 requestId;
uint256 currentReturnDataPayloadId;
uint256 maxSlippageSetting;
LiqRequest currentLiqRequest; // if different than address 0 signals keepers to update txData
uint8[] ambIds;
}
struct ClaimAvailableDepositsLocalVars {
address superformAddress;
uint256 claimableDeposit;
}
/// @dev holds information about a sync withdraw txdata payload
struct SyncWithdrawTxDataPayload {
uint64 srcChainId;
InitSingleVaultData data;
AsyncStatus status;
}
/// @title IAsyncStateRegistry
/// @dev Interface for AsyncStateRegistry
/// @author ZeroPoint Labs
interface IAsyncStateRegistry {
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @dev is emitted when a async deposit/redeem request is updated
event UpdatedRequestsConfig(address indexed user_, uint256 indexed superformId_, uint256 indexed requestId_);
/// @dev is emitted when shares are successfull claimed
event ClaimedAvailableDeposits(address indexed user_, uint256 indexed superformId_, uint256 indexed requestId_);
/// @dev is emitted when available funds are successfull redeemed
event ClaimedAvailableRedeems(address indexed user_, uint256 indexed superformId_, uint256 indexed requestId_);
/// @dev is emitted when async deposit fails
event FailedDepositClaim(address indexed user_, uint256 indexed superformId_, uint256 indexed requestId_);
/// @dev is emitted when async redeem fails
event FailedRedeemClaim(address indexed user_, uint256 indexed superformId_, uint256 indexed requestId_);
/// @dev is emitted when a sync redeem tx data payload is received
event ReceivedSyncWithdrawTxDataPayload(uint256 indexed payloadId_);
/// @dev is emitted when a sync redeem tx data payload is finalized
event FinalizedSyncWithdrawTxDataPayload(uint256 indexed payloadId_);
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @notice retrieves the request configuration for a given user and superform
/// @param user_ The address of the user
/// @param superformId_ The ID of the superform
/// @return requestConfig for the specified user and superform
function getRequestConfig(
address user_,
uint256 superformId_
)
external
view
returns (RequestConfig memory requestConfig);
/// @notice retrieves the sync withdraw txData payload for a given payload ID
/// @param payloadId_ The ID of the payload
/// @return syncWithdrawTxDataPayload_ for the specified payload ID
function getSyncWithdrawTxDataPayload(
uint256 payloadId_
)
external
view
returns (SyncWithdrawTxDataPayload memory syncWithdrawTxDataPayload_);
/// @notice retrieves the current withdraw tx data payload counter
function syncWithdrawTxDataPayloadCounter() external view returns (uint256);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @notice updates the request configuration for a given superform
/// @dev the request parameters of the latest update overrides all preceding requests
/// @param type_ The type of the request
/// @param srcChainId_ The source chain ID
/// @param isDeposit_ Whether the request is a deposit
/// @param requestId_ The ID of the request
/// @param data_ The InitSingleVaultData containing request information
function updateRequestConfig(
uint8 type_,
uint64 srcChainId_,
bool isDeposit_,
uint256 requestId_,
InitSingleVaultData memory data_
)
external;
/// @notice claims available deposits for a user
/// @param user_ The address of the user
/// @param superformId_ the ID of the superform
function claimAvailableDeposits(address user_, uint256 superformId_) external payable;
/// @notice claims available redeems for a user
/// @param user_ The address of the user
/// @param superformId_ The ID of the superform
/// @param updatedTxData_ The updated transaction data
function claimAvailableRedeem(address user_, uint256 superformId_, bytes memory updatedTxData_) external;
/// @notice Receives the off-chain generated transaction data for the sync withdraw tx
/// @param srcChainId_ is the chainId of the source chain
/// @param data_ is the basic information of the action intent
function receiveSyncWithdrawTxDataPayload(uint64 srcChainId_, InitSingleVaultData memory data_) external;
/// @notice Form Keeper finalizes sync withdraw tx data payload to process the action fully.
/// @param payloadId_ is the id of the payload to finalize
/// @param txData_ is the off-chain generated transaction data
function processSyncWithdrawWithUpdatedTxData(uint256 payloadId_, bytes memory txData_) external payable;
}