🍍Exchange

Buy Option

We use MTX technology to handle orders in our aggregation engine. All you need to do is sign a data structure that fits our protocol with the EIP-712 standard and post the data signed to our aggregation service. You can either do it manually or use our SDK. Here we'll demonstrate how to sign and put a limit order using our SDK.

We will skip the wallet creation.

// Cash corresponds the money in ordinary option trade
const cash = await apis.cash();

const exchange = new Exchange({
  chainId: ChainId.Ropsten,
  endpoint: ETH_ENDPOINT,
  addresses,
  vTokenAddress: "0x...", // The VToken Address
  cashAddress: cash.address, // The Cash Address
});

await exchange.init();

// This step will compose an object and sign it with your wallet
const order = await exchange.buy(
  wallet,
  1.88, // Size
  2852.31, // Limit Price
  // Deadline, the helper method is imported from library, param unit is second
  getFutureExpiryInSeconds(1800) 
);

// This step will upload your signed data to our backend for aggregation
await apis.orderPutLimit(
  "0x...", // VToken Address
  order,
);

Sell Option

The sell option is very similar to the buying part; the only difference is to call a different function on the exchange class.

// Cash corresponds the money in ordinary option trade
const cash = await apis.cash();

const exchange = new Exchange({
  chainId: ChainId.Ropsten,
  endpoint: ETH_ENDPOINT,
  addresses,
  vTokenAddress: "0x...", // The VToken Address
  cashAddress: cash.address, // The Cash Address
});

await exchange.init();

// This step will compose an object and sign it with your wallet
const order = await exchange.buy(
  wallet,
  1.88, // Size
  2852.31, // Limit Price
  // Deadline, the helper method is imported from library, param unit is second
  getFutureExpiryInSeconds(1800) 
);

// This step will upload your signed data to our backend for aggregation
await APIs.orderPutLimit(
  "0x...", // VToken Address
  order,
);

Last updated