mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add constants
This commit is contained in:
parent
9200be874b
commit
751a7369a4
@ -35,15 +35,51 @@ describe('Pool unit test', () => {
|
|||||||
let erc20Contract: Contract
|
let erc20Contract: Contract
|
||||||
let daiContract: Contract
|
let daiContract: Contract
|
||||||
let usdcContract: Contract
|
let usdcContract: Contract
|
||||||
|
let ercParams: Erc20CreateParams
|
||||||
|
|
||||||
|
const VESTING_AMOUNT = '10000'
|
||||||
|
const CAP_AMOUNT = '1000000'
|
||||||
|
const NFT_NAME = '72120Bundle'
|
||||||
|
const NFT_SYMBOL = '72Bundle'
|
||||||
|
const NFT_TOKEN_URI = 'https://oceanprotocol.com/nft/'
|
||||||
|
const ERC20_NAME = 'ERC20B1'
|
||||||
|
const ERC20_SYMBOL = 'ERC20DT1Symbol'
|
||||||
|
const FEE_ZERO = '0'
|
||||||
const DAI_AMOUNT = 2000
|
const DAI_AMOUNT = 2000
|
||||||
const USDC_AMOUNT = 10000
|
const USDC_AMOUNT = 10000
|
||||||
|
const RATE = '1'
|
||||||
|
const VESTED_BLOCKS = 2500000
|
||||||
|
const FEE_LIQUIDITY_PROVIDER = '0.001'
|
||||||
|
const FEE_MARKET = '0.001'
|
||||||
|
|
||||||
|
const NFT_DATA: NftCreateData = {
|
||||||
|
name: NFT_NAME,
|
||||||
|
symbol: NFT_SYMBOL,
|
||||||
|
templateIndex: 1,
|
||||||
|
tokenURI: NFT_TOKEN_URI,
|
||||||
|
transferable: true,
|
||||||
|
owner: factoryOwner
|
||||||
|
}
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
const accounts = await web3.eth.getAccounts()
|
const accounts = await web3.eth.getAccounts()
|
||||||
factoryOwner = accounts[0]
|
factoryOwner = accounts[0]
|
||||||
user1 = accounts[3]
|
user1 = accounts[3]
|
||||||
user2 = accounts[4]
|
user2 = accounts[4]
|
||||||
|
|
||||||
|
NFT_DATA.owner = factoryOwner
|
||||||
|
|
||||||
|
ercParams = {
|
||||||
|
templateIndex: 1,
|
||||||
|
minter: factoryOwner,
|
||||||
|
paymentCollector: user2,
|
||||||
|
mpFeeAddress: factoryOwner,
|
||||||
|
feeToken: ZERO_ADDRESS,
|
||||||
|
cap: CAP_AMOUNT,
|
||||||
|
feeAmount: FEE_ZERO,
|
||||||
|
name: ERC20_NAME,
|
||||||
|
symbol: ERC20_SYMBOL
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should deploy contracts', async () => {
|
it('should deploy contracts', async () => {
|
||||||
@ -101,27 +137,6 @@ describe('Pool unit test', () => {
|
|||||||
it('#create a pool', async () => {
|
it('#create a pool', async () => {
|
||||||
// CREATE A POOL
|
// CREATE A POOL
|
||||||
// we prepare transaction parameters objects
|
// we prepare transaction parameters objects
|
||||||
const nftData: NftCreateData = {
|
|
||||||
name: '72120Bundle',
|
|
||||||
symbol: '72Bundle',
|
|
||||||
templateIndex: 1,
|
|
||||||
tokenURI: 'https://oceanprotocol.com/nft/',
|
|
||||||
transferable: true,
|
|
||||||
owner: factoryOwner
|
|
||||||
}
|
|
||||||
|
|
||||||
const ercParams: Erc20CreateParams = {
|
|
||||||
templateIndex: 1,
|
|
||||||
minter: factoryOwner,
|
|
||||||
paymentCollector: user2,
|
|
||||||
mpFeeAddress: factoryOwner,
|
|
||||||
feeToken: ZERO_ADDRESS,
|
|
||||||
cap: '1000000',
|
|
||||||
feeAmount: '0',
|
|
||||||
name: 'ERC20B1',
|
|
||||||
symbol: 'ERC20DT1Symbol'
|
|
||||||
}
|
|
||||||
|
|
||||||
const poolParams: PoolCreationParams = {
|
const poolParams: PoolCreationParams = {
|
||||||
ssContract: contracts.sideStakingAddress,
|
ssContract: contracts.sideStakingAddress,
|
||||||
baseTokenAddress: contracts.daiAddress,
|
baseTokenAddress: contracts.daiAddress,
|
||||||
@ -129,20 +144,20 @@ describe('Pool unit test', () => {
|
|||||||
publisherAddress: factoryOwner,
|
publisherAddress: factoryOwner,
|
||||||
marketFeeCollector: factoryOwner,
|
marketFeeCollector: factoryOwner,
|
||||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||||
rate: '1',
|
rate: RATE,
|
||||||
baseTokenDecimals: 18,
|
baseTokenDecimals: 18,
|
||||||
vestingAmount: '10000',
|
vestingAmount: VESTING_AMOUNT,
|
||||||
vestedBlocks: 2500000,
|
vestedBlocks: VESTED_BLOCKS,
|
||||||
initialBaseTokenLiquidity: '2000',
|
initialBaseTokenLiquidity: '2000',
|
||||||
swapFeeLiquidityProvider: '0.001',
|
swapFeeLiquidityProvider: FEE_LIQUIDITY_PROVIDER,
|
||||||
swapFeeMarketRunner: '0.001'
|
swapFeeMarketRunner: FEE_MARKET
|
||||||
}
|
}
|
||||||
|
|
||||||
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
||||||
|
|
||||||
const txReceipt = await nftFactory.createNftErc20WithPool(
|
const txReceipt = await nftFactory.createNftErc20WithPool(
|
||||||
factoryOwner,
|
factoryOwner,
|
||||||
nftData,
|
NFT_DATA,
|
||||||
ercParams,
|
ercParams,
|
||||||
poolParams
|
poolParams
|
||||||
)
|
)
|
||||||
@ -176,6 +191,7 @@ describe('Pool unit test', () => {
|
|||||||
(2 * Number(dtOwnerLPTBalance)).toString()
|
(2 * Number(dtOwnerLPTBalance)).toString()
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getCurrentTokens - should return current pool tokens', async () => {
|
it('#getCurrentTokens - should return current pool tokens', async () => {
|
||||||
const currentTokens = await pool.getCurrentTokens(poolAddress)
|
const currentTokens = await pool.getCurrentTokens(poolAddress)
|
||||||
expect(currentTokens[0]).to.equal(erc20Token)
|
expect(currentTokens[0]).to.equal(erc20Token)
|
||||||
@ -303,6 +319,7 @@ describe('Pool unit test', () => {
|
|||||||
expect(tx.events.LOG_JOIN.event === 'LOG_JOIN')
|
expect(tx.events.LOG_JOIN.event === 'LOG_JOIN')
|
||||||
expect(tx.events.LOG_BPT.event === 'LOG_BPT')
|
expect(tx.events.LOG_BPT.event === 'LOG_BPT')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#joinswapExternAmountIn- user1 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'
|
||||||
@ -551,27 +568,6 @@ describe('Pool unit test', () => {
|
|||||||
it('#create a pool', async () => {
|
it('#create a pool', async () => {
|
||||||
// CREATE A POOL
|
// CREATE A POOL
|
||||||
// we prepare transaction parameters objects
|
// we prepare transaction parameters objects
|
||||||
const nftData: NftCreateData = {
|
|
||||||
name: '72120Bundle',
|
|
||||||
symbol: '72Bundle',
|
|
||||||
templateIndex: 1,
|
|
||||||
tokenURI: 'https://oceanprotocol.com/nft/',
|
|
||||||
transferable: true,
|
|
||||||
owner: factoryOwner
|
|
||||||
}
|
|
||||||
|
|
||||||
const ercParams: Erc20CreateParams = {
|
|
||||||
templateIndex: 1,
|
|
||||||
minter: factoryOwner,
|
|
||||||
paymentCollector: user2,
|
|
||||||
mpFeeAddress: factoryOwner,
|
|
||||||
feeToken: ZERO_ADDRESS,
|
|
||||||
cap: '1000000',
|
|
||||||
feeAmount: '0',
|
|
||||||
name: 'ERC20B1',
|
|
||||||
symbol: 'ERC20DT1Symbol'
|
|
||||||
}
|
|
||||||
|
|
||||||
const poolParams: PoolCreationParams = {
|
const poolParams: PoolCreationParams = {
|
||||||
ssContract: contracts.sideStakingAddress,
|
ssContract: contracts.sideStakingAddress,
|
||||||
baseTokenAddress: contracts.usdcAddress,
|
baseTokenAddress: contracts.usdcAddress,
|
||||||
@ -579,24 +575,24 @@ describe('Pool unit test', () => {
|
|||||||
publisherAddress: factoryOwner,
|
publisherAddress: factoryOwner,
|
||||||
marketFeeCollector: factoryOwner,
|
marketFeeCollector: factoryOwner,
|
||||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||||
rate: '1',
|
rate: RATE,
|
||||||
baseTokenDecimals: await usdcContract.methods.decimals().call(),
|
baseTokenDecimals: await usdcContract.methods.decimals().call(),
|
||||||
vestingAmount: '10000',
|
vestingAmount: VESTING_AMOUNT,
|
||||||
vestedBlocks: 2500000,
|
vestedBlocks: VESTED_BLOCKS,
|
||||||
initialBaseTokenLiquidity: await unitsToAmount(
|
initialBaseTokenLiquidity: await unitsToAmount(
|
||||||
web3,
|
web3,
|
||||||
contracts.usdcAddress,
|
contracts.usdcAddress,
|
||||||
await amountToUnits(web3, contracts.usdcAddress, '2000')
|
await amountToUnits(web3, contracts.usdcAddress, '2000')
|
||||||
),
|
),
|
||||||
swapFeeLiquidityProvider: '0.001',
|
swapFeeLiquidityProvider: FEE_LIQUIDITY_PROVIDER,
|
||||||
swapFeeMarketRunner: '0.001'
|
swapFeeMarketRunner: FEE_MARKET
|
||||||
}
|
}
|
||||||
|
|
||||||
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
||||||
|
|
||||||
const txReceipt = await nftFactory.createNftErc20WithPool(
|
const txReceipt = await nftFactory.createNftErc20WithPool(
|
||||||
factoryOwner,
|
factoryOwner,
|
||||||
nftData,
|
NFT_DATA,
|
||||||
ercParams,
|
ercParams,
|
||||||
poolParams
|
poolParams
|
||||||
)
|
)
|
||||||
@ -701,6 +697,7 @@ describe('Pool unit test', () => {
|
|||||||
(2 * Number(dtOwnerLPTBalance)).toString()
|
(2 * Number(dtOwnerLPTBalance)).toString()
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getCurrentTokens - should return current pool tokens', async () => {
|
it('#getCurrentTokens - should return current pool tokens', async () => {
|
||||||
const currentTokens = await pool.getCurrentTokens(poolAddress)
|
const currentTokens = await pool.getCurrentTokens(poolAddress)
|
||||||
expect(currentTokens[0]).to.equal(erc20Token)
|
expect(currentTokens[0]).to.equal(erc20Token)
|
||||||
@ -834,6 +831,7 @@ describe('Pool unit test', () => {
|
|||||||
// console.log(tx.events.LOG_JOIN)
|
// console.log(tx.events.LOG_JOIN)
|
||||||
// console.log(tx.events.LOG_BPT)
|
// console.log(tx.events.LOG_BPT)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#joinswapExternAmountIn- user1 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'
|
||||||
@ -891,7 +889,6 @@ describe('Pool unit test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('#getAmountInExactOut- should get the amount in for exact out', async () => {
|
it('#getAmountInExactOut- should get the amount in for exact out', async () => {
|
||||||
const maxBTPIn = '0.5'
|
|
||||||
const exactUSDCOut = '1'
|
const exactUSDCOut = '1'
|
||||||
|
|
||||||
const result = await pool.getAmountInExactOut(
|
const result = await pool.getAmountInExactOut(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user