Skip to content

rotcivegaf/mooniswap_orders

Repository files navigation

Lint Status Test Status Coverage Status

Coverage

Mooniswap Orders

Contracts

The Mooniswap Orders Contract:

This contract has 2 important function:

function cancelOrder(
  Mooniswap _mooniswapPool, // Mooniswap Pool Address
  IERC20 _fromToken,        // From Token Address
  IERC20 _toToken,          // To Token Address
  uint256 _fromAmount,      // From Amount
  uint256 _minReturn,       // Minimum To Amount Return
  uint256 _maxLoss,         // Maximum Loss in To Amount
  address _referral,        // Referral for Mooniswap
  uint256 _expiry,          // The expiry of signature
  bytes32 _salt             // Add entropy to the hash id
) external;

This function uses to cancel a signed Order.

function executeOrder(
  Mooniswap _mooniswapPool, // Mooniswap Pool Address
  IERC20 _fromToken,        // From Token Address
  IERC20 _toToken,          // To Token Address
  uint256 _fromAmount,      // From Amount
  uint256 _minReturn,       // Minimum To Amount Return
  uint256 _maxLoss,         // Maximum Loss in To Amount
  address _referral,        // Referral for Mooniswap
  uint256 _expiry,          // The expiry of signature
  bytes32 _salt,            // Add entropy to the hash id
  bytes calldata _signature // Signature
) external;

This function uses to execute a signed Order.

When an user sign a order swap on Mooniswap should be specify address of the poll, the from token, to token and thefrom token amount, also the expiry and a salt. The minReturn is used for the amount of To Token to be received for the amount of From Token. The maxLoss is used for order type, if is greater than To Token Amount is a 'Take Profit Order' else is a "Stop Loss Limit Order". Another observation of masLoss parameter its if is a Take Profit order the minLoss can be really hight.

The contract require this: minReturn <= To Token Amount <= maxLoss

MinReturn To Amount MaxLoss Order Type Execute Range change To Amount
900 1000 1100 Market / Stop Loss Ok 900 to 1100
1100 1000 1200 Market Wait 1100 to 1200 (1)
800 1000 900 Stop Loss Wait 800 to 900 (2)
900 1000 800 - Never -
1100 1000 900 - Never -
1200 1000 1100 - Never -
  1. If the amount goes up the 1100(minReturn) To Token the order was execute and accept as maximum 1200(maxLoss) To Token
  2. If the amount goes down the 900(maxLoss) To Token the order was execute and accept as minimum 800(minReturn) To Token

Finally, there an another issue, if we have a Stop Loss Limit Order, somebody can manipulate the price to execute this order(Front Running).

Ropsten Contracts Addresses

The front

The front provide the signatures to the back and show a table with all signatures.

The Back and Bot Signer

In the back storage all the signatures provide by the front. The signer bot consult the back and execute the orders when can.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published