bonding

Bonding curves and automated market makers that use them.
Introduction:
As a kid I liked to invent board games. One was like monopoly, except that you got to buy stocks. For each stock there was a pile of cards, each card representing a share. The first card indicated a price of 100. The second card indicated a price of 130, and so forth. Landing on one square you got to buy before others did. Landing on another you got to sell.
Skipping forward to the reinvention of everything financial in web3, we have the modern equivalent with terminology bonding curve, for which there is a good simple intro here. A market maker charges a deterministic incremental price that is a monotonic (usually) function of the number of outstanding shares x. To compute hypothetical trades (e.g. size dependence bids or offers) or actual trades it performs an integration of the price curve. In this package we also account for and acrue breakage when shares are rounded by a small QUANTA, and the AMM can optionally collect a proportional fee.
If you like control theory then this is a greenfield, I suspect. I'm collating questions and literature sporadically.
Usage:
Create a market maker:
from bonding.amms.sqrtbondingcurveamm import SqrtBondingCurveAMM
amm = SqrtBondingCurveAMM(scale=1000.0, fee_rate=0.001)
Invest $1000:
shares = amm.buy_value(1000.0)
Then sell out:
sale_proceeds_value = amm.sell_shares(shares)
print(f"Proceeds from buying and selling all shares: {sale_proceeds_value}")
print(f"Net cost of buying and selling all shares: {initial_investment_value - sale_proceeds_value}")
Install
pip install bonding
pip install matplotlib
pip install scipy
Latter two are optional. Scipy is only used for numerical verification at present.
Interpretation of scale
All curves satisfy:
price(0)=1
price(scale)=2
See the bondingcurve.py for verification methods.
They are also monotonic, as you can verify. For example:
from bonding.amms.sqrtbondingcurve import SqrtBondingCurve
SqrtBondingCurve(scale=10).plot()
Automated market maker properties
Round trip buying and selling, in either direction, cannot yield an arbitrage whether we specify quantity or cost. See bondingcurveamm,py for verification methods.
Metadata
Release files for bonding 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bonding-0.0.5.tar.gz | 16.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bonding-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.4 kB
Release files / bonding-0.0.5.tar.gz
| Download URL | bonding-0.0.5.tar.gz |
|---|---|
| Size | 16.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6874a96aa7589ad9a4d9a3a80268745adaee739bb07d7ec9d6f3e86439a419e6
|
|
BLAKE2b-256 checksum How to use checksums |
c8289103629e51ede32a5c7fbe059b17707507969c74bb2fa3184e0b9d638353
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / bonding-0.0.5-py3-none-any.whl
| Download URL | bonding-0.0.5-py3-none-any.whl |
|---|---|
| Size | 21.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3c1864fc468a76ac56eb05f2891c7855db7a7203e89588ef5144b1a2e1427d5e
|
|
BLAKE2b-256 checksum How to use checksums |
7c2096a27e45cd65ad4bb9ae6fbd013e588cfdc44d62462a0697012da05cb043
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|