mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
parent
2b27a0f7e9
commit
77fe186949
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -58,6 +58,8 @@ jobs:
|
|||||||
working-directory: ${{ github.workspace }}/barge
|
working-directory: ${{ github.workspace }}/barge
|
||||||
run: |
|
run: |
|
||||||
bash -x start_ocean.sh --no-aquarius --no-elasticsearch --no-provider --no-dashboard 2>&1 > start_ocean.log &
|
bash -x start_ocean.sh --no-aquarius --no-elasticsearch --no-provider --no-dashboard 2>&1 > start_ocean.log &
|
||||||
|
env:
|
||||||
|
CONTRACTS_VERSION: v1.0.0-alpha.31
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- name: Wait for contracts deployment
|
- name: Wait for contracts deployment
|
||||||
working-directory: ${{ github.workspace }}/barge
|
working-directory: ${{ github.workspace }}/barge
|
||||||
@ -115,6 +117,8 @@ jobs:
|
|||||||
working-directory: ${{ github.workspace }}/barge
|
working-directory: ${{ github.workspace }}/barge
|
||||||
run: |
|
run: |
|
||||||
bash -x start_ocean.sh --with-provider2 --no-dashboard --with-c2d 2>&1 > start_ocean.log &
|
bash -x start_ocean.sh --with-provider2 --no-dashboard --with-c2d 2>&1 > start_ocean.log &
|
||||||
|
env:
|
||||||
|
CONTRACTS_VERSION: v1.0.0-alpha.31
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build:metadata
|
- run: npm run build:metadata
|
||||||
|
|
||||||
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -9,7 +9,7 @@
|
|||||||
"version": "1.0.0-next.37",
|
"version": "1.0.0-next.37",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oceanprotocol/contracts": "1.0.0-alpha.28",
|
"@oceanprotocol/contracts": "^1.0.0-alpha.31",
|
||||||
"bignumber.js": "^9.0.2",
|
"bignumber.js": "^9.0.2",
|
||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
@ -2471,9 +2471,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@oceanprotocol/contracts": {
|
"node_modules/@oceanprotocol/contracts": {
|
||||||
"version": "1.0.0-alpha.28",
|
"version": "1.0.0-alpha.31",
|
||||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.28.tgz",
|
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.31.tgz",
|
||||||
"integrity": "sha512-M/yyKfpWmMRHWPTjvKlrRWUcIbfkRWyHhjHUI1kPggJPPX6ADxApTwtzwVXJ/+WyegcaYc7bqwuclqvg9XPqBQ=="
|
"integrity": "sha512-WqrhjO0Qu8Bxdr2dAkdUL1Q/rHEkTuhx8OT4J/uJltnlxykCo6F8raNQAlhdh+84hm2Bv1irXE+PdpizNLwntQ=="
|
||||||
},
|
},
|
||||||
"node_modules/@octokit/auth-token": {
|
"node_modules/@octokit/auth-token": {
|
||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
@ -18803,9 +18803,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@oceanprotocol/contracts": {
|
"@oceanprotocol/contracts": {
|
||||||
"version": "1.0.0-alpha.28",
|
"version": "1.0.0-alpha.31",
|
||||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.28.tgz",
|
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.31.tgz",
|
||||||
"integrity": "sha512-M/yyKfpWmMRHWPTjvKlrRWUcIbfkRWyHhjHUI1kPggJPPX6ADxApTwtzwVXJ/+WyegcaYc7bqwuclqvg9XPqBQ=="
|
"integrity": "sha512-WqrhjO0Qu8Bxdr2dAkdUL1Q/rHEkTuhx8OT4J/uJltnlxykCo6F8raNQAlhdh+84hm2Bv1irXE+PdpizNLwntQ=="
|
||||||
},
|
},
|
||||||
"@octokit/auth-token": {
|
"@octokit/auth-token": {
|
||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
"web3": "^1.7.3"
|
"web3": "^1.7.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oceanprotocol/contracts": "1.0.0-alpha.28",
|
"@oceanprotocol/contracts": "^1.0.0-alpha.31",
|
||||||
"bignumber.js": "^9.0.2",
|
"bignumber.js": "^9.0.2",
|
||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
|
@ -1077,177 +1077,6 @@ export class Pool {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Estimate gas cost for joinPool method
|
|
||||||
* @param {String} address
|
|
||||||
* @param {String} poolAddress
|
|
||||||
* @param {String} poolAmountOut expected number of pool shares that you will get
|
|
||||||
* @param {String[]} maxAmountsIn array with maxium amounts spent
|
|
||||||
* @param {Contract} contractInstance optional contract instance
|
|
||||||
* @return {Promise<number>}
|
|
||||||
*/
|
|
||||||
public async estJoinPool(
|
|
||||||
address: string,
|
|
||||||
poolAddress: string,
|
|
||||||
poolAmountOut: string,
|
|
||||||
maxAmountsIn: string[],
|
|
||||||
contractInstance?: Contract
|
|
||||||
): Promise<number> {
|
|
||||||
const poolContract =
|
|
||||||
contractInstance ||
|
|
||||||
setContractDefaults(
|
|
||||||
new this.web3.eth.Contract(this.poolAbi as AbiItem[], poolAddress),
|
|
||||||
this.config
|
|
||||||
)
|
|
||||||
|
|
||||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
|
||||||
let estGas
|
|
||||||
try {
|
|
||||||
estGas = await poolContract.methods
|
|
||||||
.joinPool(poolAmountOut, maxAmountsIn)
|
|
||||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
|
||||||
} catch (e) {
|
|
||||||
estGas = gasLimitDefault
|
|
||||||
}
|
|
||||||
return estGas
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds dual side liquidity to the pool (both datatoken and basetoken)
|
|
||||||
* This will pull some of each of the currently trading tokens in the pool,
|
|
||||||
* meaning you must have called approve for each token for this pool.
|
|
||||||
* These values are limited by the array of maxAmountsIn in the order of the pool tokens.
|
|
||||||
* @param {String} address
|
|
||||||
* @param {String} poolAddress
|
|
||||||
* @param {String} poolAmountOut expected number of pool shares that you will get
|
|
||||||
* @param {String[]} maxAmountsIn array with maxium amounts spent
|
|
||||||
* @return {TransactionReceipt}
|
|
||||||
*/
|
|
||||||
async joinPool(
|
|
||||||
address: string,
|
|
||||||
poolAddress: string,
|
|
||||||
poolAmountOut: string,
|
|
||||||
maxAmountsIn: string[]
|
|
||||||
): Promise<TransactionReceipt> {
|
|
||||||
const pool = setContractDefaults(
|
|
||||||
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
|
||||||
this.config
|
|
||||||
)
|
|
||||||
const weiMaxAmountsIn = []
|
|
||||||
const tokens = await this.getFinalTokens(poolAddress)
|
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
|
||||||
const amount = await amountToUnits(this.web3, tokens[i], maxAmountsIn[i])
|
|
||||||
weiMaxAmountsIn.push(amount)
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = null
|
|
||||||
|
|
||||||
const estGas = await this.estJoinPool(
|
|
||||||
address,
|
|
||||||
poolAddress,
|
|
||||||
this.web3.utils.toWei(poolAmountOut),
|
|
||||||
weiMaxAmountsIn
|
|
||||||
)
|
|
||||||
|
|
||||||
try {
|
|
||||||
result = await pool.methods
|
|
||||||
.joinPool(this.web3.utils.toWei(poolAmountOut), weiMaxAmountsIn)
|
|
||||||
.send({
|
|
||||||
from: address,
|
|
||||||
gas: estGas + 1,
|
|
||||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to join pool: ${e.message}`)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Estimate gas cost for exitPool
|
|
||||||
* @param {String} address
|
|
||||||
* @param {String} poolAddress
|
|
||||||
``* @param {String} poolAmountIn amount of pool shares spent
|
|
||||||
* @param {String[]} minAmountsOut aarray with minimum amount of tokens expected
|
|
||||||
* @param {Contract} contractInstance optional contract instance
|
|
||||||
* @return {Promise<number>}
|
|
||||||
*/
|
|
||||||
public async estExitPool(
|
|
||||||
address: string,
|
|
||||||
poolAddress: string,
|
|
||||||
poolAmountIn: string,
|
|
||||||
minAmountsOut: string[],
|
|
||||||
contractInstance?: Contract
|
|
||||||
): Promise<number> {
|
|
||||||
const poolContract =
|
|
||||||
contractInstance ||
|
|
||||||
setContractDefaults(
|
|
||||||
new this.web3.eth.Contract(this.poolAbi as AbiItem[], poolAddress),
|
|
||||||
this.config
|
|
||||||
)
|
|
||||||
|
|
||||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
|
||||||
let estGas
|
|
||||||
try {
|
|
||||||
estGas = await poolContract.methods
|
|
||||||
.exitPool(poolAmountIn, minAmountsOut)
|
|
||||||
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
|
||||||
} catch (e) {
|
|
||||||
estGas = gasLimitDefault
|
|
||||||
}
|
|
||||||
return estGas
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes dual side liquidity from the pool (both datatoken and basetoken)
|
|
||||||
* Exit the pool, paying poolAmountIn pool tokens and getting some of each of the currently trading tokens in return.
|
|
||||||
* These values are limited by the array of minAmountsOut in the order of the pool tokens.
|
|
||||||
* @param {String} account
|
|
||||||
* @param {String} poolAddress
|
|
||||||
* @param {String} poolAmountIn amount of pool shares spent
|
|
||||||
* @param {String[]} minAmountsOut array with minimum amount of tokens expected
|
|
||||||
* @return {TransactionReceipt}
|
|
||||||
*/
|
|
||||||
async exitPool(
|
|
||||||
account: string,
|
|
||||||
poolAddress: string,
|
|
||||||
poolAmountIn: string,
|
|
||||||
minAmountsOut: string[]
|
|
||||||
): Promise<TransactionReceipt> {
|
|
||||||
const pool = setContractDefaults(
|
|
||||||
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
|
||||||
this.config
|
|
||||||
)
|
|
||||||
const weiMinAmountsOut = []
|
|
||||||
const tokens = await this.getFinalTokens(poolAddress)
|
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
|
||||||
const amount = await amountToUnits(this.web3, tokens[i], minAmountsOut[i])
|
|
||||||
weiMinAmountsOut.push(amount)
|
|
||||||
}
|
|
||||||
let result = null
|
|
||||||
const estGas = await this.estExitPool(
|
|
||||||
account,
|
|
||||||
poolAddress,
|
|
||||||
this.web3.utils.toWei(poolAmountIn),
|
|
||||||
weiMinAmountsOut
|
|
||||||
)
|
|
||||||
|
|
||||||
try {
|
|
||||||
result = await pool.methods
|
|
||||||
.exitPool(this.web3.utils.toWei(poolAmountIn), weiMinAmountsOut)
|
|
||||||
.send({
|
|
||||||
from: account,
|
|
||||||
gas: estGas,
|
|
||||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to exit pool: ${e.message}`)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimate gas cost for joinswapExternAmountIn
|
* Estimate gas cost for joinswapExternAmountIn
|
||||||
* @param {String} address
|
* @param {String} address
|
||||||
|
@ -294,21 +294,6 @@ describe('Pool unit test', () => {
|
|||||||
assert(tx != null)
|
assert(tx != null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#joinPool- user2 should add liquidity, receiving LP tokens', async () => {
|
|
||||||
const BPTAmountOut = '0.01'
|
|
||||||
const maxAmountsIn = [
|
|
||||||
'50', // Amounts IN
|
|
||||||
'50' // Amounts IN
|
|
||||||
]
|
|
||||||
|
|
||||||
await approve(web3, user2, erc20Token, poolAddress, '50')
|
|
||||||
await approve(web3, user2, contracts.daiAddress, poolAddress, '50')
|
|
||||||
const tx = await pool.joinPool(user2, poolAddress, BPTAmountOut, maxAmountsIn)
|
|
||||||
assert(tx != null)
|
|
||||||
expect(await pool.sharesBalance(user2, poolAddress)).to.equal(BPTAmountOut)
|
|
||||||
expect(tx.events.LOG_JOIN.event === 'LOG_JOIN')
|
|
||||||
expect(tx.events.LOG_BPT.event === 'LOG_BPT')
|
|
||||||
})
|
|
||||||
it('#joinswapExternAmountIn- user2 should add liquidity, receiving LP tokens', async () => {
|
it('#joinswapExternAmountIn- user2 should add liquidity, receiving LP tokens', async () => {
|
||||||
const daiAmountIn = '100'
|
const daiAmountIn = '100'
|
||||||
const minBPTOut = '0.1'
|
const minBPTOut = '0.1'
|
||||||
@ -333,21 +318,6 @@ describe('Pool unit test', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#exitPool- user2 exit the pool receiving both tokens, burning LP', async () => {
|
|
||||||
const BPTAmountIn = '0.5'
|
|
||||||
const minAmountOut = [
|
|
||||||
'1', // min amount out for OCEAN AND DT
|
|
||||||
'1'
|
|
||||||
]
|
|
||||||
|
|
||||||
const tx = await pool.exitPool(user2, poolAddress, BPTAmountIn, minAmountOut)
|
|
||||||
|
|
||||||
assert(tx != null)
|
|
||||||
|
|
||||||
expect(tx.events.LOG_EXIT[0].returnValues.tokenOut).to.equal(erc20Token)
|
|
||||||
expect(tx.events.LOG_EXIT[1].returnValues.tokenOut).to.equal(contracts.daiAddress)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('#exitswapPoolAmountIn- user2 exit the pool receiving only DAI', async () => {
|
it('#exitswapPoolAmountIn- user2 exit the pool receiving only DAI', async () => {
|
||||||
const BPTAmountIn = '0.5'
|
const BPTAmountIn = '0.5'
|
||||||
const minDAIOut = '0.5'
|
const minDAIOut = '0.5'
|
||||||
@ -826,25 +796,6 @@ describe('Pool unit test', () => {
|
|||||||
// console.log(tx.events)
|
// console.log(tx.events)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#joinPool- user2 should add liquidity, receiving LP tokens', async () => {
|
|
||||||
const BPTAmountOut = '0.01'
|
|
||||||
const maxAmountsIn = [
|
|
||||||
'50', // Amounts IN
|
|
||||||
'50' // Amounts IN
|
|
||||||
]
|
|
||||||
|
|
||||||
await approve(web3, user2, erc20Token, poolAddress, '50')
|
|
||||||
await approve(web3, user2, contracts.usdcAddress, poolAddress, '50')
|
|
||||||
const tx = await pool.joinPool(user2, poolAddress, BPTAmountOut, maxAmountsIn)
|
|
||||||
assert(tx != null)
|
|
||||||
expect(await pool.sharesBalance(user2, poolAddress)).to.equal(BPTAmountOut)
|
|
||||||
expect(tx.events.LOG_JOIN.event === 'LOG_JOIN')
|
|
||||||
expect(tx.events.LOG_BPT.event === 'LOG_BPT')
|
|
||||||
|
|
||||||
// console.log(tx)
|
|
||||||
// console.log(tx.events.LOG_JOIN)
|
|
||||||
// console.log(tx.events.LOG_BPT)
|
|
||||||
})
|
|
||||||
it('#joinswapExternAmountIn- user2 should add liquidity, receiving LP tokens', async () => {
|
it('#joinswapExternAmountIn- user2 should add liquidity, receiving LP tokens', async () => {
|
||||||
const usdcAmountIn = '100'
|
const usdcAmountIn = '100'
|
||||||
const minBPTOut = '0.1'
|
const minBPTOut = '0.1'
|
||||||
@ -867,21 +818,6 @@ describe('Pool unit test', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#exitPool- user2 exit the pool receiving both tokens, burning LP', async () => {
|
|
||||||
const BPTAmountIn = '0.5'
|
|
||||||
const minAmountOut = [
|
|
||||||
'1', // min amount out for USDC AND DT
|
|
||||||
'1'
|
|
||||||
]
|
|
||||||
|
|
||||||
const tx = await pool.exitPool(user2, poolAddress, BPTAmountIn, minAmountOut)
|
|
||||||
|
|
||||||
assert(tx != null)
|
|
||||||
|
|
||||||
expect(tx.events.LOG_EXIT[0].returnValues.tokenOut).to.equal(erc20Token)
|
|
||||||
expect(tx.events.LOG_EXIT[1].returnValues.tokenOut).to.equal(contracts.usdcAddress)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('#exitswapPoolAmountIn- user2 exit the pool receiving only USDC', async () => {
|
it('#exitswapPoolAmountIn- user2 exit the pool receiving only USDC', async () => {
|
||||||
const BPTAmountIn = '0.5'
|
const BPTAmountIn = '0.5'
|
||||||
const minUSDCOut = '0.5'
|
const minUSDCOut = '0.5'
|
||||||
|
@ -219,7 +219,7 @@ describe('SideStaking unit test', () => {
|
|||||||
|
|
||||||
it('#getvestingAmount ', async () => {
|
it('#getvestingAmount ', async () => {
|
||||||
expect(await sideStaking.getvestingAmount(sideStakingAddress, erc20Token)).to.equal(
|
expect(await sideStaking.getvestingAmount(sideStakingAddress, erc20Token)).to.equal(
|
||||||
'10000'
|
'0'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
it('#getvestingLastBlock ', async () => {
|
it('#getvestingLastBlock ', async () => {
|
||||||
@ -228,38 +228,12 @@ describe('SideStaking unit test', () => {
|
|||||||
).to.equal(initialBlock.toString())
|
).to.equal(initialBlock.toString())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getvestingEndBlock ', async () => {
|
|
||||||
expect(
|
|
||||||
await sideStaking.getvestingEndBlock(sideStakingAddress, erc20Token)
|
|
||||||
).to.equal((initialBlock + vestedBlocks).toString())
|
|
||||||
})
|
|
||||||
it('#getvestingAmountSoFar ', async () => {
|
it('#getvestingAmountSoFar ', async () => {
|
||||||
expect(
|
expect(
|
||||||
await sideStaking.getvestingAmountSoFar(sideStakingAddress, erc20Token)
|
await sideStaking.getvestingAmountSoFar(sideStakingAddress, erc20Token)
|
||||||
).to.equal('0')
|
).to.equal('0')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getVesting ', async () => {
|
|
||||||
expect(await erc20Contract.methods.balanceOf(factoryOwner).call()).to.equal('0')
|
|
||||||
|
|
||||||
const tx = await sideStaking.getVesting(
|
|
||||||
factoryOwner,
|
|
||||||
sideStakingAddress,
|
|
||||||
erc20Token
|
|
||||||
)
|
|
||||||
const collector = await erc20Contract.methods.getPaymentCollector().call()
|
|
||||||
expect(
|
|
||||||
await sideStaking.unitsToAmount(
|
|
||||||
erc20Token,
|
|
||||||
await erc20Contract.methods.balanceOf(collector).call()
|
|
||||||
)
|
|
||||||
).to.equal(await sideStaking.getvestingAmountSoFar(sideStakingAddress, erc20Token))
|
|
||||||
|
|
||||||
expect(
|
|
||||||
await sideStaking.getvestingLastBlock(sideStakingAddress, erc20Token)
|
|
||||||
).to.equal((await web3.eth.getBlockNumber()).toString())
|
|
||||||
})
|
|
||||||
|
|
||||||
it('#swapExactAmountIn - should swap', async () => {
|
it('#swapExactAmountIn - should swap', async () => {
|
||||||
await daiContract.methods
|
await daiContract.methods
|
||||||
.transfer(user2, web3.utils.toWei('1000'))
|
.transfer(user2, web3.utils.toWei('1000'))
|
||||||
@ -428,7 +402,7 @@ describe('SideStaking unit test', () => {
|
|||||||
|
|
||||||
it('#getvestingAmount ', async () => {
|
it('#getvestingAmount ', async () => {
|
||||||
expect(await sideStaking.getvestingAmount(sideStakingAddress, erc20Token)).to.equal(
|
expect(await sideStaking.getvestingAmount(sideStakingAddress, erc20Token)).to.equal(
|
||||||
'10000'
|
'0'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
it('#getvestingLastBlock ', async () => {
|
it('#getvestingLastBlock ', async () => {
|
||||||
@ -437,38 +411,12 @@ describe('SideStaking unit test', () => {
|
|||||||
).to.equal(initialBlock.toString())
|
).to.equal(initialBlock.toString())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getvestingEndBlock ', async () => {
|
|
||||||
expect(
|
|
||||||
await sideStaking.getvestingEndBlock(sideStakingAddress, erc20Token)
|
|
||||||
).to.equal((initialBlock + vestedBlocks).toString())
|
|
||||||
})
|
|
||||||
it('#getvestingAmountSoFar ', async () => {
|
it('#getvestingAmountSoFar ', async () => {
|
||||||
expect(
|
expect(
|
||||||
await sideStaking.getvestingAmountSoFar(sideStakingAddress, erc20Token)
|
await sideStaking.getvestingAmountSoFar(sideStakingAddress, erc20Token)
|
||||||
).to.equal('0')
|
).to.equal('0')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getVesting ', async () => {
|
|
||||||
expect(await erc20Contract.methods.balanceOf(factoryOwner).call()).to.equal('0')
|
|
||||||
|
|
||||||
const tx = await sideStaking.getVesting(
|
|
||||||
factoryOwner,
|
|
||||||
sideStakingAddress,
|
|
||||||
erc20Token
|
|
||||||
)
|
|
||||||
const collector = await erc20Contract.methods.getPaymentCollector().call()
|
|
||||||
expect(
|
|
||||||
await sideStaking.unitsToAmount(
|
|
||||||
erc20Token,
|
|
||||||
await erc20Contract.methods.balanceOf(collector).call()
|
|
||||||
)
|
|
||||||
).to.equal(await sideStaking.getvestingAmountSoFar(sideStakingAddress, erc20Token))
|
|
||||||
|
|
||||||
expect(
|
|
||||||
await sideStaking.getvestingLastBlock(sideStakingAddress, erc20Token)
|
|
||||||
).to.equal((await web3.eth.getBlockNumber()).toString())
|
|
||||||
})
|
|
||||||
|
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user