Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Each storyline token trades on a Mint Club V2 bonding curve with 1% creator roya
| Contract | Address |
|----------|---------|
| StoryFactory | [`0x337c5b96f03fB335b433291695A4171fd5dED8B0`](https://basescan.org/address/0x337c5b96f03fB335b433291695A4171fd5dED8B0) |
| ZapPlotLinkV2 | [`0x952606df750C01e0a12458C3F814598B94AD5C5f`](https://basescan.org/address/0x952606df750C01e0a12458C3F814598B94AD5C5f) |
| ZapPlotLinkV2 | [`0xAe50C9444DA2Ac80B209dC8B416d1B4A7D3939B0`](https://basescan.org/address/0xAe50C9444DA2Ac80B209dC8B416d1B4A7D3939B0) |

## External Dependencies

Expand Down
2 changes: 1 addition & 1 deletion script/E2EZapTest.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract E2EZapTest is Script {
// -----------------------------------------------------------------------
// Base mainnet addresses
// -----------------------------------------------------------------------
ZapPlotLinkV2 constant ZAP = ZapPlotLinkV2(payable(0x7bC192848003ab1Ba286C66AFD0dd8a1729c6b02));
ZapPlotLinkV2 constant ZAP = ZapPlotLinkV2(payable(0xAe50C9444DA2Ac80B209dC8B416d1B4A7D3939B0));
IMCV2_Bond constant BOND = IMCV2_Bond(0xc5a076cad94176c2996B32d8466Be1cE757FAa27);
IERC20 constant PLOT = IERC20(0xF8A2C39111FCEB9C950aAf28A9E34EBaD99b85C1);
IERC20 constant HUNT = IERC20(0x37f0c2915CeCC7e977183B8543Fc0864d03E064C);
Expand Down
16 changes: 14 additions & 2 deletions src/ZapPlotLinkV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,10 @@ contract ZapPlotLinkV2 {
hookData: bytes("")
});

actionParams[0] = abi.encode(USDC, path, amountIn, uint128(0));
// V4 Router's CalldataDecoder.decodeSwapExactInParams reads the first word as
// an offset pointer to the struct data. _encodeAsStruct prepends 0x20 to match
// the ABI encoding of a single struct parameter (abi.encode(ExactInputParams)).
actionParams[0] = _encodeAsStruct(abi.encode(USDC, path, amountIn, uint128(0)));
actionParams[1] = abi.encode(USDC, amountIn);
actionParams[2] = abi.encode(plotToken, address(this), ActionConstants.OPEN_DELTA);

Expand Down Expand Up @@ -520,7 +523,7 @@ contract ZapPlotLinkV2 {
hookData: bytes("")
});

actionParams[0] = abi.encode(plotToken, path, plotAmountOut, maxUsdcIn);
actionParams[0] = _encodeAsStruct(abi.encode(plotToken, path, plotAmountOut, maxUsdcIn));
actionParams[1] = abi.encode(USDC, maxUsdcIn);
actionParams[2] = abi.encode(plotToken, address(this), ActionConstants.OPEN_DELTA);

Expand All @@ -531,6 +534,15 @@ contract ZapPlotLinkV2 {
UNIVERSAL_ROUTER.execute(commands, inputs, block.timestamp);
}

/// @dev Wraps ABI-encoded fields with an outer offset word (0x20) to match
/// struct-style ABI encoding expected by the V4 Router's CalldataDecoder.
/// decodeSwapExactInParams/decodeSwapExactOutParams read the first word
/// of params as an offset pointer to the struct data. abi.encode(field1, ...)
/// produces a flat tuple without this offset; this function adds it.
function _encodeAsStruct(bytes memory data) private pure returns (bytes memory) {
return abi.encodePacked(uint256(0x20), data);
}

function _refundPlot() private {
uint256 balance = IERC20(plotToken).balanceOf(address(this));
if (balance > 0) {
Expand Down