bump contracts & add optimism (#1786)

* bump contracts

* fix contracts

* add optimism

* use upcoming barge

* update fre tests

* make sure all fres are withMint
This commit is contained in:
Alex Coseru 2023-11-24 15:12:21 +02:00 committed by GitHub
parent 4e86a2d505
commit 91460b9cf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 65 additions and 54 deletions

View File

@ -55,6 +55,7 @@ jobs:
with:
repository: 'oceanprotocol/barge'
path: 'barge'
ref: feature/bump_contracts_and_subgraph
- name: Run Ganache with Barge
working-directory: ${{ github.workspace }}/barge
@ -103,6 +104,7 @@ jobs:
with:
repository: 'oceanprotocol/barge'
path: 'barge'
ref: feature/bump_contracts_and_subgraph
- name: Login to Docker Hub
if: ${{ env.DOCKERHUB_PASSWORD && env.DOCKERHUB_USERNAME }}

14
package-lock.json generated
View File

@ -9,7 +9,7 @@
"version": "3.1.4",
"license": "Apache-2.0",
"dependencies": {
"@oceanprotocol/contracts": "^1.1.14",
"@oceanprotocol/contracts": "^2.0.3",
"cross-fetch": "^4.0.0",
"crypto-js": "^4.1.1",
"decimal.js": "^10.4.1",
@ -2963,9 +2963,9 @@
}
},
"node_modules/@oceanprotocol/contracts": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.1.14.tgz",
"integrity": "sha512-PJih7C6LHaWHHj1qgxZsSkEqKphhJrL3G7WuMOxl4N1daDrF6sooDDU+9dZkcHSVPc7cMjkFqLc5fP58NSAobw=="
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-2.0.3.tgz",
"integrity": "sha512-D2YtlsgmhBuSmF/Ue8zMWPtXNiB4zgW09NjUQzvDFrloUo0a7yC8r8L84LrVniw+0Nmly/PhLcdm8i018yc34g=="
},
"node_modules/@octokit/auth-token": {
"version": "3.0.3",
@ -19724,9 +19724,9 @@
}
},
"@oceanprotocol/contracts": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.1.14.tgz",
"integrity": "sha512-PJih7C6LHaWHHj1qgxZsSkEqKphhJrL3G7WuMOxl4N1daDrF6sooDDU+9dZkcHSVPc7cMjkFqLc5fP58NSAobw=="
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-2.0.3.tgz",
"integrity": "sha512-D2YtlsgmhBuSmF/Ue8zMWPtXNiB4zgW09NjUQzvDFrloUo0a7yC8r8L84LrVniw+0Nmly/PhLcdm8i018yc34g=="
},
"@octokit/auth-token": {
"version": "3.0.3",

View File

@ -53,7 +53,7 @@
"web3": "^1.8.0"
},
"dependencies": {
"@oceanprotocol/contracts": "^1.1.14",
"@oceanprotocol/contracts": "^2.0.3",
"cross-fetch": "^4.0.0",
"crypto-js": "^4.1.1",
"decimal.js": "^10.4.1",

View File

@ -136,6 +136,24 @@ export const configHelperNetworks: Config[] = [
subgraphUri: 'https://subgraph.v4.genx.minimal-gaia-x.eu',
explorerUri: 'https://explorer.genx.minimal-gaia-x.eu/',
gasFeeMultiplier: 1
},
{
...configHelperNetworksBase,
chainId: 10,
network: 'optimism',
nodeUri: 'https://mainnet.optimism.io',
subgraphUri: 'https://v4.subgraph.optimism.oceanprotocol.com',
explorerUri: 'https://optimistic.etherscan.io/',
gasFeeMultiplier: 1.1
},
{
...configHelperNetworksBase,
chainId: 11155420,
network: 'optimism-sepolia',
nodeUri: 'https://sepolia.optimism.io',
subgraphUri: 'https://v4.subgraph.optimism-sepolia.oceanprotocol.com',
explorerUri: 'https://sepolia-optimism.etherscan.io/',
gasFeeMultiplier: 1.1
}
]

View File

