diff --git a/package-lock.json b/package-lock.json index be6e59427..c08d9a33a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@coingecko/cryptoformat": "^0.4.4", "@loadable/component": "^5.15.2", "@oceanprotocol/art": "^3.2.0", - "@oceanprotocol/lib": "^1.0.0-next.42", + "@oceanprotocol/lib": "^1.0.0-next.44", "@oceanprotocol/typographies": "^0.1.0", "@portis/web3": "^4.0.7", "@tippyjs/react": "^4.2.6", @@ -4554,16 +4554,16 @@ "integrity": "sha512-aUQtg4m5hJlQ0u8C29O9TXJWcAenO3G9vP+vf6LNFkpTDOCMycN/F0SzHS89VNrvGUha8oTDEg7FAkfZBPv2WA==" }, "node_modules/@oceanprotocol/contracts": { - "version": "1.0.0-alpha.32", - "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.32.tgz", - "integrity": "sha512-gCHw4ZVnNjSozzCVT/cQiDqLNP0Xvy4fe+g5PKy8rwMR/h2rRW65Txi6wkb4HfZiUPKCdHbzpUFOwYfJFbW0Jw==" + "version": "1.0.0-alpha.34", + "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.34.tgz", + "integrity": "sha512-ZhNCakYbUpXrffpS98Hj0r5K70IzzTXNoYKBX4Ks3Qqc2T7mhXIxtakzygkM0lEk038ImWuzS2PAZKTATz+X2w==" }, "node_modules/@oceanprotocol/lib": { - "version": "1.0.0-next.42", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-1.0.0-next.42.tgz", - "integrity": "sha512-5me2upjrDBls4RfnMOwEMF4pTo225fFIl7TKuz1KH8+i44VnPtz0WXnqh8g6fKPcpthmIaYFc0krsF/sh9Y7Gg==", + "version": "1.0.0-next.44", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-1.0.0-next.44.tgz", + "integrity": "sha512-TXrHvY7+t7WSJXAVkSip0hp5byE8G4citJGirB5qJt34VGA+ujd+CoLU1bB/5gFSYH3eM56K4pcUPfCHZjeN3w==", "dependencies": { - "@oceanprotocol/contracts": "^1.0.0-alpha.32", + "@oceanprotocol/contracts": "^1.0.0-alpha.34", "bignumber.js": "^9.0.2", "cross-fetch": "^3.1.5", "crypto-js": "^4.1.1", @@ -41836,16 +41836,16 @@ "integrity": "sha512-aUQtg4m5hJlQ0u8C29O9TXJWcAenO3G9vP+vf6LNFkpTDOCMycN/F0SzHS89VNrvGUha8oTDEg7FAkfZBPv2WA==" }, "@oceanprotocol/contracts": { - "version": "1.0.0-alpha.32", - "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.32.tgz", - "integrity": "sha512-gCHw4ZVnNjSozzCVT/cQiDqLNP0Xvy4fe+g5PKy8rwMR/h2rRW65Txi6wkb4HfZiUPKCdHbzpUFOwYfJFbW0Jw==" + "version": "1.0.0-alpha.34", + "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.34.tgz", + "integrity": "sha512-ZhNCakYbUpXrffpS98Hj0r5K70IzzTXNoYKBX4Ks3Qqc2T7mhXIxtakzygkM0lEk038ImWuzS2PAZKTATz+X2w==" }, "@oceanprotocol/lib": { - "version": "1.0.0-next.42", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-1.0.0-next.42.tgz", - "integrity": "sha512-5me2upjrDBls4RfnMOwEMF4pTo225fFIl7TKuz1KH8+i44VnPtz0WXnqh8g6fKPcpthmIaYFc0krsF/sh9Y7Gg==", + "version": "1.0.0-next.44", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-1.0.0-next.44.tgz", + "integrity": "sha512-TXrHvY7+t7WSJXAVkSip0hp5byE8G4citJGirB5qJt34VGA+ujd+CoLU1bB/5gFSYH3eM56K4pcUPfCHZjeN3w==", "requires": { - "@oceanprotocol/contracts": "^1.0.0-alpha.32", + "@oceanprotocol/contracts": "^1.0.0-alpha.34", "bignumber.js": "^9.0.2", "cross-fetch": "^3.1.5", "crypto-js": "^4.1.1", diff --git a/package.json b/package.json index 9dce6cc87..582cda424 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@coingecko/cryptoformat": "^0.4.4", "@loadable/component": "^5.15.2", "@oceanprotocol/art": "^3.2.0", - "@oceanprotocol/lib": "^1.0.0-next.42", + "@oceanprotocol/lib": "^1.0.0-next.44", "@oceanprotocol/typographies": "^0.1.0", "@portis/web3": "^4.0.7", "@tippyjs/react": "^4.2.6", diff --git a/src/@utils/accessDetailsAndPricing.ts b/src/@utils/accessDetailsAndPricing.ts index 319aa712e..dbdb5c38b 100644 --- a/src/@utils/accessDetailsAndPricing.ts +++ b/src/@utils/accessDetailsAndPricing.ts @@ -16,7 +16,7 @@ import { AccessDetails, OrderPriceAndFees } from 'src/@types/Price' import Decimal from 'decimal.js' import { consumeMarketOrderFee } from '../../app.config' -const TokensPriceQuery = gql` +const tokensPriceQuery = gql` query TokensPriceQuery($datatokenIds: [ID!], $account: String) { tokens(where: { id_in: $datatokenIds }) { id @@ -81,7 +81,7 @@ const TokensPriceQuery = gql` } } ` -const TokenPriceQuery = gql` +const tokenPriceQuery = gql` query TokenPriceQuery($datatokenId: ID!, $account: String) { token(id: $datatokenId) { id @@ -298,11 +298,10 @@ export async function getOrderPriceAndFees( } /** - * @param {number} chain + * @param {number} chainId * @param {string} datatokenAddress * @param {number} timeout timout of the service, this is needed to return order details * @param {string} account account that wants to buy, is needed to return order details - * @param {bool} includeOrderPriceAndFees if false price will be spot price (pool) and rate (fre), if true you will get the order price including fees !! fees not yet done * @returns {Promise} */ export async function getAccessDetails( @@ -317,7 +316,7 @@ export async function getAccessDetails( TokenPriceQuery, { datatokenId: string; account: string } > = await fetchData( - TokenPriceQuery, + tokenPriceQuery, { datatokenId: datatokenAddress.toLowerCase(), account: account?.toLowerCase() @@ -360,7 +359,7 @@ export async function getAccessDetailsForAssets( TokensPriceQuery, { datatokenIds: [string]; account: string } > = await fetchData( - TokensPriceQuery, + tokensPriceQuery, { datatokenIds: chainAssetLists[chainKey], account: account?.toLowerCase() diff --git a/src/@utils/pool.ts b/src/@utils/pool.ts index b81b5141d..6db2cb590 100644 --- a/src/@utils/pool.ts +++ b/src/@utils/pool.ts @@ -144,17 +144,13 @@ export function calcSingleOutGivenPoolIn( ): string { const tokenLiquidityD = new Decimal(tokenLiquidity) const poolSupplyD = new Decimal(poolSupply) - const poolShareAmountD = new Decimal(poolShareAmount) - + const poolShareAmountD = new Decimal(poolShareAmount).mul(2) const newPoolSupply = poolSupplyD.sub(poolShareAmountD) const poolRatio = newPoolSupply.div(poolSupplyD) - const tokenOutRatio = poolRatio.pow(2) + const tokenOutRatio = new Decimal(1).sub(poolRatio) const newTokenBalanceOut = tokenLiquidityD.mul(tokenOutRatio) - - const tokensOut = tokenLiquidityD.sub(newTokenBalanceOut) - - return tokensOut.toString() + return newTokenBalanceOut.toString() } /** diff --git a/src/@utils/subgraph.ts b/src/@utils/subgraph.ts index 8a87e3ded..2972980dd 100644 --- a/src/@utils/subgraph.ts +++ b/src/@utils/subgraph.ts @@ -194,7 +194,7 @@ const OpcFeesQuery = gql` opc(id: $id) { swapOceanFee swapNonOceanFee - consumeFee + orderFee providerFee } }