pancake flattens volatility in ETH -> USD payments
This is a simple hack day project which aims to solve a very simple problem, using chainlink:
- Receive some ETH at an address
- Automatically transfer that ETH to an exchange wallet
- Sell that ETH for USD at the exchange
@j16r and @rupurt
So far the plan is to have:
- A receiving Solidity contract, that upon transfer of some ETH, transfers to a new target address (your exchange's wallet) and creates a RunLog for chainlink
- A JobSpec that listens for the above RunLog and triggers an external adaptor
- A small service, likely written in Node/JS, that upon triggering by chainlink, will watch for the amount to be deposited in the exchange, then trigger a sell.
So how do you use this? First you'll need:
- NodeJS + npm/yarn. NodeJS >= 8.x
- A running Ethereum node, with RPC listening on 18545
- An Ethereum wallet to get ETH shipped to
- Create a GDAX sandbox account
- Create API credentials with view & trade permissions
- Store the API credentials in a
.env
file and apply them to your current shellsource .env
- Start the
pancake-trader
servicenpm run dev / yarn dev
(configuration options)
- Create an ethereum account, with geth you can do
geth account new
- Migrate the job spec and contract with:
WALLET_ADDRESS=$YourWalletAddress npm run deploy
- Transfer some coins to your contract address!
- This will trigger the job run on your Chainlink node. Verify that the job
run has sent the request from the bridge adapter by checking the
pancake-trader
logs. You should see the following message every 100ms... No ETH balance to sell. Check balance again in 100ms
- Simulate GDAX crediting your account by depositing funds into the sandbox
- Verify that
pancake-trader
has sold your ETH by checking for the log✔✔✔ Successfully sold 10 ETH
- Verify that GDAX has sold your ETH by checking the filler orders