mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Fix lint issues.
This commit is contained in:
parent
afa2996768
commit
5af50c4c92
@ -37,7 +37,7 @@ export class OceanPool extends Pool {
|
|||||||
token: string,
|
token: string,
|
||||||
amount: string,
|
amount: string,
|
||||||
weight: string,
|
weight: string,
|
||||||
fee: string,
|
fee: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
if (this.oceanAddress == null) {
|
if (this.oceanAddress == null) {
|
||||||
console.error('oceanAddress is not defined')
|
console.error('oceanAddress is not defined')
|
||||||
@ -66,9 +66,14 @@ export class OceanPool extends Pool {
|
|||||||
)
|
)
|
||||||
|
|
||||||
await super.setup(
|
await super.setup(
|
||||||
account, address,
|
account,
|
||||||
token, this.web3.utils.toWei(String(amount)), this.web3.utils.toWei(String(weight)),
|
address,
|
||||||
this.oceanAddress, this.web3.utils.toWei(String(oceanAmount)), this.web3.utils.toWei(String(oceanWeight)),
|
token,
|
||||||
|
this.web3.utils.toWei(String(amount)),
|
||||||
|
this.web3.utils.toWei(String(weight)),
|
||||||
|
this.oceanAddress,
|
||||||
|
this.web3.utils.toWei(String(oceanAmount)),
|
||||||
|
this.web3.utils.toWei(String(oceanWeight)),
|
||||||
this.web3.utils.toWei(fee)
|
this.web3.utils.toWei(fee)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,20 +35,20 @@ export class Pool extends PoolFactory {
|
|||||||
return await super.createPool(account)
|
return await super.createPool(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup a new pool by setting datatoken, base token, swap fee and
|
* Setup a new pool by setting datatoken, base token, swap fee and
|
||||||
* finalizing the pool to make it public.
|
* finalizing the pool to make it public.
|
||||||
*
|
*
|
||||||
* @param {String} account ethereum address to use for sending this transaction
|
* @param {String} account ethereum address to use for sending this transaction
|
||||||
* @param {String} poolAddress address of new Balancer Pool
|
* @param {String} poolAddress address of new Balancer Pool
|
||||||
* @param {String} dataToken address of datatoken ERC20 contract
|
* @param {String} dataToken address of datatoken ERC20 contract
|
||||||
* @param {String} dataTokenAmount in wei
|
* @param {String} dataTokenAmount in wei
|
||||||
* @param {String} dataTokenWeight in wei
|
* @param {String} dataTokenWeight in wei
|
||||||
* @param {String} baseToken address of base token ERC20 contract
|
* @param {String} baseToken address of base token ERC20 contract
|
||||||
* @param {String} baseTokenAmount in wei
|
* @param {String} baseTokenAmount in wei
|
||||||
* @param {String} baseTokenWeight in wei
|
* @param {String} baseTokenWeight in wei
|
||||||
* @param {String} swapFee in wei
|
* @param {String} swapFee in wei
|
||||||
*/
|
*/
|
||||||
async setup(
|
async setup(
|
||||||
account: string,
|
account: string,
|
||||||
poolAddress: string,
|
poolAddress: string,
|
||||||
@ -58,7 +58,7 @@ export class Pool extends PoolFactory {
|
|||||||
baseToken: string,
|
baseToken: string,
|
||||||
baseTokenAmount: string,
|
baseTokenAmount: string,
|
||||||
baseTokenWeight: string,
|
baseTokenWeight: string,
|
||||||
swapFee: string,
|
swapFee: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||||
from: account
|
from: account
|
||||||
@ -67,15 +67,19 @@ export class Pool extends PoolFactory {
|
|||||||
try {
|
try {
|
||||||
result = await pool.methods
|
result = await pool.methods
|
||||||
.setup(
|
.setup(
|
||||||
dataToken, dataTokenAmount, dataTokenWeight,
|
dataToken,
|
||||||
baseToken, baseTokenAmount, baseTokenWeight,
|
dataTokenAmount,
|
||||||
|
dataTokenWeight,
|
||||||
|
baseToken,
|
||||||
|
baseTokenAmount,
|
||||||
|
baseTokenWeight,
|
||||||
swapFee
|
swapFee
|
||||||
).send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
)
|
||||||
|
.send({ from: account, gas: this.GASLIMIT_DEFAULT })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Pool.setup failed:' + e)
|
console.error('Pool.setup failed:' + e)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,13 +105,15 @@ describe('Balancer flow', () => {
|
|||||||
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 () => {
|
||||||
const ts = 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')
|
||||||
assert(await Pool.totalSupply(alicePoolAddress) == 100)
|
const s = await Pool.totalSupply(alicePoolAddress)
|
||||||
assert(await Pool.getNumTokens(alice, alicePoolAddress) == 2)
|
assert(String(s) === '100', 'totalSupply does not match: ' + s)
|
||||||
|
const n = await Pool.getNumTokens(alice, alicePoolAddress)
|
||||||
|
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user