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
|
||||
metadataCacheUri:
|
||||
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.
|
||||
// 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",
|
||||
"@loadable/component": "^5.15.2",
|
||||
"@oceanprotocol/art": "^3.2.0",
|
||||
"@oceanprotocol/lib": "^1.0.0-next.17",
|
||||
"@oceanprotocol/lib": "^1.0.0-next.20",
|
||||
"@oceanprotocol/typographies": "^0.1.0",
|
||||
"@portis/web3": "^4.0.6",
|
||||
"@tippyjs/react": "^4.2.6",
|
||||
|
@ -262,12 +262,23 @@ export async function getOrderPriceAndFees(
|
||||
switch (accessDetails.type) {
|
||||
case 'dynamic': {
|
||||
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
|
||||
}
|
||||
case 'fixed': {
|
||||
const fixed = await getFixedBuyPrice(accessDetails, asset.chainId)
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,12 @@ export async function order(
|
||||
const orderParams = {
|
||||
consumer: accountId,
|
||||
serviceIndex: 0,
|
||||
_providerFees: initializeData.providerFee
|
||||
_providerFee: initializeData.providerFee,
|
||||
_consumeMarketFee: {
|
||||
consumeMarketFeeAddress: appConfig.marketFeeAddress,
|
||||
consumeMarketFeeAmount: appConfig.consumeMarketOrderFee,
|
||||
consumeMarketFeeToken: config.oceanTokenAddress
|
||||
}
|
||||
} as OrderParams
|
||||
|
||||
// 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 { getSiteMetadata } from './siteConfig'
|
||||
import { getDummyWeb3 } from './web3'
|
||||
@ -11,13 +11,13 @@ import { AccessDetails } from 'src/@types/Price'
|
||||
* @param {AccessDetails} accessDetails
|
||||
* @param {Web3?} [web3]
|
||||
* @param {number?} [chainId]
|
||||
* @return {Promise<PriceAndEstimation>}
|
||||
* @return {Promise<PoolPriceAndFees>}
|
||||
*/
|
||||
export async function calculateBuyPrice(
|
||||
accessDetails: AccessDetails,
|
||||
chainId?: number,
|
||||
web3?: Web3
|
||||
): Promise<string> {
|
||||
): Promise<PoolPriceAndFees> {
|
||||
if (!web3 && !chainId)
|
||||
throw new Error("web3 and chainId can't be undefined at the same time!")
|
||||
|
||||
@ -52,7 +52,7 @@ export async function buyDtFromPool(
|
||||
accountId,
|
||||
accessDetails.baseToken.address,
|
||||
accessDetails.addressOrId,
|
||||
dtPrice,
|
||||
dtPrice.tokenAmount,
|
||||
false
|
||||
)
|
||||
const result = await pool.swapExactAmountOut(
|
||||
@ -65,7 +65,7 @@ export async function buyDtFromPool(
|
||||
},
|
||||
{
|
||||
// this is just to be safe
|
||||
maxAmountIn: new Decimal(dtPrice).mul(10).toString(),
|
||||
maxAmountIn: new Decimal(dtPrice.tokenAmount).mul(10).toString(),
|
||||
swapMarketFee: appConfig.consumeMarketPoolSwapFee,
|
||||
tokenAmountOut: '1'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user