-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
794 improve pricing method #916
Conversation
@@ -6,6 +6,14 @@ export const localAssets: Metadata[] = LocalAssetRegistry.map(a => | |||
Metadata.fromJson(a as JsonValue), | |||
); | |||
|
|||
export const NUMERAIRE_DENOMS: string[] = ['test_usd', 'usdc']; | |||
export const NUMERAIRES: Metadata[] = localAssets.filter(m => NUMERAIRE_DENOMS.includes(m.display)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we will have two different local assets registy for testnet and mainnet. And we will have to revise the definition of NUMERAIRES
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm working on related registry stuff now
|
||
const aggregator = new BalancesAggregator(ctx, indexedDb); | ||
const latestBlockHeight = await querier.tendermint.latestBlockHeight(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to use latestBlockHeight
rather than fullSyncHeight
to avoid showing old prices during the sync process
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. Can you add a code comment above about this?
return results | ||
.map(price => EstimatedPrice.fromJson(price)) | ||
.filter(price => price.asOfHeight >= minHeight); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to do this in-memory filtering because we won't have a lot of price records for each asset. And using a cursor or double index would make the code and its support much more complicated
d932701
to
a69f97a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -6,6 +6,14 @@ export const localAssets: Metadata[] = LocalAssetRegistry.map(a => | |||
Metadata.fromJson(a as JsonValue), | |||
); | |||
|
|||
export const NUMERAIRE_DENOMS: string[] = ['test_usd', 'usdc']; | |||
export const NUMERAIRES: Metadata[] = localAssets.filter(m => NUMERAIRE_DENOMS.includes(m.display)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm working on related registry stuff now
|
||
const aggregator = new BalancesAggregator(ctx, indexedDb); | ||
const latestBlockHeight = await querier.tendermint.latestBlockHeight(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. Can you add a code comment above about this?
const assetId = getAssetId.optional()(new Metadata(denomMetadata)); | ||
if (assetId?.inner && !this.estimatedPriceByPricedAsset[uint8ArrayToBase64(assetId.inner)]) { | ||
const prices = await this.indexedDb.getPricesForAsset(new AssetId(assetId)); | ||
const assetMetadata = new Metadata(denomMetadata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why assetMetadataById() returns a partial 🤔 . You can also do:
const prices = await this.indexedDb.getPricesForAsset(
denomMetadata as Metadata,
this.latestBlockHeight,
);
This PR contains some improvements on asset pricing
Close #794