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: Smarter exchange rate updates #1308

Merged
merged 15 commits into from
Mar 21, 2024
Merged

Conversation

nicholaspai
Copy link
Member

@nicholaspai nicholaspai commented Mar 19, 2024

This is from a comment added in Dataworker.ts that also explains this PR well:

// There are three times that we should look to update the HubPool's liquid reserves:
// 1. First, before we attempt to execute the HubChain PoolRebalance leaves and RelayerRefund leaves.
//    We should see if there are new liquid reserves we need to account for before sending out these
//    netSendAmounts.
// 2. Second, before we attempt to execute the PoolRebalance leaves for the other chains. We should
//    see if there are new liquid reserves we need to account for before sending out these netSendAmounts. This
//    updated liquid reserves balance could be from previous finalizations or any amountToReturn value sent
//    back from the Ethereum RelayerRefundLeaves.
// 3. Third, we haven't updated the exchange rate for an L1 token on a PoolRebalanceLeaf in a while that
//    we're going to execute, so we should batch in an update.

The motivation for this PR is to reduce the # of exchangeRateCurrent() calls to reduce dataworker costs. This PR should make it such that these calls are only batched with PoolRebalanceLeaf executions and never sent otherwise.

This is from a comment added in `Dataworker.ts` that also explains this PR well:

```
// There are three times that we should look to update the HubPool's liquid reserves:
    // 1. First, before we attempt to execute the HubChain PoolRebalance leaves and RelayerRefund leaves.
    //    We should see if there are new liquid reserves we need to account for before sending out these
    //    netSendAmounts.
    // 2. Second, before we attempt to execute the PoolRebalance leaves for the other chains. We should
    //    see if there are new liquid reserves we need to account for before sending out these netSendAmounts. This
    //    updated liquid reserves balance could be from previous finalizations or any amountToReturn value sent
    //    back from the Ethereum RelayerRefundLeaves.
    // 3. Third, we haven't updated the exchange rate for an L1 token on a PoolRebalanceLeaf in a while that
    //    we're going to execute, so we should batch in an update.
```

The motivation for this PR is to reduce the # of `exchangeRateCurrent()` calls to reduce dataworker costs. This PR should make it such that these calls are only batched with PoolRebalanceLeaf executions and never sent otherwise.
@pxrl pxrl changed the base branch from master to pxrl/buildRootsTest March 19, 2024 15:18
Base automatically changed from pxrl/buildRootsTest to master March 19, 2024 15:39
Copy link
Contributor

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

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

Code looks great! Only question is around the updates that aren't directly related to an execution need.

src/dataworker/Dataworker.ts Show resolved Hide resolved
src/dataworker/Dataworker.ts Show resolved Hide resolved
src/dataworker/Dataworker.ts Outdated Show resolved Hide resolved
@nicholaspai nicholaspai requested a review from mrice32 March 21, 2024 17:20
@nicholaspai nicholaspai merged commit 3aa299e into master Mar 21, 2024
4 checks passed
@pxrl pxrl deleted the npai/exchange-rate-update branch September 5, 2024 10:27
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