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

Aavechan/llamarisk risk provider #309

Merged
merged 10 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol';

/**
* @title Llamarisk Risk Provider
* @author Aave Chan Initiative
* - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x2b7433455b16d50b9b6afdf2e60bfd6e733896224688c9891c371aa2597853a2
* - Discussion: https://governance.aave.com/t/arfc-onboard-new-risk-service-provider/17348
*/
contract AaveV3Ethereum_LlamariskRiskProvider_20240421 is IProposalGenericExecutor {
address public constant LLAMARISK_RECIPIENT = 0x0000000000000000000000000000000000000000;
marczeller marked this conversation as resolved.
Show resolved Hide resolved
uint256 public constant GHO_STREAM = 250_000 ether;
uint256 public constant STREAM_DURATION = 180 days;

uint256 public constant ACTUAL_GHO_STREAM = (GHO_STREAM / STREAM_DURATION) * STREAM_DURATION;
function execute() external {
// create a stream of 250 000 GHO to the Llamarisk team
AaveV3Ethereum.COLLECTOR.createStream(
LLAMARISK_RECIPIENT,
ACTUAL_GHO_STREAM,
AaveV3EthereumAssets.GHO_UNDERLYING,
block.timestamp,
block.timestamp + STREAM_DURATION
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol';
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';
import 'forge-std/Test.sol';
import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol';
import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol';
import {AaveV3Ethereum_LlamariskRiskProvider_20240421} from './AaveV3Ethereum_LlamariskRiskProvider_20240421.sol';

/**
* @dev Test for AaveV3Ethereum_LlamariskRiskProvider_20240421
* command: make test-contract filter=AaveV3Ethereum_LlamariskRiskProvider_20240421
*/
contract AaveV3Ethereum_LlamariskRiskProvider_20240421_Test is ProtocolV3TestBase {
AaveV3Ethereum_LlamariskRiskProvider_20240421 internal proposal;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 19705748);
proposal = new AaveV3Ethereum_LlamariskRiskProvider_20240421();
}

/**
* @dev executes the generic test suite including e2e and config snapshots
*/
function test_defaultProposalExecution() public {
defaultTest(
'AaveV3Ethereum_LlamariskRiskProvider_20240421',
AaveV3Ethereum.POOL,
address(proposal)
);
}

function test_validateStreamsConfig() public {
GovV3Helpers.executePayload(vm, address(proposal));

uint256 currentCollectorStreamId = AaveV3Ethereum.COLLECTOR.getNextStreamId() - 1;

_validateGhoStreamConfig(currentCollectorStreamId - 1);
brotherlymite marked this conversation as resolved.
Show resolved Hide resolved
marczeller marked this conversation as resolved.
Show resolved Hide resolved
}

function test_withdrawFromStream() public {
GovV3Helpers.executePayload(vm, address(proposal));

uint256 currentCollectorStreamId = AaveV3Ethereum.COLLECTOR.getNextStreamId() - 1;

uint256 timeWarp = 180 days + 1;
vm.warp(block.timestamp + timeWarp);

_validateGhoStreamWithdrawal(currentCollectorStreamId - 1, timeWarp);
marczeller marked this conversation as resolved.
Show resolved Hide resolved
}

function _validateGhoStreamConfig(uint256 streamId) internal {
(
address sender,
address recipient,
uint256 amount,
address token,
uint256 startTime,
uint256 endTime,
uint256 toClaim,

) = AaveV3Ethereum.COLLECTOR.getStream(streamId);

assertEq(sender, address(AaveV3Ethereum.COLLECTOR));
assertEq(recipient, proposal.LLAMARISK_RECIPIENT());
assertEq(amount, proposal.ACTUAL_GHO_STREAM());
assertEq(token, AaveV3EthereumAssets.GHO_UNDERLYING);
assertEq(endTime - startTime, proposal.STREAM_DURATION());
assertEq(toClaim, proposal.ACTUAL_GHO_STREAM());
}

function _validateGhoStreamWithdrawal(uint256 streamId, uint256 timeWarp) internal {
marczeller marked this conversation as resolved.
Show resolved Hide resolved
uint256 balanceBefore = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
proposal.LLAMARISK_RECIPIENT()
);

vm.startPrank(proposal.LLAMARISK_RECIPIENT());
uint256 streamSpeed = proposal.ACTUAL_GHO_STREAM() / proposal.STREAM_DURATION();
uint256 accrued = streamSpeed * timeWarp;
marczeller marked this conversation as resolved.
Show resolved Hide resolved

AaveV3Ethereum.COLLECTOR.withdrawFromStream(streamId, accrued);
marczeller marked this conversation as resolved.
Show resolved Hide resolved

uint256 balanceAfter = IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).balanceOf(
proposal.LLAMARISK_RECIPIENT()
);
assertEq(balanceAfter, balanceBefore + accrued);
marczeller marked this conversation as resolved.
Show resolved Hide resolved
vm.stopPrank();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: "Onboard Llamarisk as a Risk Provider"
author: "Aave Chan Initiative"
discussions: "https://governance.aave.com/t/arfc-onboard-new-risk-service-provider/17348"
snapshot: "https://snapshot.org/#/aave.eth/proposal/0x2b7433455b16d50b9b6afdf2e60bfd6e733896224688c9891c371aa2597853a2"
---

## Simple Summary

This AIP will onboard the LlamaRisk team as Aave's second Risk Service Provider and set up the payment stream.

## Motivation

The Aave DAO is using a dual risk provider models, since a spot is vacant and a [snapshot vote](https://snapshot.org/#/aave.eth/proposal/0x2b7433455b16d50b9b6afdf2e60bfd6e733896224688c9891c371aa2597853a2) to choose a new one among three candidates ended with the community voicing their support for the LlamaRisk Team, this AIP is here to make it official and set the payement stream to compensate them with 250,000 GHO over the next 6 months of their engagement.
marczeller marked this conversation as resolved.
Show resolved Hide resolved

## Specification

Recognizing the significance of a dual risk provider model, LlamaRisk’s proposal is designed to complement Chaos Labs’ risk services, with whom we plan to collaborate extensively.

The initial 6-month engagement, which may be extended pending DAO approval, involves the following scope:

- **On-demand Risk Assessments:** LlamaRisk will deliver prompt and in-depth risk assessments for assets listed or considered to be listed on Aave with particular emphasis on the collateral types comprising the GHO stablecoin. This will involve developing a custom framework tailored specifically to the categories of relevant assets and Aave’s needs, which will standardize the assessment process.
- **Collaborative Engagement with Chaos Labs:** We plan to collaborate extensively with Chaos Labs, combining our expertise to provide Aave with comprehensive and nuanced risk analysis, enhancing the protocol’s risk management capacity.
- **Active Involvement in DAO Governance:** LlamaRisk will actively participate in Aave’s DAO governance, offering informed insights and strategic recommendations on risk management practices for principal stakeholders and the community.
- **Legal Regulatory Advisory and Policy Work:** We will offer specialized legal research and regulatory guidance, including a thorough analysis of evolving legal frameworks and regulatory policies, and equip Aave with the necessary foresight to navigate the regulatory landscape of the DeFi sector effectively.

Risk vectors are diverse and cannot be fully managed by qualitative risk tools. That is why we specialize in comprehensive risk assessment of tokenized assets and DeFi protocols. Our work supports our partners in making informed decisions that mitigate potential threats and promote a culture of transparency and sustainability. Our team of experts meticulously evaluate various risk factors, including but not limited to:

- Protocol design and architecture
- Tokenomics and economic incentives
- Smart contract security
- Governance mechanisms
- Regulatory compliance

LlamaRisk leverages advanced simulation techniques, including statistical and agent-based modeling, to test and validate DeFi protocols and their collateral assets under various stress scenarios. Our simulations provide valuable insights into potential risks, allowing our partner protocols to set competitive parameters resilient to adverse market conditions.

Our DeFi strategy managers employ data analytics and risk monitoring tools that allow us to maintain high efficiency and safety standards. We support our partners with publications and dashboards that give users the information they need to interact with the protocol responsibly.

Our advisory services cater to the unique needs of DeFi projects, providing strategic guidance and support throughout their lifecycle. From ideation to implementation, our experienced advisors offer expert advice on protocol design, tokenomics, governance, and risk management strategies, ensuring optimal outcomes for our partners.
Comment

Traversing the complex regulatory landscape is crucial for DeFi protocols and projects. Our team of legal experts provides in-depth analysis and guidance to ensure compliance with applicable laws and regulations. We evaluate legal risks, assist with regulatory filings, and help clients develop robust strategies for operating within the evolving regulatory framework.

We actively engage in policy development and legislative processes related to crypto and blockchain at national, supranational, and international levels. This includes participating in specialized working groups, contributing opinions to public discussions on regulatory developments, and involvement in policymaking dialogues. We aim to ensure that DeFi stakeholders are represented and protected in the evolving regulatory landscape, facilitating informed and proactive responses to legislative changes.

## Technical specification

This AIP will have the collector setup a 250 000 GHO stream for 6 months toward the LlamaRisk treasury address.

## References

- Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240421_AaveV3Ethereum_LlamariskRiskProvider/AaveV3Ethereum_LlamariskRiskProvider_20240421.sol)
- Tests: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240421_AaveV3Ethereum_LlamariskRiskProvider/AaveV3Ethereum_LlamariskRiskProvider_20240421.t.sol)
- [Snapshot](https://snapshot.org/#/aave.eth/proposal/0x2b7433455b16d50b9b6afdf2e60bfd6e733896224688c9891c371aa2597853a2)
- [Discussion](https://governance.aave.com/t/arfc-onboard-new-risk-service-provider/17348)

## Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol';
import {EthereumScript} from 'aave-helpers/ScriptUtils.sol';
import {AaveV3Ethereum_LlamariskRiskProvider_20240421} from './AaveV3Ethereum_LlamariskRiskProvider_20240421.sol';

/**
* @dev Deploy Ethereum
* deploy-command: make deploy-ledger contract=src/20240421_AaveV3Ethereum_LlamariskRiskProvider/LlamariskRiskProvider_20240421.s.sol:DeployEthereum chain=mainnet
* verify-command: npx catapulta-verify -b broadcast/LlamariskRiskProvider_20240421.s.sol/1/run-latest.json
*/
contract DeployEthereum is EthereumScript {
function run() external broadcast {
// deploy payloads
address payload0 = GovV3Helpers.deployDeterministic(
type(AaveV3Ethereum_LlamariskRiskProvider_20240421).creationCode
);

// compose action
IPayloadsControllerCore.ExecutionAction[]
memory actions = new IPayloadsControllerCore.ExecutionAction[](1);
actions[0] = GovV3Helpers.buildAction(payload0);

// register action at payloadsController
GovV3Helpers.createPayload(actions);
}
}

/**
* @dev Create Proposal
* command: make deploy-ledger contract=src/20240421_AaveV3Ethereum_LlamariskRiskProvider/LlamariskRiskProvider_20240421.s.sol:CreateProposal chain=mainnet
*/
contract CreateProposal is EthereumScript {
function run() external {
// create payloads
PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](1);

// compose actions for validation
IPayloadsControllerCore.ExecutionAction[]
memory actionsEthereum = new IPayloadsControllerCore.ExecutionAction[](1);
actionsEthereum[0] = GovV3Helpers.buildAction(
type(AaveV3Ethereum_LlamariskRiskProvider_20240421).creationCode
);
payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum);

// create proposal
vm.startBroadcast();
GovV3Helpers.createProposal(
vm,
payloads,
GovV3Helpers.ipfsHashFile(
vm,
'src/20240421_AaveV3Ethereum_LlamariskRiskProvider/LlamariskRiskProvider.md'
)
);
}
}
14 changes: 14 additions & 0 deletions src/20240421_AaveV3Ethereum_LlamariskRiskProvider/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {ConfigFile} from '../../generator/types';
export const config: ConfigFile = {
rootOptions: {
author: 'Aave Chan Initiative',
pools: ['AaveV3Ethereum'],
title: 'Llamarisk Risk Provider',
shortName: 'LlamariskRiskProvider',
date: '20240421',
discussion: 'https://governance.aave.com/t/arfc-onboard-new-risk-service-provider/17348',
snapshot:
'https://snapshot.org/#/aave.eth/proposal/0x2b7433455b16d50b9b6afdf2e60bfd6e733896224688c9891c371aa2597853a2',
},
poolOptions: {AaveV3Ethereum: {configs: {OTHERS: {}}, cache: {blockNumber: 19705748}}},
};