The structure of the encoding is
abi.encodePacked(
abi.encodePacked(
address,
uint256,
uint256,
address,
uint256,
address,
uint32,
uint16
),
abi.encodePacked(
address,
uint256,
uint256
),
address,
uint256
)
(They only save 2 slots, I'm not sure why they did it this way)
I want to decode the first encode packed (called the 'offer' which is 162 bytes) from the entire thing.
I wrote this code which isn't working, though the bottom assembly block works for a non-nested encodePacked (abi.encode(encodePacked(..),encodePacked(...),...
)
bytes memory data; // = abi.encodePacked(abi.encodePacked(...),abi.encodePacked(...),address,uint256)
bytes memory offer;
assembly {
offer := mload(add(offer,162))
}
address denomination;
uint principal;
uint repaymentWithFee;
address collection;
uint nft_id;
address referrer;
uint32 duration;
uint16 adminFee_bps;
assembly {
denomination := mload(add(offer,20))
principal := mload(add(offer,52))
repaymentWithFee := mload(add(offer,84))
collection := mload(add(offer,104))
nft_id := mload(add(offer,136))
referrer := mload(add(offer,156))
duration := mload(add(offer,160))
adminFee_bps := mload(add(offer,162))
}