GithubHelp home page GithubHelp logo

wildcat-protocol's Introduction

wildcat-protocol's People

Contributors

d1ll0n avatar jtriley-eth avatar laurenceday avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wildcat-protocol's Issues

Adjust reserve ratio change from 90% to a dynamic ratio

Current thinking is to set it to max( 2 * (newRate - oldRate)/oldRate, currentReserve ).

This means that a reduction in APR from 10% to 7% (a 30% change) would produce a temporary reserve ratio of 60%. If the existing reserve ratio is higher than 60%, it would keep that rate as is.

The relative difference change is capped out at 100% - i.e. reducing the APR by 60% doesn't produce a 120% reserve.

Designed to force liquidity back into the market for a ragequit option, but without completely crippling the borrowers ability to utilise the market for those two weeks.

Demo commit here: 1a5e4bc

Modify vault role management

Only call controller isAuthorizedLender if account has null status.

Replace grant/revoke functions with single update function.

Add ability to remove Blocked role from an account once sanctioned status is lifted.

  • Requires a new function in WildcatMarketConfig

Modify sentinel to allow borrower to override an account's sanctioned status so that accounts can't immediately be blocked after escrowed assets are released.

C4: borrowers can still borrow up to max reserves while sanctioned

My thinking here is that if the lenders notice that borrower is sanctioned, they're going to want to withdraw quick - someone who's sanctioned might not give a damn because they're clearly already in trouble and just borrow right up to the reserve limit if there's anything still available.

Say a market is at 50% reserves on a 20% minimum reserve ratio vault, then borrower is sanctioned - this could be the difference between an 80% and 50% haircut in the scenario where borrower goes 'well, better take all I can!'.

The way this is overridden is just that they get unsanctioned (we obviously shouldn't allow borrowers to override their own sanction) - they can still deposit assets either directly or via repay, which is bad in terms of strict liability but we can't prevent it, and a sanctioned borrower can still close a market, so even though that's a real mess the functionality is still all there.

Fixed by 299833d

C4: Apply payments to unexpired pending batches in _getUpdatedState

Ref: code-423n4/2023-10-wildcat-findings#365

Currently there is no way for borrowers to avoid interest accrual on pending batches with sufficient available liquidity, absent a call to queueWithdrawal.

Fix: apply payments to pending batches in _getUpdatedState.

This will also require a change to _calculateCurrentState which returns the expired batch data if one exists so that queries for withdrawal batches can retrieve the correct pending status of that batch. This should be modified to return the pending batch if one exists but has not expired.

Update `MarketDeployed` and `ScaleFactorUpdated` events

These should have additional data to reduce the complexity of indexing the protocol off-chain.

Replace ScaleFactorUpdated with:

  event InterestAndFeesAccrued(
    uint256 fromTimestamp,
    uint256 toTimestamp,
    uint256 scaleFactor,
    uint256 baseInterestRay,
    uint256 delinquencyFeeRay,
    uint256 protocolFees
  );

Replace MarketDeployed with:

  event MarketDeployed(
    address indexed market,
    address asset,
    uint256 maxTotalSupply,
    uint256 annualInterestBips,
    uint256 delinquencyFeeBips,
    uint256 withdrawalBatchDuration,
    uint256 reserveRatioBips,
    uint256 delinquencyGracePeriod,
    string name,
    string symbol
  );

Additionally, WildcatMarketController does not actually emit the MarketDeployed event, so fix that.

C4: closing a market even with no outstanding batches may still have a non-zero grace tracker value

The problem with this is that it means that the scale factor will still inflate according to the delinquencyFee for as long as it's in excess of the grace period - the result is that the last person who attempts to redeem their market tokens when exiting won't be able to access enough reserves.

The check on the unpaidBatches.length() > 0 isn't actually checking for delinquency (which is state.timeDelinquent > delinquencyGracePeriod) it's just checking whether or not there's anything that still needs assigning assets to.

delinquencyFee is an immutable value, so it's cleaner to just zero the tracker.

Fixed by 292ebda

Cast `scaledAmountBurned` to uint104 instead of `scaledAvailableLiquidity`

uint104 scaledAvailableLiquidity = state.scaleAmount(availableLiquidity).toUint104();
uint104 scaledAmountBurned = uint104(MathUtils.min(scaledAvailableLiquidity, scaledAmountOwed));

uint104 scaledAvailableLiquidity = state.scaleAmount(availableLiquidity).toUint104();
uint104 scaledAmountOwed = batch.scaledTotalAmount - batch.scaledAmountBurned;

Adjust temporary reserve ratio rules

Add the original interest rate to the TemporaryReserveRatio struct.

When setting the interest rate, modify the code so that:

  • If there is a temporary reserve ratio in place and the new APR is gte the original interest rate, cancel the temporary reserve ratio.
  • For APR reductions, use the original reserve ratio and APR (from the market if there is no temporary ratio in place, otherwise from storage) for the formula from #56.

Update market events

Index expiry in all withdrawal events.

Index account in SanctionedAccountAssetsSentToEscrow and SanctionedAccountWithdrawalSentToEscrow

Add normalizedAmount to WithdrawalQueued

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.