SDKs

to be changed with zkEVM deployment

Currently there is a Typescript package available on NPMarrow-up-right to help with your implementation of the Phantazm Protocol. The SDK provides easy to use methods to interact with the Phantazm Protocol, as well as methods to calculate user positions such as the health factor.

circle-info

The SDK requires a basic understanding of Javascript/Typescript, as well as experience using NPM.

You can easily install the SDK using the command:

// with npm
npm install @Phantazm/protocol-js

// or with yarn
yarn add @Phantazm/protocol-js

Protocol-js

An example of using the SDK with data fetched from the subgraph:

import { v1, v2 } from '@Phantazm/protocol-js';

// returns user summary data in big units.
v1.formatUserSummaryData(
  poolReservesData,
  rawUserReserves,
  userId,
  usdPriceEth,
  currentTimestamp
);

// returns user summary data in small units with 0 decimal places, except health-factor.
v1.computeRawUserSummaryData(
  poolReservesData,
  rawUserReserves,
  userId,
  usdPriceEth,
  currentTimestamp
);

// returns reserves data formatted to big units.
v2.formatReserves(reserves, currentTimestamp);

For a list of transaction methods, see the Github repoarrow-up-right.

Rates calculation

Calculating rates in Phantazm is somewhat complicated due to the interest bearing nature of aTokens.

The reason for that is twofold:

  1. liquidity of aTokens constantly changes which is making utilization based rates extremely dynamic (it's changing every second)

  2. depositor interest is not only based on interest, but also includes factors like flash premiums (so it's usually "a little more")

Therefore the Phantazm protocol keeps track of two values:

Rate: The rate is a purely utilization based metric which represents the current rate at a specific point in time.

Index: The index keeps track of reserve growth also incorporating things like the flash premium.

To calculate correct historically archived deposit rates you should use index based rate calculation.

Last updated