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:
Charles Bachmeier 2022-11-23 14:14:26 -08:00 committed by GitHub
parent ef964ab120
commit 588567b900
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 8 deletions

@ -2,7 +2,7 @@ import type { JsonRpcSigner, Web3Provider } from '@ethersproject/providers'
import { LOOKSRARE_MARKETPLACE_CONTRACT, X2Y2_TRANSFER_CONTRACT } from 'nft/queries'
import { OPENSEA_CROSS_CHAIN_CONDUIT } from 'nft/queries/openSea'
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'
export const updateStatus = ({
@ -124,11 +124,11 @@ export const getTotalEthValue = (sellAssets: WalletAsset[]) => {
const total = sellAssets.reduce((total, asset: WalletAsset) => {
if (asset.newListings?.length) {
const maxListing = asset.newListings.reduce((a, b) => ((a.price ?? 0) > (b.price ?? 0) ? a : b))
return (
total +
(maxListing.price ?? 0) -
(maxListing.price ?? 0) * ((maxListing.marketplace.fee + asset.basisPoints / 100) / 100)
)
// LooksRare is a unique case where creator royalties are a flat 0.5% or 50 basis points
const maxFee =
maxListing.marketplace.fee +
(maxListing.marketplace.name === 'LooksRare' ? LOOKS_RARE_CREATOR_BASIS_POINTS : asset.basisPoints) / 100
return total + (maxListing.price ?? 0) - (maxListing.price ?? 0) * (maxFee / 100)
}
return total
}, 0)

@ -6,6 +6,7 @@ import { NumericInput } from 'nft/components/layout/Input'
import { badge, body, bodySmall, subheadSmall } from 'nft/css/common.css'
import { useSellAsset } from 'nft/hooks'
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 { fetchPrice } from 'nft/utils/fetchPrice'
import { Dispatch, FormEvent, useEffect, useMemo, useRef, useState } from 'react'
@ -311,7 +312,12 @@ const MarketplaceRow = ({
const marketplaceFee = selectedMarkets.length > 0 ? maxMarketFee(selectedMarkets) : 0
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 profit = userReceives && asset.lastPrice && userReceives - asset.lastPrice
const profitPercent = profit && asset.lastPrice && Math.round(profit && (profit / asset.lastPrice) * 100)
@ -430,7 +436,7 @@ const MarketplaceRow = ({
</Row>
<Row flex="1" display={{ sm: 'none', md: 'flex' }}>
<Box className={body} color="textSecondary" width="full" textAlign="right">
{(asset.basisPoints * 0.01).toFixed(1)}%
{royalties.toFixed(1)}%
</Box>
</Row>
<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 { createSellOrder, encodeOrder, OfferItem, OrderPayload, signOrderData } from './x2y2'
export const LOOKS_RARE_CREATOR_BASIS_POINTS = 50
export const ListingMarkets: ListingMarket[] = [
{
name: 'X2Y2',