mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge pull request #323 from oceanprotocol/feature/contracts_050
Feature/contracts 0.5.0 & account removed where possible
This commit is contained in:
commit
42cb8e358b
@ -23,6 +23,7 @@ before_script:
|
||||
- export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
||||
- export AQUARIUS_URI="http://172.15.0.5:5000"
|
||||
- export DEPLOY_CONTRACTS=true
|
||||
- export CONTRACTS_VERSION=v0.5.0
|
||||
- bash -x start_ocean.sh --no-dashboard 2>&1 > start_ocean.log &
|
||||
- cd ..
|
||||
- ./scripts/waitforcontracts.sh
|
||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -939,9 +939,9 @@
|
||||
}
|
||||
},
|
||||
"@oceanprotocol/contracts": {
|
||||
"version": "0.4.4",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.4.4.tgz",
|
||||
"integrity": "sha512-0+Tp6UdoDTBJZp4yX3kkSrV+CcOS/hJ3SJ4HuWiL5FE5Nlj3JCeV86iuWPkFuXzIdgri00DaGvQhP58knzJ2Uw=="
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.5.0.tgz",
|
||||
"integrity": "sha512-6HQVP/Dvbh5b+wdu0rBR78pDwH4I+KeVaK80U5q47R/CvuSin5VpGSii3ZiCLY+O6JRxzjAMzCYo9ugL1cXvbg=="
|
||||
},
|
||||
"@octokit/auth-token": {
|
||||
"version": "2.4.2",
|
||||
|
@ -42,7 +42,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ethereum-navigator/navigator": "^0.5.0",
|
||||
"@oceanprotocol/contracts": "^0.4.4",
|
||||
"@oceanprotocol/contracts": "^0.5.0",
|
||||
"decimal.js": "^10.2.0",
|
||||
"fs": "0.0.1-security",
|
||||
"lzma": "^2.3.2",
|
||||
|
@ -118,27 +118,25 @@ export class OceanPool extends Pool {
|
||||
|
||||
/**
|
||||
* Get Ocean Token balance of a pool
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @return {String}
|
||||
*/
|
||||
public async getOceanReserve(account: string, poolAddress: string): Promise<string> {
|
||||
public async getOceanReserve(poolAddress: string): Promise<string> {
|
||||
if (this.oceanAddress == null) {
|
||||
console.error('oceanAddress is not defined')
|
||||
return null
|
||||
}
|
||||
return super.getReserve(account, poolAddress, this.oceanAddress)
|
||||
return super.getReserve(poolAddress, this.oceanAddress)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Data Token balance of a pool
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @return {String}
|
||||
*/
|
||||
public async getDTReserve(account: string, poolAddress: string): Promise<string> {
|
||||
public async getDTReserve(poolAddress: string): Promise<string> {
|
||||
await this.getDTAddress(poolAddress)
|
||||
return super.getReserve(account, poolAddress, this.dtAddress)
|
||||
return super.getReserve(poolAddress, this.dtAddress)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -328,29 +326,25 @@ export class OceanPool extends Pool {
|
||||
|
||||
/**
|
||||
* Get Data Token price from pool
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @return {String}
|
||||
*/
|
||||
public async getDTPrice(account: string, poolAddress: string): Promise<string> {
|
||||
public async getDTPrice(poolAddress: string): Promise<string> {
|
||||
if (this.oceanAddress == null) {
|
||||
console.error('oceanAddress is not defined')
|
||||
return null
|
||||
}
|
||||
return this.getOceanNeeded(account, poolAddress, '1')
|
||||
return this.getOceanNeeded(poolAddress, '1')
|
||||
}
|
||||
|
||||
/**
|
||||
* Search all pools that have Data Token in their composition
|
||||
* @param {String} account
|
||||
* @param {String} dtAddress
|
||||
* @return {String[]}
|
||||
*/
|
||||
public async searchPoolforDT(account: string, dtAddress: string): Promise<string[]> {
|
||||
public async searchPoolforDT(dtAddress: string): Promise<string[]> {
|
||||
const result: string[] = []
|
||||
const factory = new this.web3.eth.Contract(this.factoryABI, this.factoryAddress, {
|
||||
from: account
|
||||
})
|
||||
const factory = new this.web3.eth.Contract(this.factoryABI, this.factoryAddress)
|
||||
const events = await factory.getPastEvents('BPoolRegistered', {
|
||||
filter: {},
|
||||
fromBlock: 0,
|
||||
@ -363,25 +357,13 @@ export class OceanPool extends Pool {
|
||||
return result
|
||||
}
|
||||
|
||||
public async getOceanNeeded(
|
||||
account: string,
|
||||
poolAddress: string,
|
||||
dtRequired: string
|
||||
): Promise<string> {
|
||||
public async getOceanNeeded(poolAddress: string, dtRequired: string): Promise<string> {
|
||||
await this.getDTAddress(poolAddress)
|
||||
const tokenBalanceIn = await this.getReserve(account, poolAddress, this.oceanAddress)
|
||||
const tokenWeightIn = await this.getDenormalizedWeight(
|
||||
account,
|
||||
poolAddress,
|
||||
this.oceanAddress
|
||||
)
|
||||
const tokenBalanceOut = await this.getReserve(account, poolAddress, this.dtAddress)
|
||||
const tokenWeightOut = await this.getDenormalizedWeight(
|
||||
account,
|
||||
poolAddress,
|
||||
this.dtAddress
|
||||
)
|
||||
const swapFee = await this.getSwapFee(account, poolAddress)
|
||||
const tokenBalanceIn = await this.getReserve(poolAddress, this.oceanAddress)
|
||||
const tokenWeightIn = await this.getDenormalizedWeight(poolAddress, this.oceanAddress)
|
||||
const tokenBalanceOut = await this.getReserve(poolAddress, this.dtAddress)
|
||||
const tokenWeightOut = await this.getDenormalizedWeight(poolAddress, this.dtAddress)
|
||||
const swapFee = await this.getSwapFee(poolAddress)
|
||||
return super.calcInGivenOut(
|
||||
tokenBalanceIn,
|
||||
tokenWeightIn,
|
||||
@ -428,7 +410,7 @@ export class OceanPool extends Pool {
|
||||
/**
|
||||
* Get all actions from a pool (join,exit,swap)
|
||||
* @param {String} poolAddress Pool address
|
||||
* @param {String} account
|
||||
* @param {String} account Optional, filter for this address
|
||||
* @return {PoolTransaction[]}
|
||||
*/
|
||||
public async getPoolLogs(
|
||||
|
@ -256,14 +256,11 @@ export class Pool extends PoolFactory {
|
||||
|
||||
/**
|
||||
* Get number of tokens composing this pool
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @return {String}
|
||||
*/
|
||||
async getNumTokens(account: string, poolAddress: string): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||
from: account
|
||||
})
|
||||
async getNumTokens(poolAddress: string): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||
let result = null
|
||||
try {
|
||||
result = await pool.methods.getNumTokens().call()
|
||||
@ -307,14 +304,11 @@ export class Pool extends PoolFactory {
|
||||
|
||||
/**
|
||||
* Get controller address of this pool
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @return {String}
|
||||
*/
|
||||
async getController(account: string, poolAddress: string): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||
from: account
|
||||
})
|
||||
async getController(poolAddress: string): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||
let result = null
|
||||
try {
|
||||
result = await pool.methods.getController().call()
|
||||
@ -352,15 +346,12 @@ export class Pool extends PoolFactory {
|
||||
|
||||
/**
|
||||
* Get if a token is bounded to a pool
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @param {String} token Address of the token
|
||||
* @return {Boolean}
|
||||
*/
|
||||
async isBound(account: string, poolAddress: string, token: string): Promise<boolean> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||
from: account
|
||||
})
|
||||
async isBound(poolAddress: string, token: string): Promise<boolean> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||
let result = null
|
||||
try {
|
||||
result = await pool.methods.isBound(token).call()
|
||||
@ -372,15 +363,12 @@ export class Pool extends PoolFactory {
|
||||
|
||||
/**
|
||||
* Get how many tokens are in the pool
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @param {String} token Address of the token
|
||||
* @return {String}
|
||||
*/
|
||||
async getReserve(account: string, poolAddress: string, token: string): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||
from: account
|
||||
})
|
||||
async getReserve(poolAddress: string, token: string): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||
let amount = null
|
||||
try {
|
||||
const result = await pool.methods.getBalance(token).call()
|
||||
@ -393,14 +381,11 @@ export class Pool extends PoolFactory {
|
||||
|
||||
/**
|
||||
* Get if a pool is finalized
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @return {Boolean}
|
||||
*/
|
||||
async isFinalized(account: string, poolAddress: string): Promise<boolean> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||
from: account
|
||||
})
|
||||
async isFinalized(poolAddress: string): Promise<boolean> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||
let result = null
|
||||
try {
|
||||
result = await pool.methods.isFinalized().call()
|
||||
@ -412,14 +397,11 @@ export class Pool extends PoolFactory {
|
||||
|
||||
/**
|
||||
* Get pool fee
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @return {String} Swap fee in wei
|
||||
*/
|
||||
async getSwapFee(account: string, poolAddress: string): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||
from: account
|
||||
})
|
||||
async getSwapFee(poolAddress: string): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||
let fee = null
|
||||
try {
|
||||
const result = await pool.methods.getSwapFee().call()
|
||||
@ -432,19 +414,12 @@ export class Pool extends PoolFactory {
|
||||
|
||||
/**
|
||||
* The normalized weight of a token. The combined normalized weights of all tokens will sum up to 1. (Note: the actual sum may be 1 plus or minus a few wei due to division precision loss)
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @param {String} token
|
||||
* @return {String}
|
||||
*/
|
||||
async getNormalizedWeight(
|
||||
account: string,
|
||||
poolAddress: string,
|
||||
token: string
|
||||
): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||
from: account
|
||||
})
|
||||
async getNormalizedWeight(poolAddress: string, token: string): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||
let weight = null
|
||||
try {
|
||||
const result = await pool.methods.getNormalizedWeight(token).call()
|
||||
@ -457,19 +432,12 @@ export class Pool extends PoolFactory {
|
||||
|
||||
/**
|
||||
* getDenormalizedWeight of a token in pool
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @param {String} token
|
||||
* @return {String}
|
||||
*/
|
||||
async getDenormalizedWeight(
|
||||
account: string,
|
||||
poolAddress: string,
|
||||
token: string
|
||||
): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||
from: account
|
||||
})
|
||||
async getDenormalizedWeight(poolAddress: string, token: string): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||
let weight = null
|
||||
try {
|
||||
const result = await pool.methods.getDenormalizedWeight(token).call()
|
||||
@ -482,17 +450,11 @@ export class Pool extends PoolFactory {
|
||||
|
||||
/**
|
||||
* getTotalDenormalizedWeight in pool
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @return {String}
|
||||
*/
|
||||
async getTotalDenormalizedWeight(
|
||||
account: string,
|
||||
poolAddress: string
|
||||
): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||
from: account
|
||||
})
|
||||
async getTotalDenormalizedWeight(poolAddress: string): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||
let weight = null
|
||||
try {
|
||||
const result = await pool.methods.getTotalDenormalizedWeight().call()
|
||||
@ -792,21 +754,17 @@ export class Pool extends PoolFactory {
|
||||
|
||||
/**
|
||||
* Get Spot Price of swaping tokenIn to tokenOut
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @param {String} tokenIn
|
||||
* @param {String} tokenOut
|
||||
* @return {String}
|
||||
*/
|
||||
async getSpotPrice(
|
||||
account: string,
|
||||
poolAddress: string,
|
||||
tokenIn: string,
|
||||
tokenOut: string
|
||||
): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||
from: account
|
||||
})
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||
let price = null
|
||||
try {
|
||||
const result = await pool.methods.getSpotPrice(tokenIn, tokenOut).call()
|
||||
@ -819,21 +777,17 @@ export class Pool extends PoolFactory {
|
||||
|
||||
/**
|
||||
* Get Spot Price of swaping tokenIn to tokenOut without fees
|
||||
* @param {String} account
|
||||
* @param {String} poolAddress
|
||||
* @param {String} tokenIn
|
||||
* @param {String} tokenOut
|
||||
* @return {String}
|
||||
*/
|
||||
async getSpotPriceSansFee(
|
||||
account: string,
|
||||
poolAddress: string,
|
||||
tokenIn: string,
|
||||
tokenOut: string
|
||||
): Promise<string> {
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, {
|
||||
from: account
|
||||
})
|
||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||
let price = null
|
||||
try {
|
||||
const result = await pool.methods.getSpotPriceSansFee(tokenIn, tokenOut).call()
|
||||
|
@ -287,52 +287,40 @@ export class DataTokens {
|
||||
|
||||
/** Get Blob
|
||||
* @param {String} dataTokenAddress
|
||||
* @param {String} address
|
||||
* @return {Promise<string>} string
|
||||
*/
|
||||
public async getBlob(dataTokenAddress: string, address: string): Promise<string> {
|
||||
const datatoken = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress, {
|
||||
from: address
|
||||
})
|
||||
public async getBlob(dataTokenAddress: string): Promise<string> {
|
||||
const datatoken = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress)
|
||||
const trxReceipt = await datatoken.methods.blob().call()
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/** Get Name
|
||||
* @param {String} dataTokenAddress
|
||||
* @param {String} address
|
||||
* @return {Promise<string>} string
|
||||
*/
|
||||
public async getName(dataTokenAddress: string, address: string): Promise<string> {
|
||||
const datatoken = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress, {
|
||||
from: address
|
||||
})
|
||||
public async getName(dataTokenAddress: string): Promise<string> {
|
||||
const datatoken = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress)
|
||||
const trxReceipt = await datatoken.methods.name().call()
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/** Get Symbol
|
||||
* @param {String} dataTokenAddress
|
||||
* @param {String} address
|
||||
* @return {Promise<string>} string
|
||||
*/
|
||||
public async getSymbol(dataTokenAddress: string, address: string): Promise<string> {
|
||||
const datatoken = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress, {
|
||||
from: address
|
||||
})
|
||||
public async getSymbol(dataTokenAddress: string): Promise<string> {
|
||||
const datatoken = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress)
|
||||
const trxReceipt = await datatoken.methods.symbol().call()
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/** Get Cap
|
||||
* @param {String} dataTokenAddress
|
||||
* @param {String} address
|
||||
* @return {Promise<string>} string
|
||||
*/
|
||||
public async getCap(dataTokenAddress: string, address: string): Promise<string> {
|
||||
const datatoken = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress, {
|
||||
from: address
|
||||
})
|
||||
public async getCap(dataTokenAddress: string): Promise<string> {
|
||||
const datatoken = new this.web3.eth.Contract(this.datatokensABI, dataTokenAddress)
|
||||
const trxReceipt = await datatoken.methods.cap().call()
|
||||
return this.web3.utils.fromWei(trxReceipt)
|
||||
}
|
||||
|
@ -205,10 +205,13 @@ export class OceanFixedRateExchange {
|
||||
exchangeId: string,
|
||||
address: string
|
||||
): Promise<TransactionReceipt> {
|
||||
const exchange = await this.getExchange(exchangeId)
|
||||
if (!exchange) return null
|
||||
if (exchange.active === true) return null
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.contract.methods
|
||||
.activate(exchangeId)
|
||||
.toggleExchangeState(exchangeId)
|
||||
.estimateGas(function (err, estGas) {
|
||||
if (err) {
|
||||
// console.log('FixedPriceExchange: ' + err)
|
||||
@ -219,7 +222,7 @@ export class OceanFixedRateExchange {
|
||||
} catch (e) {
|
||||
estGas = DEFAULT_GAS_LIMIT
|
||||
}
|
||||
const trxReceipt = await this.contract.methods.activate(exchangeId).send({
|
||||
const trxReceipt = await this.contract.methods.toggleExchangeState(exchangeId).send({
|
||||
from: address,
|
||||
gas: estGas + 1
|
||||
})
|
||||
@ -236,10 +239,13 @@ export class OceanFixedRateExchange {
|
||||
exchangeId: string,
|
||||
address: string
|
||||
): Promise<TransactionReceipt> {
|
||||
const exchange = await this.getExchange(exchangeId)
|
||||
if (!exchange) return null
|
||||
if (exchange.active === false) return null
|
||||
let estGas
|
||||
try {
|
||||
estGas = await this.contract.methods
|
||||
.deactivate(exchangeId)
|
||||
.toggleExchangeState(exchangeId)
|
||||
.estimateGas(function (err, estGas) {
|
||||
if (err) {
|
||||
// console.log('FixedPriceExchange: ' + err)
|
||||
@ -250,7 +256,7 @@ export class OceanFixedRateExchange {
|
||||
} catch (e) {
|
||||
estGas = DEFAULT_GAS_LIMIT
|
||||
}
|
||||
const trxReceipt = await this.contract.methods.deactivate(exchangeId).send({
|
||||
const trxReceipt = await this.contract.methods.toggleExchangeState(exchangeId).send({
|
||||
from: address,
|
||||
gas: estGas + 1
|
||||
})
|
||||
|
@ -32,13 +32,13 @@ const configs: ConfigHelperConfig[] = [
|
||||
chainId: 4,
|
||||
network: 'rinkeby',
|
||||
nodeUri: 'https://rinkeby.infura.io/v3',
|
||||
factoryAddress: '0x732cad3502e2A543118C8047D6bb20D5DB9c3242',
|
||||
factoryAddress: '0xA7a711A09396DF82D9be46A26B48BafdB9BB4fA6',
|
||||
oceanTokenAddress: '0x8967BCF84170c91B0d24D4302C2376283b0B3a07',
|
||||
metadataStoreUri: 'https://aquarius.rinkeby.v3.dev-ocean.com',
|
||||
providerUri: 'https://provider.rinkeby.v3.dev-ocean.com',
|
||||
poolFactoryAddress: '0x1735C3A59EcedC617bB570b79A71A6FC7C0380E8',
|
||||
fixedRateExchangeAddress: '0x2B8da1F6DE33EfCDEc254ebE57d1D854a314b81b',
|
||||
metadataContractAddress: '0x01906293EAd697f6038b0E3E1f0591F56ABf8EC0'
|
||||
poolFactoryAddress: '0x4658cD157B57E9D0053Bb2d5CbC7B2Aad06dA5E6',
|
||||
fixedRateExchangeAddress: '0x09285F0290D74f01D3287ED9B45d2456956758B4',
|
||||
metadataContractAddress: '0x1da8E04D2ae9b7c32C24e4DB94899b93d8E4751A'
|
||||
},
|
||||
{
|
||||
chainId: 1,
|
||||
|
@ -52,8 +52,8 @@ describe('DataTokens', () => {
|
||||
tokenAddress = await datatoken.create(blob, minter)
|
||||
assert(tokenAddress !== null)
|
||||
|
||||
const tokenName = await datatoken.getName(tokenAddress, minter)
|
||||
const tokenSymbol = await datatoken.getSymbol(tokenAddress, minter)
|
||||
const tokenName = await datatoken.getName(tokenAddress)
|
||||
const tokenSymbol = await datatoken.getSymbol(tokenAddress)
|
||||
assert(tokenName !== null || tokenName !== '')
|
||||
assert(tokenSymbol !== null || tokenSymbol !== '')
|
||||
})
|
||||
|
@ -118,7 +118,7 @@ describe('Balancer flow', () => {
|
||||
alicePoolAddress = await Pool.createDTPool(alice, tokenAddress, '45', '9', '0.02')
|
||||
const s = await Pool.totalSupply(alicePoolAddress)
|
||||
assert(String(s) === '100', 'totalSupply does not match: ' + s)
|
||||
const n = await Pool.getNumTokens(alice, alicePoolAddress)
|
||||
const n = await Pool.getNumTokens(alicePoolAddress)
|
||||
assert(String(n) === '2', 'unexpected num tokens: ' + n)
|
||||
})
|
||||
it('Get pool information', async () => {
|
||||
@ -129,13 +129,12 @@ describe('Balancer flow', () => {
|
||||
})
|
||||
|
||||
it('Get pool swap fee', async () => {
|
||||
const currentSwapFee = await Pool.getSwapFee(alice, alicePoolAddress)
|
||||
const currentSwapFee = await Pool.getSwapFee(alicePoolAddress)
|
||||
assert(currentSwapFee === '0.02')
|
||||
})
|
||||
|
||||
it('Get spot price for swapping', async () => {
|
||||
const spotPrice = await Pool.getSpotPrice(
|
||||
alice,
|
||||
alicePoolAddress,
|
||||
tokenAddress,
|
||||
oceanTokenAddress
|
||||
@ -145,7 +144,6 @@ describe('Balancer flow', () => {
|
||||
|
||||
it('Get spot price for swapping without fees', async () => {
|
||||
const spotPrice = await Pool.getSpotPriceSansFee(
|
||||
alice,
|
||||
alicePoolAddress,
|
||||
tokenAddress,
|
||||
oceanTokenAddress
|
||||
@ -154,15 +152,15 @@ describe('Balancer flow', () => {
|
||||
})
|
||||
|
||||
it('Get dtPrice from the pool ', async () => {
|
||||
currentDtPrice = await Pool.getDTPrice(alice, alicePoolAddress)
|
||||
currentDtPrice = await Pool.getDTPrice(alicePoolAddress)
|
||||
assert(Number(currentDtPrice) > 0)
|
||||
})
|
||||
it('Get dtToken pool reserve ', async () => {
|
||||
const currentDtReserve = await Pool.getDTReserve(alice, alicePoolAddress)
|
||||
const currentDtReserve = await Pool.getDTReserve(alicePoolAddress)
|
||||
assert(Number(currentDtReserve) > 0)
|
||||
})
|
||||
it('Get Ocean pool reserve ', async () => {
|
||||
const currentOceanReserve = await Pool.getOceanReserve(alice, alicePoolAddress)
|
||||
const currentOceanReserve = await Pool.getOceanReserve(alicePoolAddress)
|
||||
assert(Number(currentOceanReserve) > 0)
|
||||
})
|
||||
it('Get total supply of pool tokens', async () => {
|
||||
@ -170,12 +168,12 @@ describe('Balancer flow', () => {
|
||||
assert(Number(totalSupply) > 0)
|
||||
})
|
||||
it('Get amount of Ocean needed to buy 1 dtToken', async () => {
|
||||
const requiredOcean = await Pool.getOceanNeeded(alice, alicePoolAddress, '1')
|
||||
const requiredOcean = await Pool.getOceanNeeded(alicePoolAddress, '1')
|
||||
assert(Number(requiredOcean) > 0)
|
||||
})
|
||||
|
||||
it('Bob should search for pools with this DT', async () => {
|
||||
const pools = await Pool.searchPoolforDT(bob, tokenAddress)
|
||||
const pools = await Pool.searchPoolforDT(tokenAddress)
|
||||
assert(pools.length > 0)
|
||||
greatPool = pools[0]
|
||||
})
|
||||
@ -188,7 +186,7 @@ describe('Balancer flow', () => {
|
||||
assert(Number(bobOceanBalance) > 0)
|
||||
})
|
||||
it('Bob should add DT liquidity to pool ', async () => {
|
||||
const currentDtReserve = await Pool.getDTReserve(bob, greatPool)
|
||||
const currentDtReserve = await Pool.getDTReserve(greatPool)
|
||||
if (consoleDebug) console.log('currentDtReserve:' + currentDtReserve)
|
||||
const bobDtBalance = await datatoken.balance(tokenAddress, bob)
|
||||
if (consoleDebug) console.log('BOB DT Balance:' + bobDtBalance)
|
||||
@ -196,7 +194,7 @@ describe('Balancer flow', () => {
|
||||
|
||||
const newbobDtBalance = await datatoken.balance(tokenAddress, bob)
|
||||
|
||||
const newDtReserve = await Pool.getDTReserve(bob, greatPool)
|
||||
const newDtReserve = await Pool.getDTReserve(greatPool)
|
||||
|
||||
const sharesBalance = await Pool.sharesBalance(bob, greatPool)
|
||||
if (consoleDebug) console.log('newDtReserve:' + newDtReserve)
|
||||
@ -208,7 +206,7 @@ describe('Balancer flow', () => {
|
||||
})
|
||||
|
||||
it('Bob should remove DT liquidity from pool ', async () => {
|
||||
const currentDtReserve = await Pool.getDTReserve(bob, greatPool)
|
||||
const currentDtReserve = await Pool.getDTReserve(greatPool)
|
||||
if (consoleDebug) console.log('currentDtReserve:' + currentDtReserve)
|
||||
const bobDtBalance = await datatoken.balance(tokenAddress, bob)
|
||||
if (consoleDebug) console.log('bobDtBalance:' + bobDtBalance)
|
||||
@ -216,7 +214,7 @@ describe('Balancer flow', () => {
|
||||
if (consoleDebug) console.log('poolShares:' + poolShares)
|
||||
await Pool.removeDTLiquidity(bob, greatPool, '0.75', poolShares)
|
||||
|
||||
const newDtReserve = await Pool.getDTReserve(bob, greatPool)
|
||||
const newDtReserve = await Pool.getDTReserve(greatPool)
|
||||
if (consoleDebug) console.log('newDtReserve:' + newDtReserve)
|
||||
const newbobDtBalance = await datatoken.balance(tokenAddress, bob)
|
||||
if (consoleDebug) console.log('newbobDtBalance:' + newbobDtBalance)
|
||||
@ -228,7 +226,7 @@ describe('Balancer flow', () => {
|
||||
})
|
||||
|
||||
it('Bob should add Ocean liquidity to pool ', async () => {
|
||||
const currentDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
||||
const currentDtReserve = await Pool.getOceanReserve(greatPool)
|
||||
const bobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
||||
if (consoleDebug) console.log('currentDtReserve:' + currentDtReserve)
|
||||
if (consoleDebug) console.log('bobDtBalance:' + bobDtBalance)
|
||||
@ -237,7 +235,7 @@ describe('Balancer flow', () => {
|
||||
|
||||
const newbobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
||||
|
||||
const newDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
||||
const newDtReserve = await Pool.getOceanReserve(greatPool)
|
||||
|
||||
const sharesBalance = await Pool.sharesBalance(bob, greatPool)
|
||||
if (consoleDebug) console.log('newDtReserve:' + newDtReserve)
|
||||
@ -249,7 +247,7 @@ describe('Balancer flow', () => {
|
||||
})
|
||||
|
||||
it('Bob should remove Ocean liquidity from pool ', async () => {
|
||||
const currentDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
||||
const currentDtReserve = await Pool.getOceanReserve(greatPool)
|
||||
const bobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
||||
|
||||
const poolShares = await Pool.sharesBalance(bob, greatPool)
|
||||
@ -259,7 +257,7 @@ describe('Balancer flow', () => {
|
||||
|
||||
await Pool.removeOceanLiquidity(bob, greatPool, '0.75', poolShares)
|
||||
|
||||
const newDtReserve = await Pool.getOceanReserve(bob, greatPool)
|
||||
const newDtReserve = await Pool.getOceanReserve(greatPool)
|
||||
const newbobDtBalance = await datatoken.balance(oceanTokenAddress, bob)
|
||||
const newpoolShares = await Pool.sharesBalance(bob, greatPool)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user