Smart Contract Integration

The system is composed of two main modules: iAsset and PoEL.

Status
Contract Address
Modules Link

Testnet

0xc4a734e5b84deb218ab7ba5a46af45da54d5ff4aa8846e842c3ac2e32ce0eebd

https://testnet.suprascan.io/address/0xc4a734e5b84deb218ab7ba5a46af45da54d5ff4aa8846e842c3ac2e32ce0eebd/f?tab=modules

dApps that hold iAssets (e.g., liquidity pools) and need to withdraw rewards periodically can use the following methods from the PoEL and iAsset modules.

iAsset Module

Method
In / out
Comment

View method

get_user_rewards

(user_address: address): UserRewardsInfo

in

user_address:

address of the iasset holder

out

UserRewardsInfo result object with various details.

Fields:

  • Allocated rewards for a user allocated_rewards: u64,

  • Withdrawable (claimed) rewards for a user withdrawable_rewards: u64,

  • Epoch when rewards were claimed (moved to withdrawable) withdrawable_rewards_epoch: u64,

  • Timestamp when rewards were claimed (moved to withdrawable) withdrawable_rewards_ts: u64,

  • Withdrawn rewards for a user withdrawn_rewards: u64

Method returns total allocated rewards, withdrawable, withdrawn etc

View method

get_allocatable_rewards

(user_address: address, asset: Object<Metadata>): u64

in

user_address:

address of the iasset holder

asset : iasset object

out

amount of supra coins

Return number of rewards could be allocated by calling method update_rewards

View method

get_withdraw_timer_for_user

(user_address: address): u64

in

user_address: address of the iasset holder

Method is useful for the claim/withdraw scenario. This method indicates the remaining time to wait until withdraw_rewards can be invoked

PoEL Module

Method
In / out
Comment

update_rewards(account: &signer, asset: Object)

in

account: signer, who updates the rewards

asset : iasset object, for which rewards has to be updated

Call this method whenever get_allocatable_rewards returns a non-zero value

claim_rewards(account: &signer)

in

account: signer, who claims already allocated rewards

Call this method only when allocated_reward>0

withdraw_rewards(account: &signer)

in

account: signer, who withdraw already claimed rewards

Method can be called if withdrawable_rewards not 0 (something claimed) and Get_withdraw_timer_for_user is 0

Last updated