mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
more pool tests
This commit is contained in:
parent
7456360d00
commit
6f85014e00
@ -15,12 +15,12 @@ import OceanSPool from '@oceanprotocol/contracts/artifacts/BPool.json'
|
|||||||
const web3 = new Web3('http://127.0.0.1:8545')
|
const web3 = new Web3('http://127.0.0.1:8545')
|
||||||
|
|
||||||
describe('Balancer flow', () => {
|
describe('Balancer flow', () => {
|
||||||
let oceanTokenAddress
|
let oceanTokenAddress: string
|
||||||
let OceanPoolFactoryAddress
|
let OceanPoolFactoryAddress: string
|
||||||
let Pool: OceanPool
|
let Pool: OceanPool
|
||||||
let oceandatatoken: DataTokens
|
let oceandatatoken: DataTokens
|
||||||
let alicePoolAddress
|
let alicePoolAddress: string
|
||||||
let currentDtPrice
|
let currentDtPrice: string
|
||||||
let owner: string
|
let owner: string
|
||||||
let bob: string
|
let bob: string
|
||||||
let alice: string
|
let alice: string
|
||||||
@ -28,226 +28,246 @@ describe('Balancer flow', () => {
|
|||||||
let datatoken: DataTokens
|
let datatoken: DataTokens
|
||||||
let tokenAddress: string
|
let tokenAddress: string
|
||||||
let consoleDebug: false
|
let consoleDebug: false
|
||||||
let greatPool
|
let greatPool: string
|
||||||
const tokenAmount = '1000'
|
const tokenAmount = '1000'
|
||||||
const transferAmount = '200'
|
const transferAmount = '200'
|
||||||
const blob = 'http://localhost:8030/api/v1/services/consume'
|
const blob = 'http://localhost:8030/api/v1/services/consume'
|
||||||
|
|
||||||
describe('#test', () => {
|
before(async () => {
|
||||||
before(async () => {
|
// deploy SFactory
|
||||||
// deploy SFactory
|
const SContracts = new BalancerContractHandler(
|
||||||
const SContracts = new BalancerContractHandler(
|
OceanPoolFactory.abi as AbiItem[],
|
||||||
OceanPoolFactory.abi as AbiItem[],
|
OceanPoolFactory.bytecode,
|
||||||
OceanPoolFactory.bytecode,
|
OceanSPool.abi as AbiItem[],
|
||||||
OceanSPool.abi as AbiItem[],
|
OceanSPool.bytecode,
|
||||||
OceanSPool.bytecode,
|
web3
|
||||||
web3
|
)
|
||||||
)
|
await SContracts.getAccounts()
|
||||||
await SContracts.getAccounts()
|
owner = SContracts.accounts[0]
|
||||||
owner = SContracts.accounts[0]
|
|
||||||
|
|
||||||
await SContracts.SdeployContracts(owner)
|
await SContracts.SdeployContracts(owner)
|
||||||
OceanPoolFactoryAddress = SContracts.factoryAddress
|
OceanPoolFactoryAddress = SContracts.factoryAddress
|
||||||
assert(OceanPoolFactoryAddress !== null)
|
assert(OceanPoolFactoryAddress !== null)
|
||||||
|
|
||||||
// deploy DT Factory
|
// deploy DT Factory
|
||||||
contracts = new TestContractHandler(
|
contracts = new TestContractHandler(
|
||||||
factory.abi as AbiItem[],
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi as AbiItem[],
|
datatokensTemplate.abi as AbiItem[],
|
||||||
datatokensTemplate.bytecode,
|
datatokensTemplate.bytecode,
|
||||||
factory.bytecode,
|
factory.bytecode,
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
await contracts.getAccounts()
|
await contracts.getAccounts()
|
||||||
owner = contracts.accounts[0]
|
owner = contracts.accounts[0]
|
||||||
alice = contracts.accounts[1]
|
alice = contracts.accounts[1]
|
||||||
bob = contracts.accounts[2]
|
bob = contracts.accounts[2]
|
||||||
await contracts.deployContracts(owner)
|
await contracts.deployContracts(owner)
|
||||||
|
|
||||||
// initialize DataTokens
|
// initialize DataTokens
|
||||||
datatoken = new DataTokens(
|
datatoken = new DataTokens(
|
||||||
contracts.factoryAddress,
|
contracts.factoryAddress,
|
||||||
factory.abi as AbiItem[],
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi as AbiItem[],
|
datatokensTemplate.abi as AbiItem[],
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
assert(datatoken !== null)
|
assert(datatoken !== null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should create datatokens smart contract', async () => {
|
it('should create datatokens smart contract', async () => {
|
||||||
tokenAddress = await datatoken.create(blob, alice, '10000000000', 'AliceDT', 'DTA')
|
tokenAddress = await datatoken.create(blob, alice, '10000000000', 'AliceDT', 'DTA')
|
||||||
assert(tokenAddress !== null)
|
assert(tokenAddress !== null)
|
||||||
})
|
})
|
||||||
it('Create a dummy OceanToken', async () => {
|
it('Create a dummy OceanToken', async () => {
|
||||||
// Alice creates a Datatoken
|
// Alice creates a Datatoken
|
||||||
oceandatatoken = new DataTokens(
|
oceandatatoken = new DataTokens(
|
||||||
contracts.factoryAddress,
|
contracts.factoryAddress,
|
||||||
factory.abi as AbiItem[],
|
factory.abi as AbiItem[],
|
||||||
datatokensTemplate.abi as AbiItem[],
|
datatokensTemplate.abi as AbiItem[],
|
||||||
web3
|
web3
|
||||||
)
|
)
|
||||||
oceanTokenAddress = await oceandatatoken.create(
|
oceanTokenAddress = await oceandatatoken.create(
|
||||||
blob,
|
blob,
|
||||||
alice,
|
alice,
|
||||||
'10000000000',
|
'10000000000',
|
||||||
'AliceDT2',
|
'AliceDT2',
|
||||||
'DTA2'
|
'DTA2'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
it('should initialize OceanPool class', async () => {
|
it('should initialize OceanPool class', async () => {
|
||||||
Pool = new OceanPool(
|
Pool = new OceanPool(
|
||||||
web3,
|
web3,
|
||||||
OceanPoolFactory.abi as AbiItem[],
|
OceanPoolFactory.abi as AbiItem[],
|
||||||
OceanSPool.abi as AbiItem[],
|
OceanSPool.abi as AbiItem[],
|
||||||
OceanPoolFactoryAddress,
|
OceanPoolFactoryAddress,
|
||||||
oceanTokenAddress
|
oceanTokenAddress
|
||||||
)
|
)
|
||||||
assert(Pool !== null)
|
assert(Pool !== null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Alice mints 1000 tokens', async () => {
|
it('Alice mints 1000 tokens', async () => {
|
||||||
await datatoken.mint(tokenAddress, alice, tokenAmount)
|
await datatoken.mint(tokenAddress, alice, tokenAmount)
|
||||||
})
|
})
|
||||||
it('Alice mints 1000 Ocean tokens', async () => {
|
it('Alice mints 1000 Ocean tokens', async () => {
|
||||||
await oceandatatoken.mint(oceanTokenAddress, alice, tokenAmount)
|
await oceandatatoken.mint(oceanTokenAddress, alice, tokenAmount)
|
||||||
})
|
})
|
||||||
it('Alice transfers 200 ocean token to Bob', async () => {
|
it('Alice transfers 200 ocean token to Bob', async () => {
|
||||||
await datatoken.transfer(oceanTokenAddress, bob, transferAmount, alice)
|
await datatoken.transfer(oceanTokenAddress, bob, transferAmount, alice)
|
||||||
})
|
})
|
||||||
it('Alice creates a new OceanPool pool', async () => {
|
it('Alice creates a new OceanPool pool', async () => {
|
||||||
/// new pool with total DT = 45 , dt weight=90% with swap fee 2%
|
/// new pool with total DT = 45 , dt weight=90% with swap fee 2%
|
||||||
alicePoolAddress = await Pool.createDTPool(alice, tokenAddress, '45', '9', '0.02')
|
alicePoolAddress = await Pool.createDTPool(alice, tokenAddress, '45', '9', '0.02')
|
||||||
const s = await Pool.totalSupply(alicePoolAddress)
|
const s = await Pool.totalSupply(alicePoolAddress)
|
||||||
assert(String(s) === '100', 'totalSupply does not match: ' + s)
|
assert(String(s) === '100', 'totalSupply does not match: ' + s)
|
||||||
const n = await Pool.getNumTokens(alice, alicePoolAddress)
|
const n = await Pool.getNumTokens(alice, alicePoolAddress)
|
||||||
assert(String(n) === '2', 'unexpected num tokens: ' + n)
|
assert(String(n) === '2', 'unexpected num tokens: ' + n)
|
||||||
})
|
})
|
||||||
it('Get pool information', async () => {
|
it('Get pool information', async () => {
|
||||||
const currentTokens = await Pool.getCurrentTokens(alice, alicePoolAddress)
|
const currentTokens = await Pool.getCurrentTokens(alice, alicePoolAddress)
|
||||||
assert(currentTokens.length === 2)
|
assert(currentTokens.length === 2)
|
||||||
assert(currentTokens.includes(tokenAddress))
|
assert(currentTokens.includes(tokenAddress))
|
||||||
assert(currentTokens.includes(oceanTokenAddress))
|
assert(currentTokens.includes(oceanTokenAddress))
|
||||||
})
|
})
|
||||||
it('Get pool swap fee', async () => {
|
|
||||||
const currentSwapFee = await Pool.getSwapFee(alice, alicePoolAddress)
|
|
||||||
assert(currentSwapFee === '0.02')
|
|
||||||
})
|
|
||||||
it('Get dtPrice from the pool ', async () => {
|
|
||||||
currentDtPrice = await Pool.getDTPrice(alice, alicePoolAddress)
|
|
||||||
assert(currentDtPrice > 0)
|
|
||||||
})
|
|
||||||
it('Get dtToken pool reserve ', async () => {
|
|
||||||
const currentDtReserve = await Pool.getDTReserve(alice, alicePoolAddress)
|
|
||||||
assert(Number(currentDtReserve) > 0)
|
|
||||||
})
|
|
||||||
it('Get Ocean pool reserve ', async () => {
|
|
||||||
const currentOceanReserve = await Pool.getOceanReserve(alice, alicePoolAddress)
|
|
||||||
assert(Number(currentOceanReserve) > 0)
|
|
||||||
})
|
|
||||||
it('Get total supply of pool tokens', async () => {
|
|
||||||
const totalSupply = await Pool.totalSupply(alicePoolAddress)
|
|
||||||
assert(Number(totalSupply) > 0)
|
|
||||||
})
|
|
||||||
it('Get amount of Ocean needed to buy 1 dtToken', async () => {
|
|
||||||
const requiredOcean = await Pool.getOceanNeeded(alice, alicePoolAddress, '1')
|
|
||||||
assert(Number(requiredOcean) > 0)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Bob should search for pools with this DT', async () => {
|
it('Get pool swap fee', async () => {
|
||||||
const pools = await Pool.searchPoolforDT(bob, tokenAddress)
|
const currentSwapFee = await Pool.getSwapFee(alice, alicePoolAddress)
|
||||||
assert(pools.length > 0)
|
assert(currentSwapFee === '0.02')
|
||||||
greatPool = pools[0]
|
})
|
||||||
})
|
|
||||||
it('Bob should buy a DT ', async () => {
|
|
||||||
const maxPrice = parseFloat(currentDtPrice) * 2
|
|
||||||
await Pool.buyDT(bob, greatPool, '1', '2', String(maxPrice))
|
|
||||||
const bobDtBalance = await datatoken.balance(tokenAddress, bob)
|
|
||||||
const bobOceanBalance = await datatoken.balance(oceanTokenAddress, bob)
|
|
||||||
assert(Number(bobDtBalance) > 0)
|
|
||||||
assert(Number(bobOceanBalance) > 0)
|
|
||||||
})
|
|
||||||
it('Bob should add DT liquidity to pool ', async () => {
|
|
||||||
const currentDtReserve = await Pool.getDTReserve(bob, greatPool)
|
|
||||||
if (consoleDebug) console.log('currentDtReserve:' + currentDtReserve)
|
|
||||||
const bobDtBalance = await datatoken.balance(tokenAddress, bob)
|
|
||||||
if (consoleDebug) console.log('BOB DT Balance:' + bobDtBalance)
|
|
||||||
await Pool.addDTLiquidity(bob, greatPool, bobDtBalance)
|
|
||||||
|
|
||||||
const newbobDtBalance = await datatoken.balance(tokenAddress, bob)
|
it('Get spot price for swapping', async () => {
|
||||||
|
const spotPrice = await Pool.getSpotPrice(
|
||||||
|
alice,
|
||||||
|
alicePoolAddress,
|
||||||
|
tokenAddress,
|
||||||
|
oceanTokenAddress
|
||||||
|
)
|
||||||
|
assert(Number(spotPrice) > 0)
|
||||||
|
})
|
||||||
|
|
||||||
const newDtReserve = await Pool.getDTReserve(bob, greatPool)
|
it('Get spot price for swapping without fees', async () => {
|
||||||
|
const spotPrice = await Pool.getSpotPriceSansFee(
|
||||||
|
alice,
|
||||||
|
alicePoolAddress,
|
||||||
|
tokenAddress,
|
||||||
|
oceanTokenAddress
|
||||||
|
)
|
||||||
|
assert(Number(spotPrice) > 0)
|
||||||
|
})
|
||||||
|
|
||||||
const sharesBalance = await Pool.sharesBalance(bob, greatPool)
|
it('Get dtPrice from the pool ', async () => {
|
||||||
if (consoleDebug) console.log('newDtReserve:' + newDtReserve)
|
currentDtPrice = await Pool.getDTPrice(alice, alicePoolAddress)
|
||||||
if (consoleDebug) console.log('newbobDtBalance:' + newbobDtBalance)
|
assert(currentDtPrice > 0)
|
||||||
if (consoleDebug) console.log('sharesBalance:' + sharesBalance)
|
})
|
||||||
assert(parseFloat(newbobDtBalance) < parseFloat(bobDtBalance))
|
it('Get dtToken pool reserve ', async () => {
|
||||||
assert(parseFloat(newDtReserve) > parseFloat(currentDtReserve))
|
const currentDtReserve = await Pool.getDTReserve(alice, alicePoolAddress)
|
||||||
assert(parseFloat(sharesBalance) > 0)
|
assert(Number(currentDtReserve) > 0)
|
||||||
})
|
})
|
||||||
|
it('Get Ocean pool reserve ', async () => {
|
||||||
|
const currentOceanReserve = await Pool.getOceanReserve(alice, alicePoolAddress)
|
||||||
|
assert(Number(currentOceanReserve) > 0)
|
||||||
|
})
|
||||||
|
it('Get total supply of pool tokens', async () => {
|
||||||
|
const totalSupply = await Pool.totalSupply(alicePoolAddress)
|
||||||
|
assert(Number(totalSupply) > 0)
|
||||||
|
})
|
||||||
|
it('Get amount of Ocean needed to buy 1 dtToken', async () => {
|
||||||
|
const requiredOcean = await Pool.getOceanNeeded(alice, alicePoolAddress, '1')
|
||||||
|
assert(Number(requiredOcean) > 0)
|
||||||
|
})
|
||||||
|
|
||||||
it('Bob should remove DT liquidity from pool ', async () => {
|
it('Bob should search for pools with this DT', async () => {
|
||||||
const currentDtReserve = await Pool.getDTReserve(bob, greatPool)
|
const pools = await Pool.searchPoolforDT(bob, tokenAddress)
|
||||||
if (consoleDebug) console.log('currentDtReserve:' + currentDtReserve)
|
assert(pools.length > 0)
|
||||||
const bobDtBalance = await datatoken.balance(tokenAddress, bob)
|
greatPool = pools[0]
|
||||||
if (consoleDebug) console.log('bobDtBalance:' + bobDtBalance)
|
})
|
||||||
const poolShares = await Pool.sharesBalance(bob, greatPool)
|
it('Bob should buy a DT ', async () => {
|
||||||
if (consoleDebug) console.log('poolShares:' + poolShares)
|
const maxPrice = parseFloat(currentDtPrice) * 2
|
||||||
await Pool.removeDTLiquidity(bob, greatPool, '0.75', poolShares)
|
await Pool.buyDT(bob, greatPool, '1', '2', String(maxPrice))
|
||||||
|
const bobDtBalance = await datatoken.balance(tokenAddress, bob)
|
||||||
|
const bobOceanBalance = await datatoken.balance(oceanTokenAddress, bob)
|
||||||
|
assert(Number(bobDtBalance) > 0)
|
||||||
|
assert(Number(bobOceanBalance) > 0)
|
||||||
|
})
|
||||||
|
it('Bob should add DT liquidity to pool ', async () => {
|
||||||
|
const currentDtReserve = await Pool.getDTReserve(bob, greatPool)
|
||||||
|
if (consoleDebug) console.log('currentDtReserve:' + currentDtReserve)
|
||||||
|
const bobDtBalance = await datatoken.balance(tokenAddress, bob)
|
||||||
|
if (consoleDebug) console.log('BOB DT Balance:' + bobDtBalance)
|
||||||
|
await Pool.addDTLiquidity(bob, greatPool, bobDtBalance)
|
||||||
|
|
||||||
const newDtReserve = await Pool.getDTReserve(bob, greatPool)
|
const newbobDtBalance = await datatoken.balance(tokenAddress, bob)
|
||||||
if (consoleDebug) console.log('newDtReserve:' + newDtReserve)
|
|
||||||
const newbobDtBalance = await datatoken.balance(tokenAddress, bob)
|
|
||||||
if (consoleDebug) console.log('newbobDtBalance:' + newbobDtBalance)
|
|
||||||
const newpoolShares = await Pool.sharesBalance(bob, greatPool)
|
|
||||||
if (consoleDebug) console.log('newpoolShares:' + newpoolShares)
|
|
||||||
assert(parseFloat(newDtReserve) < parseFloat(currentDtReserve))
|
|
||||||
assert(parseFloat(bobDtBalance) < parseFloat(newbobDtBalance))
|
|
||||||
assert(parseFloat(poolShares) > parseFloat(newpoolShares))
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Bob should add Ocean liquidity to pool ', async () => {
|
const newDtReserve = await Pool.getDTReserve(bob, greatPool)
|
||||||
const currentDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
|
||||||
const bobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
|
||||||
if (consoleDebug) console.log('currentDtReserve:' + currentDtReserve)
|
|
||||||
if (consoleDebug) console.log('bobDtBalance:' + bobDtBalance)
|
|
||||||
|
|
||||||
await Pool.addOceanLiquidity(bob, greatPool, '1')
|
const sharesBalance = await Pool.sharesBalance(bob, greatPool)
|
||||||
|
if (consoleDebug) console.log('newDtReserve:' + newDtReserve)
|
||||||
|
if (consoleDebug) console.log('newbobDtBalance:' + newbobDtBalance)
|
||||||
|
if (consoleDebug) console.log('sharesBalance:' + sharesBalance)
|
||||||
|
assert(parseFloat(newbobDtBalance) < parseFloat(bobDtBalance))
|
||||||
|
assert(parseFloat(newDtReserve) > parseFloat(currentDtReserve))
|
||||||
|
assert(parseFloat(sharesBalance) > 0)
|
||||||
|
})
|
||||||
|
|
||||||
const newbobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
it('Bob should remove DT liquidity from pool ', async () => {
|
||||||
|
const currentDtReserve = await Pool.getDTReserve(bob, greatPool)
|
||||||
|
if (consoleDebug) console.log('currentDtReserve:' + currentDtReserve)
|
||||||
|
const bobDtBalance = await datatoken.balance(tokenAddress, bob)
|
||||||
|
if (consoleDebug) console.log('bobDtBalance:' + bobDtBalance)
|
||||||
|
const poolShares = await Pool.sharesBalance(bob, greatPool)
|
||||||
|
if (consoleDebug) console.log('poolShares:' + poolShares)
|
||||||
|
await Pool.removeDTLiquidity(bob, greatPool, '0.75', poolShares)
|
||||||
|
|
||||||
const newDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
const newDtReserve = await Pool.getDTReserve(bob, greatPool)
|
||||||
|
if (consoleDebug) console.log('newDtReserve:' + newDtReserve)
|
||||||
|
const newbobDtBalance = await datatoken.balance(tokenAddress, bob)
|
||||||
|
if (consoleDebug) console.log('newbobDtBalance:' + newbobDtBalance)
|
||||||
|
const newpoolShares = await Pool.sharesBalance(bob, greatPool)
|
||||||
|
if (consoleDebug) console.log('newpoolShares:' + newpoolShares)
|
||||||
|
assert(parseFloat(newDtReserve) < parseFloat(currentDtReserve))
|
||||||
|
assert(parseFloat(bobDtBalance) < parseFloat(newbobDtBalance))
|
||||||
|
assert(parseFloat(poolShares) > parseFloat(newpoolShares))
|
||||||
|
})
|
||||||
|
|
||||||
const sharesBalance = await Pool.sharesBalance(bob, greatPool)
|
it('Bob should add Ocean liquidity to pool ', async () => {
|
||||||
if (consoleDebug) console.log('newDtReserve:' + newDtReserve)
|
const currentDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
||||||
if (consoleDebug) console.log('newbobDtBalance:' + newbobDtBalance)
|
const bobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
||||||
if (consoleDebug) console.log('sharesBalance:' + sharesBalance)
|
if (consoleDebug) console.log('currentDtReserve:' + currentDtReserve)
|
||||||
assert(parseFloat(newbobDtBalance) < parseFloat(bobDtBalance))
|
if (consoleDebug) console.log('bobDtBalance:' + bobDtBalance)
|
||||||
assert(parseFloat(newDtReserve) > parseFloat(currentDtReserve))
|
|
||||||
assert(parseFloat(sharesBalance) > 0)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Bob should remove Ocean liquidity from pool ', async () => {
|
await Pool.addOceanLiquidity(bob, greatPool, '1')
|
||||||
const currentDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
|
||||||
const bobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
|
||||||
|
|
||||||
const poolShares = await Pool.sharesBalance(bob, greatPool)
|
const newbobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
||||||
if (consoleDebug) console.log('currentDtReserve:' + currentDtReserve)
|
|
||||||
if (consoleDebug) console.log('bobDtBalance:' + bobDtBalance)
|
|
||||||
if (consoleDebug) console.log('poolShares:' + poolShares)
|
|
||||||
|
|
||||||
await Pool.removeOceanLiquidity(bob, greatPool, '0.75', poolShares)
|
const newDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
||||||
|
|
||||||
const newDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
const sharesBalance = await Pool.sharesBalance(bob, greatPool)
|
||||||
const newbobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
if (consoleDebug) console.log('newDtReserve:' + newDtReserve)
|
||||||
const newpoolShares = await Pool.sharesBalance(bob, greatPool)
|
if (consoleDebug) console.log('newbobDtBalance:' + newbobDtBalance)
|
||||||
|
if (consoleDebug) console.log('sharesBalance:' + sharesBalance)
|
||||||
|
assert(parseFloat(newbobDtBalance) < parseFloat(bobDtBalance))
|
||||||
|
assert(parseFloat(newDtReserve) > parseFloat(currentDtReserve))
|
||||||
|
assert(parseFloat(sharesBalance) > 0)
|
||||||
|
})
|
||||||
|
|
||||||
if (consoleDebug) console.log('newDtReserve:' + newDtReserve)
|
it('Bob should remove Ocean liquidity from pool ', async () => {
|
||||||
if (consoleDebug) console.log('newbobDtBalance:' + newbobDtBalance)
|
const currentDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
||||||
if (consoleDebug) console.log('newpoolShares:' + newpoolShares)
|
const bobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
||||||
assert(parseFloat(newDtReserve) < parseFloat(currentDtReserve))
|
|
||||||
assert(parseFloat(bobDtBalance) < parseFloat(newbobDtBalance))
|
const poolShares = await Pool.sharesBalance(bob, greatPool)
|
||||||
assert(parseFloat(poolShares) > parseFloat(newpoolShares))
|
if (consoleDebug) console.log('currentDtReserve:' + currentDtReserve)
|
||||||
})
|
if (consoleDebug) console.log('bobDtBalance:' + bobDtBalance)
|
||||||
|
if (consoleDebug) console.log('poolShares:' + poolShares)
|
||||||
|
|
||||||
|
await Pool.removeOceanLiquidity(bob, greatPool, '0.75', poolShares)
|
||||||
|
|
||||||
|
const newDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
||||||
|
const newbobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
||||||
|
const newpoolShares = await Pool.sharesBalance(bob, greatPool)
|
||||||
|
|
||||||
|
if (consoleDebug) console.log('newDtReserve:' + newDtReserve)
|
||||||
|
if (consoleDebug) console.log('newbobDtBalance:' + newbobDtBalance)
|
||||||
|
if (consoleDebug) console.log('newpoolShares:' + newpoolShares)
|
||||||
|
assert(parseFloat(newDtReserve) < parseFloat(currentDtReserve))
|
||||||
|
assert(parseFloat(bobDtBalance) < parseFloat(newbobDtBalance))
|
||||||
|
assert(parseFloat(poolShares) > parseFloat(newpoolShares))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user