Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentine1898 committed Apr 9, 2024
1 parent 1a53acd commit a69f97a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/constants/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ export const localAssets: Metadata[] = LocalAssetRegistry.map(a =>
export const NUMERAIRE_DENOMS: string[] = ['test_usd', 'usdc'];
export const NUMERAIRES: Metadata[] = localAssets.filter(m => NUMERAIRE_DENOMS.includes(m.display));

// PRICE_RELEVANCE_THRESHOLDS defines how long prices for different asset types remain relevant (in blocks)
// 1 block = 5 seconds, 200 blocks approximately equals 17 minutes
export const PRICE_RELEVANCE_THRESHOLDS = {
delegationToken: 719,
default: 200,
};

export const STAKING_TOKEN = 'penumbra';
export const STAKING_TOKEN_METADATA = localAssets.find(
metadata => metadata.display === STAKING_TOKEN,
Expand Down
5 changes: 5 additions & 0 deletions packages/storage/src/indexed-db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,11 @@ export class IndexedDb implements IndexedDbInterface {
});
}

/**
* Uses priceRelevanceThreshold to return only actual prices
* If more than priceRelevanceThreshold blocks have passed since the price was saved, such price is not returned
* priceRelevanceThreshold depends on the type of assets, for example, for delegation tokens the relevance lasts longer
*/
async getPricesForAsset(
assetMetadata: Metadata,
latestBlockHeight: bigint,
Expand Down

0 comments on commit a69f97a

Please sign in to comment.