# sushi-rewards-spec <!-- @version: v0.1.0 @date: 08/11/2021 @license: CC-ND-NC-2.5 @note: naive implementation, expect changes --> [TOC] ## Rebate Calculations *Note*: naive implementation, expect changes bundleCost = mev bribe + bundleTxs[1,2,...] gasAllowance = mev bribe - bundleTxs[1,2,...] BundleTransactionGas[1,2,...] = Individual Gas Cost BundleId = The Block Number (or hash?) in which the bundle was included max_gasRebate = (BundleId(BundleTransactionGas[1,2,...])) ```json { "confidence": 80, "price": 150, "maxPriorityFeePerGas" :1.75, "maxFeePerGas": 100 } ``` ## Rebate Mechanism 1. Eligible transactions are rebated based on the 80th confidence interval for gas estimation pricing. 2. This is porportionally distributed based on transactional weight. *Note: a naive formula would consider pairings, then slippage tolernance and finally transactional amount* 3. The amount of compensation is the remainder less fees to miners and network operational transactional costs. 4. Compensation payouts occur no later than a half hour ## Glossary and Definitions **Atomic arbitrage profit (aarb)**: is defined as the gain of two atomically executed arbitrage trades $TA$ and $TB$ on exchange $A$ and $B$. **Non-atomic arbitrage profit (naarb)**: is defined as the arbitrage gain, if $TA$ executes first, and $TB$’s execution follows after $i$ intermediary transactions. **Holding value ($Hv$)**: is defined as the change in the averaged price of the given asset pair on the two exchanges, which represents the asset value change during the non-atomic execution period. **Borrowing Capacity ($Bc$)**: Refers to the total value that a borrower is allowed to request from a lending pool, given its collateral amount. For each collateral asset 𝑖 of a borrower, its borrowing capacity is defined in Equation 3. $$ Bc =βˆ‘οΈ 𝑉 π‘Žπ‘™π‘’π‘’ π‘œπ‘“ πΆπ‘œπ‘™π‘™π‘Žπ‘‘π‘’π‘Ÿal Γ— LT𝑖 $$ **Health Factor ($Hhf$)**: The health factor measures the collateralization status of a position, defined as the ratio of the borrowing capacity over the outstanding debts (cf. Equation 4). $$ Hhf = BC / βˆ‘οΈ π‘‰π‘Žπ‘™π‘’π‘’ π‘œπ‘“ 𝐷𝑒𝑏𝑑t $$ **MVI**: Mininumal Profitable Viable Input **Unexpected Price Slippage **\((P- E [P]):\) is the difference between \(P\) and \(E [P]\). **Unexpected Slippage Rate** \(\left(\frac{P- E [P]}{ E [P]}\right):\) is \(\quad\) the unexpected slippage over the expected price. **Expected Execution Price**: $E [P]$ When a liquidity taker issues a trade on $X / Y,$ the taker wishes to execute the trade with the expected execution price $E [P]$ (based on the AMM algorithm and $X / Y$ state), given the expected slippage. **Execution Price**: $P$ During the time difference between a liquidity taker issuing a transaction, and the transaction being executed (e.g. mined in a block), the state of the AMM market $X / Y$ may change. This state change may induce unexpected slippage resulting in an execution price $P \neq E [P]$. **Unexpected Price Slippage**: $P- E [P]$ is the difference between $P$ and $E [P]$. Unexpected Slippage Rate $\left(\frac{P- E [P]}{ E [P]}\right)$ is $\quad$ the unexpected slippage over the expected price. $$ REV _{M}^{\text {Flashbots }} \gtrsim s_{ MEV } \cdot\left(g_{ MEV }-g_{\text {tail }}\right)+V_{\text {direct }}, $$ ' ' ![](https://cdn.mathpix.com/snip/images/Qx56XacZmtiogmmFUeJTV71BVcNIWuzApYTX_H1DpiM.original.fullsize.png) Multi-Dex Optimal Quantity Ward Bradt Let $0<\gamma<1$ be the trading fee. Let $A, B$ be the reserves of a given pool. We want to sell quantity $b>0$ of token $B .$ The quantity $a$ of token $A$ received is $$ a(A, B, b)=\frac{\gamma A b}{B+\gamma b} $$ Assume there are $n$ pools for the pair $\mathrm{A} / \mathrm{B}$ with the common fee $\gamma .$ We want to maximize the amount of $A$ we get for a fixed amount $T$ of $B$. For $i \in\{1, \ldots, n\}$, let the constants $A_{i}, B_{i}$ be the reserves of tokens $A, B$ in pool $i$. Let $b_{i}$ be the amount of token $B$ we sell in pool $i$ and $a_{i}$ be the amount of token $A$ we receive on pool $i$. Then $a_{i}\left(b_{i}\right)=f\left(A_{i}, B_{i}, b_{i}\right)$ and $T=\sum_{i=1}^{n} b_{i} .$ We use Lagrangian optimization. Define the objective $f\left(b_{1}, \ldots, b_{n}\right)=\sum_{i=1}^{n} a_{i}\left(b_{i}\right) .$ Define the constraint $g\left(b_{1}, \ldots, b_{n}\right)=\sum_{i=1}^{n} b_{i}-T$ Doing some arithmetic, we get the system of equalities $$ \begin{aligned} b_{i} &=\frac{1}{\gamma}\left(\sqrt{\frac{\gamma A_{i} B_{i}}{\lambda}}-B_{i}\right) \\ T &=\frac{1}{\gamma} \cdot \sum_{i=1}^{n} \sqrt{\frac{\gamma A_{i} B_{i}}{\lambda}}-B_{i} \end{aligned} $$ Solving gives us $$ \lambda=\left(\frac{\sum_{i=1}^{n} \sqrt{\gamma A_{i} B_{i}}}{\gamma T+\sum_{i=1}^{n} B_{i}}\right)^{2} $$ This implies $$ \begin{array}{l} b_{i}=\frac{1}{\gamma}\left(\sqrt{\gamma A_{i} B_{i}}\left(\frac{\gamma T+\sum_{j=1}^{n} B_{j}}{\sum_{j=1}^{n} \sqrt{\gamma A_{j} B_{j}}}\right)-B_{i}\right) \\ a_{i}=\sqrt{\gamma}\left(A_{i} \cdot \sqrt{A_{i} B_{i}}-B_{i} \frac{\sum_{j=1}^{n} \sqrt{A_{j} B_{j}}}{\gamma T+\sum_{j=1}^{n} B_{j}}\right) \end{array} $$ ## Appendix **Expected Execution Price** $(( E [P])$ When a liquidity taker issues a trade on \(X / Y,\) the taker wishes to execute the trade with the expected execution price \(E [P]\) (based on the AMM algorithm and \(X / Y\) state), given the expected slippage. **Execution Price**: $(P)$ During the time difference between a liquidity taker issuing a transaction, and the transaction being executed (e.g. mined in a block), the state of the AMM market \(X / Y\) may change. This state change may induce unexpected slippage resulting in an execution price \(P \neq E [P]\). $$ \operatorname{spread}_{\min }=\frac{\cos t_{\min t}(330)}{\text { profit }_{\text {free }}(330)}=\frac{11^{\prime} 993^{\prime} 334}{6^{\prime} 013^{\prime} 004}=1.9946 $$