Batched Bonding Curves

Initial State

s = {
balance: 100,
totalSupply: 1000,
connectorWeight: .5,
currentPrice: 0.2,
slope: 0.0002,
power: 1
}
buys = Array(3) [10, 20, 5]sells = Array(3) [100, 200, 50]
allBuys = 35
allSells = 350
Photo by Waldemar Brandt on Unsplash

Implementation #1 Batched & Ordered

First all the buys are executed and then all the sells:

{
balance: 65.9173,
totalSupply: 811.895,
connectorWeight: .5,
currentPrice: 0.1624,
slope: 0.00020000000880536034,
power: 1
}

First all the sells are executed and then all the buys:

{
balance: 77.25,
totalSupply: 878.9198,
connectorWeight: .5,
currentPrice: 0.1758,
slope: 0.0002,
power: 1
}
  • The price for the sellers would have been 0.1650 👎
  • The price for the buyers would have been 0.1529 👍
  • The final market price would be 0.1758 👍
  • The non-weighted average of the two would have been 0.159
  • The price for the sellers would have been 0.1974 👍
  • The price for the buyers would have been 0.2162 👎
  • The final market price would be 0.1624 👎
  • The non-weighted average of the two would have been 0.2068
Photo by Alex Block on Unsplash

Implementation #2 Match & Fill

price = 0.2 collateral per token
totalBuy / price =
35 / 0.2 =
175 tokens as a result of the buys
totalSell * price =
350 * 0.2 =
70 collateral as a result of the sells

If the sells outweigh the buys

totalSell - (totalBuy / price) = 
350 - (35 / 0.2) =
350 - 175 =
175 token that still need to be sold
saleReturn(175, s) = 
31.937500000000007 collateral
(matchedSellResult + curvedSellResult) / totalSell =
(35 + 31.937500000000007) / 350 =
0.19125 collateral/token
  • The price for the sellers would be 0.1913
  • The price for the buyers would be 0.2
  • The final market price would be 0.165
  • The non-weighted average of the two would have been 0.1956
Photo by rawpixel on Unsplash

Implementation #3 Common Clearing Price

_c = 35
_x = 350
m = 0.0002
n = 1
totalSupply = 1000
p_1 = -0.0190197
p_2 = 0.1
p_3 = 0.18402

p_1

{
balance: 141.656895,
totalSupply: -1190.1972691472524,
connectorWeight: 0.5,
currentPrice: 0.2,
slope: 0.0002,
power: 1
}

p_2

{
balance: 100,
totalSupply: 1000,
connectorWeight: 0.5,
currentPrice: 0.2,
slope: 0.0002,
power: 1
}

p_3

{
balance: 70.593,
totalSupply: 840.1967177480708,
connectorWeight: 0.5,
currentPrice: 0.2,
slope: 0.0002,
power: 1
}

Selecting a Solution

  • it does not result in a negative token supply
  • it does not result in no change at all
  • it does not change the slope of the contract (within some margin of error for rounding)
Photo by Neil Thomas on Unsplash

Conclusion

--

--

--

https://okw.me

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Cosmos’ contribution at NFT

How to Deploy a DAO on Remix

How to depoly a dao on remix

CloudCoin Finance (CCFI) tokens have functional bridges to Ethereum, Heco, OKExChain, NULS, and…

VeChain (VET) Price Prediction

Blockchain At Its Peak — Digital Real Estate

Blockchain At Its Peak – Digital Real Estate

New to Streamr? Welcome! Here’s a quick start guide to get you started.

How Blockchain Can Save the Environment

Congestion happens frequently, how NGK ensures the performance of the public chain

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Billy Rennekamp

Billy Rennekamp

https://okw.me

More from Medium

Liquidity in Hayek

A Breakdown of the Bancor v3 Tokenomics

TeaDAO’s Tokenomics Part 1

Aleph.im Load Balancers go live on the Network