Skip to content

Commit 2215c14

Browse files
authored
refactor(coins): use 20 bytes for trade referral decoding (#1349)
## Description Updated the `getTradeReferral` function in `CoinRewardsV4.sol` to check for a minimum hook data length of 20 bytes instead of 32 bytes when decoding the referral address. ## Motivation and Context The function was checking for a minimum of 32 bytes, but an Ethereum address is only 20 bytes. This change makes the function more efficient by allowing it to decode valid addresses from smaller hook data payloads. ## Does this change the ABI/API? - [ ] This changes the ABI/API ## What tests did you add/modify to account for these changes Tested the function with hook data of various lengths to ensure it correctly decodes addresses when the data is at least 20 bytes and returns address(0) for smaller payloads. ## Types of changes - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New module / feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) ## Checklist: - [x] My code follows the code style of this project. - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [x] I added a changeset to account for this change ## Reviewer Checklist: - [ ] My review includes a symposis of the changes and potential issues - [ ] The code style is enforced - [ ] There are no risky / concerning changes / additions to the PR
1 parent 55950cc commit 2215c14

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/coins/src/libs/CoinRewardsV4.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ library CoinRewardsV4 {
5353
uint256 public constant LP_REWARD_BPS = 3333;
5454

5555
function getTradeReferral(bytes calldata hookData) internal pure returns (address) {
56-
return hookData.length >= 32 ? abi.decode(hookData, (address)) : address(0);
56+
return hookData.length >= 20 ? abi.decode(hookData, (address)) : address(0);
5757
}
5858

5959
/// @dev Converts collected fees from LP positions into target payout currency, and transfers to hook contract, so

0 commit comments

Comments
 (0)