DeFi points integration instructions

Technical integration guide with TypeScript interfaces: getContracts, getUserShares, getBalances, getDeFiPools. Includes full Zircuit example implementation and all type definitions.

DeFi Integrations

Get contracts

Async function to load contracts holding LRTs on behalf of users.

getContracts: (params: GetContractsParams) => Promise<DeFiContract[]> | DeFiContract[];

Get user shares

Async function to load user shares between 2 blocks (inclusive).

This function is called for all contracts returned by getContracts.

getUserShares: (params: GetUserSharesParams) => Promise<IDeFiUserShare[]> | IDeFiUserShare[];

A user share represents the amount of LRT owned by an address pro-rata to others.

User shares are sorted by block and a new entry must be added each time LRT ratios change.

Example:

chainId
block
user
amount
vault
protocol_address
1

1

0x01

100

0x0

0x0

1

1

0x02

200

0x0

0x0

1

1

0x03

50

0x0

0x0

1

3

0x03

20

0x0

0x0

1

4

0x01

150

0x0

0x0

1

5

0x02

0

0x0

0x0

  • At block 1, 0x01 owns ~28% of the user shares (100 / (100 + 200 + 50)), 0x02 owns ~57% and 0x03 owns ~14%.

  • At block 3, 0x03 underlying LRT balance changed, he now owns ~6% of the user shares (20 / (100 + 200 + 20)), while 0x01 owns ~31% and 0x02 owns ~62%.

  • At block 5, 0x02 withdrew all his funds from the protocol, he now owns 0% of the user shares, while 0x01 owns ~88.2% (150 / (150 + 20)) and 0x03 owns ~11.8% (20 / (150 + 20)).

Get user balances (optional)

Optional async function to load user balances (if they're not 1:1 to user shares).

This function is called for all contracts returned by getContracts.

Example

Interface

Last updated