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

Adds RISK_MANAGER role #181

Merged
merged 2 commits into from
Feb 19, 2024
Merged

Adds RISK_MANAGER role #181

merged 2 commits into from
Feb 19, 2024

Conversation

magnetto90
Copy link
Contributor

Solves #178

    /// @dev bound on notional cap to mitigate back-running attack
    /// @dev bound = macroWindowInBlocks * reserveInOv * 2 * delta
    function backRunBound(Oracle.Data memory data) public view returns (uint256) {
        uint256 averageBlockTime = params.get(Risk.Parameters.AverageBlockTime);
        uint256 window = (data.macroWindow * ONE * TO_MS) / averageBlockTime;
        uint256 delta = params.get(Risk.Parameters.Delta);
        return delta.mulDown(data.reserveOverMicroWindow).mulDown(window).mulDown(2 * ONE);
    }

Reference code

As @EperezOk mentions in this comment if the averageBlockTime decrease the window is increasead and also the cap(not visible in this segment of code).

Due the fact the current average block time of Arbitrum is 0.26s (source), we should set the averageBlockTime to this number and set an alarm to change it if necessary, for this purpose we add a new role named RISK_MANAGER that is able to change any Risk Parameter. This could be done automatically with a BOT or maybe using Defender.

Note: In the current version of Overlay Protocol this code is unreachable because we are using Chain Link Feed that sets the hasReserve property to false by default making any effort to solve this issue not necessary at the moment considering that adding a new feed also could lead to more modifications and a new audit.

@magnetto90 magnetto90 marked this pull request as ready for review February 19, 2024 19:03
@TomasCImach TomasCImach merged commit c947791 into staging Feb 19, 2024
4 checks passed
@TomasCImach TomasCImach deleted the s/risk-management branch February 19, 2024 19:16
@magnetto90 magnetto90 added the ToB label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants