2018-12-01 20:32:00 +00:00
|
|
|
import LPVault from 'Embark/contracts/LPVault'
|
|
|
|
import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock'
|
|
|
|
import StandardToken from 'Embark/contracts/StandardToken'
|
2018-12-08 17:52:22 +00:00
|
|
|
import web3 from 'Embark/web3'
|
2018-12-01 20:32:00 +00:00
|
|
|
|
2018-12-01 22:16:58 +00:00
|
|
|
export const initVaultAndLP = async () => {
|
|
|
|
const lpInit = await LiquidPledgingMock.methods.initialize(LPVault._address).send()
|
2018-12-01 14:31:04 +00:00
|
|
|
console.log(lpInit)
|
2018-12-08 17:52:22 +00:00
|
|
|
const vaultInit = await LPVault.methods.initialize(LiquidPledgingMock._address).send()
|
|
|
|
console.log(vaultInit)
|
2018-12-01 14:31:04 +00:00
|
|
|
}
|
2018-12-01 20:32:00 +00:00
|
|
|
|
|
|
|
export const vaultPledgingNeedsInit = async () => {
|
2018-12-08 17:52:22 +00:00
|
|
|
const needsInit = !!Number(await LiquidPledgingMock.methods.getInitializationBlock().call())
|
|
|
|
&& !!Number(await LPVault.methods.getInitializationBlock().call())
|
2018-12-01 20:32:00 +00:00
|
|
|
return needsInit
|
|
|
|
}
|
|
|
|
|
|
|
|
export const standardTokenApproval = async () => {
|
2018-12-01 22:16:58 +00:00
|
|
|
const { approve } = StandardToken.methods
|
|
|
|
const spender = LiquidPledgingMock._address
|
|
|
|
return await approve(
|
|
|
|
spender,
|
|
|
|
web3.utils.toWei('10000000', 'tether')
|
|
|
|
).send()
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getLpAllowance = async () => {
|
|
|
|
const { allowance } = StandardToken.methods
|
2018-12-01 20:32:00 +00:00
|
|
|
const account = await web3.eth.getCoinbase()
|
|
|
|
const spender = LiquidPledgingMock._address
|
|
|
|
const allowanceAmt = Number(await allowance(account, spender).call())
|
2018-12-01 22:16:58 +00:00
|
|
|
return allowanceAmt
|
2018-12-01 20:32:00 +00:00
|
|
|
}
|