Skip to content
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

eth: implement multi-balance contract for evm balance checks #2520

Merged
merged 2 commits into from
Sep 22, 2023

Conversation

buck54321
Copy link
Member

Contract MultiBalanceV0 has one public view function

function balances(address acct, address[] calldata tokenAddresses) public view returns (uint256[] memory)

that returns the balance for an account and for any number of tokens. Greatly reduces the request rate to providers.

Additionally implements a cache for balances, so repeated Balance calls don't hammer the provider between blocks.

Copy link
Contributor

@martonp martonp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

if w.balances.m == nil {
w.balances.m = make(map[uint32]*cachedBalance)
}
// Check to see if wa already have one up-to-date
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we

Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool idea. Did you just think it up?

@buck54321 buck54321 merged commit c7fa56d into decred:master Sep 22, 2023
peterzen pushed a commit to peterzen/dcrdex that referenced this pull request Sep 25, 2023
…2520)

* implement multi-wallet balance contract for eth and polygon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants