Skip to content

🧹 dedust price server refactor#59

Open
zknpr wants to merge 1 commit intomainfrom
dedust-price-server-refactor-18268025706267532251
Open

🧹 dedust price server refactor#59
zknpr wants to merge 1 commit intomainfrom
dedust-price-server-refactor-18268025706267532251

Conversation

@zknpr
Copy link
Copy Markdown
Owner

@zknpr zknpr commented Mar 8, 2026

🎯 What: Removed explicit external API call to tonapi.io for fetching the price of SCALE token against TON, replacing it with the direct inclusion of SCALE balance to the api object. Also removed the unused ADDRESSES variable import.
💡 Why: Simplifies the code, removes a fragile external API dependency in the TVL calculation, and lets the DefiLlama SDK and native price server optimally resolve token valuation.
Verification: Ran node test.js projects/dedust/index.js to confirm TVL and staking values correctly printed the equivalent DUST valuation logic using the price server mapping.
Result: Improved maintainability, cleaner code, and fewer external HTTP calls during adapter execution.


PR created automatically by Jules for task 18268025706267532251 started by @zknpr

Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 8, 2026

Warning

Rate limit exceeded

@zknpr has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 55 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0716dc44-bdbb-4fcb-9118-bcde1f972d0b

📥 Commits

Reviewing files that changed from the base of the PR and between 0d3be2a and 1929f9d.

📒 Files selected for processing (1)
  • projects/dedust/index.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dedust-price-server-refactor-18268025706267532251

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@llamabutler
Copy link
Copy Markdown

The adapter at projects/dedust exports TVL:

ton                       4.54 M
ton-staking               763.56 k
staking                   763.56 k

total                    4.54 M 

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 8, 2026

Greptile Summary

This PR refactors the DeDust staking adapter by removing an explicit HTTP call to tonapi.io for SCALE/TON price resolution and instead passing the raw SCALE token balance directly to api.add, delegating valuation to the DefiLlama price server. It also removes the now-unused ADDRESSES import.

  • The external tonapi.io API dependency (https://tonapi.io/v2/rates) is eliminated, simplifying the adapter and reducing potential failure points.
  • api.add(SCALE, parseInt(get_staking_data[3])) replaces the old pattern of manually computing a TON-denominated equivalent, leaning on the price server to resolve "EQBlqsm144Dq6SjbPI4jjZvA1hqTIP3CvHovbIfW_t-SCALE".
  • The return keyword was dropped from the staking function, which is fine since api.add mutates the api object in place — the caller already holds a reference to it.
  • The misrepresentedTokens: true flag was already present before this PR, indicating the adapter already relied on non-standard token identifiers.
  • The SCALE token constant ("EQBlqsm144Dq6SjbPI4jjZvA1hqTIP3CvHovbIfW_t-SCALE") has a synthetic -SCALE suffix rather than a real on-chain TON address. If the DefiLlama price server ever loses the mapping for this identifier, the staking TVL would silently report $0.

Confidence Score: 4/5

  • This PR is safe to merge — it's a clean simplification with no new logic risks, though correctness depends entirely on an existing price server mapping.
  • The change is small and well-scoped. The only implicit risk is that the SCALE token's custom synthetic identifier (-SCALE suffix) must have a valid entry in the DefiLlama price server for staking TVL to be non-zero; the author confirmed this via local testing. No new bugs are introduced.
  • No files require special attention

Sequence Diagram

sequenceDiagram
    participant SDK as DefiLlama SDK
    participant Adapter as dedust/index.js
    participant TonChain as TON Chain (get_staking_data)
    participant DeDustAPI as DeDust API (TVL)
    participant PriceServer as DefiLlama Price Server

    SDK->>Adapter: tvl()
    Adapter->>DeDustAPI: GET /v1/pools
    DeDustAPI-->>Adapter: pool reserves
    Adapter-->>SDK: transformDexBalances(pools)

    SDK->>Adapter: staking(api)
    Adapter->>TonChain: call(SCALE_STAKING_ADDRESS, get_staking_data)
    TonChain-->>Adapter: staking_data[3] (raw SCALE amount)
    Adapter->>Adapter: api.add(SCALE, parseInt(staking_data[3]))
    SDK->>PriceServer: resolve price for SCALE token
    PriceServer-->>SDK: SCALE/USD price
    SDK-->>SDK: compute staking TVL
Loading

Last reviewed commit: 1929f9d

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.

2 participants