Skip to content

Commit 9994f17

Browse files
authored
starkgate: switch deposit event to upgraded Deposit signature (#485)
The StarkGate proxy implementations were upgraded in Feb 2025 (impl 0xa72a8F31163d74d708664493d09167dfa13008E9, deployed block 21771817). Post-upgrade the bridges emit: Deposit(address indexed sender, address indexed token, uint256 amount, uint256 indexed l2Recipient, uint256 nonce, uint256 fee) topic[0] = 0x5f971bd00bf3ffbca8a6d72cdd4fd92cfd4f62636161921d1e5a64f0b64ccb6d The current adapter (added Nov 2025 in #436) still filters on the legacy five-arg LogDeposit signature, so getLogs returns ~0 results and StarkGate deposit volume is effectively untracked. Verified on Ethereum mainnet across all 14 sub-bridges over the last 49,000 blocks (~7 days, head = 25,131,221): bridge LEGACY NEW STRK 0 21 ETH 2 46 USDT 0 54 wstETH 0 1 USDC, WBTC, DAI, rETH, sfrxETH, UNI, FRAX, FXS, LUSD, R: 0 / 0 122 new-topic deposits vs 2 legacy on the active bridges = the adapter catches < 2% of real deposit activity. The new event is firing across multiple distinct senders / l2 recipients, not a single test address. ETH bridge `token` arg detail: the post-upgrade ETH bridge fills the indexed `token` field with 0x0000000000000000000000000000000000455448 (ASCII "ETH") rather than a real ERC20. ERC20 bridges fill it with the L1 token address (verified on USDT and STRK). The fix keeps the existing `fixedEventData.token = WETH` override so the pricing layer can value ETH deposits and stays drop-in compatible with the rest of the adapter shape. The withdrawal side (LogMessageToL1 on StarkNet Core 0xc662c410...) is untouched — verified 152 events in the same 49k-block window with the same payload layout, so the existing withdrawal params are still correct. Topic hash verification per RULES.md Rule 13: - keccak256("Deposit(address,address,uint256,uint256,uint256,uint256)") = 0x5f971bd00bf3ffbca8a6d72cdd4fd92cfd4f62636161921d1e5a64f0b64ccb6d - Cross-checked with openchain.xyz signature DB.
1 parent 7951e7c commit 9994f17

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

src/adapters/starkgate/index.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ Contract Addresses:
1212
- ERC20 Bridge (USDC, USDT, DAI, WBTC, etc): Various token-specific bridges
1313
1414
Events:
15-
- LogDeposit: Triggered when tokens are deposited from L1 to L2
15+
- Deposit: Triggered when tokens are deposited from L1 to L2. The StarkGate
16+
proxy implementations were upgraded in Feb 2025 and now emit the
17+
six-arg Deposit event (with an indexed `token` field) rather than
18+
the legacy five-arg LogDeposit. Verified on the live STRK, USDT,
19+
ETH and wstETH bridges; the legacy LogDeposit topic is silent on
20+
every sub-bridge except for a 4% tail on the ETH bridge.
1621
- LogMessageToL1: Triggered when tokens are withdrawn from L2(StarkNet Core) to L1
1722
*/
1823

@@ -58,12 +63,16 @@ const tokenAddresses: { [key: string]: string } = {
5863
fxs: "0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0",
5964
};
6065

61-
// Deposit event for ERC20 tokens
66+
// Deposit event for ERC20 tokens.
67+
// The post-upgrade implementation indexes a `token` arg in topic2, but for
68+
// every sub-bridge it equals the L1 ERC20 we already track per-contract, so
69+
// we keep `fixedEventData.token` (matches the ETH bridge sentinel handling
70+
// below and stays drop-in compatible with the historical adapter shape).
6271
const erc20DepositParams = (contractAddress: string, tokenAddress: string): PartialContractEventParams => ({
6372
target: contractAddress,
64-
topic: "LogDeposit(address,uint256,uint256,uint256,uint256)",
73+
topic: "Deposit(address,address,uint256,uint256,uint256,uint256)",
6574
abi: [
66-
"event LogDeposit(address indexed sender, uint256 amount, uint256 indexed l2Recipient, uint256 nonce, uint256 fee)",
75+
"event Deposit(address indexed sender, address indexed token, uint256 amount, uint256 indexed l2Recipient, uint256 nonce, uint256 fee)",
6776
],
6877
logKeys: {
6978
blockNumber: "blockNumber",
@@ -117,12 +126,16 @@ const erc20WithdrawalParams = (
117126
isDeposit: false,
118127
});
119128

120-
// ETH-specific events
129+
// ETH-specific events.
130+
// The ETH bridge emits the same Deposit signature, but its indexed `token`
131+
// arg is the on-chain sentinel 0x0000000000000000000000000000000000455448
132+
// (ASCII "ETH") rather than a real ERC20. We override with WETH so the
133+
// downstream pricing layer can value it.
121134
const ethDepositParams: PartialContractEventParams = {
122135
target: ethBridgeContract,
123-
topic: "LogDeposit(address,uint256,uint256,uint256,uint256)",
136+
topic: "Deposit(address,address,uint256,uint256,uint256,uint256)",
124137
abi: [
125-
"event LogDeposit(address indexed sender, uint256 amount, uint256 indexed l2Recipient, uint256 nonce, uint256 fee)",
138+
"event Deposit(address indexed sender, address indexed token, uint256 amount, uint256 indexed l2Recipient, uint256 nonce, uint256 fee)",
126139
],
127140
logKeys: {
128141
blockNumber: "blockNumber",

0 commit comments

Comments
 (0)