You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, we only fetch and save historical token prices for NEAR native token. We need to expand this to include FTs.
To-do:
Add nullable coingecko_id field to Token model
When a new Token is created (e.g. in save() override when it's a new record - see this example), call Coingecko /coins/list API with include_platform=true, and find the Coingecko ID for this token if it exists (you'll have to check the platforms property of each Coingecko record for a near-protocol key and a value that matches the FT's address - see example response below)
If it exists on Coingecko, save Coingecko ID on Token record
Refactor Donation.fetch_usd_prices and PotPayout.fetch_usd_prices to share a single util method (e.g. tokens.utils.fetch_usd_prices_common) that takes a token, an amount, and a timestamp and returns the amount_usd that can be saved to the Donation or PotPayout record. This common method should probably also save the historical token price.
When fetching usd prices, use Token.coingecko_id in the request URL instead of Token.id.id. Skip the coingecko request if Token.coingecko_id is None.
Add "near" as coingecko_id for existing NEAR native token record (do this together with Lachlan on the EC2 instance)
Motivation
[More detailed explanation of the motivation for the enhancement, including any benefits it would provide]
Coingecko tokens could alternatively be fetched and added in a recurring job, but this would create many more tokens than are actually used in PotLock, and additionally token metadata would need to be fetched for each token to get its decimals etc. I think a Token.save() method override is a simpler and more targeted solution at this point.
Risks
[Identification and mitigation of any potential risks associated with the enhancement]
Acceptance Criteria
[List of criteria that must be met for the enhancement to be considered accepted]
Additional Information
[Any other relevant information, such as links to related issues or pull requests]
The text was updated successfully, but these errors were encountered:
Summary
Currently, we only fetch and save historical token prices for NEAR native token. We need to expand this to include FTs.
To-do:
coingecko_id
field toToken
modelToken
is created (e.g. insave()
override when it's a new record - see this example), call Coingecko/coins/list
API withinclude_platform=true
, and find the Coingecko ID for this token if it exists (you'll have to check theplatforms
property of each Coingecko record for anear-protocol
key and a value that matches the FT's address - see example response below)Donation.fetch_usd_prices
andPotPayout.fetch_usd_prices
to share a single util method (e.g.tokens.utils.fetch_usd_prices_common
) that takes atoken
, anamount
, and atimestamp
and returns theamount_usd
that can be saved to theDonation
orPotPayout
record. This common method should probably also save the historical token price.Token.coingecko_id
in the request URL instead ofToken.id.id
. Skip the coingecko request ifToken.coingecko_id
isNone
."near"
ascoingecko_id
for existing NEAR native token record (do this together with Lachlan on the EC2 instance)Motivation
[More detailed explanation of the motivation for the enhancement, including any benefits it would provide]
Description
Here is an example Coingecko response:
Alternatives
Coingecko tokens could alternatively be fetched and added in a recurring job, but this would create many more tokens than are actually used in PotLock, and additionally token metadata would need to be fetched for each token to get its decimals etc. I think a
Token.save()
method override is a simpler and more targeted solution at this point.Risks
[Identification and mitigation of any potential risks associated with the enhancement]
Acceptance Criteria
[List of criteria that must be met for the enhancement to be considered accepted]
Additional Information
[Any other relevant information, such as links to related issues or pull requests]
The text was updated successfully, but these errors were encountered: