DEV Community

Marques Traylor
Marques Traylor

Posted on • Edited on

ShadowGas - Trade

v1.0.0 of the ShadowGas smart contract is finished. My two recent posts (below) go over the Store and Transfer features of the contract and this one will go over the Trade feature.


https://dev.to/traylorboy/shadowgas-store-40m9

https://dev.to/traylorboy/shadowgas-transfer-59jg


The Trade feature currently only trades the liquid gas token, however I plan on including the other 2 later down the road

Updated the shadowGas.config.json file

shadow.config.json

`RefuelChiAmt` - Mint Chi Amount
`RefuelLgtAmt` - Mint Lgt Amount
`EmptyChiAmt` - Transfer Chi Amount
`EmptyLgtAmt` - Transfer Lgt Amount
`EmptyChiTo` - Address to transfer Chi to
`EmptyLgtTo` - Address to transfer Lgt to
`GasLimit` - Gas Limit
`GasSpeed` - Gas Speed ("fast", "average", "slow") 
`TradeLimit` - The amount of trades to perform
`LgtTradeAmount` - Amount of LGT Tokens to trade
Enter fullscreen mode Exit fullscreen mode

Trade

Only trades LGT, but can use refueled CHI for discounts so profit may be more than expected if discount is applied

Oracle

npx buidler oracle
Enter fullscreen mode Exit fullscreen mode

Will retrieve trade information for arbitrage

Arbitrage

npx buidler arbitrage
Enter fullscreen mode Exit fullscreen mode

Will run a loop to continuously check for trade opportunities every minute and will execute trades if an opportunity is found until TradeLimit is reached

Examples

Check for trade opportunity

npx buidler oracle
Enter fullscreen mode Exit fullscreen mode

Alt Text

If the costToMint > expectedProfit, no opportunity found

Testing the Arbitrage Strategy

Since the costToMint is heavily weighted by the current gasPrice, by changing the gasPrice variable (ex. 1 Gwei) on a testnet, you will be able to mint the LGT tokens for cheap and sell them for a profit within the same transaction since the costToMint will be much lower when minting at 1 Gwei than at 116 Gwei thus forcing a trade opportunity.

npx buidler arbitrage
Enter fullscreen mode Exit fullscreen mode

Alt Text

v1.0.0 for the ShadowGas contract is released; after adding GST compatibility (v1.1.0), I will be developing the UI in React in order to interact with the contract!

The repo can be found here: https://github.com/TraylorBoy/ShadowGas

Top comments (0)