Skip to content

Commit

Permalink
Turn decimals(x,y) y> 0 to double for implicit coercion with uint256
Browse files Browse the repository at this point in the history
  • Loading branch information
belen-pruvost committed Nov 10, 2023
1 parent 71ad1a1 commit 16deb0c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ SELECT
end as trade_type,
case
when a.seller = coalesce(minter.to, minter_superrare.to)
then cast(ROUND((0.03+0.15) * (a.price_raw)) as uint256) -- superrare takes fixed 3% fee + 15% commission on primary sales
else cast(ROUND(0.03 * (a.price_raw)) as uint256) -- fixed 3% fee
then cast(ROUND((double '0.03' + double '0.15') * (a.price_raw)) as uint256) -- superrare takes fixed 3% fee + 15% commission on primary sales
else cast(ROUND(double '0.03' * (a.price_raw)) as uint256) -- fixed 3% fee
end as platform_fee_amount_raw,
case
when a.seller = coalesce(minter.to, minter_superrare.to)
then uint256 '0'
else cast(ROUND(0.10 * (a.price_raw)) as uint256) -- fixed 10% royalty fee on secondary sales
else cast(ROUND(double '0.10' * (a.price_raw)) as uint256) -- fixed 10% royalty fee on secondary sales
end as royalty_fee_amount_raw,
cast(NULL as varbinary) as royalty_fee_address,
cast(NULL as varbinary) as platform_fee_address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ SELECT
src.evt_tx_hash as tx_hash,
t."from" AS tx_from,
t."to" AS tx_to,
CAST(COALESCE(src.price_raw, uint256 '0') * 0.025 as uint256) as platform_fee_amount_raw,
CAST(COALESCE(src.price_converted, 0) * 0.025 as double) as platform_fee_amount,
CAST(COALESCE(src.price_converted, 0) * p.price * 0.025 as double) as platform_fee_amount_usd,
CAST((COALESCE(src.price_raw, uint256 '0') * double '0.025') as uint256) as platform_fee_amount_raw,
CAST(COALESCE(src.price_converted, 0) * double '0.025' as double) as platform_fee_amount,
CAST(COALESCE(src.price_converted, 0) * p.price * double '0.025' as double) as platform_fee_amount_usd,
CAST(2.5 as double) as platform_fee_percentage,
CAST(NULL as uint256) as royalty_fee_amount_raw,
CAST(NULL as double) as royalty_fee_amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ WITH events AS (
buyer AS buyer,
seller AS seller,
askPrice AS amount_raw,
0.02 AS platform_fee_percentage,
double '0.02' AS platform_fee_percentage,
case when askPrice > uint256 '0' and (netPrice/cast(askPrice as double))<0.98 then (askPrice-netPrice)/cast(askPrice as double) - 0.02 else 0.0 end AS royalty_fee_percentage,
0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c AS currency_contract,
CASE when withBNB then 'BNB' else 'WBNB' end AS currency_symbol,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ SELECT 'arbitrum' AS blockchain
, sc.evt_tx_hash AS tx_hash
, at."from" AS tx_from
, at.to AS tx_to
, CAST(0.1*surplus_value AS uint256) AS platform_fee_amount_raw
, CAST(0.1*surplus_value/POWER(10, 18) AS double) AS platform_fee_amount
, CAST(pu.price*0.1*surplus_value/POWER(10, 18) AS double) AS platform_fee_amount_usd
, CAST(coalesce(100*(0.1*surplus_value/sc.value),0) AS double) AS platform_fee_percentage
, CAST(double '0.1'*surplus_value AS uint256) AS platform_fee_amount_raw
, CAST(double '0.1'*surplus_value/POWER(10, 18) AS double) AS platform_fee_amount
, CAST(pu.price*double '0.1'*surplus_value/POWER(10, 18) AS double) AS platform_fee_amount_usd
, CAST(coalesce(100*(double '0.1'*surplus_value/sc.value),0) AS double) AS platform_fee_percentage
, 'ETH' as royalty_fee_currency_symbol
, CAST(0.45*surplus_value AS uint256) AS royalty_fee_amount_raw
, CAST(0.45*surplus_value/POWER(10, 18) AS double) AS royalty_fee_amount
, CAST(pu.price*0.45*surplus_value/POWER(10, 18) AS double) AS royalty_fee_amount_usd
, CAST(coalesce(100*(0.45*surplus_value/sc.value),0) AS double) AS royalty_fee_percentage
, CAST(double '0.45'*surplus_value AS uint256) AS royalty_fee_amount_raw
, CAST(double '0.45'*surplus_value/POWER(10, 18) AS double) AS royalty_fee_amount
, CAST(pu.price*double '0.45'*surplus_value/POWER(10, 18) AS double) AS royalty_fee_amount_usd
, CAST(coalesce(100*(double '0.45'*surplus_value/sc.value),0) AS double) AS royalty_fee_percentage
, m._creator AS royalty_fee_receive_address
, sc.evt_index
, 'arbitrum-stealcam-' || cast(sc.evt_tx_hash as varchar)|| '-' || cast(sc.evt_index as varchar) AS unique_trade_id
Expand Down

0 comments on commit 16deb0c

Please sign in to comment.