Summary
Currently, we only fetch and save historical token prices for NEAR native token. We need to expand this to include FTs.
To-do:
Motivation
[More detailed explanation of the motivation for the enhancement, including any benefits it would provide]
Description
Here is an example Coingecko response:
[
{
"id": "1inch",
"symbol": "1inch",
"name": "1inch",
"platforms": {
"ethereum": "0x111111111117dc0aa78b770fa6a738034120c302",
"harmony-shard-0": "0x58f1b044d8308812881a1433d9bbeff99975e70c",
"avalanche": "0xd501281565bf7789224523144fe5d98e8b28f267",
"binance-smart-chain": "0x111111111117dc0aa78b770fa6a738034120c302",
"near-protocol": "111111111117dc0aa78b770fa6a738034120c302.factory.bridge.near",
"polygon-pos": "0x9c2c5fd7b07e95ee044ddeba0e97a665f142394f",
"energi": "0xdda6205dc3f47e5280eb726613b27374eee9d130"
}
},
...
]
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]
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_idfield toTokenmodelTokenis created (e.g. insave()override when it's a new record - see this example), call Coingecko/coins/listAPI withinclude_platform=true, and find the Coingecko ID for this token if it exists (you'll have to check theplatformsproperty of each Coingecko record for anear-protocolkey and a value that matches the FT's address - see example response below)Donation.fetch_usd_pricesandPotPayout.fetch_usd_pricesto share a single util method (e.g.tokens.utils.fetch_usd_prices_common) that takes atoken, anamount, and atimestampand returns theamount_usdthat can be saved to theDonationorPotPayoutrecord. This common method should probably also save the historical token price.Token.coingecko_idin the request URL instead ofToken.id.id. Skip the coingecko request ifToken.coingecko_idisNone."near"ascoingecko_idfor 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:
[ { "id": "1inch", "symbol": "1inch", "name": "1inch", "platforms": { "ethereum": "0x111111111117dc0aa78b770fa6a738034120c302", "harmony-shard-0": "0x58f1b044d8308812881a1433d9bbeff99975e70c", "avalanche": "0xd501281565bf7789224523144fe5d98e8b28f267", "binance-smart-chain": "0x111111111117dc0aa78b770fa6a738034120c302", "near-protocol": "111111111117dc0aa78b770fa6a738034120c302.factory.bridge.near", "polygon-pos": "0x9c2c5fd7b07e95ee044ddeba0e97a665f142394f", "energi": "0xdda6205dc3f47e5280eb726613b27374eee9d130" } }, ... ]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]