forked from superform-xyz/superform-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathICoreStateRegistry.sol
106 lines (89 loc) · 4.59 KB
/
ICoreStateRegistry.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
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;
import { IBridgeValidator } from "../interfaces/IBridgeValidator.sol";
import "../types/DataTypes.sol";
/// @title ICoreStateRegistry
/// @author ZeroPoint Labs
/// @notice Interface for Core State Registry
interface ICoreStateRegistry {
/*///////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
/// @dev local struct to avoid stack too deep errors in `processPayload`
struct CoreProcessPayloadLocalVars {
uint8 txType;
uint8 callbackType;
uint8 multi;
address srcSender;
uint64 srcChainId;
}
/// @dev local struct to avoid stack too deep errors in `updateWithdrawPayload`
struct UpdateWithdrawPayloadVars {
bytes32 prevPayloadProof;
bytes prevPayloadBody;
uint256 prevPayloadHeader;
uint8 isMulti;
uint64 srcChainId;
uint64 dstChainId;
address srcSender;
}
/// @dev local struct to avoid stack too deep errors in `updateWithdrawPayload`
struct UpdateMultiVaultWithdrawPayloadLocalVars {
InitMultiVaultData multiVaultData;
InitSingleVaultData singleVaultData;
address superform;
uint256[] tSuperFormIds;
uint256[] tAmounts;
uint256[] tMaxSlippage;
LiqRequest[] tLiqData;
}
struct FailedDeposit {
uint256[] superformIds;
uint256[] amounts;
address refundAddress;
uint256 lastProposedTimestamp;
}
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
/// @dev is emitted when any deposit fails
event FailedXChainDeposits(uint256 indexed payloadId);
/// @dev is emitted when a rescue is proposed for failed deposits in a payload
event RescueProposed(
uint256 indexed payloadId, uint256[] superformIds, uint256[] proposedAmount, uint256 proposedTime
);
/// @dev is emitted when an user disputed his refund amounts
event RescueDisputed(uint256 indexed payloadId);
/// @dev is emitted when deposit rescue is finalized
event RescueFinalized(uint256 indexed payloadId);
/*///////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @dev allows users to read the superformIds that failed in a specific payloadId_
/// @param payloadId_ is the identifier of the cross-chain payload.
/// @return superformIds_ is the identifiers of superforms in the payloadId that got failed.
function getFailedDeposits(uint256 payloadId_)
external
view
returns (uint256[] memory superformIds_, uint256[] memory amounts);
/// @dev allows accounts with {CORE_STATE_REGISTRY_UPDATER_ROLE} to modify a received cross-chain deposit payload.
/// @param payloadId_ is the identifier of the cross-chain payload to be updated.
/// @param finalAmounts_ is the amount to be updated.
/// NOTE: amounts cannot be updated beyond user specified safe slippage limit.
function updateDepositPayload(uint256 payloadId_, uint256[] calldata finalAmounts_) external;
/// @dev allows accounts with {CORE_STATE_REGISTRY_UPDATER_ROLE} to modify a received cross-chain withdraw payload.
/// @param payloadId_ is the identifier of the cross-chain payload to be updated.
/// @param txData_ is the transaction data to be updated.
function updateWithdrawPayload(uint256 payloadId_, bytes[] calldata txData_) external;
/// @dev allows accounts with {CORE_STATE_REGISTRY_PROCESSOR_ROLE} to rescue tokens on failed deposits
/// @param payloadId_ is the identifier of the cross-chain payload.
/// @param proposedAmounts_ is the array of proposed rescue amounts.
function proposeRescueFailedDeposits(uint256 payloadId_, uint256[] memory proposedAmounts_) external;
/// @dev allows refund receivers to challenge their final receiving token amounts on failed deposits
/// @param payloadId_ is the identifier of the cross-chain payload
/// @notice should challenge within the delay window configured on SuperRegistry
function disputeRescueFailedDeposits(uint256 payloadId_) external;
/// @dev allows anyone to settle refunds for unprocessed/failed deposits past the challenge period
/// @param payloadId_ is the identifier of the cross-chain payload
function finalizeRescueFailedDeposits(uint256 payloadId_) external;
}