functionbuy(address recipient,
uint256 orderSize,
uint256 minAmountOut,
uint160 sqrtPriceLimitX96,
address tradeReferrer
) publicpayablenonReentrantreturns (uint256, uint256) {
// Ensure the recipient is not the zero addressif (recipient ==address(0)) {
revert AddressZero();
}
// Calculate the trade rewarduint256 tradeReward = _calculateReward(orderSize, TOTAL_FEE_BPS);
// Calculate the remaining sizeuint256 trueOrderSize = orderSize - tradeReward;
// Handle incoming currency
_handleIncomingCurrency(orderSize, trueOrderSize);
// Set up the swap parameters
ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({
tokenIn: currency,
tokenOut: address(this),
fee: LP_FEE,
recipient: recipient,
amountIn: trueOrderSize,
amountOutMinimum: minAmountOut,
sqrtPriceLimitX96: sqrtPriceLimitX96
});
// Execute the swapuint256 amountOut = ISwapRouter(swapRouter).exactInputSingle(params);
_handleTradeRewards(tradeReward, tradeReferrer);
_handleMarketRewards();
emit CoinBuy(msg.sender, recipient, tradeReferrer, amountOut, currency, tradeReward, trueOrderSize);
return (orderSize, amountOut);
}
buy goodsell okaysell simulation failing via injected wallet because im doing the data wrangling wrong after calling getProfileBalances via coins sdk; sdk says address from wagmi useAddress has horse balance, contract simulation says it has 0. i need to understand zora profiles i thinkday 5 trello