-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathIDstSwapper.sol
105 lines (89 loc) · 4.82 KB
/
IDstSwapper.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
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
/// @title IDstSwapper
/// @dev Interface for DstSwapper
/// @author Zeropoint Labs
interface IDstSwapper {
//////////////////////////////////////////////////////////////
// STRUCTS //
//////////////////////////////////////////////////////////////
struct FailedSwap {
address interimToken;
uint256 amount;
}
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @dev is emitted when the super registry is updated.
event SuperRegistryUpdated(address indexed superRegistry);
/// @dev is emitted when a dst swap transaction is processed
event SwapProcessed(
uint256 indexed payloadId, uint256 indexed index, uint256 indexed bridgeId, uint256 finalAmount
);
/// @dev is emitted when a dst swap fails and intermediary tokens are sent to CoreStateRegistry for rescue
event SwapFailed(
uint256 indexed payloadId, uint256 indexed index, address indexed intermediaryToken, uint256 amount
);
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @notice returns the swapped amounts (if dst swap is successful)
/// @param payloadId_ is the id of payload
/// @param index_ represents the index in the payload (0 for single vault payload)
/// @return amount is the amount forwarded to core state registry after the swap
function swappedAmount(uint256 payloadId_, uint256 index_) external view returns (uint256 amount);
/// @notice returns the interim amounts (if dst swap is failing)
/// @param payloadId_ is the id of payload
/// @param index_ represents the index in the payload (0 for single vault payload)
/// @return interimToken is the token that is to be refunded
/// @return amount is the amount of interim token to be refunded
function getPostDstSwapFailureUpdatedTokenAmount(
uint256 payloadId_,
uint256 index_
)
external
view
returns (address interimToken, uint256 amount);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @notice will process dst swap through a liquidity bridge
/// @param payloadId_ represents the id of the payload
/// @param bridgeId_ represents the id of liquidity bridge used
/// @param txData_ represents the transaction data generated by liquidity bridge API.
function processTx(uint256 payloadId_, uint8 bridgeId_, bytes calldata txData_) external;
/// @notice will process dst swaps in batch through a liquidity bridge
/// @param payloadId_ represents the array of payload ids used
/// @param indices_ represents the index of the superformid in the payload
/// @param bridgeIds_ represents the array of ids of liquidity bridges used
/// @param txDatas_ represents the array of transaction data generated by liquidity bridge API
function batchProcessTx(
uint256 payloadId_,
uint256[] calldata indices_,
uint8[] calldata bridgeIds_,
bytes[] calldata txDatas_
)
external;
/// @notice updates the amounts of intermediary tokens stuck because of failing dst swap
/// @param payloadId_ represents the id of the payload
/// @param interimToken_ is the intermediary token that cannot be swapped to the vault underlying
/// @param amount_ is the amount of the intermediary token
function updateFailedTx(uint256 payloadId_, address interimToken_, uint256 amount_) external;
/// @notice updates the amounts of intermediary tokens stuck because of failing dst swap in batch
/// @param payloadId_ represents the id of the payload
/// @param indices_ represents the failing indices in the payload
/// @param interimTokens_ is the list of intermediary tokens that cannot be swapped
/// @param amounts_ are the amount of intermediary tokens that need to be refunded to the user
function batchUpdateFailedTx(
uint256 payloadId_,
uint256[] calldata indices_,
address[] calldata interimTokens_,
uint256[] calldata amounts_
)
external;
/// @notice is a privileged function that allows Core State Registry to process refunds
/// @param user_ is the final refund receiver of the interimToken_
/// @param interimToken_ is the refund token
/// @param amount_ is the refund amount
function processFailedTx(address user_, address interimToken_, uint256 amount_) external;
}