1#![allow(clippy::too_many_arguments)]
2
3use alloy_sol_types::sol;
4
5sol! {
6 #[derive(Default, Debug, PartialEq, Eq, Hash)]
8 struct SpendSpec {
9 bytes32 srcSpender;
10 uint32 srcDomain;
11 bytes32 srcToken;
12 bytes32 srcDepositContract;
13 uint32 dstDomain;
14 bytes32 dstToken;
15 bytes32 dstDeliveryContract;
16 bytes32 dstRecipient;
17 bytes32 dstCaller;
18 uint256 amount;
19 bytes32 salt;
20 }
21
22 #[derive(Default, Debug, PartialEq, Eq, Hash)]
24 struct SpendIntent {
25 uint256 maxFee;
26 uint256 expiryHeight;
27 SpendSpec spec;
28 }
29
30 #[derive(Default, Debug, PartialEq, Eq, Hash)]
36 struct SpendAttestation {
37 SpendSpec spec;
38 uint256 expiryHeight;
39 uint8 liquidityPath;
40 bytes liquidityPathData;
41 }
42
43 #[sol(rpc, all_derives)]
45 contract TridentDeposits {
46 error ZeroAmount();
47 error InvalidClaimDomain();
48 error InvalidClaimDepositContract();
49 error InvalidClaimAmount();
50 error InvalidSpendIntentSigner();
51 error ClaimSpendSpecHashAlreadyUsed(bytes32 hash);
52 error SpendIntentExpired();
53 error UnsupportedToken(address token);
54 error EnforcedPause();
55
56 event Deposit(address indexed depositor, address indexed token, uint256 amount);
57 event DepositClaimed(
58 bytes32 indexed spendSpecHash,
59 address indexed token,
60 uint256 amount,
61 address indexed recipient,
62 address signer,
63 uint256 fee,
64 address feeCollector
65 );
66 event DepositBalanceDeficit(
67 address indexed depositor,
68 address indexed token,
69 bytes32 indexed spendSpecHash,
70 uint256 claimAmount,
71 uint256 fee,
72 uint256 availableBalance
73 );
74
75 function deposit(address token, uint256 amount) external;
77
78 function isTokenSupported(address token) external view returns (bool);
80
81 function getSupportedTokens() external view returns (address[] memory);
83
84 function depositedAmount(address depositor, address token) external view returns (uint256);
90
91 function usedSpendSpecHashes(bytes32 spendSpecHash) external view returns (bool);
93
94 function domain() external view returns (uint32);
96
97 function tridentDelivery() external view returns (address);
99
100 function withdrawalDelay() external view returns (uint256);
102
103 function feeCollector() external view returns (address);
105
106 function spendIntentStructHash(SpendIntent calldata intent) external pure returns (bytes32);
108
109 function spendIntentDigest(SpendIntent calldata intent) external pure returns (bytes32);
111
112 function recoverSpendIntentSigner(SpendIntent calldata intent, bytes calldata signature)
114 external
115 pure
116 returns (address);
117 }
118
119 #[sol(rpc, all_derives)]
121 contract TridentDelivery {
122 error InvalidAttestationDomain();
123 error InvalidAttestationCaller();
124 error InvalidAttestationRecipient();
125 error InvalidAttestationDeliveryContract();
126 error InvalidAttestationAmount();
127 error InvalidAttestationExpired();
128 error InvalidAttestationToken();
129 error AttestationSpendSpecHashAlreadyUsed(bytes32 hash);
130 error InvalidLiquidityPath();
131 error NotSameChainSpend();
132 error TridentDepositsNotSet();
133 error InvalidAttestationSigner();
134 error UnsupportedToken(address token);
135 error EnforcedPause();
136
137 event SpendAttestationProcessed(
138 bytes32 indexed spendSpecHash,
139 address indexed token,
140 uint256 amount,
141 uint256 usdcMinted,
142 address indexed signer
143 );
144
145 function tridentSpend(bytes calldata attestation, bytes calldata signature) external;
147
148 function validateSpendAttestation(bytes calldata attestation)
152 external
153 view
154 returns (SpendAttestation memory spendAttestation);
155
156 function isTokenSupported(address token) external view returns (bool);
158
159 function getSupportedTokens() external view returns (address[] memory);
161
162 function usedSpendSpecHashes(bytes32 spendSpecHash) external view returns (bool);
164
165 function domain() external view returns (uint32);
167
168 function tridentDeposits() external view returns (address);
170
171 function isAttestationSigner(address signer) external view returns (bool);
173
174 function hashSpendAttestation(bytes calldata attestation) external pure returns (bytes32);
176
177 function digestSpendAttestation(bytes calldata attestation) external pure returns (bytes32);
179 }
180
181 #[sol(rpc)]
183 interface IERC20 {
184 function allowance(address owner, address spender) external view returns (uint256);
186 function approve(address spender, uint256 value) external returns (bool);
188 }
189}