@@ -4,6 +4,9 @@ import { slugify } from '$lib/helpers/slugify';
44import type { StablecoinMetadata } from './schemas' ;
55
66export const STABLECOIN_DEPEG_RATE_THRESHOLD = 0.9 ;
7+ export const OFFCHAIN_USD_STABLECOIN_SLUG = 'usd-offchain' ;
8+ export const OFFCHAIN_USD_SHORT_DESCRIPTION = 'U.S. Dollars in the banking system without onchain transparency' ;
9+ const OFFCHAIN_USD_LOGO_URL = '/flags/us.svg' ;
710
811interface StablecoinLookupInput {
912 slug ?: string | null ;
@@ -127,6 +130,54 @@ export function resolveStablecoinSlug(
127130 return undefined ;
128131}
129132
133+ /**
134+ * Return the stablecoin details page URL when the denomination is navigable.
135+ *
136+ * Off-chain USD has a standalone page, but is intentionally not linked from
137+ * stablecoin listings because it is a vault accounting denomination rather
138+ * than an on-chain stablecoin product.
139+ *
140+ * @param slug stablecoin denomination slug
141+ */
142+ export function getStablecoinDetailsHref ( slug : string | null | undefined ) : string | undefined {
143+ const trimmedSlug = slug ?. trim ( ) . toLowerCase ( ) ;
144+ if ( ! trimmedSlug || trimmedSlug === OFFCHAIN_USD_STABLECOIN_SLUG ) return undefined ;
145+
146+ return `/trading-view/vaults/stablecoins/${ trimmedSlug } ` ;
147+ }
148+
149+ /**
150+ * Whether a vault is denominated in Midas' raw USD accounting currency.
151+ *
152+ * This is distinct from tokenised stablecoins such as USDT, even though their
153+ * metadata can expose a USD symbol alias.
154+ *
155+ * @param vault vault denomination fields
156+ */
157+ export function isMidasRawUsdVault ( vault : { protocol_slug ?: string | null ; denomination ?: string | null } ) : boolean {
158+ return vault . protocol_slug === 'midas' && vault . denomination ?. trim ( ) . toLowerCase ( ) === 'usd' ;
159+ }
160+
161+ /**
162+ * Return the denomination logo for a vault.
163+ *
164+ * Midas reports certain vaults as raw USD rather than an on-chain token. These
165+ * use the US flag; tokenised denominations such as USDT retain their own logos.
166+ *
167+ * @param vault vault denomination fields
168+ * @param slug resolved stablecoin denomination slug
169+ */
170+ export function getVaultDenominationLogoUrl (
171+ vault : { protocol_slug ?: string | null ; denomination ?: string | null } ,
172+ slug : string | null | undefined
173+ ) : string | undefined {
174+ if ( isMidasRawUsdVault ( vault ) ) {
175+ return OFFCHAIN_USD_LOGO_URL ;
176+ }
177+
178+ return slug ? getStablecoinLogoUrl ( slug ) : undefined ;
179+ }
180+
130181/**
131182 * Return the CoinGecko URL for a stablecoin metadata record.
132183 *
@@ -193,6 +244,10 @@ export function isStablecoinDepegged(metadata: StablecoinRateInput | null | unde
193244 * Returns undefined if the stablecoin metadata URL is not configured.
194245 */
195246export function getStablecoinLogoUrl ( slug : string , options : MetadataLogoOptions = { } ) : string | undefined {
247+ const normalisedSlug = slug . trim ( ) . toLowerCase ( ) ;
248+ if ( normalisedSlug === OFFCHAIN_USD_STABLECOIN_SLUG ) {
249+ return OFFCHAIN_USD_LOGO_URL ;
250+ }
196251 if ( ! stablecoinMetadataUrl ) return undefined ;
197252 return buildMetadataLogoProxyPath ( 'stablecoin' , slug , {
198253 format : 'webp' ,
0 commit comments