Skip to content

Commit

Permalink
Updated swap spec to use amount of asset fee removed instead of perce…
Browse files Browse the repository at this point in the history
…ntage, to match implementation
  • Loading branch information
poliwop committed Jan 15, 2025
1 parent 5855866 commit 7f7b2a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 4 additions & 3 deletions hydradx/spec/Swap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"- $f_A$: asset fee\n",
"- $f_Q$: h2o fee\n",
"- $m$: h2o fee burn percentage\n",
"- $m_A$: asset fee removal percentage"
"- $m_A$: asset fee removal percentage\n",
"- $F_j \\geq 0$: asset fee removed from Omnipool"
],
"id": "8ad547f2eb9ee196"
},
Expand Down Expand Up @@ -75,7 +76,7 @@
"source": [
"$$\n",
"\\begin{align}\n",
"\\Delta R_j &= -\\Delta r_j\\left(1+\\frac{f_Am_A}{1-f_A}\\right)\\\\\n",
"\\Delta R_j &= -\\Delta r_j - F_j\\\\\n",
"\\tilde{\\Delta Q_j} &= Q_j\\frac{\\Delta r_j}{R_j(1 - f_A) - \\Delta r_j}\\\\\n",
"\\tilde{\\Delta Q_i} &= -\\frac{\\tilde{\\Delta Q_j}}{1 - f_Q}\\\\\n",
"\\Delta R_i &= R_i\\frac{- \\tilde{\\Delta Q_i}}{Q_i + \\tilde{\\Delta Q_i}}\\\\\n",
Expand Down Expand Up @@ -106,8 +107,8 @@
"\\Delta Q_i &= Q_i\\frac{- \\Delta R_i}{R_i + \\Delta R_i}\\\\\n",
"\\Delta Q_j' &= -\\Delta Q_i (1 - f_Q)\\\\\n",
"\\Delta R_j' &= R_j\\frac{- \\Delta Q_j'}{Q_j + \\Delta Q_j'}\\\\\n",
"\\Delta R_j &= \\Delta R_j'(1 - f_A(1-m_A))\\\\\n",
"\\Delta r_j &= -\\Delta R_j'(1 - f_A)\\\\\n",
"\\Delta R_j &= -\\Delta r_j - F_j\\\\\n",
"\\Delta Q_j^m &= f_A\\frac{(Q_j + \\Delta Q_j')\\Delta Q_j'}{Q_j}\\\\\n",
"\\Delta Q_j &= \\Delta Q_j' + \\Delta Q_j^m\n",
"\\end{align}\n",
Expand Down
12 changes: 10 additions & 2 deletions hydradx/spec/SwapLRNA.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"\\Delta R_i' &= R_i\\frac{\\Delta q^\\alpha}{Q_i -\\Delta q^\\alpha}\\\\\n",
"\\Delta Q_m &= -\\frac{f_A \\Delta q^\\alpha(Q_i -\\Delta q^\\alpha)}{Q_i}\\\\\n",
"\\Delta r_i^\\alpha &= -\\Delta R_i'(1-f_A)\\\\\n",
"\\Delta R_i &= \\Delta R_i'(1-f_A(1-m_A))\\\\\n",
"\\Delta R_i &= -\\Delta r_i^\\alpha - F_i\\\\\n",
"\\Delta Q_i &= -\\Delta q^\\alpha + \\Delta Q_m\\\\\n",
"\\end{align}\n",
"$$"
Expand All @@ -99,7 +99,7 @@
"source": [
"$$\n",
"\\begin{align}\n",
"\\Delta R_i &= -\\Delta r_i^\\alpha\\left(1+\\frac{f_Am_A}{1-f_A}\\right)\\\\\n",
"\\Delta R_i &= -\\Delta r_i^\\alpha - F_i\\\\\n",
"\\Delta q^\\alpha &= Q_i\\frac{-\\Delta r_i^\\alpha}{R_i(1 - f_A) - \\Delta r_i^\\alpha}\\\\\n",
"\\Delta Q_m &= \\frac{f_A(Q_i -\\Delta q^\\alpha)\\Delta r_i^\\alpha}{R_i(1 - f_A) - \\Delta r_i^\\alpha}\\\\\n",
"\\Delta Q_i &= -\\Delta q^\\alpha + \\Delta Q_m\\\\\n",
Expand All @@ -108,6 +108,14 @@
"\n",
"If $-\\Delta q^\\alpha > q^\\alpha$, the user does not have enough LRNA to sell, and the transaction must fail."
]
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": "",
"id": "d57886f3d18a45a5"
}
],
"metadata": {
Expand Down

0 comments on commit 7f7b2a5

Please sign in to comment.