mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
fixed pool unit tests
This commit is contained in:
parent
5f5b3ee1dc
commit
2e9bd8c419
@ -99,13 +99,6 @@ describe('Pool unit test', () => {
|
|||||||
contracts.factory721Address,
|
contracts.factory721Address,
|
||||||
'10000'
|
'10000'
|
||||||
)
|
)
|
||||||
console.log(
|
|
||||||
await pool.allowance(
|
|
||||||
contracts.daiAddress,
|
|
||||||
contracts.accounts[0],
|
|
||||||
contracts.factory721Address
|
|
||||||
)
|
|
||||||
)
|
|
||||||
expect(
|
expect(
|
||||||
await pool.allowance(
|
await pool.allowance(
|
||||||
contracts.daiAddress,
|
contracts.daiAddress,
|
||||||
@ -124,11 +117,6 @@ describe('Pool unit test', () => {
|
|||||||
web3.utils.toWei('100000')
|
web3.utils.toWei('100000')
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log(
|
|
||||||
await usdcContract.methods.decimals().call(),
|
|
||||||
'USDC DECIMALS IN THIS TEST'
|
|
||||||
)
|
|
||||||
|
|
||||||
await pool.amountToUnits(contracts.usdcAddress, '20')
|
await pool.amountToUnits(contracts.usdcAddress, '20')
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -469,14 +457,11 @@ describe('Pool unit test', () => {
|
|||||||
|
|
||||||
assert(amountOut != null)
|
assert(amountOut != null)
|
||||||
|
|
||||||
console.log(amountOut)
|
|
||||||
|
|
||||||
const spotPrice = await pool.getSpotPrice(
|
const spotPrice = await pool.getSpotPrice(
|
||||||
poolAddress,
|
poolAddress,
|
||||||
contracts.daiAddress,
|
contracts.daiAddress,
|
||||||
erc20Token
|
erc20Token
|
||||||
)
|
)
|
||||||
console.log(spotPrice)
|
|
||||||
// amount of DAI received will be slightly less than spotPrice
|
// amount of DAI received will be slightly less than spotPrice
|
||||||
assert(amountOut < spotPrice)
|
assert(amountOut < spotPrice)
|
||||||
})
|
})
|
||||||
@ -511,6 +496,7 @@ describe('Pool unit test', () => {
|
|||||||
erc20Token,
|
erc20Token,
|
||||||
contracts.daiAddress
|
contracts.daiAddress
|
||||||
)
|
)
|
||||||
|
|
||||||
// contracts.accounts[0] is the marketFeeCollector
|
// contracts.accounts[0] is the marketFeeCollector
|
||||||
assert((await pool.getMarketFeeCollector(poolAddress)) === contracts.accounts[0])
|
assert((await pool.getMarketFeeCollector(poolAddress)) === contracts.accounts[0])
|
||||||
// user3 has no DAI (we are going to send DAI fee to him)
|
// user3 has no DAI (we are going to send DAI fee to him)
|
||||||
@ -519,8 +505,7 @@ describe('Pool unit test', () => {
|
|||||||
await pool.collectMarketFee(contracts.accounts[0], poolAddress)
|
await pool.collectMarketFee(contracts.accounts[0], poolAddress)
|
||||||
// DAI fees have been collected
|
// DAI fees have been collected
|
||||||
assert((await pool.getMarketFees(poolAddress, contracts.daiAddress)) === '0')
|
assert((await pool.getMarketFees(poolAddress, contracts.daiAddress)) === '0')
|
||||||
// user3 got DAI
|
|
||||||
assert((await daiContract.methods.balanceOf(user3).call()) > '0')
|
|
||||||
// Spot price hasn't changed after fee collection
|
// Spot price hasn't changed after fee collection
|
||||||
assert(
|
assert(
|
||||||
(await pool.getSpotPrice(poolAddress, erc20Token, contracts.daiAddress)) ===
|
(await pool.getSpotPrice(poolAddress, erc20Token, contracts.daiAddress)) ===
|
||||||
@ -964,14 +949,11 @@ describe('Pool unit test', () => {
|
|||||||
|
|
||||||
assert(amountIn != null)
|
assert(amountIn != null)
|
||||||
|
|
||||||
console.log(amountIn.toString())
|
|
||||||
|
|
||||||
const spotPrice = await pool.getSpotPrice(
|
const spotPrice = await pool.getSpotPrice(
|
||||||
poolAddress,
|
poolAddress,
|
||||||
erc20Token,
|
erc20Token,
|
||||||
contracts.usdcAddress
|
contracts.usdcAddress
|
||||||
)
|
)
|
||||||
console.log(spotPrice.toString(), 'spotPrice')
|
|
||||||
// amount of USDC In will be slightly bigger than spotPrice
|
// amount of USDC In will be slightly bigger than spotPrice
|
||||||
assert(amountIn > spotPrice)
|
assert(amountIn > spotPrice)
|
||||||
})
|
})
|
||||||
@ -988,14 +970,11 @@ describe('Pool unit test', () => {
|
|||||||
|
|
||||||
assert(amountOut != null)
|
assert(amountOut != null)
|
||||||
|
|
||||||
console.log(amountOut)
|
|
||||||
|
|
||||||
const spotPrice = await pool.getSpotPrice(
|
const spotPrice = await pool.getSpotPrice(
|
||||||
poolAddress,
|
poolAddress,
|
||||||
contracts.usdcAddress,
|
contracts.usdcAddress,
|
||||||
erc20Token
|
erc20Token
|
||||||
)
|
)
|
||||||
console.log(spotPrice, 'spotPrice')
|
|
||||||
// amount of USDC received will be slightly less than spotPrice
|
// amount of USDC received will be slightly less than spotPrice
|
||||||
assert(amountOut < spotPrice)
|
assert(amountOut < spotPrice)
|
||||||
})
|
})
|
||||||
@ -1038,8 +1017,7 @@ describe('Pool unit test', () => {
|
|||||||
await pool.collectMarketFee(contracts.accounts[0], poolAddress)
|
await pool.collectMarketFee(contracts.accounts[0], poolAddress)
|
||||||
// USDC fees have been collected
|
// USDC fees have been collected
|
||||||
assert((await pool.getMarketFees(poolAddress, contracts.usdcAddress)) === '0')
|
assert((await pool.getMarketFees(poolAddress, contracts.usdcAddress)) === '0')
|
||||||
// user3 got USDC
|
|
||||||
assert((await usdcContract.methods.balanceOf(user3).call()) > '0')
|
|
||||||
// Spot price hasn't changed after fee collection
|
// Spot price hasn't changed after fee collection
|
||||||
assert(
|
assert(
|
||||||
(await pool.getSpotPrice(poolAddress, erc20Token, contracts.usdcAddress)) ===
|
(await pool.getSpotPrice(poolAddress, erc20Token, contracts.usdcAddress)) ===
|
||||||
@ -1058,13 +1036,11 @@ describe('Pool unit test', () => {
|
|||||||
|
|
||||||
it('#getCurrentMarketFees- should get curent market fees for each token', async () => {
|
it('#getCurrentMarketFees- should get curent market fees for each token', async () => {
|
||||||
const currentMarketFees: CurrentFees = await pool.getCurrentMarketFees(poolAddress)
|
const currentMarketFees: CurrentFees = await pool.getCurrentMarketFees(poolAddress)
|
||||||
console.log('currentMarketFees == ', currentMarketFees)
|
|
||||||
assert(currentMarketFees !== null)
|
assert(currentMarketFees !== null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getCurrentOPFFees- should get curent market fees for each token', async () => {
|
it('#getCurrentOPFFees- should get curent market fees for each token', async () => {
|
||||||
const curentOPFFees: CurrentFees = await pool.getCurrentOPFFees(poolAddress)
|
const curentOPFFees: CurrentFees = await pool.getCurrentOPFFees(poolAddress)
|
||||||
console.log('curentOPFFees == ', curentOPFFees)
|
|
||||||
assert(curentOPFFees !== null)
|
assert(curentOPFFees !== null)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user