8

怎么在合约里调用DEX进行交易呢

 3 years ago
source link: https://learnblockchain.cn/question/2524
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
怎么在合约里调用DEX进行交易呢 | 登链社区 | 技术问答

怎么在合约里调用DEX进行交易呢

function swap(address token,uint amountIn,uint amountOutMin,address[] calldata path,address to,uint deadline)external {
//require(block.timestamp>Users[msg.sender].time_overdue,"time < block.timestamp");
	    IMdexRouter(token).swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn,amountOutMin,path,to,deadline);
	}

这是百度找着写的代码,但是交易一直失败,原因见下图!
这里有几个问题搞不明白
1.在合约里调用这个方法是合约与DEX之间进行交易呢,还是由调用者进行交易的
2.不知道为什么交易不成功,我往合约里面转了1个USDT也是同样的错误

求路过的大佬解惑

QQ20210908163706.png


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK