fix: incorrect looks rare creator royalties (#5392)
* properly show LR royalties in grid * add LR royalty to total return calculation * common LR basis points const Co-authored-by: Charles Bachmeier <charlie@genie.xyz>
This commit is contained in:
parent
ef964ab120
commit
588567b900
@ -2,7 +2,7 @@ import type { JsonRpcSigner, Web3Provider } from '@ethersproject/providers'
|
|||||||
import { LOOKSRARE_MARKETPLACE_CONTRACT, X2Y2_TRANSFER_CONTRACT } from 'nft/queries'
|
import { LOOKSRARE_MARKETPLACE_CONTRACT, X2Y2_TRANSFER_CONTRACT } from 'nft/queries'
|
||||||
import { OPENSEA_CROSS_CHAIN_CONDUIT } from 'nft/queries/openSea'
|
import { OPENSEA_CROSS_CHAIN_CONDUIT } from 'nft/queries/openSea'
|
||||||
import { AssetRow, CollectionRow, ListingMarket, ListingRow, ListingStatus, WalletAsset } from 'nft/types'
|
import { AssetRow, CollectionRow, ListingMarket, ListingRow, ListingStatus, WalletAsset } from 'nft/types'
|
||||||
import { approveCollection, signListing } from 'nft/utils/listNfts'
|
import { approveCollection, LOOKS_RARE_CREATOR_BASIS_POINTS, signListing } from 'nft/utils/listNfts'
|
||||||
import { Dispatch } from 'react'
|
import { Dispatch } from 'react'
|
||||||
|
|
||||||
export const updateStatus = ({
|
export const updateStatus = ({
|
||||||
@ -124,11 +124,11 @@ export const getTotalEthValue = (sellAssets: WalletAsset[]) => {
|
|||||||
const total = sellAssets.reduce((total, asset: WalletAsset) => {
|
const total = sellAssets.reduce((total, asset: WalletAsset) => {
|
||||||
if (asset.newListings?.length) {
|
if (asset.newListings?.length) {
|
||||||
const maxListing = asset.newListings.reduce((a, b) => ((a.price ?? 0) > (b.price ?? 0) ? a : b))
|
const maxListing = asset.newListings.reduce((a, b) => ((a.price ?? 0) > (b.price ?? 0) ? a : b))
|
||||||
return (
|
// LooksRare is a unique case where creator royalties are a flat 0.5% or 50 basis points
|
||||||
total +
|
const maxFee =
|
||||||
(maxListing.price ?? 0) -
|
maxListing.marketplace.fee +
|
||||||
(maxListing.price ?? 0) * ((maxListing.marketplace.fee + asset.basisPoints / 100) / 100)
|
(maxListing.marketplace.name === 'LooksRare' ? LOOKS_RARE_CREATOR_BASIS_POINTS : asset.basisPoints) / 100
|
||||||
)
|
return total + (maxListing.price ?? 0) - (maxListing.price ?? 0) * (maxFee / 100)
|
||||||
}
|
}
|
||||||
return total
|
return total
|
||||||
}, 0)
|
}, 0)
|
||||||
|
@ -6,6 +6,7 @@ import { NumericInput } from 'nft/components/layout/Input'
|
|||||||
import { badge, body, bodySmall, subheadSmall } from 'nft/css/common.css'
|
import { badge, body, bodySmall, subheadSmall } from 'nft/css/common.css'
|
||||||
import { useSellAsset } from 'nft/hooks'
|
import { useSellAsset } from 'nft/hooks'
|
||||||
import { DropDownOption, ListingMarket, ListingWarning, WalletAsset } from 'nft/types'
|
import { DropDownOption, ListingMarket, ListingWarning, WalletAsset } from 'nft/types'
|
||||||
|
import { LOOKS_RARE_CREATOR_BASIS_POINTS } from 'nft/utils'
|
||||||
import { formatEth, formatUsdPrice } from 'nft/utils/currency'
|
import { formatEth, formatUsdPrice } from 'nft/utils/currency'
|
||||||
import { fetchPrice } from 'nft/utils/fetchPrice'
|
import { fetchPrice } from 'nft/utils/fetchPrice'
|
||||||
import { Dispatch, FormEvent, useEffect, useMemo, useRef, useState } from 'react'
|
import { Dispatch, FormEvent, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
@ -311,7 +312,12 @@ const MarketplaceRow = ({
|
|||||||
|
|
||||||
const marketplaceFee = selectedMarkets.length > 0 ? maxMarketFee(selectedMarkets) : 0
|
const marketplaceFee = selectedMarkets.length > 0 ? maxMarketFee(selectedMarkets) : 0
|
||||||
const price = showGlobalPrice ? globalPrice : listPrice
|
const price = showGlobalPrice ? globalPrice : listPrice
|
||||||
const feeInEth = price && (price * (asset.basisPoints * 0.01 + marketplaceFee)) / 100
|
// LooksRare is a unique case where royalties for creators are a flat 0.5% or 50 basis points
|
||||||
|
const royalties =
|
||||||
|
(selectedMarkets.length === 1 && selectedMarkets[0].name === 'LooksRare'
|
||||||
|
? LOOKS_RARE_CREATOR_BASIS_POINTS
|
||||||
|
: asset.basisPoints) * 0.01
|
||||||
|
const feeInEth = price && (price * (royalties + marketplaceFee)) / 100
|
||||||
const userReceives = price && feeInEth && price - feeInEth
|
const userReceives = price && feeInEth && price - feeInEth
|
||||||
const profit = userReceives && asset.lastPrice && userReceives - asset.lastPrice
|
const profit = userReceives && asset.lastPrice && userReceives - asset.lastPrice
|
||||||
const profitPercent = profit && asset.lastPrice && Math.round(profit && (profit / asset.lastPrice) * 100)
|
const profitPercent = profit && asset.lastPrice && Math.round(profit && (profit / asset.lastPrice) * 100)
|
||||||
@ -430,7 +436,7 @@ const MarketplaceRow = ({
|
|||||||
</Row>
|
</Row>
|
||||||
<Row flex="1" display={{ sm: 'none', md: 'flex' }}>
|
<Row flex="1" display={{ sm: 'none', md: 'flex' }}>
|
||||||
<Box className={body} color="textSecondary" width="full" textAlign="right">
|
<Box className={body} color="textSecondary" width="full" textAlign="right">
|
||||||
{(asset.basisPoints * 0.01).toFixed(1)}%
|
{royalties.toFixed(1)}%
|
||||||
</Box>
|
</Box>
|
||||||
</Row>
|
</Row>
|
||||||
<Row style={{ flex: '1.5' }} display={{ sm: 'none', md: 'flex' }}>
|
<Row style={{ flex: '1.5' }} display={{ sm: 'none', md: 'flex' }}>
|
||||||
|
@ -25,6 +25,8 @@ import { INVERSE_BASIS_POINTS, OPENSEA_DEFAULT_FEE, OPENSEA_FEE_ADDRESS } from '
|
|||||||
import { ListingMarket, ListingStatus, WalletAsset } from '../types'
|
import { ListingMarket, ListingStatus, WalletAsset } from '../types'
|
||||||
import { createSellOrder, encodeOrder, OfferItem, OrderPayload, signOrderData } from './x2y2'
|
import { createSellOrder, encodeOrder, OfferItem, OrderPayload, signOrderData } from './x2y2'
|
||||||
|
|
||||||
|
export const LOOKS_RARE_CREATOR_BASIS_POINTS = 50
|
||||||
|
|
||||||
export const ListingMarkets: ListingMarket[] = [
|
export const ListingMarkets: ListingMarket[] = [
|
||||||
{
|
{
|
||||||
name: 'X2Y2',
|
name: 'X2Y2',
|
||||||
|
Loading…
Reference in New Issue
Block a user