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

Add missing transfers for sDAI deposits and withdraws #327

Merged
merged 4 commits into from
Dec 15, 2023
Merged

Conversation

fhenneke
Copy link
Collaborator

@fhenneke fhenneke commented Dec 13, 2023

Conversions DAI<>sDAI are not correctly accounted for in the current slippage query. This has led to two settlements with computes slippage even though the slippage was actually small.

The reason is that Withdraw and Deposit events are only accompanied by one transfer. But in terms buffer changes they correspond to two transfers.

Tenderly and eigenphi get this wrong as well in their asset change calculations. To see what happens to buffers one can use phalcon or look at state changes.

With the proposed change, additional transfers are created by looking at event logs of the SavingsDAI contract.

  • One AMM_IN transfer is created for each Withdraw event.
  • One AMM_OUT transfer is created for each Deposit event.

This is not a general solution and only works for sDAI. Since we want to support that token now, I added this fix to the query.
Long term it would be nice to have a more general solution.

looks at event logs of the savings dai contract and adds a
- AMM_IN transfers for Withdraw events
- AMM_OUT transfers for Deposit events
@fhenneke fhenneke requested a review from harisang December 13, 2023 18:35
Copy link
Contributor

@bh2smith bh2smith left a comment

Choose a reason for hiding this comment

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

Nice job here!

@fhenneke fhenneke changed the title Add missing transfers for cDAI deposits and withdraws Add missing transfers for sDAI deposits and withdraws Dec 15, 2023
@fhenneke
Copy link
Collaborator Author

I fixed some typos and added the pull request number.

For completeness, here is a forked query on dune for the two affected auctions:

If this PR is merged, I will update

  • the original period slippage query
  • the period payout query (for the dashboard)
  • the unusual slippage query (for our dune alerts)

@fhenneke fhenneke requested a review from harisang December 15, 2023 09:03
@harisang
Copy link
Contributor

Looks good! Doing some sanity checks with settlements with sDAI for which we didn't have any accounting issues, and if things look good, will approve

@fhenneke
Copy link
Collaborator Author

Good catch. The problem was that the tranfer ledger should only contain transfers to and from the settlement contract. Thus it also only should add additional transfers for sDAI if the settlement contract is doing the trading. I added a check in the query.

@harisang
Copy link
Contributor

All tests that I ran checked out, and the code makes sense, so I am approving!

@fhenneke fhenneke merged commit 7571656 into main Dec 15, 2023
6 checks passed
@fhenneke fhenneke deleted the sDAI_workaround branch December 15, 2023 18:14
@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants