Skip to content

Commit 925be69

Browse files
squadgazzzYour Name
andauthored
Avoid redundant calldata bytes extension (#173)
As @MartinquaXD [noticed](#171 (comment)): > This calldata needed to be changed (removed 24 bytes or 48 characters) due to removing the extra encoding logic in the Permit2 handling. Turns out that was not needed at all - not sure what made me believe that was needed before. To verify I used this [page](https://calldata.swiss-knife.xyz/decoder?calldata=0x87517c45000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000136f1efcc3f8f88516b9e94110d56fdbfb1778d10000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000). Pasting the shortened calldata still results in correct decoding but removing 1 more character causes the decoding to fail. This did not cause any issues so far because the EVM ignores additional bytes instead of throwing an error. This change has been extracted into a separate PR. --------- Co-authored-by: Your Name <your-email@example.com>
1 parent 05fe58e commit 925be69

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

src/infra/dex/balancer/v3.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,14 @@ impl Permit2 {
4343

4444
// Transfers are done via Permit2, so we approve the balancer v3 router to spend
4545
// the input tokens
46-
let mut calldata = Permit2Contract::Permit2::approveCall {
46+
let calldata = Permit2Contract::Permit2::approveCall {
4747
token: token_in,
4848
spender,
4949
amount: U160::from(max_input),
5050
expiration,
5151
}
5252
.abi_encode();
5353

54-
// As alloy encodes the last argument (expiration) as a U48 (6 bytes),
55-
// we need to add 24 bytes to pad it into a U256 (32 bytes) (which is the
56-
// expected for EVM arguments)
57-
calldata.extend_from_slice(&[0u8; 24]);
58-
5954
dex::Call { to, calldata }
6055
}
6156
}

src/tests/balancer/market_order.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ async fn sell_v3() {
334334
"token": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
335335
}
336336
],
337-
"callData": "0x87517c45000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000136f1efcc3f8f88516b9e94110d56fdbfb1778d10000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
337+
"callData": "0x87517c45000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000136f1efcc3f8f88516b9e94110d56fdbfb1778d10000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000",
338338
"inputs": [
339339
{
340340
"amount": "1000000000000000000",

0 commit comments

Comments
 (0)