Created
June 29, 2020 10:08
-
-
Save alexroan/683491c625e7b838cf6dc9ab1bfe146f to your computer and use it in GitHub Desktop.
compound_interactions.js
This file contains hidden or 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
export const supplyEth = async (dispatch, cEthInstance, account, supplyValue, web3, network) => { | |
cEthInstance.methods.mint().send({from: account, value: supplyValue}) | |
.once('transactionHash', (hash) => { | |
dispatch(depositing()); | |
}) | |
.on('confirmation', (number, receipt) => { | |
if (number < 4){ | |
dispatch(depositConfirmation(number+1)); | |
if (number === 3) { | |
dispatch(finishedDepositing()); | |
loadBalance(dispatch, web3, account, network); | |
} | |
} | |
}) | |
.on('error', (error) => { | |
console.log(error); | |
}); | |
} | |
export const redeemEth = async (dispatch, cEthInstance, account, redeemAmount, web3, network) => { | |
cEthInstance.methods.redeemUnderlying(redeemAmount).send({from: account}) | |
.once('transactionHash', (hash) => { | |
dispatch(withdrawing()); | |
}) | |
.on('confirmation', (number, receipt) => { | |
if(number < 4){ | |
dispatch(withdrawConfirmation(number+1)); | |
if(number === 3) { | |
dispatch(finishedWithdrawing()); | |
loadBalance(dispatch, web3, account, network); | |
} | |
} | |
}) | |
.on('error', (error) => { | |
console.log(error); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment