ebtc-protocol / ebtc

GNU General Public License v3.0
56 stars 25 forks source link

lens replacement, closed sync accounting #692

Closed dapp-whisperer closed 1 year ago

dapp-whisperer commented 1 year ago

Close syncAccounting

The open syncAccounting was closed to just be callable by borrower operations. This prevents using it to desort CDPs It's called on adjust and close

We do rely on syncing CDPs on tests. This seemed to work fine - take out and repay 1 debt unit as two actions

/// @dev sync cdp by adding and removing debt
function _syncIndividualCdp(bytes32 _cdpId) internal {
    address borrower = sortedCdps.getOwnerAddress(_cdpId);
    vm.startPrank(borrower);
    borrowerOperations.withdrawDebt(_cdpId, 1, bytes32(0), bytes32(0));
    borrowerOperations.repayDebt(_cdpId, 1, bytes32(0), bytes32(0));

    vm.stopPrank();
}

Replace CRLens Usage

CRLens relies on open syncAccounting.

Rather than create a CdpManagerTester with an open version, or replace syncAccounting with an open version that reinserts, I opted to remove CRLens usage for synced TCR, ICR, NICR.

These functions exist in the main code now.

CRLens method revamp

Invariants

invariant_GENERAL_12 invariant_GENERAL_13 invariant_GENERAL_14

were about confirming the CRLens values versus the native synced versions. This was very useful to confirm synced implemenation worked. They have been modified to reflect the above.

dapp-whisperer commented 1 year ago

Great, I can see that perspective.

So your proposal is to:

GalloDaSballo commented 1 year ago

@dapp-whisperer

Suggestion:

GalloDaSballo commented 1 year ago

Intuitively:

Alternatively:

GalloDaSballo commented 1 year ago

Could also do some weirdness with HEVM to have the CR Lens prank BO

dapp-whisperer commented 1 year ago

scrapped