Open krzkaczor opened 2 years ago
CC: @Padraic-O-Mhuiris
The general idea is that it would be useful to generate contract metadata statically as opposed to making numerous calls at runtime. The simplest example of this is for a frontend that is dependent on N
amount of ERC20 contracts and would require 3N
requests for getting the name, symbol and decimals for each. Where an application may have a small number of tokens, it would not be any significant gain, but where there are a large number of request to contract data which specifically never changes like in the ERC20 case, it is more performant for the application to have them stored statically.
It can also be remediated somewhat using multicall but that does complicate the methodology in how you fetch async contract data
mainnet: {
dai: {
address: '0x0',
meta: {
decimals: "decimals()"
}
}
...
const sdk = getMainnetSDK()
sdk.dai.meta.decimals === 18 // true
Another way we could do it that would be cleaner but maybe more obfuscating is by replacing the async call to decimals
with a static one if we know we have it. This would mean we would reference the contract information intuitively as opposed to the meta tag.
mainnet: {
dai: {
address: '0x0',
meta: {
decimals: "decimals()"
}
}
...
const sdk = getMainnetSDK()
sdk.dai.decimals === 18 // true - changed from Promise<BigNumberish> to BigNumberish
That may be opinionated and the meta or a static
key could be also used.
Another idea would be to include a label or tagging scheme for each contract which could make categorisation easier - say tagging a number of tokens to the name of a pool contract for easier lookup.
It's so nice to store everything in one place. It could be useful to enable arbitrary metadata stored for each contract.