mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
remove unused variables
This commit is contained in:
parent
05e8a91227
commit
bd3bb4dbcd
@ -27,17 +27,13 @@ import {
|
|||||||
|
|
||||||
describe('SideStaking unit test', () => {
|
describe('SideStaking unit test', () => {
|
||||||
let factoryOwner: string
|
let factoryOwner: string
|
||||||
let nftOwner: string
|
|
||||||
let user1: string
|
let user1: string
|
||||||
let user2: string
|
let user2: string
|
||||||
let user3: string
|
|
||||||
let initialBlock: number
|
let initialBlock: number
|
||||||
let sideStakingAddress: string
|
let sideStakingAddress: string
|
||||||
let contracts: Addresses
|
let contracts: Addresses
|
||||||
let pool: Pool
|
let pool: Pool
|
||||||
let sideStaking: SideStaking
|
let sideStaking: SideStaking
|
||||||
let dtAddress: string
|
|
||||||
let dtAddress2: string
|
|
||||||
let poolAddress: string
|
let poolAddress: string
|
||||||
let erc20Token: string
|
let erc20Token: string
|
||||||
let erc20Contract: Contract
|
let erc20Contract: Contract
|
||||||
@ -48,10 +44,8 @@ describe('SideStaking unit test', () => {
|
|||||||
before(async () => {
|
before(async () => {
|
||||||
const accounts = await web3.eth.getAccounts()
|
const accounts = await web3.eth.getAccounts()
|
||||||
factoryOwner = accounts[0]
|
factoryOwner = accounts[0]
|
||||||
nftOwner = accounts[1]
|
user1 = accounts[1]
|
||||||
user1 = accounts[2]
|
user2 = accounts[2]
|
||||||
user2 = accounts[3]
|
|
||||||
user3 = accounts[4]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should deploy contracts', async () => {
|
it('should deploy contracts', async () => {
|
||||||
@ -127,7 +121,7 @@ describe('SideStaking unit test', () => {
|
|||||||
const ercParams: Erc20CreateParams = {
|
const ercParams: Erc20CreateParams = {
|
||||||
templateIndex: 1,
|
templateIndex: 1,
|
||||||
minter: factoryOwner,
|
minter: factoryOwner,
|
||||||
paymentCollector: user3,
|
paymentCollector: user2,
|
||||||
mpFeeAddress: factoryOwner,
|
mpFeeAddress: factoryOwner,
|
||||||
feeToken: '0x0000000000000000000000000000000000000000',
|
feeToken: '0x0000000000000000000000000000000000000000',
|
||||||
cap: '1000000',
|
cap: '1000000',
|
||||||
@ -164,11 +158,12 @@ describe('SideStaking unit test', () => {
|
|||||||
poolAddress = txReceipt.events.NewPool.returnValues.poolAddress
|
poolAddress = txReceipt.events.NewPool.returnValues.poolAddress
|
||||||
|
|
||||||
erc20Contract = new web3.eth.Contract(ERC20Template.abi as AbiItem[], erc20Token)
|
erc20Contract = new web3.eth.Contract(ERC20Template.abi as AbiItem[], erc20Token)
|
||||||
// user2 has no dt1
|
// user1 has no dt1
|
||||||
expect(await erc20Contract.methods.balanceOf(user2).call()).to.equal('0')
|
expect(await erc20Contract.methods.balanceOf(user1).call()).to.equal('0')
|
||||||
|
|
||||||
sideStakingAddress = contracts.sideStakingAddress
|
sideStakingAddress = contracts.sideStakingAddress
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getRouter - should get Router address', async () => {
|
it('#getRouter - should get Router address', async () => {
|
||||||
expect(await sideStaking.getRouter(sideStakingAddress)).to.equal(
|
expect(await sideStaking.getRouter(sideStakingAddress)).to.equal(
|
||||||
contracts.routerAddress
|
contracts.routerAddress
|
||||||
@ -183,6 +178,7 @@ describe('SideStaking unit test', () => {
|
|||||||
)
|
)
|
||||||
).to.equal(web3.utils.toWei('2000'))
|
).to.equal(web3.utils.toWei('2000'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getDatatokenCurrentCirculatingSupply - should get datatoken supply in circulation ', async () => {
|
it('#getDatatokenCurrentCirculatingSupply - should get datatoken supply in circulation ', async () => {
|
||||||
expect(
|
expect(
|
||||||
await sideStaking.getDatatokenCurrentCirculatingSupply(
|
await sideStaking.getDatatokenCurrentCirculatingSupply(
|
||||||
@ -191,21 +187,25 @@ describe('SideStaking unit test', () => {
|
|||||||
)
|
)
|
||||||
).to.equal(web3.utils.toWei('2000'))
|
).to.equal(web3.utils.toWei('2000'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getBaseToken - should get baseToken address', async () => {
|
it('#getBaseToken - should get baseToken address', async () => {
|
||||||
expect(await sideStaking.getBaseToken(sideStakingAddress, erc20Token)).to.equal(
|
expect(await sideStaking.getBaseToken(sideStakingAddress, erc20Token)).to.equal(
|
||||||
contracts.daiAddress
|
contracts.daiAddress
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getPoolAddress - should get pool address', async () => {
|
it('#getPoolAddress - should get pool address', async () => {
|
||||||
expect(await sideStaking.getPoolAddress(sideStakingAddress, erc20Token)).to.equal(
|
expect(await sideStaking.getPoolAddress(sideStakingAddress, erc20Token)).to.equal(
|
||||||
poolAddress
|
poolAddress
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getPublisherAddress - should get publisher address', async () => {
|
it('#getPublisherAddress - should get publisher address', async () => {
|
||||||
expect(
|
expect(
|
||||||
await sideStaking.getPublisherAddress(sideStakingAddress, erc20Token)
|
await sideStaking.getPublisherAddress(sideStakingAddress, erc20Token)
|
||||||
).to.equal(factoryOwner)
|
).to.equal(factoryOwner)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getBaseTokenBalance ', async () => {
|
it('#getBaseTokenBalance ', async () => {
|
||||||
expect(
|
expect(
|
||||||
await sideStaking.getBaseTokenBalance(sideStakingAddress, erc20Token)
|
await sideStaking.getBaseTokenBalance(sideStakingAddress, erc20Token)
|
||||||
@ -222,6 +222,7 @@ describe('SideStaking unit test', () => {
|
|||||||
'10000'
|
'10000'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getvestingLastBlock ', async () => {
|
it('#getvestingLastBlock ', async () => {
|
||||||
expect(
|
expect(
|
||||||
await sideStaking.getvestingLastBlock(sideStakingAddress, erc20Token)
|
await sideStaking.getvestingLastBlock(sideStakingAddress, erc20Token)
|
||||||
@ -233,6 +234,7 @@ describe('SideStaking unit test', () => {
|
|||||||
await sideStaking.getvestingEndBlock(sideStakingAddress, erc20Token)
|
await sideStaking.getvestingEndBlock(sideStakingAddress, erc20Token)
|
||||||
).to.equal((initialBlock + vestedBlocks).toString())
|
).to.equal((initialBlock + vestedBlocks).toString())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getvestingAmountSoFar ', async () => {
|
it('#getvestingAmountSoFar ', async () => {
|
||||||
expect(
|
expect(
|
||||||
await sideStaking.getvestingAmountSoFar(sideStakingAddress, erc20Token)
|
await sideStaking.getvestingAmountSoFar(sideStakingAddress, erc20Token)
|
||||||
@ -262,9 +264,9 @@ describe('SideStaking unit test', () => {
|
|||||||
|
|
||||||
it('#swapExactAmountIn - should swap', async () => {
|
it('#swapExactAmountIn - should swap', async () => {
|
||||||
await daiContract.methods
|
await daiContract.methods
|
||||||
.transfer(user2, web3.utils.toWei('1000'))
|
.transfer(user1, web3.utils.toWei('1000'))
|
||||||
.send({ from: factoryOwner })
|
.send({ from: factoryOwner })
|
||||||
await approve(web3, user2, contracts.daiAddress, poolAddress, '10')
|
await approve(web3, user1, contracts.daiAddress, poolAddress, '10')
|
||||||
const tokenInOutMarket: TokenInOutMarket = {
|
const tokenInOutMarket: TokenInOutMarket = {
|
||||||
tokenIn: contracts.daiAddress,
|
tokenIn: contracts.daiAddress,
|
||||||
tokenOut: erc20Token,
|
tokenOut: erc20Token,
|
||||||
@ -277,18 +279,18 @@ describe('SideStaking unit test', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tx = await pool.swapExactAmountIn(
|
const tx = await pool.swapExactAmountIn(
|
||||||
user2,
|
user1,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
tokenInOutMarket,
|
tokenInOutMarket,
|
||||||
amountsInOutMaxFee
|
amountsInOutMaxFee
|
||||||
)
|
)
|
||||||
expect(await erc20Contract.methods.balanceOf(user2).call()).to.equal(
|
expect(await erc20Contract.methods.balanceOf(user1).call()).to.equal(
|
||||||
tx.events.LOG_SWAP.returnValues.tokenAmountOut
|
tx.events.LOG_SWAP.returnValues.tokenAmountOut
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#swapExactAmountOut - should swap', async () => {
|
it('#swapExactAmountOut - should swap', async () => {
|
||||||
await approve(web3, user2, contracts.daiAddress, poolAddress, '100')
|
await approve(web3, user1, contracts.daiAddress, poolAddress, '100')
|
||||||
const tokenInOutMarket: TokenInOutMarket = {
|
const tokenInOutMarket: TokenInOutMarket = {
|
||||||
tokenIn: contracts.daiAddress,
|
tokenIn: contracts.daiAddress,
|
||||||
tokenOut: erc20Token,
|
tokenOut: erc20Token,
|
||||||
@ -300,7 +302,7 @@ describe('SideStaking unit test', () => {
|
|||||||
swapMarketFee: '0.1'
|
swapMarketFee: '0.1'
|
||||||
}
|
}
|
||||||
const tx = await pool.swapExactAmountOut(
|
const tx = await pool.swapExactAmountOut(
|
||||||
user2,
|
user1,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
tokenInOutMarket,
|
tokenInOutMarket,
|
||||||
amountsInOutMaxFee
|
amountsInOutMaxFee
|
||||||
@ -308,15 +310,15 @@ describe('SideStaking unit test', () => {
|
|||||||
assert(tx != null)
|
assert(tx != null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#joinswapExternAmountIn- user2 should add liquidity, receiving LP tokens', async () => {
|
it('#joinswapExternAmountIn- user1 should add liquidity, receiving LP tokens', async () => {
|
||||||
const daiAmountIn = '100'
|
const daiAmountIn = '100'
|
||||||
const minBPTOut = '0.1'
|
const minBPTOut = '0.1'
|
||||||
await approve(web3, user2, contracts.daiAddress, poolAddress, '100', true)
|
await approve(web3, user1, contracts.daiAddress, poolAddress, '100', true)
|
||||||
expect(await allowance(web3, contracts.daiAddress, user2, poolAddress)).to.equal(
|
expect(await allowance(web3, contracts.daiAddress, user1, poolAddress)).to.equal(
|
||||||
'100'
|
'100'
|
||||||
)
|
)
|
||||||
const tx = await pool.joinswapExternAmountIn(
|
const tx = await pool.joinswapExternAmountIn(
|
||||||
user2,
|
user1,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
daiAmountIn,
|
daiAmountIn,
|
||||||
minBPTOut
|
minBPTOut
|
||||||
@ -332,12 +334,12 @@ describe('SideStaking unit test', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#exitswapPoolAmountIn- user2 exit the pool receiving only DAI', async () => {
|
it('#exitswapPoolAmountIn- user1 exit the pool receiving only DAI', async () => {
|
||||||
const BPTAmountIn = '0.5'
|
const BPTAmountIn = '0.5'
|
||||||
const minDAIOut = '0.5'
|
const minDAIOut = '0.5'
|
||||||
|
|
||||||
const tx = await pool.exitswapPoolAmountIn(
|
const tx = await pool.exitswapPoolAmountIn(
|
||||||
user2,
|
user1,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
BPTAmountIn,
|
BPTAmountIn,
|
||||||
minDAIOut
|
minDAIOut
|
||||||
@ -370,7 +372,7 @@ describe('SideStaking unit test', () => {
|
|||||||
const ercParams: Erc20CreateParams = {
|
const ercParams: Erc20CreateParams = {
|
||||||
templateIndex: 1,
|
templateIndex: 1,
|
||||||
minter: factoryOwner,
|
minter: factoryOwner,
|
||||||
paymentCollector: user3,
|
paymentCollector: user2,
|
||||||
mpFeeAddress: factoryOwner,
|
mpFeeAddress: factoryOwner,
|
||||||
feeToken: '0x0000000000000000000000000000000000000000',
|
feeToken: '0x0000000000000000000000000000000000000000',
|
||||||
cap: '1000000',
|
cap: '1000000',
|
||||||
@ -411,8 +413,8 @@ describe('SideStaking unit test', () => {
|
|||||||
poolAddress = txReceipt.events.NewPool.returnValues.poolAddress
|
poolAddress = txReceipt.events.NewPool.returnValues.poolAddress
|
||||||
|
|
||||||
erc20Contract = new web3.eth.Contract(ERC20Template.abi as AbiItem[], erc20Token)
|
erc20Contract = new web3.eth.Contract(ERC20Template.abi as AbiItem[], erc20Token)
|
||||||
// user2 has no dt1
|
// user1 has no dt1
|
||||||
expect(await erc20Contract.methods.balanceOf(user2).call()).to.equal('0')
|
expect(await erc20Contract.methods.balanceOf(user1).call()).to.equal('0')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getBaseTokenBalance ', async () => {
|
it('#getBaseTokenBalance ', async () => {
|
||||||
@ -431,6 +433,7 @@ describe('SideStaking unit test', () => {
|
|||||||
'10000'
|
'10000'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getvestingLastBlock ', async () => {
|
it('#getvestingLastBlock ', async () => {
|
||||||
expect(
|
expect(
|
||||||
await sideStaking.getvestingLastBlock(sideStakingAddress, erc20Token)
|
await sideStaking.getvestingLastBlock(sideStakingAddress, erc20Token)
|
||||||
@ -442,6 +445,7 @@ describe('SideStaking unit test', () => {
|
|||||||
await sideStaking.getvestingEndBlock(sideStakingAddress, erc20Token)
|
await sideStaking.getvestingEndBlock(sideStakingAddress, erc20Token)
|
||||||
).to.equal((initialBlock + vestedBlocks).toString())
|
).to.equal((initialBlock + vestedBlocks).toString())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getvestingAmountSoFar ', async () => {
|
it('#getvestingAmountSoFar ', async () => {
|
||||||
expect(
|
expect(
|
||||||
await sideStaking.getvestingAmountSoFar(sideStakingAddress, erc20Token)
|
await sideStaking.getvestingAmountSoFar(sideStakingAddress, erc20Token)
|
||||||
@ -472,10 +476,10 @@ describe('SideStaking unit test', () => {
|
|||||||
it('#swapExactAmountIn - should swap', async () => {
|
it('#swapExactAmountIn - should swap', async () => {
|
||||||
const transferAmount = await amountToUnits(web3, contracts.usdcAddress, '1000') // 1000 USDC
|
const transferAmount = await amountToUnits(web3, contracts.usdcAddress, '1000') // 1000 USDC
|
||||||
await usdcContract.methods
|
await usdcContract.methods
|
||||||
.transfer(user2, transferAmount)
|
.transfer(user1, transferAmount)
|
||||||
.send({ from: factoryOwner })
|
.send({ from: factoryOwner })
|
||||||
|
|
||||||
await approve(web3, user2, contracts.usdcAddress, poolAddress, '10')
|
await approve(web3, user1, contracts.usdcAddress, poolAddress, '10')
|
||||||
const tokenInOutMarket: TokenInOutMarket = {
|
const tokenInOutMarket: TokenInOutMarket = {
|
||||||
tokenIn: contracts.usdcAddress,
|
tokenIn: contracts.usdcAddress,
|
||||||
tokenOut: erc20Token,
|
tokenOut: erc20Token,
|
||||||
@ -487,18 +491,18 @@ describe('SideStaking unit test', () => {
|
|||||||
swapMarketFee: '0.1'
|
swapMarketFee: '0.1'
|
||||||
}
|
}
|
||||||
const tx = await pool.swapExactAmountIn(
|
const tx = await pool.swapExactAmountIn(
|
||||||
user2,
|
user1,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
tokenInOutMarket,
|
tokenInOutMarket,
|
||||||
amountsInOutMaxFee
|
amountsInOutMaxFee
|
||||||
)
|
)
|
||||||
expect(await erc20Contract.methods.balanceOf(user2).call()).to.equal(
|
expect(await erc20Contract.methods.balanceOf(user1).call()).to.equal(
|
||||||
tx.events.LOG_SWAP.returnValues.tokenAmountOut
|
tx.events.LOG_SWAP.returnValues.tokenAmountOut
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#swapExactAmountOut - should swap', async () => {
|
it('#swapExactAmountOut - should swap', async () => {
|
||||||
await approve(web3, user2, contracts.usdcAddress, poolAddress, '100')
|
await approve(web3, user1, contracts.usdcAddress, poolAddress, '100')
|
||||||
const tokenInOutMarket: TokenInOutMarket = {
|
const tokenInOutMarket: TokenInOutMarket = {
|
||||||
tokenIn: contracts.usdcAddress,
|
tokenIn: contracts.usdcAddress,
|
||||||
tokenOut: erc20Token,
|
tokenOut: erc20Token,
|
||||||
@ -510,7 +514,7 @@ describe('SideStaking unit test', () => {
|
|||||||
swapMarketFee: '0.1'
|
swapMarketFee: '0.1'
|
||||||
}
|
}
|
||||||
const tx = await pool.swapExactAmountOut(
|
const tx = await pool.swapExactAmountOut(
|
||||||
user2,
|
user1,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
tokenInOutMarket,
|
tokenInOutMarket,
|
||||||
amountsInOutMaxFee
|
amountsInOutMaxFee
|
||||||
@ -519,13 +523,13 @@ describe('SideStaking unit test', () => {
|
|||||||
// console.log(tx.events)
|
// console.log(tx.events)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#joinswapExternAmountIn- user2 should add liquidity, receiving LP tokens', async () => {
|
it('#joinswapExternAmountIn- user1 should add liquidity, receiving LP tokens', async () => {
|
||||||
const usdcAmountIn = '100'
|
const usdcAmountIn = '100'
|
||||||
const minBPTOut = '0.1'
|
const minBPTOut = '0.1'
|
||||||
await approve(web3, user2, contracts.usdcAddress, poolAddress, '100', true)
|
await approve(web3, user1, contracts.usdcAddress, poolAddress, '100', true)
|
||||||
|
|
||||||
const tx = await pool.joinswapExternAmountIn(
|
const tx = await pool.joinswapExternAmountIn(
|
||||||
user2,
|
user1,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
usdcAmountIn,
|
usdcAmountIn,
|
||||||
minBPTOut
|
minBPTOut
|
||||||
@ -541,12 +545,12 @@ describe('SideStaking unit test', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#exitswapPoolAmountIn- user2 exit the pool receiving only USDC', async () => {
|
it('#exitswapPoolAmountIn- user1 exit the pool receiving only USDC', async () => {
|
||||||
const BPTAmountIn = '0.5'
|
const BPTAmountIn = '0.5'
|
||||||
const minUSDCOut = '0.5'
|
const minUSDCOut = '0.5'
|
||||||
|
|
||||||
const tx = await pool.exitswapPoolAmountIn(
|
const tx = await pool.exitswapPoolAmountIn(
|
||||||
user2,
|
user1,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
BPTAmountIn,
|
BPTAmountIn,
|
||||||
minUSDCOut
|
minUSDCOut
|
||||||
|
Loading…
x
Reference in New Issue
Block a user