Skip to content

kerne-usd: resolve kUSD (id 402) price from USDC instead of hardcoding it - #871

Open
enerzy17 wants to merge 1 commit into
DefiLlama:masterfrom
enerzy17:fix/kusd-price-hardcode
Open

kerne-usd: resolve kUSD (id 402) price from USDC instead of hardcoding it#871
enerzy17 wants to merge 1 commit into
DefiLlama:masterfrom
enerzy17:fix/kusd-price-hardcode

Conversation

@enerzy17

@enerzy17 enerzy17 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

kUSD (peggedasset id 402, added in #819) is a USDC-backed stablecoin on Base. It is minted and redeemed 1:1 against USDC through an on-chain Peg Stability Module.

#863 fixed the chain prefix so the balance is now read on Base, and that merged, but the price still resolves null: coins.llama.fi returns no entry for base:0x5C2EfdF0D8D286959b42308966bc2B97f5680AA3 and the gecko_id kerne-usd does not exist, so api.llama.fi shows kUSD with a null price on the stablecoins board.

This is the one-line follow-up I offered in #863: hardcode finalRes["kerne-usd"] = 1, directly beside the existing finalRes["m-2"] = 1 precedent in the same file, so the peg reads 1.00. Because kUSD is 1:1 USDC redeemable through the PSM, 1.00 is the correct pegged price.

If you would rather point the price at USDC through a coins alias instead of hardcoding, I am happy to do that instead. No rush on either.

Summary by CodeRabbit

  • Bug Fixes
    • Updated pricing for the Kerne USD asset so it’s now populated using the already-fetched USD Coin price, instead of relying on a static fixed value.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

getPrices now conditionally maps the fetched "usd-coin" price to "kerne-usd". Existing token mapping, chunking, and price-fetching logic remain unchanged.

Changes

Price mapping

Layer / File(s) Summary
Add Kerne USD price entry
src/adapters/peggedAssets/prices/index.ts
getPrices sets "kerne-usd" to the "usd-coin" price when that price is present.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is off-template and omits the required listing fields and sections from the repository template. Add the template sections (name, website, chain, token details, peg info, price source, audits) or explain why this is not a new listing.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the main change: pricing kUSD from USDC instead of a hardcoded value.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@realdealshaman

Copy link
Copy Markdown
Contributor

hey @enerzy17 will KUSD have a coingecko listing? this would be a much better option than hardcoding the price

@enerzy17

Copy link
Copy Markdown
Contributor Author

Yes, a CoinGecko listing is the plan, but I cannot submit one honestly yet. CG requires live trading with real liquidity and volume, and kUSD does not have that today. The audit engagement with Hexens is signed with the report due in the coming weeks, and the plan is to seed real liquidity once it lands, so the CG application goes in when it can actually clear their bar. The id 402 entry from #819 already carries gecko_id kerne-usd with onCoinGecko false for that reason. Once CG lists kUSD, this line gets deleted and the price resolves through the normal path, either the Base contract address on coins.llama.fi once CG indexes it, or with priceSource flipped to coingecko.

On the interim number, kUSD mints and redeems 1:1 for USDC through an on-chain PSM, and reserves are published live at kerne.fi/api/por. Right now that shows 1,115.85 USDC held in the PSM against 1,114.74 kUSD outstanding, and the response includes the cast commands to recompute it from chain.

If you would rather not carry a hardcode in the interim, pointing kerne-usd at USDC as an alias works for me too, or I can close this and come back once the CG listing is live. Whatever is easiest on your side.

@enerzy17

Copy link
Copy Markdown
Contributor Author

Following up on this one, since my last reply ended by handing you three options and no recommendation, which was not much help.

On the mechanism, what I am asking for is the same shape as what that function already does. finalRes["m-2"] = 1 and finalRes["terrausd"] = 0 have both sat there since 0xngmi added them to correct prices the pipeline could not resolve on its own, and id 403 ships gecko_id: "money-protocol", //fake with the same priceSource: "defillama" and onCoinGecko: "false" that id 402 carries. So a pegged asset holding an interim price without a real CoinGecko id already has a place here, which is why I wrote the PR that way instead of as a special case.

Being straight about what the 1 is: it is a par value backed by permissionless 1:1 USDC redemption through the on-chain PSM, not a market observed price. kUSD has no real secondary market yet, which is the same reason I am not submitting to CoinGecko. If you would rather the API never serve a par price, aliasing kerne-usd to USDC gets the same result through a live feed and I can push that commit today.

Alias, or the hardcode as it stands, whichever you prefer? If neither, close it and I will come back once CoinGecko lists us. I mostly did not want to leave it sitting on you with no decision in it.

Replaces the hardcode this PR originally proposed.

kUSD (id 402) reads price: null because coins.llama.fi returns nothing for
base:0x5C2EfdF0D8D286959b42308966bc2B97f5680AA3, so the asset has no price on
the stablecoins list or on its detail page.

Rather than pin it to 1, this reads the USDC price already fetched in the same
call. kUSD is minted and redeemed 1:1 for USDC through a permissionless
on-chain PSM on Base, so what a holder can redeem is a USDC claim, and the
reported price now tracks USDC's own deviation instead of asserting a constant.
If USDC does not resolve, kUSD stays unpriced rather than falling back to a
hardcoded value.

Verified against the live prices call with the full pegged asset list:
usd-coin 0.9998355475266617, kerne-usd 0.9998355475266617.
@enerzy17
enerzy17 force-pushed the fix/kusd-price-hardcode branch from c41a585 to 9bc62f0 Compare July 28, 2026 17:36
@enerzy17 enerzy17 changed the title Hardcode kUSD (id 402) price to 1 in peggedAssets prices kerne-usd: resolve kUSD (id 402) price from USDC instead of hardcoding it Jul 28, 2026
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