Last active
April 30, 2020 21:27
-
-
Save erin-koen/2d81d0b142dc756814c4a80b6686abd7 to your computer and use it in GitHub Desktop.
The Melon Bot's Trade Method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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