Curve Encoding

Pricing of services on the zap platform is determined via a pricing mechanism set by the provider known as a Bonding Curve. This section details how a user can setup their bonding curve.

NOTE: If you're using Zap tools like the web-admin or cli, you wont need to know how to parse our curve encodings but a brief breakdown follows where encode/decode a few examples. Tldr; we provide some examples at the bottom of this page

Curve Encoding

Zap curves are piece-wise functions where each piece-wise segment is a sum-of-powers polynomial.

c0x0+c1x1+c2x2+...c0x^0+c1x^1+c2x^2+...

So if you have a function like 2+x^2, you'd want to put it in the form

2+2x2=>2x0+0x1+2x22+ 2x^2 => 2x^0+0x^1+2x^2

If you just wanted a stable price, you'd just stick a constant, ala 3

3=>3x03 => 3x^0

Since Zap bonding curves are piece-wise functions, our curves are encoded via integer encoded as follows

[n1,c0,c1,...,cn,l1,n2,c0,c1,...,cn,l2,...][n_1, c_0,c_1,...,c_n,l_1,n_2, c_0,c_1,...,c_n,l_2,...]

where

  • n1 is the number of terms in the first polynomial

  • c0, c1, ... are the coefficients of their respective n terms

  • l1 is the x limit of the first polynomial function

  • n2 is the number of terms in the second polynomial

  • etc, etc

For the following examples we have equation + encoding

Example 1:

[3,0,0,3,10000000000]

This curve has 1 polynomial function, 3x^2. This takes 3 terms in the sum of powers repesentation

0x0+0x1+3x20x^0+ 0x^1+3x^2

Hence we have 3 terms in the 1st polynomial, [3,0,0,3,10000000000]

and c0=0, c1=0, and c2=3, [3,0,0,3,10000000000]

Since the x-limit of the first term is 10000000000, we use this for our l1 term , [3,0,0,3,10000000000]

Example 2:

[1,3,10,1,5,20,1,7,30,1,9,40,1,11,50]

Here we have 5 different piece-wise functions but they are all constants, so each consists of 1 term

3x0,5x0,7x0,9x0,11x03x^0, 5x^0, 7x^0, 9x^0, 11x^0