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

feat: on-Ethereum listing engines #52

Merged
merged 1 commit into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 13 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
ETHERSCAN_API_KEY=
RPC_URL=
PRIVATE_KEY=
MNEMONIC_INDEX=
LEDGER_SENDER=

# Test rpc_endpoints
RPC_MAINNET=https://rpc.flashbots.net
RPC_AVALANCHE=https://api.avax.network/ext/bc/C/rpc
RPC_OPTIMISM=https://mainnet.optimism.io
RPC_POLYGON=https://polygon-rpc.com
RPC_POLYGON=https://polygon-rpc.com
RPC_ARBITRUM=https://arb1.arbitrum.io/rpc
RPC_FANTOM=https://rpc.ftm.tools
RPC_HARMONY=https://api.harmony.one

ETHERSCAN_API_KEY_MAINNET=
ETHERSCAN_API_KEY_POLYGON=
ETHERSCAN_API_KEY_AVALANCHE=
ETHERSCAN_API_KEY_FANTOM=
ETHERSCAN_API_KEY_OPTIMISM=
ETHERSCAN_API_KEY_ARBITRUM=
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ build :; forge build --sizes --via-ir
test :; forge test -vvv
test-v3-listing-engine:; forge test -vvv --match-contract GenericV3ListingEngineTest --gas-report


# Scripts
listing-engine-opt :; forge script script/GenericListingEngine.s.sol:DeployListingEngineOpt --rpc-url optimism --broadcast --legacy --ledger --mnemonic-indexes ${MNEMONIC_INDEX} --sender ${LEDGER_SENDER} --verify --etherscan-api-key ${ETHERSCAN_API_KEY_OPTIMISM} -vvvv
listing-engine-arb :; forge script script/GenericListingEngine.s.sol:DeployListingEngineArb --rpc-url arbitrum --broadcast --legacy --ledger --mnemonic-indexes ${MNEMONIC_INDEX} --sender ${LEDGER_SENDER} --verify --etherscan-api-key ${ETHERSCAN_API_KEY_ARBITRUM} -vvvv
listing-engine-pol :; forge script script/GenericListingEngine.s.sol:DeployListingEnginePol --rpc-url polygon --broadcast --legacy --ledger --mnemonic-indexes ${MNEMONIC_INDEX} --sender ${LEDGER_SENDER} --verify --etherscan-api-key ${ETHERSCAN_API_KEY_POLYGON} -vvvv
listing-engine-ava :; forge script script/GenericListingEngine.s.sol:DeployListingEngineAva --rpc-url avalanche --broadcast --legacy --ledger --mnemonic-indexes ${MNEMONIC_INDEX} --sender ${LEDGER_SENDER} --verify --etherscan-api-key ${ETHERSCAN_API_KEY_AVALANCHE} -vvvv

# Utilities
download :; cast etherscan-source --chain ${chain} -d src/etherscan/${chain}_${address} ${address}
git-diff :
Expand Down
97 changes: 97 additions & 0 deletions script/GenericListingEngine.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Script} from 'forge-std/Script.sol';
import {AaveV3Optimism} from 'aave-address-book/AaveV3Optimism.sol';
import {AaveV3Arbitrum} from 'aave-address-book/AaveV3Arbitrum.sol';
import {AaveV3Polygon} from 'aave-address-book/AaveV3Polygon.sol';
import {AaveV3Avalanche} from 'aave-address-book/AaveV3Avalanche.sol';
import {GenericV3ListingEngine} from '../src/v3-listing-engine/GenericV3ListingEngine.sol';

/**
* Helper contract to enforce correct chain selection in scripts
*/
abstract contract WithChainIdValidation is Script {
constructor(uint256 chainId) {
require(block.chainid == chainId, 'CHAIN_ID_MISMATCH');
}
}

abstract contract OptimismScript is WithChainIdValidation {
constructor() WithChainIdValidation(10) {}
}

abstract contract ArbitrumScript is WithChainIdValidation {
constructor() WithChainIdValidation(42161) {}
}

abstract contract PolygonScript is WithChainIdValidation {
constructor() WithChainIdValidation(137) {}
}

abstract contract AvalancheScript is WithChainIdValidation {
constructor() WithChainIdValidation(43114) {}
}

contract DeployListingEngineOpt is OptimismScript {
function run() external {
vm.startBroadcast();
new GenericV3ListingEngine(
AaveV3Optimism.POOL_CONFIGURATOR,
AaveV3Optimism.ORACLE,
AaveV3Optimism.DEFAULT_A_TOKEN_IMPL_REV_1,
AaveV3Optimism.DEFAULT_VARIABLE_DEBT_TOKEN_IMPL_REV_1,
AaveV3Optimism.DEFAULT_STABLE_DEBT_TOKEN_IMPL_REV_1,
AaveV3Optimism.DEFAULT_INCENTIVES_CONTROLLER,
AaveV3Optimism.COLLECTOR
);
vm.stopBroadcast();
}
}

contract DeployListingEngineArb is ArbitrumScript {
function run() external {
vm.startBroadcast();
new GenericV3ListingEngine(
AaveV3Arbitrum.POOL_CONFIGURATOR,
AaveV3Arbitrum.ORACLE,
AaveV3Arbitrum.DEFAULT_A_TOKEN_IMPL_REV_1,
AaveV3Arbitrum.DEFAULT_VARIABLE_DEBT_TOKEN_IMPL_REV_1,
AaveV3Arbitrum.DEFAULT_STABLE_DEBT_TOKEN_IMPL_REV_1,
AaveV3Arbitrum.DEFAULT_INCENTIVES_CONTROLLER,
AaveV3Arbitrum.COLLECTOR
);
vm.stopBroadcast();
}
}

