You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
THEN fp.volume_factor/ (1+fp.volume_factor) *os.sell_amount
The formula is probably correct for buy orders: Suppose the volume without fees is Y. Then after adding a fee of X = 0.0015 * Y the sell amount is os.sell_amount = Y + X = (1 + 0.0015) * Y. From this observable amount we can reconstruct the fee as X = 0.0015 * Y = 0.0015 / (1 + 0.0015) * os.sell_amount.
For sell orders the formula is probably incorrect: If the sell amount without fees is Y then the fee is X = 0.0015 Y. The user still sends os.sell_amount = Y for a sell order. Thus the correct fee is reconstucted as X = 0.0015 * Y = 0.0015 * os.sell_amount.
Is this how the driver implements volume based fees @sunce86? If so, sell and buy orders could be treated in different cases (using a CASE statement) as is done for surplus based fees.
I think the code in this repo (and in dune-sync) for the computation of protocol fees based on volume contains an error.
solver-rewards/queries/orderbook/batch_rewards.sql
Lines 102 to 103 in 2bda2b1
The formula is probably correct for buy orders: Suppose the volume without fees is
Y
. Then after adding a fee ofX = 0.0015 * Y
the sell amount isos.sell_amount = Y + X = (1 + 0.0015) * Y
. From this observable amount we can reconstruct the fee asX = 0.0015 * Y = 0.0015 / (1 + 0.0015) * os.sell_amount
.For sell orders the formula is probably incorrect: If the sell amount without fees is
Y
then the fee isX = 0.0015 Y
. The user still sendsos.sell_amount = Y
for a sell order. Thus the correct fee is reconstucted asX = 0.0015 * Y = 0.0015 * os.sell_amount
.Is this how the driver implements volume based fees @sunce86? If so, sell and buy orders could be treated in different cases (using a
CASE
statement) as is done for surplus based fees.cc @harisang
The text was updated successfully, but these errors were encountered: