mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-16 17:55:49 +00:00
Fix AMMDeposit formula
This commit is contained in:
129
content/_img-sources/amm-single-asset-deposit-formula.uxf
Normal file
129
content/_img-sources/amm-single-asset-deposit-formula.uxf
Normal file
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="14.2">
|
||||
<zoom_level>10</zoom_level>
|
||||
<element>
|
||||
<id>Text</id>
|
||||
<coordinates>
|
||||
<x>90</x>
|
||||
<y>150</y>
|
||||
<w>70</w>
|
||||
<h>30</h>
|
||||
</coordinates>
|
||||
<panel_attributes>L = T ×</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>190</x>
|
||||
<y>150</y>
|
||||
<w>180</w>
|
||||
<h>30</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=-</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;160.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Text</id>
|
||||
<coordinates>
|
||||
<x>370</x>
|
||||
<y>150</y>
|
||||
<w>30</w>
|
||||
<h>30</h>
|
||||
</coordinates>
|
||||
<panel_attributes>- 1</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Text</id>
|
||||
<coordinates>
|
||||
<x>350</x>
|
||||
<y>130</y>
|
||||
<w>30</w>
|
||||
<h>30</h>
|
||||
</coordinates>
|
||||
<panel_attributes>W</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Text</id>
|
||||
<coordinates>
|
||||
<x>160</x>
|
||||
<y>130</y>
|
||||
<w>40</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
<panel_attributes>fontsize=40
|
||||
(</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Text</id>
|
||||
<coordinates>
|
||||
<x>340</x>
|
||||
<y>130</y>
|
||||
<w>40</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
<panel_attributes>fontsize=40
|
||||
)</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Text</id>
|
||||
<coordinates>
|
||||
<x>150</x>
|
||||
<y>120</y>
|
||||
<w>40</w>
|
||||
<h>70</h>
|
||||
</coordinates>
|
||||
<panel_attributes>fontsize=60
|
||||
[</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Text</id>
|
||||
<coordinates>
|
||||
<x>390</x>
|
||||
<y>120</y>
|
||||
<w>40</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>fontsize=60
|
||||
]</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Text</id>
|
||||
<coordinates>
|
||||
<x>260</x>
|
||||
<y>160</y>
|
||||
<w>30</w>
|
||||
<h>30</h>
|
||||
</coordinates>
|
||||
<panel_attributes>P</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Text</id>
|
||||
<coordinates>
|
||||
<x>200</x>
|
||||
<y>140</y>
|
||||
<w>160</w>
|
||||
<h>20</h>
|
||||
</coordinates>
|
||||
<panel_attributes>B - (F × (1 - W) × B)</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Text</id>
|
||||
<coordinates>
|
||||
<x>170</x>
|
||||
<y>150</y>
|
||||
<w>40</w>
|
||||
<h>30</h>
|
||||
</coordinates>
|
||||
<panel_attributes>1 +</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
</diagram>
|
||||
@@ -84,17 +84,17 @@ Any other combination of these fields and flags is invalid.
|
||||
|
||||
The formula for how many LP Tokens you receive for a double-asset deposit is:
|
||||
|
||||
{{ include_svg("img/amm-single-asset-deposit-formula.svg", "L = T × ( (( (B - (F × (1 - W) × B)) ÷ P)^W) - 1)") }}
|
||||
{{ include_svg("img/amm-single-asset-deposit-formula.svg", "L = T × ( (( 1 + (B - (F × (1 - W) × B)) ÷ P)^W) - 1)") }}
|
||||
<!-- TODO: improve graphic -->
|
||||
|
||||
Where:
|
||||
|
||||
- `L` is the amount of LP Tokens returned
|
||||
- `T` is the total outstanding LP Tokens before the deposit <!-- TODO: or is it after the deposit? -->
|
||||
- `T` is the total outstanding LP Tokens before the deposit
|
||||
- `B` is the amount of the asset being deposited
|
||||
- `F` is the trading fee, as a decimal
|
||||
- `W` is the weight of the deposit asset in the pool. This is defined as 0.5 for all AMM pools (meaning a 50/50 split), so exponentiation by W is equivalent to taking the square root.
|
||||
- `P` is the total amount of the deposit asset in the pool before the deposit <!-- TODO: or is it after the deposit? -->
|
||||
- `P` is the total amount of the deposit asset in the pool before the deposit
|
||||
|
||||
### AMMDeposit Flags
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
|
||||
'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
|
||||
<svg fill-opacity="1" xmlns:xlink="http://www.w3.org/1999/xlink" color-rendering="auto" color-interpolation="auto" text-rendering="auto" stroke="black" stroke-linecap="square" width="380" stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" viewBox="70 40 380 120" height="120" xmlns="http://www.w3.org/2000/svg" font-family="'Dialog'" font-style="normal" stroke-linejoin="miter" font-size="12px" stroke-dashoffset="0" image-rendering="auto"
|
||||
<svg fill-opacity="1" xmlns:xlink="http://www.w3.org/1999/xlink" color-rendering="auto" color-interpolation="auto" text-rendering="auto" stroke="black" stroke-linecap="square" width="380" stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" viewBox="70 100 380 120" height="120" xmlns="http://www.w3.org/2000/svg" font-family="'Dialog'" font-style="normal" stroke-linejoin="miter" font-size="12px" stroke-dashoffset="0" image-rendering="auto"
|
||||
><!--Generated by the Batik Graphics2D SVG Generator--><defs id="genericDefs"
|
||||
/><g
|
||||
><defs id="defs1"
|
||||
@@ -9,65 +9,72 @@
|
||||
><path d="M0 0 L2147483647 0 L2147483647 2147483647 L0 2147483647 L0 0 Z"
|
||||
/></clipPath
|
||||
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath2"
|
||||
><path d="M0 0 L0 20 L160 20 L160 0 Z"
|
||||
><path d="M0 0 L0 30 L40 30 L40 0 Z"
|
||||
/></clipPath
|
||||
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath3"
|
||||
><path d="M0 0 L0 30 L30 30 L30 0 Z"
|
||||
><path d="M0 0 L0 20 L160 20 L160 0 Z"
|
||||
/></clipPath
|
||||
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath4"
|
||||
><path d="M0 0 L0 80 L40 80 L40 0 Z"
|
||||
><path d="M0 0 L0 30 L30 30 L30 0 Z"
|
||||
/></clipPath
|
||||
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath5"
|
||||
><path d="M0 0 L0 70 L40 70 L40 0 Z"
|
||||
><path d="M0 0 L0 80 L40 80 L40 0 Z"
|
||||
/></clipPath
|
||||
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath6"
|
||||
><path d="M0 0 L0 50 L40 50 L40 0 Z"
|
||||
><path d="M0 0 L0 70 L40 70 L40 0 Z"
|
||||
/></clipPath
|
||||
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath7"
|
||||
><path d="M0 0 L0 30 L70 30 L70 0 Z"
|
||||
><path d="M0 0 L0 50 L40 50 L40 0 Z"
|
||||
/></clipPath
|
||||
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath8"
|
||||
><path d="M0 0 L0 30 L70 30 L70 0 Z"
|
||||
/></clipPath
|
||||
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath9"
|
||||
><path d="M0 0 L0 30 L180 30 L180 0 Z"
|
||||
/></clipPath
|
||||
></defs
|
||||
><g font-family="sans-serif" font-size="14px" transform="translate(180,80)"
|
||||
><g font-family="sans-serif" font-size="14px" transform="translate(170,150)"
|
||||
><text x="5" xml:space="preserve" y="18.1094" clip-path="url(#clipPath2)" stroke="none"
|
||||
>1 +</text
|
||||
></g
|
||||
><g font-family="sans-serif" font-size="14px" transform="translate(200,140)"
|
||||
><text x="5" xml:space="preserve" y="18.1094" clip-path="url(#clipPath3)" stroke="none"
|
||||
>B - (F × (1 - W) × B)</text
|
||||
></g
|
||||
><g font-family="sans-serif" font-size="14px" transform="translate(240,100)"
|
||||
><text x="5" xml:space="preserve" y="18.1094" clip-path="url(#clipPath3)" stroke="none"
|
||||
><g font-family="sans-serif" font-size="14px" transform="translate(260,160)"
|
||||
><text x="5" xml:space="preserve" y="18.1094" clip-path="url(#clipPath4)" stroke="none"
|
||||
>P</text
|
||||
></g
|
||||
><g font-family="sans-serif" font-size="60px" transform="translate(390,60)"
|
||||
><text x="5" xml:space="preserve" y="61.2188" clip-path="url(#clipPath4)" stroke="none"
|
||||
><g font-family="sans-serif" font-size="60px" transform="translate(390,120)"
|
||||
><text x="5" xml:space="preserve" y="61.2188" clip-path="url(#clipPath5)" stroke="none"
|
||||
>]</text
|
||||
></g
|
||||
><g font-family="sans-serif" font-size="60px" transform="translate(150,60)"
|
||||
><text x="5" xml:space="preserve" y="61.2188" clip-path="url(#clipPath5)" stroke="none"
|
||||
><g font-family="sans-serif" font-size="60px" transform="translate(150,120)"
|
||||
><text x="5" xml:space="preserve" y="61.2188" clip-path="url(#clipPath6)" stroke="none"
|
||||
>[</text
|
||||
></g
|
||||
><g font-family="sans-serif" font-size="40px" transform="translate(340,70)"
|
||||
><text x="5" xml:space="preserve" y="42.4844" clip-path="url(#clipPath6)" stroke="none"
|
||||
><g font-family="sans-serif" font-size="40px" transform="translate(340,130)"
|
||||
><text x="5" xml:space="preserve" y="42.4844" clip-path="url(#clipPath7)" stroke="none"
|
||||
>)</text
|
||||
></g
|
||||
><g font-family="sans-serif" font-size="40px" transform="translate(160,70)"
|
||||
><text x="5" xml:space="preserve" y="42.4844" clip-path="url(#clipPath6)" stroke="none"
|
||||
><g font-family="sans-serif" font-size="40px" transform="translate(160,130)"
|
||||
><text x="5" xml:space="preserve" y="42.4844" clip-path="url(#clipPath7)" stroke="none"
|
||||
>(</text
|
||||
></g
|
||||
><g font-family="sans-serif" font-size="14px" transform="translate(350,70)"
|
||||
><text x="5" xml:space="preserve" y="18.1094" clip-path="url(#clipPath3)" stroke="none"
|
||||
><g font-family="sans-serif" font-size="14px" transform="translate(350,130)"
|
||||
><text x="5" xml:space="preserve" y="18.1094" clip-path="url(#clipPath4)" stroke="none"
|
||||
>W</text
|
||||
></g
|
||||
><g font-family="sans-serif" font-size="14px" transform="translate(370,90)"
|
||||
><text x="5" xml:space="preserve" y="18.1094" clip-path="url(#clipPath3)" stroke="none"
|
||||
><g font-family="sans-serif" font-size="14px" transform="translate(370,150)"
|
||||
><text x="5" xml:space="preserve" y="18.1094" clip-path="url(#clipPath4)" stroke="none"
|
||||
>- 1</text
|
||||
></g
|
||||
><g font-family="sans-serif" font-size="14px" transform="translate(90,90)"
|
||||
><text x="5" xml:space="preserve" y="18.1094" clip-path="url(#clipPath7)" stroke="none"
|
||||
><g font-family="sans-serif" font-size="14px" transform="translate(90,150)"
|
||||
><text x="5" xml:space="preserve" y="18.1094" clip-path="url(#clipPath8)" stroke="none"
|
||||
>L = T ×</text
|
||||
></g
|
||||
><g transform="translate(170,90)"
|
||||
><path fill="none" d="M10.5 10.5 L160.5 10.5" clip-path="url(#clipPath8)"
|
||||
><g transform="translate(190,150)"
|
||||
><path fill="none" d="M10.5 10.5 L160.5 10.5" clip-path="url(#clipPath9)"
|
||||
/></g
|
||||
></g
|
||||
></svg
|
||||
|
||||
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 4.0 KiB |
Reference in New Issue
Block a user