Skip to content

Instantly share code, notes, and snippets.

@erin-koen
Last active April 30, 2020 21:27
Show Gist options
  • Save erin-koen/2d81d0b142dc756814c4a80b6686abd7 to your computer and use it in GitHub Desktop.
Save erin-koen/2d81d0b142dc756814c4a80b6686abd7 to your computer and use it in GitHub Desktop.
The Melon Bot's Trade Method
public async makeTransaction(priceInfo: PriceQueryResult){
// adjust the target amount of token to buy
const slippage = 0.97;
// use the price query results to construct the uniswap order argument object
const orderArgs = {
makerQuantity: priceInfo.sizeInQuote.integerValue().multipliedBy(slippage),
takerQuantity: priceInfo.sizeInBase.integerValue(),
makerAsset: priceInfo.quoteCurrency.address,
takerAsset: priceInfo.baseCurrency.address,
};
console.log(
`Buying ${orderArgs.makerQuantity} ${priceInfo.quoteCurrency.symbol} by selling ${orderArgs.takerQuantity} ${priceInfo.baseCurrency.symbol}`
);
// instantiate the transaction object
return this.uniswapAdapterContract.takeOrder(this.account, orderArgs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment