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

make CDP debt index always update as long as there is a global index update #694

Merged
merged 4 commits into from
Oct 13, 2023

Conversation

rayeaster
Copy link
Contributor

@rayeaster rayeaster changed the title make CDP debt index always update as long as there is a glogal index … make CDP debt index always update as long as there is a global index update Oct 13, 2023
Comment on lines +357 to +358
_cdp.debt = _newDebt;
_emitCdpUpdatedEventForSyncAccounting(_cdpId, _cdp, _newDebt, _cdp.coll);
Copy link

@dmitriia dmitriia Oct 13, 2023

Choose a reason for hiding this comment

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

It looks like it is always _cdp.debt == _newDebt, _cdp.coll == _newColl for the event:

    function _emitCdpUpdatedEventForSyncAccounting(
        bytes32 _cdpId,
        Cdp storage _cdp,
        uint256 _newDebt,
        uint256 _newColl
    ) internal {
        emit CdpUpdated(
            _cdpId,
            ISortedCdps(sortedCdps).getOwnerAddress(_cdpId),
            msg.sender,
>           _cdp.debt,
>           _cdp.coll,
>           _newDebt,
>           _newColl,
            _cdp.stake,
            CdpOperation.syncAccounting
        );
    }

For collateral part it is needed to have old one returned or it can be just said that CdpFeeSplitApplied is enough for reporting.

For debt the order can be changed:

https://github.com/Badger-Finance/ebtc/blob/c8b1f4b6d390983b37e0d52a3ea8e44efb07acd6/packages/contracts/contracts/CdpManagerStorage.sol#L354-L360

            if (prevDebt != _newDebt) {
                {
                    // Apply pending debt redistribution to this CDP
-                   _cdp.debt = _newDebt;
                    _emitCdpUpdatedEventForSyncAccounting(_cdpId, _cdp, _newDebt, _cdp.coll);
+                   _cdp.debt = _newDebt;
                }
            }

@dapp-whisperer
Copy link
Contributor

optimistic merging as per thread

@dapp-whisperer dapp-whisperer merged commit c8b3fe8 into feat/release-0.5 Oct 13, 2023
3 checks passed
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