mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge branch 'issue-1356-rewrite-testcontracthandler-helper-class' into issue-1346-rewrite-datatoken-test
This commit is contained in:
commit
623261d548
2677
CHANGELOG.md
2677
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
2
package-lock.json
generated
2
package-lock.json
generated
@ -31068,4 +31068,4 @@
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@oceanprotocol/lib",
|
||||
"source": "./src/index.ts",
|
||||
"version": "1.0.0-next.29",
|
||||
"version": "1.0.0-next.32",
|
||||
"description": "JavaScript client library for Ocean Protocol",
|
||||
"main": "./dist/lib.js",
|
||||
"umd:main": "dist/lib.umd.js",
|
||||
@ -90,7 +90,7 @@
|
||||
"mock-local-storage": "^1.1.20",
|
||||
"nyc": "^15.1.0",
|
||||
"ora": "5.4.1",
|
||||
"prettier": "^2.6.0",
|
||||
"prettier": "^2.6.1",
|
||||
"release-it": "^14.13.1",
|
||||
"source-map-support": "^0.5.19",
|
||||
"ts-node": "^10.7.0",
|
||||
|
@ -12,7 +12,7 @@ const { description, version } = libJsPackage
|
||||
|
||||
// Setup our paths, relative to project root
|
||||
const outPath = './dist/lib.json'
|
||||
const files = ['./src/lib.ts']
|
||||
const files = ['./src/index.ts']
|
||||
|
||||
// specifically point to tsconfig, otherwise TypeDoc fails
|
||||
const config = typescript.findConfigFile('./tsconfig.js', typescript.sys.fileExists)
|
||||
@ -30,8 +30,8 @@ const generateJson = async () => {
|
||||
entryPoints: files
|
||||
})
|
||||
|
||||
const src = app.expandInputFiles(files)
|
||||
const project = app.convert(src)
|
||||
const src = app.getEntryPoints()
|
||||
const project = app.converter.convert(src)
|
||||
|
||||
// Generate the JSON file
|
||||
await app.generateJson(project, outPath)
|
||||
|
@ -1,7 +1,7 @@
|
||||
export interface Erc20CreateParams {
|
||||
templateIndex: number
|
||||
minter: string
|
||||
feeManager: string
|
||||
paymentCollector: string
|
||||
mpFeeAddress: string
|
||||
feeToken: string
|
||||
feeAmount: string
|
||||
|
@ -492,14 +492,14 @@ export class NftFactory {
|
||||
if ((await this.getOwner()) !== address) {
|
||||
throw new Error(`Caller is not Factory Owner`)
|
||||
}
|
||||
if (templateIndex > (await this.getCurrentNFTTemplateCount())) {
|
||||
if (templateIndex > (await this.getCurrentTokenTemplateCount())) {
|
||||
throw new Error(`Template index doesnt exist`)
|
||||
}
|
||||
|
||||
if (templateIndex === 0) {
|
||||
throw new Error(`Template index cannot be ZERO`)
|
||||
}
|
||||
if ((await this.getNFTTemplate(templateIndex)).isActive === false) {
|
||||
if ((await this.getTokenTemplate(templateIndex)).isActive === false) {
|
||||
throw new Error(`Template is already disabled`)
|
||||
}
|
||||
const estGas = await this.estGasDisableTokenTemplate(address, templateIndex)
|
||||
@ -551,7 +551,7 @@ export class NftFactory {
|
||||
if ((await this.getOwner()) !== address) {
|
||||
throw new Error(`Caller is not Factory Owner`)
|
||||
}
|
||||
if (templateIndex > (await this.getCurrentNFTTemplateCount())) {
|
||||
if (templateIndex > (await this.getCurrentTokenTemplateCount())) {
|
||||
throw new Error(`Template index doesnt exist`)
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ export class FixedRateExchange {
|
||||
* @param {String} maxBaseTokenAmount max amount of baseToken we want to pay for datatokenAmount
|
||||
* @param {String} address User address
|
||||
* @param {String} consumeMarketAddress consumeMarketAddress
|
||||
* @param {String} consumeMarketFee consumeMarketFee
|
||||
* @param {String} consumeMarketFee consumeMarketFee in fraction
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
*/
|
||||
public async buyDT(
|
||||
@ -168,10 +168,7 @@ export class FixedRateExchange {
|
||||
consumeMarketFee: string = '0'
|
||||
): Promise<TransactionReceipt> {
|
||||
const exchange = await this.getExchange(exchangeId)
|
||||
const consumeMarketFeeFormatted = await this.amountToUnits(
|
||||
exchange.baseToken,
|
||||
consumeMarketFee
|
||||
)
|
||||
const consumeMarketFeeFormatted = this.web3.utils.toWei(consumeMarketFee)
|
||||
const dtAmountFormatted = await this.amountToUnits(
|
||||
exchange.datatoken,
|
||||
datatokenAmount
|
||||
@ -255,7 +252,7 @@ export class FixedRateExchange {
|
||||
* @param {String} minBaseTokenAmount min amount of baseToken we want to receive back
|
||||
* @param {String} address User address
|
||||
* @param {String} consumeMarketAddress consumeMarketAddress
|
||||
* @param {String} consumeMarketFee consumeMarketFee
|
||||
* @param {String} consumeMarketFee consumeMarketFee in fraction
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
*/
|
||||
public async sellDT(
|
||||
@ -267,10 +264,7 @@ export class FixedRateExchange {
|
||||
consumeMarketFee: string = '0'
|
||||
): Promise<TransactionReceipt> {
|
||||
const exchange = await this.getExchange(exchangeId)
|
||||
const consumeMarketFeeFormatted = await this.amountToUnits(
|
||||
exchange.baseToken,
|
||||
consumeMarketFee
|
||||
)
|
||||
const consumeMarketFeeFormatted = this.web3.utils.toWei(consumeMarketFee)
|
||||
const dtAmountFormatted = await this.amountToUnits(
|
||||
exchange.datatoken,
|
||||
datatokenAmount
|
||||
@ -571,7 +565,7 @@ export class FixedRateExchange {
|
||||
* calcBaseInGivenOutDT - Calculates how many base tokens are needed to get specified amount of datatokens
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {string} datatokenAmount Amount of datatokens user wants to buy
|
||||
* @param {String} consumeMarketFee consumeMarketFee
|
||||
* @param {String} consumeMarketFee consumeMarketFee in fraction
|
||||
* @return {Promise<PriceAndFees>} how many base tokens are needed and fees
|
||||
*/
|
||||
public async calcBaseInGivenOutDT(
|
||||
@ -584,7 +578,7 @@ export class FixedRateExchange {
|
||||
.calcBaseInGivenOutDT(
|
||||
exchangeId,
|
||||
await this.amountToUnits(fixedRateExchange.datatoken, datatokenAmount),
|
||||
await this.amountToUnits(fixedRateExchange.baseToken, consumeMarketFee)
|
||||
this.web3.utils.toWei(consumeMarketFee)
|
||||
)
|
||||
.call()
|
||||
|
||||
@ -613,7 +607,7 @@ export class FixedRateExchange {
|
||||
* getBTOut - returns amount in baseToken that user will receive for datatokenAmount sold
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {Number} datatokenAmount Amount of datatokens
|
||||
* @param {String} consumeMarketFee consumeMarketFee
|
||||
* @param {String} consumeMarketFee consumeMarketFee in fraction
|
||||
* @return {Promise<string>} Amount of baseTokens user will receive
|
||||
*/
|
||||
public async getAmountBTOut(
|
||||
@ -626,7 +620,7 @@ export class FixedRateExchange {
|
||||
.calcBaseOutGivenInDT(
|
||||
exchangeId,
|
||||
await this.amountToUnits(exchange.datatoken, datatokenAmount),
|
||||
await this.amountToUnits(exchange.baseToken, consumeMarketFee)
|
||||
this.web3.utils.toWei(consumeMarketFee)
|
||||
)
|
||||
.call()
|
||||
|
||||
|
@ -528,26 +528,21 @@ export class Provider {
|
||||
}
|
||||
}
|
||||
|
||||
/** Get status for a specific jobId/documentId/owner.
|
||||
* @param {string} did
|
||||
* @param {string} consumerAddress
|
||||
* @param {string} providerUri
|
||||
* @param {Web3} web3
|
||||
/** Get compute status for a specific jobId/documentId/owner.
|
||||
* @param {string} providerUri The URI of the provider we want to query
|
||||
* @param {string} consumerAddress The consumer ethereum address
|
||||
* @param {string} jobId The ID of a compute job.
|
||||
* @param {string} did The ID of the asset
|
||||
* @param {AbortSignal} signal abort signal
|
||||
* @param {string} jobId
|
||||
* @return {Promise<ComputeJob | ComputeJob[]>}
|
||||
*/
|
||||
public async computeStatus(
|
||||
providerUri: string,
|
||||
signal?: AbortSignal,
|
||||
consumerAddress: string,
|
||||
jobId?: string,
|
||||
did?: string,
|
||||
consumerAddress?: string
|
||||
signal?: AbortSignal
|
||||
): Promise<ComputeJob | ComputeJob[]> {
|
||||
if (!jobId && !did && !consumerAddress) {
|
||||
throw new Error('You need at least one of jobId, did, consumerAddress')
|
||||
}
|
||||
|
||||
const providerEndpoints = await this.getEndpoints(providerUri)
|
||||
const serviceEndpoints = await this.getServiceEndpoints(
|
||||
providerUri,
|
||||
@ -557,8 +552,8 @@ export class Provider {
|
||||
? this.getEndpointURL(serviceEndpoints, 'computeStatus').urlPath
|
||||
: null
|
||||
|
||||
let url = '?documentId=' + noZeroX(did)
|
||||
url += (consumerAddress && `&consumerAddress=${consumerAddress}`) || ''
|
||||
let url = `?consumerAddress=${consumerAddress}`
|
||||
url += (did && `&documentId=${noZeroX(did)}`) || ''
|
||||
url += (jobId && `&jobId=${jobId}`) || ''
|
||||
|
||||
if (!computeStatusUrl) return null
|
||||
|
@ -44,7 +44,7 @@ export class Nft {
|
||||
* @param {String} nftAddress ERC721 addreess
|
||||
* @param {String} address User address
|
||||
* @param {String} minter User set as initial minter for the ERC20
|
||||
* @param {String} feeManager initial feeManager for this DT
|
||||
* @param {String} paymentCollector initial paymentCollector for this DT
|
||||
* @param {String} mpFeeAddress Consume marketplace fee address
|
||||
* @param {String} feeToken address of the token marketplace wants to add fee on top
|
||||
* @param {String} feeAmount amount of feeToken to be transferred to mpFeeAddress on top, will be converted to WEI
|
||||
@ -59,7 +59,7 @@ export class Nft {
|
||||
nftAddress: string,
|
||||
address: string,
|
||||
minter: string,
|
||||
feeManager: string,
|
||||
paymentCollector: string,
|
||||
mpFeeAddress: string,
|
||||
feeToken: string,
|
||||
feeAmount: string,
|
||||
@ -82,7 +82,7 @@ export class Nft {
|
||||
.createERC20(
|
||||
templateIndex,
|
||||
[name, symbol],
|
||||
[minter, feeManager, mpFeeAddress, feeToken],
|
||||
[minter, paymentCollector, mpFeeAddress, feeToken],
|
||||
[this.web3.utils.toWei(cap), this.web3.utils.toWei(feeAmount)],
|
||||
[]
|
||||
)
|
||||
@ -98,7 +98,7 @@ export class Nft {
|
||||
* @param {String} nftAddress ERC721 addreess
|
||||
* @param {String} address User address
|
||||
* @param {String} minter User set as initial minter for the ERC20
|
||||
* @param {String} feeManager initial feeManager for this DT
|
||||
* @param {String} paymentCollector initial paymentCollector for this DT
|
||||
* @param {String} mpFeeAddress Consume marketplace fee address
|
||||
* @param {String} feeToken address of the token marketplace wants to add fee on top
|
||||
* @param {String} feeAmount amount of feeToken to be transferred to mpFeeAddress on top, will be converted to WEI
|
||||
@ -112,7 +112,7 @@ export class Nft {
|
||||
nftAddress: string,
|
||||
address: string,
|
||||
minter: string,
|
||||
feeManager: string,
|
||||
paymentCollector: string,
|
||||
mpFeeAddress: string,
|
||||
feeToken: string,
|
||||
feeAmount: string,
|
||||
@ -141,7 +141,7 @@ export class Nft {
|
||||
nftAddress,
|
||||
address,
|
||||
minter,
|
||||
feeManager,
|
||||
paymentCollector,
|
||||
mpFeeAddress,
|
||||
feeToken,
|
||||
feeAmount,
|
||||
@ -157,7 +157,7 @@ export class Nft {
|
||||
.createERC20(
|
||||
templateIndex,
|
||||
[name, symbol],
|
||||
[minter, feeManager, mpFeeAddress, feeToken],
|
||||
[minter, paymentCollector, mpFeeAddress, feeToken],
|
||||
[this.web3.utils.toWei(cap), this.web3.utils.toWei(feeAmount)],
|
||||
[]
|
||||
)
|
||||
|
@ -45,7 +45,7 @@ export function getErcCreationParams(ercParams: Erc20CreateParams): any {
|
||||
strings: [ercParams.name || name, ercParams.symbol || symbol],
|
||||
addresses: [
|
||||
ercParams.minter,
|
||||
ercParams.feeManager,
|
||||
ercParams.paymentCollector,
|
||||
ercParams.mpFeeAddress,
|
||||
ercParams.feeToken
|
||||
],
|
||||
|
@ -142,7 +142,7 @@ describe('Simple compute tests', async () => {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
feeManager: '0x0000000000000000000000000000000000000000',
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
minter: publisherAccount,
|
||||
mpFeeAddress: '0x0000000000000000000000000000000000000000'
|
||||
@ -191,7 +191,7 @@ describe('Simple compute tests', async () => {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
feeManager: '0x0000000000000000000000000000000000000000',
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
minter: publisherAccount,
|
||||
mpFeeAddress: '0x0000000000000000000000000000000000000000'
|
||||
@ -338,10 +338,9 @@ describe('Simple compute tests', async () => {
|
||||
assert(computeJobs, 'Cannot start compute job')
|
||||
const jobStatus = await ProviderInstance.computeStatus(
|
||||
providerUrl,
|
||||
null,
|
||||
consumerAccount,
|
||||
computeJobs[0].jobId,
|
||||
resolvedDDOAsset.id,
|
||||
consumerAccount
|
||||
resolvedDDOAsset.id
|
||||
)
|
||||
assert(jobStatus)
|
||||
})
|
||||
|
@ -102,7 +102,7 @@ describe('Publish tests', async () => {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
feeManager: ZERO_ADDRESS,
|
||||
paymentCollector: ZERO_ADDRESS,
|
||||
feeToken: ZERO_ADDRESS,
|
||||
minter: accounts[0],
|
||||
mpFeeAddress: ZERO_ADDRESS
|
||||
@ -181,7 +181,7 @@ describe('Publish tests', async () => {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
feeManager: ZERO_ADDRESS,
|
||||
paymentCollector: ZERO_ADDRESS,
|
||||
feeToken: ZERO_ADDRESS,
|
||||
minter: accounts[0],
|
||||
mpFeeAddress: ZERO_ADDRESS
|
||||
@ -257,7 +257,7 @@ describe('Publish tests', async () => {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
feeManager: ZERO_ADDRESS,
|
||||
paymentCollector: ZERO_ADDRESS,
|
||||
feeToken: ZERO_ADDRESS,
|
||||
minter: accounts[0],
|
||||
mpFeeAddress: ZERO_ADDRESS
|
||||
|
@ -82,7 +82,7 @@ describe('Simple Publish & consume test', async () => {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
feeManager: '0x0000000000000000000000000000000000000000',
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
minter: publisherAccount,
|
||||
mpFeeAddress: '0x0000000000000000000000000000000000000000'
|
||||
|
@ -77,7 +77,7 @@ describe('Nft Factory test', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '10000',
|
||||
@ -113,7 +113,7 @@ describe('Nft Factory test', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: user2,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
@ -163,7 +163,7 @@ describe('Nft Factory test', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
@ -213,7 +213,7 @@ describe('Nft Factory test', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
@ -344,4 +344,72 @@ describe('Nft Factory test', () => {
|
||||
)
|
||||
assert((await nftFactory.checkNFT(nftAddress)) === nftAddress)
|
||||
})
|
||||
|
||||
it('#addNFTTemplate - should add a new erc721 token template', async () => {
|
||||
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
||||
|
||||
await nftFactory.addNFTTemplate(factoryOwner, contracts.erc721TemplateAddress)
|
||||
|
||||
expect(
|
||||
(await nftFactory.getCurrentNFTTemplateCount()) === currentNFTTemplateCount + 1
|
||||
)
|
||||
})
|
||||
|
||||
it('#disableNFTTemplate - should disable an erc721 token template', async () => {
|
||||
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
||||
|
||||
let nftTemplate = await nftFactory.getNFTTemplate(currentNFTTemplateCount)
|
||||
assert(nftTemplate.isActive === true)
|
||||
|
||||
await nftFactory.disableNFTTemplate(factoryOwner, currentNFTTemplateCount)
|
||||
|
||||
nftTemplate = await nftFactory.getNFTTemplate(currentNFTTemplateCount)
|
||||
assert(nftTemplate.isActive === false)
|
||||
})
|
||||
|
||||
it('#reactivateNFTTemplate - should reactivate an erc721 previously disabled token template', async () => {
|
||||
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
||||
|
||||
let nftTemplate = await nftFactory.getNFTTemplate(currentNFTTemplateCount)
|
||||
assert(nftTemplate.isActive === false)
|
||||
|
||||
await nftFactory.reactivateNFTTemplate(factoryOwner, currentNFTTemplateCount)
|
||||
|
||||
nftTemplate = await nftFactory.getNFTTemplate(currentNFTTemplateCount)
|
||||
assert(nftTemplate.isActive === true)
|
||||
})
|
||||
|
||||
it('#addTokenTemplate - should add a new erc20 token template', async () => {
|
||||
const currentTokenTemplateCount = await nftFactory.getCurrentTokenTemplateCount()
|
||||
|
||||
await nftFactory.addTokenTemplate(factoryOwner, contracts.erc20TemplateAddress)
|
||||
|
||||
expect(
|
||||
(await nftFactory.getCurrentTokenTemplateCount()) === currentTokenTemplateCount + 1
|
||||
)
|
||||
})
|
||||
|
||||
it('#disableTokenTemplate - should disable an erc20 token template', async () => {
|
||||
const currentTokenTemplateCount = await nftFactory.getCurrentTokenTemplateCount()
|
||||
|
||||
let tokenTemplate = await nftFactory.getTokenTemplate(currentTokenTemplateCount)
|
||||
assert(tokenTemplate.isActive === true)
|
||||
|
||||
await nftFactory.disableTokenTemplate(factoryOwner, currentTokenTemplateCount)
|
||||
|
||||
tokenTemplate = await nftFactory.getTokenTemplate(currentTokenTemplateCount)
|
||||
assert(tokenTemplate.isActive === false)
|
||||
})
|
||||
|
||||
it('#reactivateTokenTemplate - should reactivate an previously disabled erc20 token template', async () => {
|
||||
const currentTokenTemplateCount = await nftFactory.getCurrentTokenTemplateCount()
|
||||
|
||||
let tokenTemplate = await nftFactory.getTokenTemplate(currentTokenTemplateCount)
|
||||
assert(tokenTemplate.isActive === false)
|
||||
|
||||
await nftFactory.reactivateTokenTemplate(factoryOwner, currentTokenTemplateCount)
|
||||
|
||||
tokenTemplate = await nftFactory.getTokenTemplate(currentTokenTemplateCount)
|
||||
assert(tokenTemplate.isActive === true)
|
||||
})
|
||||
})
|
||||
|
@ -101,7 +101,7 @@ describe('Router unit test', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: factoryOwner,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
@ -154,7 +154,7 @@ describe('Router unit test', () => {
|
||||
const ercParams2: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: factoryOwner,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
|
@ -111,7 +111,7 @@ describe('Pool unit test', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: factoryOwner,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
@ -159,11 +159,11 @@ describe('Pool unit test', () => {
|
||||
expect(await erc20Contract.methods.balanceOf(user2).call()).to.equal('0')
|
||||
})
|
||||
|
||||
it('#sharesBalance - should return user shares balance (datatoken balance, LPT balance, etc) ', async () => {
|
||||
expect(await daiContract.methods.balanceOf(user2).call()).to.equal(
|
||||
web3.utils.toWei(await pool.sharesBalance(user2, contracts.daiAddress))
|
||||
)
|
||||
})
|
||||
// it('#sharesBalance - should return user shares balance (datatoken balance, LPT balance, etc) ', async () => {
|
||||
// expect(await daiContract.methods.balanceOf(user2).call()).to.equal(
|
||||
// web3.utils.toWei(await pool.sharesBalance(user2, contracts.daiAddress))
|
||||
// )
|
||||
// })
|
||||
|
||||
it('#getNumTokens - should return num of tokens in pool (2)', async () => {
|
||||
expect(await pool.getNumTokens(poolAddress)).to.equal('2')
|
||||
@ -566,7 +566,7 @@ describe('Pool unit test', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: factoryOwner,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
@ -687,11 +687,11 @@ describe('Pool unit test', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('#sharesBalance - should return user shares balance (datatoken balance, LPT balance, etc) ', async () => {
|
||||
expect(await usdcContract.methods.balanceOf(user2).call()).to.equal(
|
||||
await pool.sharesBalance(user2, contracts.usdcAddress)
|
||||
)
|
||||
})
|
||||
// it('#sharesBalance - should return user shares balance (datatoken balance, LPT balance, etc) ', async () => {
|
||||
// expect(await usdcContract.methods.balanceOf(user2).call()).to.equal(
|
||||
// await pool.sharesBalance(user2, contracts.usdcAddress)
|
||||
// )
|
||||
// })
|
||||
|
||||
it('#getNumTokens - should return num of tokens in pool (2)', async () => {
|
||||
expect(await pool.getNumTokens(poolAddress)).to.equal('2')
|
||||
|
@ -62,7 +62,7 @@ describe('Dispenser flow', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '10000',
|
||||
|
@ -75,7 +75,7 @@ describe('Fixed Rate unit test', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: factoryOwner,
|
||||
feeToken: ADDRESS_ZERO,
|
||||
cap: '1000000',
|
||||
@ -339,26 +339,26 @@ describe('Fixed Rate unit test', () => {
|
||||
// Only allowance left since dt is ZERO
|
||||
expect(result2.dtSupply).to.equal('990')
|
||||
})
|
||||
it('#collectMarketFee- should collect marketFee and send it to marketFeeCollector, anyone can call it', async () => {
|
||||
let result = await fixedRate.getFeesInfo(exchangeId)
|
||||
// we made 2 swaps for 10 DT at rate 1, the fee is 0.1% for market and always in baseToken so it's 0.01 DAI
|
||||
// plus another swap for 1 DT
|
||||
expect(result.marketFeeAvailable).to.equal('0.021') // formatted for baseToken decimals
|
||||
// same for ocean fee
|
||||
expect(result.oceanFeeAvailable).to.equal('0.042') // formatted for baseToken decimals
|
||||
expect(result.marketFeeCollector).to.equal(user3)
|
||||
// it('#collectMarketFee- should collect marketFee and send it to marketFeeCollector, anyone can call it', async () => {
|
||||
// let result = await fixedRate.getFeesInfo(exchangeId)
|
||||
// // we made 2 swaps for 10 DT at rate 1, the fee is 0.1% for market and always in baseToken so it's 0.01 DAI
|
||||
// // plus another swap for 1 DT
|
||||
// expect(result.marketFeeAvailable).to.equal('0.021') // formatted for baseToken decimals
|
||||
// // same for ocean fee
|
||||
// expect(result.oceanFeeAvailable).to.equal('0.042') // formatted for baseToken decimals
|
||||
// expect(result.marketFeeCollector).to.equal(user3)
|
||||
|
||||
// user4 calls collectMarketFee
|
||||
await fixedRate.collectMarketFee(user4, exchangeId)
|
||||
result = await fixedRate.getFeesInfo(exchangeId)
|
||||
expect(result.marketFeeAvailable).to.equal('0')
|
||||
// ocean fee still available
|
||||
expect(result.oceanFeeAvailable).to.equal('0.042')
|
||||
// user3 is the marketFeeCollector
|
||||
expect(await daiContract.methods.balanceOf(user3).call()).to.equal(
|
||||
web3.utils.toWei('1.021')
|
||||
)
|
||||
})
|
||||
// // user4 calls collectMarketFee
|
||||
// await fixedRate.collectMarketFee(user4, exchangeId)
|
||||
// result = await fixedRate.getFeesInfo(exchangeId)
|
||||
// expect(result.marketFeeAvailable).to.equal('0')
|
||||
// // ocean fee still available
|
||||
// expect(result.oceanFeeAvailable).to.equal('0.042')
|
||||
// // user3 is the marketFeeCollector
|
||||
// expect(await daiContract.methods.balanceOf(user3).call()).to.equal(
|
||||
// web3.utils.toWei('1.021')
|
||||
// )
|
||||
// })
|
||||
|
||||
it('#updateMarketFee- should update Market fee if market fee collector', async () => {
|
||||
expect((await fixedRate.getFeesInfo(exchangeId)).marketFee).to.equal('0.001')
|
||||
@ -393,7 +393,7 @@ describe('Fixed Rate unit test', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: factoryOwner,
|
||||
feeToken: ADDRESS_ZERO,
|
||||
cap: '1000000',
|
||||
|
@ -125,7 +125,7 @@ describe('SideStaking unit test', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: factoryOwner,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
@ -209,11 +209,11 @@ describe('SideStaking unit test', () => {
|
||||
await sideStaking.getBaseTokenBalance(sideStakingAddress, erc20Token)
|
||||
).to.equal('0')
|
||||
})
|
||||
it('#getDatatokenBalance ', async () => {
|
||||
expect(
|
||||
await sideStaking.getDatatokenBalance(sideStakingAddress, erc20Token)
|
||||
).to.equal('997999.9999999999')
|
||||
})
|
||||
// it('#getDatatokenBalance ', async () => {
|
||||
// expect(
|
||||
// await sideStaking.getDatatokenBalance(sideStakingAddress, erc20Token)
|
||||
// ).to.equal('997999.9999999999')
|
||||
// })
|
||||
|
||||
it('#getvestingAmount ', async () => {
|
||||
expect(await sideStaking.getvestingAmount(sideStakingAddress, erc20Token)).to.equal(
|
||||
@ -366,7 +366,7 @@ describe('SideStaking unit test', () => {
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
feeManager: user3,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: factoryOwner,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
@ -416,11 +416,11 @@ describe('SideStaking unit test', () => {
|
||||
await sideStaking.getBaseTokenBalance(sideStakingAddress, erc20Token)
|
||||
).to.equal('0')
|
||||
})
|
||||
it('#getDatatokenBalance ', async () => {
|
||||
expect(
|
||||
await sideStaking.getDatatokenBalance(sideStakingAddress, erc20Token)
|
||||
).to.equal('997999.9999999999')
|
||||
})
|
||||
// it('#getDatatokenBalance ', async () => {
|
||||
// expect(
|
||||
// await sideStaking.getDatatokenBalance(sideStakingAddress, erc20Token)
|
||||
// ).to.equal('997999.9999999999')
|
||||
// })
|
||||
|
||||
it('#getvestingAmount ', async () => {
|
||||
expect(await sideStaking.getvestingAmount(sideStakingAddress, erc20Token)).to.equal(
|
||||
|
Loading…
x
Reference in New Issue
Block a user