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

feat(twap): fetch first 200 transactions using pagination #2994

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

shoom3301
Copy link
Collaborator

@shoom3301 shoom3301 commented Aug 3, 2023

Summary

Important! Change the target branch before merging!

Fixes #2642 #2993

To fetch Safe transactions we use @safe-global/api-kit, exactly: safeApiKit.getAllTransactions(safeAddress).
By default, it returns only the last 20 transactions. Unfortunately, the limit is hardcoded on the backend, so we can't set limit=200 and fetch all at once.
Anyway, getAllTransactions() method returns an URL for the next batch, so we can fetch as many as we want using pagination.

How the fetching works now:
Every 15 seconds we make 10 requests by 20 transactions (total = 200).
Just in case, I've added 100ms delay between requests.

@shoom3301 shoom3301 added the TWAP label Aug 3, 2023
@shoom3301 shoom3301 requested review from a team August 3, 2023 11:42
@shoom3301 shoom3301 self-assigned this Aug 3, 2023
@vercel
Copy link

vercel bot commented Aug 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
swap-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 3, 2023 11:52am

Copy link
Collaborator

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

Some questions and nitpicks

@elena-zh elena-zh mentioned this pull request Aug 3, 2023
Copy link

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

LGTM!

@shoom3301 shoom3301 changed the base branch from release/1.44.0 to main August 4, 2023 08:10
@shoom3301 shoom3301 changed the base branch from main to release/1.44-rc1 August 4, 2023 08:38
@shoom3301 shoom3301 merged commit 784ceb1 into release/1.44-rc1 Aug 4, 2023
11 of 12 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 4, 2023
@alfetopito alfetopito deleted the feat/2642 branch August 4, 2023 08:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants