> For the complete documentation index, see [llms.txt](https://zapproject.gitbook.io/zapproject/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zapproject.gitbook.io/zapproject/oracles/endpoints-bonding-curve/curve-encoding.md).

# 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.&#x20;

$$
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+ 2x^2 => 2x^0+0x^1+2x^2
$$

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

$$
3 => 3x^0
$$

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

$$
\[n\_1, c\_0,c\_1,...,c\_n,l\_1,n\_2, c\_0,c\_1,...,c\_n,l\_2,...]
$$

where&#x20;

* 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:

![](https://1587561480-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZfJHix_Ia6ja0KtINp%2F-L_Yj3RiKz4dAtVSxDnS%2F-L_YtomUK-ngn7ZoqEiW%2Fx%5E2.png?alt=media\&token=52c5e45c-e2f4-4b5f-8c60-06b20cd471e8)

![\[3,0,0,3,10000000000\]](https://1587561480-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZfJHix_Ia6ja0KtINp%2F-L_YasJcfpYgtyHG_Fvu%2F-L_PkhXqd3nReKT3cA6X%2Fe.png?alt=media\&token=fc4af531-fec3-44d9-83f4-acad94104c91)

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

$$
0x^0+ 0x^1+3x^2
$$

Hence we have 3 terms in the 1st polynomial, \[**3**,0,0,3,10000000000]&#x20;

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: <a href="#example-1" id="example-1"></a>

![](https://1587561480-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZfJHix_Ia6ja0KtINp%2F-L_YasJcfpYgtyHG_Fvu%2F-L_PlVQyBQXzuSWPEA3e%2Fsetcurve%20-%20Edited%20\(1\).png?alt=media\&token=3855907e-cf27-407e-930f-5f44d7e51bff)

![\[1,3,10,1,5,20,1,7,30,1,9,40,1,11,50\]](https://1587561480-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZfJHix_Ia6ja0KtINp%2F-L_YasJcfpYgtyHG_Fvu%2F-L_Pjvw7LMhJA2PWb0CH%2Fpeice.png?alt=media\&token=c25a3dc1-9f87-46cc-aea9-5f6a19107669)

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

$$
3x^0,  5x^0, 7x^0, 9x^0, 11x^0
$$
