mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
merge v4 into v4-c2d
This commit is contained in:
commit
ea6a350796
@ -38,7 +38,7 @@ function MarketMetadataProvider({
|
||||
chainId: appConfig.chainIdsSupported[i],
|
||||
approvedTokens: response.data?.opc.approvedTokens,
|
||||
swapApprovedFee: response.data?.opc.swapOceanFee,
|
||||
swapNotApprovedFee: response.data.opc.swapNonOceanFee
|
||||
swapNotApprovedFee: response.data?.opc.swapNonOceanFee
|
||||
} as OpcFee)
|
||||
}
|
||||
setOpcFees(opcData)
|
||||
|
@ -67,10 +67,10 @@ function PoolProvider({ children }: { children: ReactNode }): ReactElement {
|
||||
poolInfoShares
|
||||
)
|
||||
|
||||
// Pool share in %.
|
||||
// Pool share in %. We double it to compensate for ss bot
|
||||
const poolSharePercentage = new Decimal(poolInfoShares)
|
||||
.dividedBy(new Decimal(response.poolData.totalShares))
|
||||
.mul(100)
|
||||
.mul(200)
|
||||
.toFixed(2)
|
||||
|
||||
setUserHasAddedLiquidity(Number(poolSharePercentage) > 0)
|
||||
@ -143,10 +143,10 @@ function PoolProvider({ children }: { children: ReactNode }): ReactElement {
|
||||
)
|
||||
return
|
||||
|
||||
// Pool share tokens.
|
||||
// Pool share tokens. We double it to compensate for ss bot
|
||||
const poolSharePercentage = new Decimal(poolData.shares[0]?.shares)
|
||||
.dividedBy(poolInfo.totalPoolTokens)
|
||||
.mul(100)
|
||||
.mul(200)
|
||||
.toFixed(2)
|
||||
|
||||
const ownerLiquidity = calcSingleOutGivenPoolIn(
|
||||
|
@ -157,14 +157,11 @@ function getAccessDetailsFromTokenPrice(
|
||||
timeout?: number
|
||||
): AccessDetails {
|
||||
const accessDetails = {} as AccessDetails
|
||||
if (
|
||||
tokenPrice &&
|
||||
timeout &&
|
||||
tokenPrice.orders &&
|
||||
tokenPrice.orders.length > 0
|
||||
) {
|
||||
if (tokenPrice && tokenPrice.orders && tokenPrice.orders.length > 0) {
|
||||
const order = tokenPrice.orders[0]
|
||||
accessDetails.isOwned = Date.now() / 1000 - order.createdTimestamp < timeout
|
||||
// asset is owned if there is an order and asset has timeout 0 (forever) or if the condition is valid
|
||||
accessDetails.isOwned =
|
||||
timeout === 0 || Date.now() / 1000 - order.createdTimestamp < timeout
|
||||
accessDetails.validOrderTx = order.tx
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,9 @@ export default function Download({
|
||||
useEffect(() => {
|
||||
if (!asset?.accessDetails) return
|
||||
|
||||
setIsOwned(asset?.accessDetails?.isOwned)
|
||||
setValidOrderTx(asset?.accessDetails?.validOrderTx)
|
||||
asset?.accessDetails?.isOwned && setIsOwned(asset?.accessDetails?.isOwned)
|
||||
asset?.accessDetails?.validOrderTx &&
|
||||
setValidOrderTx(asset?.accessDetails?.validOrderTx)
|
||||
|
||||
// get full price and fees
|
||||
async function init() {
|
||||
@ -166,7 +167,6 @@ export default function Download({
|
||||
if (!orderTx) {
|
||||
throw new Error()
|
||||
}
|
||||
|
||||
setIsOwned(true)
|
||||
setValidOrderTx(orderTx.transactionHash)
|
||||
}
|
||||
|
@ -87,6 +87,10 @@ export default function Remove({
|
||||
|
||||
const getValues = useRef(
|
||||
debounce(async (poolInstance, id, poolInfo, newAmountPoolShares) => {
|
||||
if (newAmountPoolShares === '0') {
|
||||
setAmountOcean('0')
|
||||
return
|
||||
}
|
||||
const newAmountOcean = await poolInstance.calcSingleOutGivenPoolIn(
|
||||
id,
|
||||
poolInfo.baseTokenAddress,
|
||||
|
@ -3,7 +3,7 @@ import { usePool } from '@context/Pool'
|
||||
import Tooltip from '@shared/atoms/Tooltip'
|
||||
import ExplorerLink from '@shared/ExplorerLink'
|
||||
import PriceUnit from '@shared/Price/PriceUnit'
|
||||
import React from 'react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import Graph from '../Graph'
|
||||
import PoolSection from '../Section'
|
||||
import Token from '../../../../@shared/Token'
|
||||
@ -11,11 +11,27 @@ import content from '../../../../../../content/price.json'
|
||||
import styles from './index.module.css'
|
||||
import Update from './Update'
|
||||
import { useMarketMetadata } from '@context/MarketMetadata'
|
||||
import { OpcFeesQuery_opc as OpcFeesData } from '../../../../../@types/subgraph/OpcFeesQuery'
|
||||
import { getOpcFees } from '@utils/subgraph'
|
||||
import { useWeb3 } from '@context/Web3'
|
||||
import Decimal from 'decimal.js'
|
||||
|
||||
export default function PoolSections() {
|
||||
const { asset } = useAsset()
|
||||
const { poolData, poolInfo, poolInfoUser, poolInfoOwner } = usePool()
|
||||
const { getOpcFeeForToken } = useMarketMetadata()
|
||||
const { chainId } = useWeb3()
|
||||
const [oceanCommunitySwapFee, setOceanCommunitySwapFee] = useState<string>('')
|
||||
useEffect(() => {
|
||||
getOpcFees(chainId || 1).then((response: OpcFeesData) => {
|
||||
setOceanCommunitySwapFee(
|
||||
response?.swapOceanFee
|
||||
? new Decimal(response.swapOceanFee).mul(100).toString()
|
||||
: '0'
|
||||
)
|
||||
})
|
||||
}, [chainId])
|
||||
|
||||
return (
|
||||
<>
|
||||
<PoolSection className={styles.dataToken}>
|
||||
@ -119,10 +135,7 @@ export default function PoolSections() {
|
||||
/>
|
||||
<Token
|
||||
symbol="% OPC fee"
|
||||
balance={getOpcFeeForToken(
|
||||
poolInfo?.baseTokenAddress,
|
||||
asset?.chainId
|
||||
)}
|
||||
balance={oceanCommunitySwapFee}
|
||||
noIcon
|
||||
size="mini"
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user