forked from superform-xyz/superform-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIPaymentHelper.sol
177 lines (161 loc) · 8.7 KB
/
IPaymentHelper.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;
import "../types/DataTypes.sol";
/// @title IPaymentHelper
/// @author ZeroPoint Labs
/// @dev helps decoding the bytes payload and returns meaningful information
interface IPaymentHelper {
/*///////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
/// @param nativeFeedOracle_ is the native price feed oracle
/// @param gasPriceOracle_ is the gas price oracle
/// @param swapGasUsed_ is the swap gas params
/// @param updateGasUsed_ is the update gas params
/// @param depositGasUsed_ is the deposit per vault gas on the chain
/// @param withdrawGasUsed_ is the withdraw per vault gas on the chain
/// @param defaultNativePrice_ is the native price on the specified chain
/// @param defaultGasPrice_ is the gas price on the specified chain
/// @param dstGasPerKB_ is the gas per size of data on the specified chain
/// @param ackGasCost_ is the gas cost for processing acknowledgements on src chain
/// @param twoStepCost_ is the extra cost for processing two-step/timelocked payloads
/// @param swapGasUsed_ is the cost for dst swap
struct PaymentHelperConfig {
address nativeFeedOracle;
address gasPriceOracle;
uint256 updateGasUsed;
uint256 depositGasUsed;
uint256 withdrawGasUsed;
uint256 defaultNativePrice;
uint256 defaultGasPrice;
uint256 dstGasPerKB;
uint256 ackGasCost;
uint256 twoStepCost;
uint256 swapGasUsed;
}
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event ChainConfigUpdated(uint64 chainId_, uint256 configType_, bytes config_);
/*///////////////////////////////////////////////////////////////
PRIVILEGED ADMIN ONLY FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @dev admin config destination chain config for estimation
/// @param chainId_ is the identifier of new chain id
/// @param config_ is the chain config
function addChain(uint64 chainId_, PaymentHelperConfig calldata config_) external;
/// @dev admin update remote chain config for estimation
/// @param chainId_ is the remote chain's identifier
/// @param configType_ is the type of config from 1 -> 6
/// @param config_ is the encoded new configuration
function updateChainConfig(uint64 chainId_, uint256 configType_, bytes memory config_) external;
/*///////////////////////////////////////////////////////////////
EXTERNAL VIEW FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @dev returns the amb overrides & gas to be used
/// @param dstChainId_ is the unique dst chain identifier
/// @param ambIds_ is the identifiers of arbitrary message bridges to be used
/// @param message_ is the encoded cross-chain payload
function calculateAMBData(
uint64 dstChainId_,
uint8[] calldata ambIds_,
bytes memory message_
)
external
view
returns (uint256 totalFees, bytes memory extraData);
/// @dev returns the gas fees estimation in native tokens if we send message through a combination of AMBs
/// @param ambIds_ is the identifier of different AMBs
/// @param dstChainId_ is the identifier of the destination chain
/// @param message_ is the cross-chain message
/// @param extraData_ is any amb-specific information
/// @return ambFees is the native_tokens to be sent along the transaction for all the ambIds_ included
function estimateAMBFees(
uint8[] memory ambIds_,
uint64 dstChainId_,
bytes memory message_,
bytes[] memory extraData_
)
external
view
returns (uint256 ambFees, uint256[] memory);
/// @dev estimates the gas fees for multiple destination and multi vault operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return dstAmount is the gas expense on dst chain in terms of src chain's native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateMultiDstMultiVault(
MultiDstMultiVaultStateReq calldata req_,
bool isDeposit
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
/// @dev estimates the gas fees for multiple destination and single vault operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return dstAmount is the gas expense on dst chain in terms of src chain's native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateMultiDstSingleVault(
MultiDstSingleVaultStateReq calldata req_,
bool isDeposit
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
/// @dev estimates the gas fees for single destination and multi vault operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter ///
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return dstAmount is the gas expense on dst chain in terms of src chain's native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateSingleXChainMultiVault(
SingleXChainMultiVaultStateReq calldata req_,
bool isDeposit
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
/// @dev estimates the gas fees for single destination and single vault operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return dstAmount is the gas expense on dst chain in terms of src chain's native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateSingleXChainSingleVault(
SingleXChainSingleVaultStateReq calldata req_,
bool isDeposit
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
/// @dev estimates the gas fees for same chain operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return dstAmount is the gas expense on dst chain in terms of src chain's native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateSingleDirectSingleVault(
SingleDirectSingleVaultStateReq calldata req_,
bool isDeposit
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
/// @dev estimates the gas fees for multiple same chain operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return dstAmount is the gas expense on dst chain in terms of src chain's native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateSingleDirectMultiVault(
SingleDirectMultiVaultStateReq calldata req_,
bool isDeposit
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
}