I am creating a contract to buy and sell different tokens in batches. and i want to ensure that all the transactions that would buy or sell the individual tokens, either pass or fail.
my code would be something like this
uint256 amountx = 100 tokenOneContract(tokenOneAddress).transfer(address(this), to, amountx) tokenTwoContract(tokenTwoAddress).transfer(to, address(this), amountx)
considering i have control over both token Contracts, if the second call (tokenTwoContract) fails and the whole transaction that these calls are part of fails and get reverted, does the tokenOneContract call also get reverted and the transfer of tokenOne fail ? or is there a way for it to pass.
if there is a way for it to pass, how can I force all calls like that to fail if one fails?
i know of optimistic transfers that would check the balances and or do estimate gas fees but that would be the second approach if there is some other atomiticty feature.