CDR #033: Algem | Price Feeds

06 January, 2023

INTRODUCTION

Protocol: ALGEM

Integration: Algem is the native liquid staking DeFi dApp on top of Astar Network offering various ways for ASTR users and holders to earn more.

REQUEST INFORMATION

Assets

Following assets will be included in the Oracle:

Asset Ticker Asset Blockchain Asset Address Asset Markets Overview Comments
nASTR (collateral ratio driven feed) Astar 0xE511…F2b0 ASTR Markets ASTR price feed with collateral ratio derived price
nASTR (market price) Astar 0xE511…F2b0 nASTR Markets nASTR market price feed

Methodology

  • Moving Average Price with Interquartile Range (MAIR) will be used to calculate the price for the assets. Learn more about it here
  • 1% deviation threshold for updates trigger will be applied for each asset
  • 120sec time window for trades aggregation will be applied for each asset
  • nASTR price using collateral feed will be derived as follows:
    • nASTR price = ASTR price * (ASTR in staking contract / nASTR total supply)
    • ASTR in staking contract will be derived by calling function read_staked_amount_on_contract on Astar DappsStaking contract
    • nASTR total supply will be derived by calling function totalSupply on nASTR token contract

DELIVERY INFORMATION

Delivery Method Oracles on Astar network
Is testnet deploy required? No
Delivery Estimate 14 days

NOTES

Additional relevant information: N/A

2 Likes

First contract: DIA Oracle: https://blockscout.com/astar/address/0x88463254469c37b9cECb71A34746707e008fb5A9
You can query “getValue()” with argument “ASTR/USD” or “nASTR/USD” to receive the market prices of both. Return values are the price (with 8 decimals, so divide by 10^8 to get the actual price) and unix timestamp of last update.
Prices will update as soon as 1% change is detected.

Second contract: Algem adapter that live connects the ASTR/USD price to onchain collateral information: https://blockscout.com/astar/address/0xCb2158f97367596A68dd1670bC848dc6B2245111
You can query “getNAstrPriceFromCollateralRatio()” (no arguments) to receive this value. It reads ASTR/USD from the oracle and applies the specified formula.

Finally: Please also add funding to the wallet that sends the update transactions to the oracle so that it doesn’t stop due to low funds: 0x7ba30ea9bf8969aab66c08074a587bb5d30452e1

4 Likes

Hello DIA Community,

On March 07, 2023, Algem deployed an update of the liquid staking model to launch the liquid staking multipools allowing users to choose the dApp of the Astar Network’s dApp Staking where they want to stake. The model goes from a single dApp for staking to as many dApps as there are in the dApp Staking and consequently, this update leads to the need to upgrade the methodology for calculating the collateral of the nASTR token performed by DIA.

Previous Methodology:

nASTR price using collateral feed will be derived as follows:

  • nASTR price = ASTR price * (ASTR in staking contract / nASTR total supply)
  • ASTR in staking contract will be derived by calling function read_staked_amount_on_contract on Astar DappsStaking contract
  • nASTR total supply will be derived by calling function totalSupply on nASTR token contract

The new Methodology should take into account:

nASTR tokens are minted on each stake call, but now there are more options for bond_and_stake after the update.

  • To get total ASTR in staking contract, we need to summarize read_staked_amount_on_contract with all the dApps supported by Algem. The staker argument as before is the Algem dapp contract.
  • To get the list of dApps and iterate over it LiquidStaking contract has the dapps mapping and getDappsList function.

We would like to ask you to provide a new calculation methodology for the nASTR collateral taking into account the above information.

Thank you

G’ from Algem team.

2 Likes

Dear Team Algem,

thank you for the update in methodology. We deployed an updated version of the Algem adapter here:

You can call getNAstrPriceFromCollateralRatio() to get the latest price from the collateral ratio and getAstrInAllStakingContracts() to retrieve the number of staked Astr in all registered contracts.

The adapter will always query all contracts in the registry and retrieve the sum of all staked amounts.

2 Likes

Hello DIA Team & Community,

Algem is currently working with lending protocols to deploy the liquid nASTR token and make it available for lending and borrowing activities.

The current nASTR price feed is based on a collateral-based feed model and based on our recent discussions with the DIA team, we would like to request an upgrade of the current model to a market price-based feed model.

Thank you.


G’ from Algem team

1 Like