Skip to content

Conversation

@nathanielfsn
Copy link

Summary

This PR adds staking functionality to the Udon protocol adapter on Chromia blockchain.

Changes

  • Added staking function to track total staked STCHR tokens
  • Refactored query URL building with helper function buildQueryUrl
  • Added constants for STCHR asset ID and decimals
  • Integrated staking endpoint: get_total_stake_all_users
  • Added price fetching for STCHR token to calculate USD value

Technical Details

  • Uses get_total_stake_all_users query to fetch total staked amount
  • Fetches STCHR price via get_latest_price_by_asset_id
  • Calculates TVL in USD by multiplying staked amount with token price
  • Properly handles decimals (6 decimals for STCHR)

Testing

  • Staking function properly calculates USD value from staked tokens
  • Query URL builder handles parameters correctly

@llamabutler
Copy link

The adapter at projects/udon exports TVL:

chromia                   334.58 k
chromia-borrowed          67.71 k
borrowed                  67.71 k
chromia-staking           1.49 k
staking                   1.49 k

total                    334.58 k 

const tvlUsd = totalStake * price;

api.addUSDValue(tvlUsd);
return api.getBalances();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we export a token balance here instead?

@waynebruce0x waynebruce0x self-assigned this Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants