@across-protocol/contracts 5.0.6-alpha.0 → 5.0.6-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/test/AcrossMessageHandlerMock.sol +14 -0
- package/contracts/test/ArbitrumMocks.sol +169 -0
- package/contracts/test/ExpandedERC20WithBlacklist.sol +19 -0
- package/contracts/test/LineaMocks.sol +83 -0
- package/contracts/test/MerkleLibTest.sol +65 -0
- package/contracts/test/MockBedrockStandardBridge.sol +115 -0
- package/contracts/test/MockBlastUsdYieldManager.sol +20 -0
- package/contracts/test/MockCCTP.sol +212 -0
- package/contracts/test/MockCaller.sol +20 -0
- package/contracts/test/MockERC1271.sol +21 -0
- package/contracts/test/MockERC20.sol +87 -0
- package/contracts/test/MockEndpoint.sol +16 -0
- package/contracts/test/MockHubPool.sol +100 -0
- package/contracts/test/MockOFTMessenger.sol +88 -0
- package/contracts/test/MockOptimism_SpokePool.sol +22 -0
- package/contracts/test/MockPermit2.sol +188 -0
- package/contracts/test/MockSpokePool.sol +263 -0
- package/contracts/test/MockSpokePoolV2.sol +27 -0
- package/contracts/test/MockZkStackBridgeHub.sol +43 -0
- package/contracts/test/PolygonERC20Test.sol +16 -0
- package/contracts/test/PolygonMocks.sol +82 -0
- package/contracts/test/PolygonZkEVMMocks.sol +72 -0
- package/contracts/test/ScrollMocks.sol +109 -0
- package/contracts/test/V2MerkleLib.sol +18 -0
- package/contracts/test/ZkSyncMocks.sol +78 -0
- package/contracts/test/interfaces/IHyperCoreFlowExecutor.sol +189 -0
- package/contracts/test/interfaces/MockV2SpokePoolInterface.sol +38 -0
- package/package.json +3 -3
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @notice Mock ZkSync ERC20 bridge for testing.
|
|
6
|
+
* @dev Mimics the ZkBridgeLike interface used by ZkSync_SpokePool.
|
|
7
|
+
*/
|
|
8
|
+
contract MockZkBridge {
|
|
9
|
+
// Call tracking for test assertions (smock-like behavior)
|
|
10
|
+
uint256 public withdrawCallCount;
|
|
11
|
+
|
|
12
|
+
event Withdrawal(address indexed l1Receiver, address indexed l2Token, uint256 amount);
|
|
13
|
+
|
|
14
|
+
struct WithdrawCall {
|
|
15
|
+
address l1Receiver;
|
|
16
|
+
address l2Token;
|
|
17
|
+
uint256 amount;
|
|
18
|
+
}
|
|
19
|
+
WithdrawCall public lastWithdrawCall;
|
|
20
|
+
|
|
21
|
+
// Store all calls for multi-call verification
|
|
22
|
+
WithdrawCall[] public withdrawCalls;
|
|
23
|
+
|
|
24
|
+
function withdraw(address _l1Receiver, address _l2Token, uint256 _amount) external {
|
|
25
|
+
withdrawCallCount++;
|
|
26
|
+
lastWithdrawCall = WithdrawCall(_l1Receiver, _l2Token, _amount);
|
|
27
|
+
withdrawCalls.push(lastWithdrawCall);
|
|
28
|
+
emit Withdrawal(_l1Receiver, _l2Token, _amount);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @notice Get a specific withdraw call by index.
|
|
33
|
+
*/
|
|
34
|
+
function getWithdrawCall(
|
|
35
|
+
uint256 index
|
|
36
|
+
) external view returns (address l1Receiver, address l2Token, uint256 amount) {
|
|
37
|
+
WithdrawCall memory call = withdrawCalls[index];
|
|
38
|
+
return (call.l1Receiver, call.l2Token, call.amount);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @notice Mock ZkSync L2 ETH contract for testing.
|
|
44
|
+
* @dev Mimics the IL2ETH interface - ETH on ZkSync implements ERC-20 subset with L1 bridge support.
|
|
45
|
+
*/
|
|
46
|
+
contract MockL2Eth {
|
|
47
|
+
// Call tracking for test assertions (smock-like behavior)
|
|
48
|
+
uint256 public withdrawCallCount;
|
|
49
|
+
|
|
50
|
+
event EthWithdrawal(address indexed l1Receiver, uint256 amount);
|
|
51
|
+
|
|
52
|
+
struct WithdrawCall {
|
|
53
|
+
address l1Receiver;
|
|
54
|
+
uint256 amount;
|
|
55
|
+
}
|
|
56
|
+
WithdrawCall public lastWithdrawCall;
|
|
57
|
+
|
|
58
|
+
// Store all calls for multi-call verification
|
|
59
|
+
WithdrawCall[] public withdrawCalls;
|
|
60
|
+
|
|
61
|
+
function withdraw(address _l1Receiver) external payable {
|
|
62
|
+
withdrawCallCount++;
|
|
63
|
+
lastWithdrawCall = WithdrawCall(_l1Receiver, msg.value);
|
|
64
|
+
withdrawCalls.push(lastWithdrawCall);
|
|
65
|
+
emit EthWithdrawal(_l1Receiver, msg.value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @notice Get a specific withdraw call by index.
|
|
70
|
+
*/
|
|
71
|
+
function getWithdrawCall(uint256 index) external view returns (address l1Receiver, uint256 amount) {
|
|
72
|
+
WithdrawCall memory call = withdrawCalls[index];
|
|
73
|
+
return (call.l1Receiver, call.amount);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Allow receiving ETH
|
|
77
|
+
receive() external payable {}
|
|
78
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import { CommonFlowParams } from "../../periphery/mintburn/Structs.sol";
|
|
5
|
+
import { DonationBox } from "../../chain-adapters/DonationBox.sol";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @title IHyperCoreFlowExecutor
|
|
9
|
+
* @notice Interface for HyperCoreFlowExecutor contract handling HyperCore interactions for transfer-to-core or swap-with-core actions after stablecoin bridge transactions
|
|
10
|
+
* @custom:security-contact bugs@across.to
|
|
11
|
+
*/
|
|
12
|
+
interface IHyperCoreFlowExecutor {
|
|
13
|
+
/**************************************
|
|
14
|
+
* PUBLIC VARIABLE GETTERS *
|
|
15
|
+
**************************************/
|
|
16
|
+
|
|
17
|
+
/// @notice Common decimals scalars - parts per million decimals
|
|
18
|
+
/// @return PPM_DECIMALS Parts per million decimals (6)
|
|
19
|
+
function PPM_DECIMALS() external returns (uint256);
|
|
20
|
+
|
|
21
|
+
/// @notice Parts per million scalar (10^6)
|
|
22
|
+
/// @return PPM_SCALAR Parts per million scalar
|
|
23
|
+
function PPM_SCALAR() external returns (uint256);
|
|
24
|
+
|
|
25
|
+
/// @notice Decimals to use for Price calculations in limit order-related calculation functions
|
|
26
|
+
/// @return PX_D Price decimals (8)
|
|
27
|
+
function PX_D() external returns (uint8);
|
|
28
|
+
|
|
29
|
+
/// @notice One in 1e8 format (10^8)
|
|
30
|
+
/// @return ONEX1e8 One in 1e8 format
|
|
31
|
+
function ONEX1e8() external returns (uint64);
|
|
32
|
+
|
|
33
|
+
/// @notice The donation box contract.
|
|
34
|
+
/// @return donationBox Address of the donation box contract
|
|
35
|
+
function donationBox() external returns (DonationBox);
|
|
36
|
+
|
|
37
|
+
/// @notice All operations performed in this contract are relative to this baseToken
|
|
38
|
+
/// @return baseToken Address of the base token
|
|
39
|
+
function baseToken() external returns (address);
|
|
40
|
+
|
|
41
|
+
/**************************************
|
|
42
|
+
* FLOW FUNCTIONS *
|
|
43
|
+
**************************************/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @notice External entrypoint to execute flow when called via delegatecall from a handler. Works with params
|
|
47
|
+
* checked by a handler. Params authorization by a handler is enforced via `onlyAuthorizedFlow` modifier
|
|
48
|
+
* @param params Common flow parameters
|
|
49
|
+
* @param maxUserSlippageBps Maximum user slippage in basis points
|
|
50
|
+
*/
|
|
51
|
+
function executeFlow(CommonFlowParams memory params, uint256 maxUserSlippageBps) external;
|
|
52
|
+
|
|
53
|
+
/// @notice External entrypoint to execute simple transfer flow (see `executeFlow` comment for details)
|
|
54
|
+
/// @param params Common flow parameters
|
|
55
|
+
function executeSimpleTransferFlow(CommonFlowParams memory params) external;
|
|
56
|
+
|
|
57
|
+
/// @notice External entrypoint to execute fallback evm flow (see `executeFlow` comment for details)
|
|
58
|
+
/// @param params Common flow parameters
|
|
59
|
+
function fallbackHyperEVMFlow(CommonFlowParams memory params) external;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @notice Finalizes multiple swap flows associated with a final token, subject to the L1 Hyperliquid balance
|
|
63
|
+
* @dev Caller is responsible for providing correct limitOrderOutput amounts per assosicated swap flow. The caller
|
|
64
|
+
* has to estimate how much final tokens it received on core based on the input of the corresponding quote nonce
|
|
65
|
+
* swap flow
|
|
66
|
+
* @param finalToken The final token address
|
|
67
|
+
* @param quoteNonces Array of quote nonces to finalize
|
|
68
|
+
* @param limitOrderOuts Array of limit order outputs corresponding to each quote nonce
|
|
69
|
+
* @return finalized Number of swaps successfully finalized
|
|
70
|
+
*/
|
|
71
|
+
function finalizeSwapFlows(
|
|
72
|
+
address finalToken,
|
|
73
|
+
bytes32[] calldata quoteNonces,
|
|
74
|
+
uint64[] calldata limitOrderOuts
|
|
75
|
+
) external returns (uint256 finalized);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @notice Activates a user account on Core by funding the account activation fee.
|
|
79
|
+
* @param quoteNonce The nonce of the quote that is used to identify the user.
|
|
80
|
+
* @param finalRecipient The address of the recipient of the funds.
|
|
81
|
+
* @param fundingToken The address of the token that is used to fund the account activation fee.
|
|
82
|
+
*/
|
|
83
|
+
function activateUserAccount(bytes32 quoteNonce, address finalRecipient, address fundingToken) external;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @notice Cancells a pending limit order by `cloid` with an intention to submit a new limit order in its place. To
|
|
87
|
+
* be used for stale limit orders to speed up executing user transactions
|
|
88
|
+
* @param finalToken The final token address
|
|
89
|
+
* @param cloid The client order ID to cancel
|
|
90
|
+
*/
|
|
91
|
+
function cancelLimitOrderByCloid(address finalToken, uint128 cloid) external;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @notice Submits a limit order from the bot
|
|
95
|
+
* @param finalToken The final token address
|
|
96
|
+
* @param priceX1e8 Price in 1e8 format
|
|
97
|
+
* @param sizeX1e8 Size in 1e8 format
|
|
98
|
+
* @param cloid The client order ID
|
|
99
|
+
*/
|
|
100
|
+
function submitLimitOrderFromBot(address finalToken, uint64 priceX1e8, uint64 sizeX1e8, uint128 cloid) external;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @notice Set or update information for the token to use it in this contract
|
|
104
|
+
* @dev To be able to use the token in the swap flow, FinalTokenInfo has to be set as well
|
|
105
|
+
* @dev Setting core token info to incorrect values can lead to loss of funds. Should NEVER be unset while the
|
|
106
|
+
* finalTokenParams are not unset
|
|
107
|
+
* @param token The token address
|
|
108
|
+
* @param coreIndex The HyperCore index of the token
|
|
109
|
+
* @param canBeUsedForAccountActivation Whether the token can be used for account activation
|
|
110
|
+
* @param accountActivationFeeCore The account activation fee in core units
|
|
111
|
+
* @param bridgeSafetyBufferCore The bridge safety buffer in core units
|
|
112
|
+
*/
|
|
113
|
+
function setCoreTokenInfo(
|
|
114
|
+
address token,
|
|
115
|
+
uint32 coreIndex,
|
|
116
|
+
bool canBeUsedForAccountActivation,
|
|
117
|
+
uint64 accountActivationFeeCore,
|
|
118
|
+
uint64 bridgeSafetyBufferCore
|
|
119
|
+
) external;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @notice Sets the parameters for a final token.
|
|
123
|
+
* @dev This function deploys a new SwapHandler contract if one is not already set. If the final token
|
|
124
|
+
* can't be used for account activation, the handler will be left unactivated and would need to be activated by the caller.
|
|
125
|
+
* @param finalToken The address of the final token.
|
|
126
|
+
* @param assetIndex The index of the asset in the Hyperliquid market.
|
|
127
|
+
* @param isBuy Whether the final token is a buy or a sell.
|
|
128
|
+
* @param feePpm The fee in parts per million.
|
|
129
|
+
* @param suggestedDiscountBps The suggested slippage in basis points.
|
|
130
|
+
* @param accountActivationFeeToken A token to pay account activation fee in. Only used if adding a new final token
|
|
131
|
+
*/
|
|
132
|
+
function setFinalTokenInfo(
|
|
133
|
+
address finalToken,
|
|
134
|
+
uint32 assetIndex,
|
|
135
|
+
bool isBuy,
|
|
136
|
+
uint32 feePpm,
|
|
137
|
+
uint32 suggestedDiscountBps,
|
|
138
|
+
address accountActivationFeeToken
|
|
139
|
+
) external;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @notice Predicts the deterministic address of a SwapHandler for a given finalToken using CREATE2
|
|
143
|
+
* @param finalToken The final token address
|
|
144
|
+
* @return The predicted address of the SwapHandler
|
|
145
|
+
*/
|
|
146
|
+
function predictSwapHandler(address finalToken) external view returns (address);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @notice Used for ad-hoc sends of sponsorship funds to associated SwapHandler @ HyperCore
|
|
150
|
+
* @param token The final token for which we want to fund the SwapHandler
|
|
151
|
+
* @param amount The amount to send
|
|
152
|
+
*/
|
|
153
|
+
function sendSponsorshipFundsToSwapHandler(address token, uint256 amount) external;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @notice Sweeps ERC20 tokens from the contract
|
|
157
|
+
* @param token The token address to sweep
|
|
158
|
+
* @param amount The amount to sweep
|
|
159
|
+
*/
|
|
160
|
+
function sweepErc20(address token, uint256 amount) external;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @notice Sweeps ERC20 tokens from the donation box
|
|
164
|
+
* @param token The token address to sweep
|
|
165
|
+
* @param amount The amount to sweep
|
|
166
|
+
*/
|
|
167
|
+
function sweepErc20FromDonationBox(address token, uint256 amount) external;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @notice Sweeps ERC20 tokens from a SwapHandler
|
|
171
|
+
* @param token The token address to sweep
|
|
172
|
+
* @param amount The amount to sweep
|
|
173
|
+
*/
|
|
174
|
+
function sweepERC20FromSwapHandler(address token, uint256 amount) external;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @notice Sweeps tokens from Core
|
|
178
|
+
* @param token The token address
|
|
179
|
+
* @param amount The amount to sweep in core units
|
|
180
|
+
*/
|
|
181
|
+
function sweepOnCore(address token, uint64 amount) external;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @notice Sweeps tokens from Core from a SwapHandler
|
|
185
|
+
* @param token The token address
|
|
186
|
+
* @param amount The amount to sweep in core units
|
|
187
|
+
*/
|
|
188
|
+
function sweepOnCoreFromSwapHandler(address token, uint64 amount) external;
|
|
189
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @notice Contains common data structures and functions used by all SpokePool implementations.
|
|
6
|
+
*/
|
|
7
|
+
interface MockV2SpokePoolInterface {
|
|
8
|
+
struct RelayData {
|
|
9
|
+
bytes32 depositor;
|
|
10
|
+
bytes32 recipient;
|
|
11
|
+
bytes32 destinationToken;
|
|
12
|
+
uint256 amount;
|
|
13
|
+
uint256 originChainId;
|
|
14
|
+
uint256 destinationChainId;
|
|
15
|
+
int64 realizedLpFeePct;
|
|
16
|
+
int64 relayerFeePct;
|
|
17
|
+
uint32 depositId;
|
|
18
|
+
bytes message;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
struct RelayExecution {
|
|
22
|
+
RelayData relay;
|
|
23
|
+
bytes32 relayHash;
|
|
24
|
+
int64 updatedRelayerFeePct;
|
|
25
|
+
bytes32 updatedRecipient;
|
|
26
|
+
bytes updatedMessage;
|
|
27
|
+
uint256 repaymentChainId;
|
|
28
|
+
uint256 maxTokensToSend;
|
|
29
|
+
uint256 maxCount;
|
|
30
|
+
bool slowFill;
|
|
31
|
+
int256 payoutAdjustmentPct;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
struct SlowFill {
|
|
35
|
+
RelayData relayData;
|
|
36
|
+
int256 payoutAdjustmentPct;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@across-protocol/contracts",
|
|
3
|
-
"version": "5.0.6-alpha.
|
|
3
|
+
"version": "5.0.6-alpha.1",
|
|
4
4
|
"author": "UMA Team",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"/contracts/**/*.sol",
|
|
15
|
-
"!/contracts/test/**",
|
|
16
15
|
"/dist/**/*"
|
|
17
16
|
],
|
|
18
17
|
"types": "dist/index.d.ts",
|
|
@@ -32,9 +31,10 @@
|
|
|
32
31
|
"generate-svm-clients": "yarn ts-node ./scripts/svm/buildHelpers/generateSvmClients.ts && yarn ts-node ./scripts/svm/buildHelpers/renameClientsImports.ts",
|
|
33
32
|
"build-svm": "bash ./scripts/svm/buildHelpers/buildSvmLocalToolchain.sh",
|
|
34
33
|
"build-svm-solana-verify": "bash ./scripts/svm/buildHelpers/buildSolanaVerify.sh",
|
|
35
|
-
"build-ts": "rm -rf ./dist && tsc
|
|
34
|
+
"build-ts": "rm -rf ./dist && tsc",
|
|
36
35
|
"export-idl": "mkdir -p dist/src/svm/assets/idl && cp src/svm/assets/idl/*.json dist/src/svm/assets/idl/",
|
|
37
36
|
"export-abi": "sh scripts/exportAbis.sh",
|
|
37
|
+
"prepublishOnly": "yarn build-ts && yarn export-idl && yarn export-abi",
|
|
38
38
|
"build": "yarn build-evm-foundry && yarn build-svm && yarn generate-svm-artifacts && yarn build-ts",
|
|
39
39
|
"build-verified": "yarn build-evm-foundry && yarn build-svm-solana-verify && yarn generate-svm-artifacts && yarn build-ts",
|
|
40
40
|
"build-evm-foundry": "forge build",
|