Skip to content

Instantly share code, notes, and snippets.

@raullenchai
Last active October 30, 2020 22:59
Show Gist options
  • Save raullenchai/dcaa39f27e699d2d91e71266f9de8f4a to your computer and use it in GitHub Desktop.
Save raullenchai/dcaa39f27e699d2d91e71266f9de8f4a to your computer and use it in GitHub Desktop.
Using Contract to trade on mimo.exchange
pragma solidity >=0.5.10;
import "./SafeMath.sol";
import "./IMimoExchange.sol";
contract MyTrade {
using SafeMath for uint256;
IMimoExchange public mimoExchange = IMimoExchange(0xb3972201f3Ae2b382665ca129Bd28d056758DBe2);
address public vitatoken = 0xB8744aE4032Be5E5ef9FaB94ee9C3bf38D5D2AE0;
constructor() public {}
function buyvita() public payable {
uint256 vitaBought = mimoExchange.iotxToTokenSwapInput.value(msg.value)(msg.value * 70, block.timestamp * 2);
_safeErc20Transfer(msg.sender, vitaBought);
}
function _safeErc20Transfer(address _to, uint256 _amount) internal {
(bool success, bytes memory data) = vitatoken.call(abi.encodeWithSelector(0xa9059cbb, _to, _amount));
require(success, "not enough tokens");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment