# Implementation of Compound Interest

Ethlizard's staking contract uses a unique method to calculate compound interest. Since it is impossible to store decimals in solidity, and there are overflow requirements, we are unable to calculate compound interest via a regular, simple means.

Instead, we use this formula to calculate continuous compound interest, using the ABDKMath64x64 library:

$$
(1+r)^t = 2^{t,\cdot, \log\_2(1+r)}
$$

This is the result of converting a basic compound interest formula into the above via log laws.

$$
(1+r)^t = 2^{\log\_2((1+r)^t)}  = 2^{(t × \log\_2(1+r))}
$$

The value of $$(1 + r)$$ is stored in our contract in 64.64-bit binary fixed-point quadruple-precision binary floating-point numbers. This was an implementation allowed by the ABDKMaths64x64 library and allows the contract to calculate compound interest via calling the logarithm and exponent functions. We use an approximation of $$1.005$$ (the rebasing factor) in our contract.

The value of $$(1 + r)$$ in our contract is:

$$
1.85389777940780994
$$

And this means our rebasing factor is:

$$
1.0050000000000000014051260155412137464736588299274444580078125
$$

The implementation of the above formulas is found within the function `calculateRebasePercentage`.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://info.ethlizards.io/staking/technical-documentation/contracts/contract-maths/implementation-of-compound-interest.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