contract DeployListingEnginePol is PolygonScript {
function run() external {
vm.startBroadcast();
new GenericV3ListingEngine(
AaveV3Polygon.POOL_CONFIGURATOR,
AaveV3Polygon.ORACLE,
AaveV3Polygon.DEFAULT_A_TOKEN_IMPL_REV_1,
AaveV3Polygon.DEFAULT_VARIABLE_DEBT_TOKEN_IMPL_REV_1,
AaveV3Polygon.DEFAULT_STABLE_DEBT_TOKEN_IMPL_REV_1,
AaveV3Polygon.DEFAULT_INCENTIVES_CONTROLLER,
AaveV3Polygon.COLLECTOR
);
vm.stopBroadcast();
}
}

contract DeployListingEngineAva is AvalancheScript {
function run() external {
vm.startBroadcast();
new GenericV3ListingEngine(
AaveV3Avalanche.POOL_CONFIGURATOR,
AaveV3Avalanche.ORACLE,
AaveV3Avalanche.DEFAULT_A_TOKEN_IMPL_REV_1,
AaveV3Avalanche.DEFAULT_VARIABLE_DEBT_TOKEN_IMPL_REV_1,
AaveV3Avalanche.DEFAULT_STABLE_DEBT_TOKEN_IMPL_REV_1,
AaveV3Avalanche.DEFAULT_INCENTIVES_CONTROLLER,
AaveV3Avalanche.COLLECTOR
);
vm.stopBroadcast();
}
}
22 changes: 22 additions & 0 deletions src/v3-listing-engine/AaveV3ListingArbitrum.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3ListingBase, IGenericV3ListingEngine} from './AaveV3ListingBase.sol';

/**
* @dev Base smart contract for an Aave v3.0.1 (compatible with 3.0.0) listing on v3 Arbitrum.
* @author BGD Labs
*/
abstract contract AaveV3ListingArbitrum is AaveV3ListingBase {
constructor(IGenericV3ListingEngine listingEngine) AaveV3ListingBase(listingEngine) {}

function getPoolContext()
public
pure
override
returns (IGenericV3ListingEngine.PoolContext memory)
{
return
IGenericV3ListingEngine.PoolContext({networkName: 'Arbitrum', networkAbbreviation: 'Arb'});
}
}
22 changes: 22 additions & 0 deletions src/v3-listing-engine/AaveV3ListingAvalanche.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3ListingBase, IGenericV3ListingEngine} from './AaveV3ListingBase.sol';

/**
* @dev Base smart contract for an Aave v3.0.1 (compatible with 3.0.0) listing on v3 Avalanche.
* @author BGD Labs
*/
abstract contract AaveV3ListingAvalanche is AaveV3ListingBase {
constructor(IGenericV3ListingEngine listingEngine) AaveV3ListingBase(listingEngine) {}

function getPoolContext()
public
pure
override
returns (IGenericV3ListingEngine.PoolContext memory)
{
return
IGenericV3ListingEngine.PoolContext({networkName: 'Avalanche', networkAbbreviation: 'Ava'});
}
}
2 changes: 1 addition & 1 deletion src/v3-listing-engine/AaveV3ListingEthereum.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
import {AaveV3ListingBase, IGenericV3ListingEngine} from './AaveV3ListingBase.sol';

/**
* @dev Base smart contract for an Aave v3.0.1 listing (or other change of configs) on v3 Ethereum.
* @dev Base smart contract for an Aave v3.0.1 (compatible with 3.0.0) listing on v3 Ethereum.
* @author BGD Labs
*/
abstract contract AaveV3ListingEthereum is AaveV3ListingBase {
Expand Down
22 changes: 22 additions & 0 deletions src/v3-listing-engine/AaveV3ListingOptimism.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3ListingBase, IGenericV3ListingEngine} from './AaveV3ListingBase.sol';

/**
* @dev Base smart contract for an Aave v3.0.1 (compatible with 3.0.0) listing on v3 Optimism.
* @author BGD Labs
*/
abstract contract AaveV3ListingOptimism is AaveV3ListingBase {
constructor(IGenericV3ListingEngine listingEngine) AaveV3ListingBase(listingEngine) {}

function getPoolContext()
public
pure
override
returns (IGenericV3ListingEngine.PoolContext memory)
{
return
IGenericV3ListingEngine.PoolContext({networkName: 'Optimism', networkAbbreviation: 'Opt'});
}
}
2 changes: 1 addition & 1 deletion src/v3-listing-engine/AaveV3ListingPolygon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
import {AaveV3ListingBase, IGenericV3ListingEngine} from './AaveV3ListingBase.sol';

/**
* @dev Base smart contract for an Aave v3.0.1 listing (or other change of configs) on v3 Polygon.
* @dev Base smart contract for an Aave v3.0.1 (compatible with 3.0.0) listing on v3 Polygon.
* @author BGD Labs
*/
abstract contract AaveV3ListingPolygon is AaveV3ListingBase {
Expand Down