@ -138,7 +138,7 @@ describe('Publish tests', async () => {
fixedRate: '1',
marketFee: '0',
allowedConsumer: await publisherAccount.getAddress(),
withMint: false
withMint: true
}
const bundleNFT = await factory.createNftWithDatatokenWithFixedRate(

View File

@ -81,7 +81,7 @@ describe('Fixed Rate unit test', () => {
fixedRate: '1',
marketFee: '0.001',
allowedConsumer: ZERO_ADDRESS,
withMint: false
withMint: true
}
const tx = await nftFactory.createNftWithDatatokenWithFixedRate(
@ -134,19 +134,16 @@ describe('Fixed Rate unit test', () => {
await fixedRate.activate(exchangeId)
expect(await fixedRate.isActive(exchangeId)).to.equal(true)
})
it('#activateMint - should activate Mint(allows fixed rate contract to mint dts if required), if exchangeOwner', async () => {
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(false)
await fixedRate.activateMint(exchangeId)
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(true)
})
it('#dectivateMint - should deactivate Mint if exchangeOwner', async () => {
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(true)
await fixedRate.deactivateMint(exchangeId)
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(false)
})
it('#activateMint - should activate Mint(allows fixed rate contract to mint dts if required), if exchangeOwner', async () => {
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(false)
await fixedRate.activateMint(exchangeId)
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(true)
})
it('#generate exchangeId - should generate a specific exchangeId', async () => {
expect(await fixedRate.generateExchangeId(addresses.MockDAI, dtAddress)).to.equal(
exchangeId
@ -175,7 +172,8 @@ describe('Fixed Rate unit test', () => {
it('#getDatatokenSupply - should get the dt supply in the exchange', async () => {
// exchange owner hasn't approved any DT for sell
expect(await fixedRate.getDatatokenSupply(exchangeId)).to.equal('0.0')
// since fre is withMint, dtSupply is 2^256
expect(parseFloat(await fixedRate.getDatatokenSupply(exchangeId))).to.greaterThan(0)
})
it('#getBasetokenSupply - should get the bt supply in the exchange', async () => {
@ -319,8 +317,6 @@ describe('Fixed Rate unit test', () => {
expect((await fixedRate.getExchange(exchangeId)).dtBalance).to.equal('10.0')
// no BTs in the contract (except for the fees, but not accounted here)
expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('0.0')
// DT supply is back at 1000 (exchange Owner allowance + dt balance in the fixed rate)
expect(await fixedRate.getDatatokenSupply(exchangeId)).to.equal('1000.0')
})
it('#getExchange - should return exchange details', async () => {
@ -331,10 +327,11 @@ describe('Fixed Rate unit test', () => {
expect(result.baseToken).to.equal(addresses.MockDAI)
expect(result.datatoken).to.equal(dtAddress)
expect(result.exchangeOwner).to.equal(await exchangeOwner.getAddress())
expect(result.withMint).to.equal(false)
expect(result.withMint).to.equal(true)
expect(result.dtBalance).to.equal('10.0') // balance in the fixedRate
expect(result.btBalance).to.equal('0.0') // balance in the fixedRate
expect(result.dtSupply).to.equal('1000.0') // total supply available (owner allowance + dtBalance)
// since fre is withMint, dtSupply is 2^256
expect(parseFloat(result.dtSupply)).to.gt(0) // total supply available (owner allowance + dtBalance)
expect(result.btSupply).to.equal('0.0') // total supply available of baseToken in the contract
expect(result.fixedRate).to.equal('1.0')
})
@ -391,9 +388,10 @@ describe('Fixed Rate unit test', () => {
await fixedRate.collectDatatokens(exchangeId, result.dtBalance)
// no more dts in the contract
const result2 = await fixedRate.getExchange(exchangeId)
// since fre is withMint, dtSupply is 2^256
expect(result2.dtBalance).to.equal('0.0')
// Only allowance left since dt is ZERO
expect(result2.dtSupply).to.equal('990.0')
// since fre is withMint, dtSupply is 2^256
expect(parseFloat(result2.dtSupply)).to.gt(0)
})
it('#collectMarketFee- should collect marketFee and send it to marketFeeCollector, anyone can call it', async () => {
@ -462,7 +460,9 @@ describe('Fixed Rate unit test', () => {
describe('Test a Fixed Rate Exchange with USDC (6 Decimals) as Basetoken', () => {
it('#create an exchange', async () => {
// CREATE AN Exchange
// since FRE is created without mint rights, owner has to send dt to that exchange
// we prepare transaction parameters objects
const nftFactory = new NftFactory(addresses.ERC721Factory, exchangeOwner)
const freParams: FreCreationParams = {
@ -475,7 +475,7 @@ describe('Fixed Rate unit test', () => {
fixedRate: '1',
marketFee: '0.001',
allowedConsumer: ZERO_ADDRESS,
withMint: false
withMint: true
}
const tx = await nftFactory.createNftWithDatatokenWithFixedRate(
@ -528,18 +528,16 @@ describe('Fixed Rate unit test', () => {
await fixedRate.activate(exchangeId)
expect(await fixedRate.isActive(exchangeId)).to.equal(true)
})
it('#activateMint - should activate Mint(allows fixed rate contract to mint dts if required), if exchangeOwner', async () => {
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(false)
await fixedRate.activateMint(exchangeId)
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(true)
})
it('#dectivateMint - should deactivate Mint if exchangeOwner', async () => {
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(true)
await fixedRate.deactivateMint(exchangeId)
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(false)
})
it('#activateMint - should activate Mint(allows fixed rate contract to mint dts if required), if exchangeOwner', async () => {
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(false)
await fixedRate.activateMint(exchangeId)
expect((await fixedRate.getExchange(exchangeId)).withMint).to.equal(true)
})
it('#generate exchangeId - should generate a specific exchangeId', async () => {
expect(await fixedRate.generateExchangeId(addresses.MockUSDC, dtAddress)).to.equal(
@ -564,8 +562,8 @@ describe('Fixed Rate unit test', () => {
})
it('#getDatatokenSupply - should get the dt supply in the exchange', async () => {
// exchange owner hasn't approved any DT for sell
expect(await fixedRate.getDatatokenSupply(exchangeId)).to.equal('0.0')
// fre has mint rights
expect(parseFloat(await fixedRate.getDatatokenSupply(exchangeId))).to.gt(0)
})
it('#getBasetokenSupply - should get the bt supply in the exchange', async () => {
@ -594,15 +592,7 @@ describe('Fixed Rate unit test', () => {
dtAddress,
await exchangeOwner.getAddress(),
'1000',
await exchangeOwner.getAddress()
)
await approve(
exchangeOwner,
config,
await exchangeOwner.getAddress(),
dtAddress,
addresses.FixedPrice,
'1000'
fixedRate.address
)
// user1 gets 100 USDC so he can buy DTs
await transfer(
@ -709,8 +699,8 @@ describe('Fixed Rate unit test', () => {
expect((await fixedRate.getExchange(exchangeId)).dtBalance).to.equal('10.0')
// no BTs in the contract (except for the fees, but not accounted here)
expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('0.0')
// DT supply is back at 1000 (exchange Owner allowance + dt balance in the fixed rate)
expect(await fixedRate.getDatatokenSupply(exchangeId)).to.equal('1000.0')
// DT supply is huge, cause fre has mint rights
expect(parseFloat(await fixedRate.getDatatokenSupply(exchangeId))).to.gt(1000)
})
it('#getExchange - should return exchange details', async () => {
@ -721,10 +711,11 @@ describe('Fixed Rate unit test', () => {
expect(result.baseToken).to.equal(addresses.MockUSDC)
expect(result.datatoken).to.equal(dtAddress)
expect(result.exchangeOwner).to.equal(await exchangeOwner.getAddress())
expect(result.withMint).to.equal(false)
expect(result.withMint).to.equal(true)
expect(result.dtBalance).to.equal('10.0') // balance in the fixedRate
expect(result.btBalance).to.equal('0.0') // balance in the fixedRate
expect(result.dtSupply).to.equal('1000.0') // total supply available (owner allowance + dtBalance)
// since fre has mint rights, dtSupply is huge
expect(parseFloat(result.dtSupply)).to.gt(1000) // total supply available (owner allowance + dtBalance)
expect(result.btSupply).to.equal('0.0') // total supply available of baseToken in the contract
expect(result.fixedRate).to.equal('1.0')
})
@ -785,8 +776,8 @@ describe('Fixed Rate unit test', () => {
// no more dts in the contract
const result2 = await fixedRate.getExchange(exchangeId)
expect(result2.dtBalance).to.equal('0.0')
// Only allowance left since dt is ZERO
expect(result2.dtSupply).to.equal('990.0')
// since fre has mint rights, dtSupply is huge
expect(parseFloat(result2.dtSupply)).to.gt(990)
})
it('#updateMarketFee- should update Market fee if market fee collector', async () => {
@ -829,7 +820,7 @@ describe('Fixed Rate unit test', () => {
fixedRate: '1',
marketFee: '0.001',
allowedConsumer: ZERO_ADDRESS,
withMint: false
withMint: true
}
dtParams.feeToken = addresses.MockDAI
@ -871,7 +862,7 @@ describe('Fixed Rate unit test', () => {
fixedRate: '1',
marketFee: '0.001',
allowedConsumer: ZERO_ADDRESS,
withMint: false
withMint: true
}
dtParams.feeToken = addresses.MockUSDC

View File

@ -132,7 +132,7 @@ describe('Nft Factory test', () => {
fixedRate: '1',
marketFee: FEE,
allowedConsumer: await user1.getAddress(),
withMint: false
withMint: true
}
const tx = await nftFactory.createNftWithDatatokenWithFixedRate(

View File

@ -130,7 +130,7 @@ describe('Router unit test', () => {
fixedRate: RATE,
marketFee: FEE,
allowedConsumer: ZERO_ADDRESS,
withMint: false
withMint: true
}
const nftFactory = new NftFactory(addresses.ERC721Factory, factoryOwner)