TMM Design

In order to stabilize the price and boost liquidity of IBTs, WrapFi proposed the Tracking Market Maker (TMM) algorithm which is improved from the PMM algorithm. TMM has three unique strengths:

1.Exchange Rate Tracking. When IBTs are traded on WrapFi, the price of the oracle will track the exchange rate of IBT in the primary market in real-time, and write it into the price discovery mechanism;

2. Customized VRF Oracles. Since some IBT assets are issued on different public chains, and the primary market prices of different tokens are displayed on various IBT issuers' Dashboards, WrapFi will customize cross-chain price oracle quotation mechanism for each IBT trading pair. WrapFi will adopt the VRF algorithm to implement a license-free decentralized oracle quotation mechanism to ensure Oracle’s security;

3.Dynamic LP Fees. WrapFi will dynamically adjust the LP commission fee based on the liquidity of each IBT pair, attracting more LPs.

1.Exchange Rate Tracking

As we mentioned above, there are actually two price discovery markets for IBT assets. The primary market price is the IBT/DT Exchange Rate announced by the asset issuers. The other often referred to as secondary market price, exists in DEXes. The latter is supported by the former and adjusted by the demand of buyers/sellers. WrapFi will track the primary market price of IBTs so that the price discovery mechanism on WrapFi can also reflect the fluctuation of the real price of the primary market.

PMM's price curve:

i is the primary market exchange rate price between IBT assets and Deposited Token, which is tracked and fetched by WrapFi's Customized VFR Oracle in real-time.

R is flexible:

If B< B0, then R=1-k+( B0/ B)^2 * k

If Q>Q0, then R=1/[1-k-(Q0/Q)^2 *k]

In other cases R=1

B is the number of base tokens currently in the inventory and B0 is the initial number of base tokens in the inventory. Q is the number of quote tokens currently in the inventory and Q0 is the initial number of quote tokens in the inventory.The value range of k is[0,1] and it affects the slope of the price.

Detailed PMM algorithm please refer to DODO PMM

2.Customized VRF Oracles.

A sharp, accurate, and secure Orcale integrated in TMM algorithm is indispensable for each IBT pair. Since the underlying chain and exchange rate mechanism of each IBT asset may vary, WrapFi will customize an oracle mechanism that can capture the corresponding primary market price (Price Fetching Script) for each IBT asset. The Script will be run by a group of SSV (StaFi Special Validators) on the StaFi chain through a verifiable random number VRF(Verifiable Random Function) algorithm. Finally, the trade price between IBTs and Deposited Tokens will be determined by PMM algorithm.

For WrapFi's oracle system, it is very important to assign random numbers for SSVs, in order to ensure absolute randomness and effectiveness. Only in this case can users trust the data uploaded by SSVs to be well-intentioned. To discourage the collusion of multiple SSVs, WrapFi will adopt a Verifiable Random Function (VRF) algorithm to ensure absolute security and verifiability in terms of the random number generation process, as well as the number's uniqueness. The VRF algorithm adopts elliptic curve encryption and zero-knowledge proof, thereby realizing the decentralization and security of the Oracle pricing mechanism.

The VRF algorithm encompasses three parts:

1) Public and private key pair generation function G

Assuming that the base point of the elliptic curve is O and the order is n, function G is as follows:

A1: Choose a random number

k=[1, n-1]

A2: Generate private and public elliptic curve keys. The former is k and the latter is


2) Random number and proof generating function F

Input: message m, private key k;

Output: random number v, proof;

B1: Choose a random number

r=[1, n-1];

B2: Use the hash function h1 to calculate H=h1(m), and map m to a point H on the elliptic curve;

B3: Calculate rH, rO;

B4: Use the function h2 to encode the input into an integer s.

s=(rH, rO)

B5: calculation

t=(r-s*k)mod n

B6: calculation


B7: Use the function h3 to encode the point on the elliptic curve into an integer. Then we have a random number value=h3(V), and proof is (V;t;s).

3) Verification function V

Input: message m', proof proof'

Output: valid or invalid

C1: Use the hash function h1 to map the message m' to a point H' on the elliptic curve;

C2: calculate:



C3: Calculate:

s'=h2(U1, U2)

C4: If s=s', it indicates that the random number and out is valid, and the verification has passed. If not, the random number and the output are invalid and the verification has not passed.

Apart from the VRF algorithm, SSV must stake certain amount FIS tokens as pledge, which further enhance the security and stability of WrapFi oracle. If any SSV does evil, it will be fined from the deposit.

3.Dynamic LP Fees

WrapFi will set different levels of LP commission fees by the liquidity of each IBT pair. This will dynamically adjust the commission income of the LP providers. When an IBT trading pair comparatively stagnant, the LP Commission Fee will increase, encouraging more LPs to join and vice versa.

Last updated