mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
update to ocean.js.next.20 (#1099)
* update and fix fees * update lib * update aquarius endpoint * update lib and fix changes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
parent
d578c135d8
commit
60c5520548
@ -7,7 +7,7 @@ module.exports = {
|
|||||||
// return appConfig.metadataCacheUri
|
// return appConfig.metadataCacheUri
|
||||||
metadataCacheUri:
|
metadataCacheUri:
|
||||||
process.env.NEXT_PUBLIC_METADATACACHE_URI ||
|
process.env.NEXT_PUBLIC_METADATACACHE_URI ||
|
||||||
'https://aquariusv4.oceanprotocol.com',
|
'https://v4.aquarius.oceanprotocol.com',
|
||||||
|
|
||||||
// List of chainIds which metadata cache queries will return by default.
|
// List of chainIds which metadata cache queries will return by default.
|
||||||
// This preselects the Chains user preferences.
|
// This preselects the Chains user preferences.
|
||||||
|
7039
package-lock.json
generated
7039
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
|||||||
"@coingecko/cryptoformat": "^0.4.4",
|
"@coingecko/cryptoformat": "^0.4.4",
|
||||||
"@loadable/component": "^5.15.2",
|
"@loadable/component": "^5.15.2",
|
||||||
"@oceanprotocol/art": "^3.2.0",
|
"@oceanprotocol/art": "^3.2.0",
|
||||||
"@oceanprotocol/lib": "^1.0.0-next.17",
|
"@oceanprotocol/lib": "^1.0.0-next.20",
|
||||||
"@oceanprotocol/typographies": "^0.1.0",
|
"@oceanprotocol/typographies": "^0.1.0",
|
||||||
"@portis/web3": "^4.0.6",
|
"@portis/web3": "^4.0.6",
|
||||||
"@tippyjs/react": "^4.2.6",
|
"@tippyjs/react": "^4.2.6",
|
||||||
|
@ -262,12 +262,23 @@ export async function getOrderPriceAndFees(
|
|||||||
switch (accessDetails.type) {
|
switch (accessDetails.type) {
|
||||||
case 'dynamic': {
|
case 'dynamic': {
|
||||||
const poolPrice = await calculateBuyPrice(accessDetails, asset.chainId)
|
const poolPrice = await calculateBuyPrice(accessDetails, asset.chainId)
|
||||||
orderPriceAndFee.price = poolPrice
|
orderPriceAndFee.price = poolPrice.tokenAmount
|
||||||
|
orderPriceAndFee.liquidityProviderSwapFee =
|
||||||
|
poolPrice.liquidityProviderSwapFeeAmount
|
||||||
|
orderPriceAndFee.publisherMarketPoolSwapFee =
|
||||||
|
poolPrice.publishMarketSwapFeeAmount
|
||||||
|
orderPriceAndFee.consumeMarketPoolSwapFee =
|
||||||
|
poolPrice.consumeMarketSwapFeeAmount
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'fixed': {
|
case 'fixed': {
|
||||||
const fixed = await getFixedBuyPrice(accessDetails, asset.chainId)
|
const fixed = await getFixedBuyPrice(accessDetails, asset.chainId)
|
||||||
orderPriceAndFee.price = fixed.baseTokenAmount
|
orderPriceAndFee.price = fixed.baseTokenAmount
|
||||||
|
orderPriceAndFee.opcFee = fixed.oceanFeeAmount
|
||||||
|
orderPriceAndFee.publisherMarketFixedSwapFee = fixed.marketFeeAmount
|
||||||
|
// hack because we don't have it in contracts
|
||||||
|
orderPriceAndFee.consumeMarketFixedSwapFee = fixed.consumeMarketFeeAmount
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,12 @@ export async function order(
|
|||||||
const orderParams = {
|
const orderParams = {
|
||||||
consumer: accountId,
|
consumer: accountId,
|
||||||
serviceIndex: 0,
|
serviceIndex: 0,
|
||||||
_providerFees: initializeData.providerFee
|
_providerFee: initializeData.providerFee,
|
||||||
|
_consumeMarketFee: {
|
||||||
|
consumeMarketFeeAddress: appConfig.marketFeeAddress,
|
||||||
|
consumeMarketFeeAmount: appConfig.consumeMarketOrderFee,
|
||||||
|
consumeMarketFeeToken: config.oceanTokenAddress
|
||||||
|
}
|
||||||
} as OrderParams
|
} as OrderParams
|
||||||
|
|
||||||
// TODO: we need to approve provider fee
|
// TODO: we need to approve provider fee
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { approve, Pool } from '@oceanprotocol/lib'
|
import { approve, Pool, PoolPriceAndFees } from '@oceanprotocol/lib'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import { getSiteMetadata } from './siteConfig'
|
import { getSiteMetadata } from './siteConfig'
|
||||||
import { getDummyWeb3 } from './web3'
|
import { getDummyWeb3 } from './web3'
|
||||||
@ -11,13 +11,13 @@ import { AccessDetails } from 'src/@types/Price'
|
|||||||
* @param {AccessDetails} accessDetails
|
* @param {AccessDetails} accessDetails
|
||||||
* @param {Web3?} [web3]
|
* @param {Web3?} [web3]
|
||||||
* @param {number?} [chainId]
|
* @param {number?} [chainId]
|
||||||
* @return {Promise<PriceAndEstimation>}
|
* @return {Promise<PoolPriceAndFees>}
|
||||||
*/
|
*/
|
||||||
export async function calculateBuyPrice(
|
export async function calculateBuyPrice(
|
||||||
accessDetails: AccessDetails,
|
accessDetails: AccessDetails,
|
||||||
chainId?: number,
|
chainId?: number,
|
||||||
web3?: Web3
|
web3?: Web3
|
||||||
): Promise<string> {
|
): Promise<PoolPriceAndFees> {
|
||||||
if (!web3 && !chainId)
|
if (!web3 && !chainId)
|
||||||
throw new Error("web3 and chainId can't be undefined at the same time!")
|
throw new Error("web3 and chainId can't be undefined at the same time!")
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ export async function buyDtFromPool(
|
|||||||
accountId,
|
accountId,
|
||||||
accessDetails.baseToken.address,
|
accessDetails.baseToken.address,
|
||||||
accessDetails.addressOrId,
|
accessDetails.addressOrId,
|
||||||
dtPrice,
|
dtPrice.tokenAmount,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
const result = await pool.swapExactAmountOut(
|
const result = await pool.swapExactAmountOut(
|
||||||
@ -65,7 +65,7 @@ export async function buyDtFromPool(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
// this is just to be safe
|
// this is just to be safe
|
||||||
maxAmountIn: new Decimal(dtPrice).mul(10).toString(),
|
maxAmountIn: new Decimal(dtPrice.tokenAmount).mul(10).toString(),
|
||||||
swapMarketFee: appConfig.consumeMarketPoolSwapFee,
|
swapMarketFee: appConfig.consumeMarketPoolSwapFee,
|
||||||
tokenAmountOut: '1'
|
tokenAmountOut: '1'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user