Just copy/pasting a comment I made on discord about how we could set up the AMM to make it possible for a secret contract that uses its own snip20 to pay for use, can easily accept payment in any snip20 that it created anAMM pair with its own token. Just wondering what people’s thoughts were.
So one use case I was thinking of regarding if we have the AMM use Send instead of Transfer…Let’s say we have a contract that uses its own token to pay for use. We could have that contract accept any snip20 as payment (assuming they create an AMM pair for that snip20 and their token). It could work as follows (making some assumptions not knowing how the AMM is coded). The customer sends a snip20 to the app contract. Via the snip20 Receive call, the contract sees it didn’t get paid its native coin, so it does a Send to the correct AMM pair where it includes in the optional msg, anything it needs to process later. Via THAT Receive call, the AMM, performs the exchange and just forwards the msg it received into the optional msg that it uses when it does Send back to the contract. So the contract gets its native token for whatever use case, and has Receive called telling it how much was paid after the exchange, and can use the msg to perform whatever it needs to do in response. And the customer was able to pay in any snip20. Obviously IF the AMM requires the user to include some msg in the Send to the AMM pair, you could just include an optional field in THAT msg which is an optional msg that it will forward (so you are just nesting the contract’s optional msg inside the AMM’s msg (if it is using one for exchange calls)). Hope that wasn’t too unclear lol
I think it would be pretty cool to have contracts that can easily accept any snip20 as payment. I don’t know if any other AMM allows that functionality, so we could be the first