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

✨ add uniswap v4 deploy scripts #258

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions script/uniswap-v4/DeployUniswapV4Step1.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Created by Pragma Labs
* SPDX-License-Identifier: BUSL-1.1
*/
pragma solidity ^0.8.22;

import { Base_Script } from "../Base.s.sol";

import { ArcadiaSafes, ExternalContracts } from "../utils/Constants.sol";
import { DefaultUniswapV4AM } from "../../src/asset-modules/UniswapV4/DefaultUniswapV4AM.sol";
import { UniswapV4HooksRegistry } from "../../src/asset-modules/UniswapV4/UniswapV4HooksRegistry.sol";

contract DeployUniswapV4Step1 is Base_Script {
constructor() { }

function run() public {
// Deploy Asset Module.
vm.startBroadcast(deployer);
UniswapV4HooksRegistry uniswapV4HooksRegistry =
new UniswapV4HooksRegistry(address(registry), ExternalContracts.UNISWAPV4_POS_MNGR);
DefaultUniswapV4AM defaultUniswapV4AM = DefaultUniswapV4AM(uniswapV4HooksRegistry.DEFAULT_UNISWAP_V4_AM());

uniswapV4HooksRegistry.transferOwnership(ArcadiaSafes.OWNER);
defaultUniswapV4AM.transferOwnership(ArcadiaSafes.OWNER);
vm.stopBroadcast();
}

function test_deploy() public {
vm.skip(true);
}
}
70 changes: 70 additions & 0 deletions script/uniswap-v4/DeployUniswapV4Step2.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Created by Pragma Labs
* SPDX-License-Identifier: BUSL-1.1
*/
pragma solidity ^0.8.22;

import { Base_Script } from "../Base.s.sol";

import { ArcadiaContracts, ArcadiaSafes, RiskParameters } from "../utils/Constants.sol";
import { DefaultUniswapV4AM } from "../../src/asset-modules/UniswapV4/DefaultUniswapV4AM.sol";
import { UniswapV4HooksRegistry } from "../../src/asset-modules/UniswapV4/UniswapV4HooksRegistry.sol";

contract DeployUniswapV4Step2 is Base_Script {
DefaultUniswapV4AM internal defaultUniswapV4AM = DefaultUniswapV4AM(ArcadiaContracts.DEFAULT_UNISWAPV4_AM);
UniswapV4HooksRegistry internal uniswapV4HooksRegistry =
UniswapV4HooksRegistry(ArcadiaContracts.UNISWAPV4_HOOKS_REGISTRY);

constructor() { }

function run() public {
bytes memory calldata_ = abi.encodeCall(registry.addAssetModule, (address(uniswapV4HooksRegistry)));
addToBatch(ArcadiaSafes.OWNER, address(registry), calldata_);

calldata_ = abi.encodeCall(uniswapV4HooksRegistry.setProtocol, ());
addToBatch(ArcadiaSafes.OWNER, address(uniswapV4HooksRegistry), calldata_);

// Create and write away batched transaction data to be signed with Safe.
bytes memory data = createBatchedData(ArcadiaSafes.OWNER);
vm.writeLine(PATH, vm.toString(data));

calldata_ = abi.encodeCall(
uniswapV4HooksRegistry.setRiskParametersOfDerivedAM,
(
address(cbbtcLendingPool),
address(defaultUniswapV4AM),
RiskParameters.EXPOSURE_DEFAULT_UNISWAPV4_AM_CBBTC,
RiskParameters.RISK_FAC_DEFAULT_UNISWAPV4_AM_CBBTC
)
);
addToBatch(ArcadiaSafes.RISK_MANAGER, address(uniswapV4HooksRegistry), calldata_);
calldata_ = abi.encodeCall(
uniswapV4HooksRegistry.setRiskParametersOfDerivedAM,
(
address(usdcLendingPool),
address(defaultUniswapV4AM),
RiskParameters.EXPOSURE_DEFAULT_UNISWAPV4_AM_USDC,
RiskParameters.RISK_FAC_DEFAULT_UNISWAPV4_AM_USDC
)
);
addToBatch(ArcadiaSafes.RISK_MANAGER, address(uniswapV4HooksRegistry), calldata_);
calldata_ = abi.encodeCall(
uniswapV4HooksRegistry.setRiskParametersOfDerivedAM,
(
address(wethLendingPool),
address(defaultUniswapV4AM),
RiskParameters.EXPOSURE_DEFAULT_UNISWAPV4_AM_WETH,
RiskParameters.RISK_FAC_DEFAULT_UNISWAPV4_AM_WETH
)
);
addToBatch(ArcadiaSafes.RISK_MANAGER, address(uniswapV4HooksRegistry), calldata_);

// Create and write away batched transaction data to be signed with Safe.
data = createBatchedData(ArcadiaSafes.RISK_MANAGER);
vm.writeLine(PATH, vm.toString(data));
}

function test_deploy() public {
vm.skip(true);
}
}
51 changes: 31 additions & 20 deletions script/utils/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ library ArcadiaContracts {
address internal constant AERO_POOL_AM = address(0xfe0FA1FD8F8E889062F03e2f126Fc7B9DE6091A5);
address internal constant ALIEN_BASE_AM = address(0x79dD8b8d4abB5dEEA986DB1BF0a02E4CA42ae416);
address internal constant CHAINLINK_OM = address(0x6a5485E3ce6913890ae5e8bDc08a868D432eEB31);
address internal constant DEFAULT_UNISWAPV4_AM = address(0);
address internal constant ERC20_PRIMARY_AM = address(0xfBecEaFC96ed6fc800753d3eE6782b6F9a60Eed7);
address internal constant FACTORY = address(0xDa14Fdd72345c4d2511357214c5B89A919768e59);
address internal constant LENDINGPOOL_CBBTC = address(0xa37E9b4369dc20940009030BfbC2088F09645e3B);
Expand All @@ -20,6 +21,7 @@ library ArcadiaContracts {
address internal constant STAKED_SLIPSTREAM_AM = address(0x1Dc7A0f5336F52724B650E39174cfcbbEdD67bF1);
address internal constant STARGATE_AM = address(0x20f7903290bF98716B62Dc1c9DA634291b8cfeD4);
address internal constant UNISWAPV3_AM = address(0x21bd524cC54CA78A7c48254d4676184f781667dC);
address internal constant UNISWAPV4_HOOKS_REGISTRY = address(0);
address internal constant WRAPPED_AERO_AM = address(0x17B5826382e3a5257b829cF0546A08Bd77409270);
}

Expand Down Expand Up @@ -357,17 +359,35 @@ library RiskParameters {
uint112 internal constant EXPOSURE_ALIEN_BASE_AM_WETH = uint112(2_000_000 * 1e18);
uint112 internal constant EXPOSURE_ALIEN_BASE_AM_USDC = uint112(2_000_000 * 1e18);

// Default UniswapV4 Asset Module
uint16 internal constant RISK_FAC_DEFAULT_UNISWAPV4_AM_CBBTC = 9800;
uint16 internal constant RISK_FAC_DEFAULT_UNISWAPV4_AM_WETH = 9800;
uint16 internal constant RISK_FAC_DEFAULT_UNISWAPV4_AM_USDC = 9800;
uint112 internal constant EXPOSURE_DEFAULT_UNISWAPV4_AM_CBBTC = uint112(5_000_000 * 1e18);
uint112 internal constant EXPOSURE_DEFAULT_UNISWAPV4_AM_WETH = uint112(5_000_000 * 1e18);
uint112 internal constant EXPOSURE_DEFAULT_UNISWAPV4_AM_USDC = uint112(5_000_000 * 1e18);

// Slipstream Asset Module
uint16 internal constant RISK_FAC_SLIPSTREAM_CBBTC = 9800;
uint16 internal constant RISK_FAC_SLIPSTREAM_WETH = 9800;
uint16 internal constant RISK_FAC_SLIPSTREAM_USDC = 9800;
uint112 internal constant EXPOSURE_SLIPSTREAM_CBBTC = uint112(2_000_000 * 1e18);
uint112 internal constant EXPOSURE_SLIPSTREAM_WETH = uint112(2_000_000 * 1e18);
uint112 internal constant EXPOSURE_SLIPSTREAM_USDC = uint112(2_000_000 * 1e18);

// Staked Aerodrome Pool Asset Module
uint16 internal constant RISK_FAC_STAKED_AERO_AM_WETH = 9800;
uint16 internal constant RISK_FAC_STAKED_AERO_AM_USDC = 9800;
uint112 internal constant EXPOSURE_STAKED_AERO_AM_WETH = uint112(2_000_000 * 1e18);
uint112 internal constant EXPOSURE_STAKED_AERO_AM_USDC = uint112(2_000_000 * 1e18);

// Wrapped Aerodrome Pool Asset Module
uint16 internal constant RISK_FAC_WRAPPED_AERO_AM_WETH = 9800;
uint16 internal constant RISK_FAC_WRAPPED_AERO_AM_USDC = 9800;
uint112 internal constant EXPOSURE_WRAPPED_AERO_AM_WETH = uint112(2_000_000 * 1e18);
uint112 internal constant EXPOSURE_WRAPPED_AERO_AM_USDC = uint112(2_000_000 * 1e18);
// Staked Slipstream Asset Module
uint16 internal constant RISK_FAC_STAKED_SLIPSTREAM_AM_CBBTC = 9800;
uint16 internal constant RISK_FAC_STAKED_SLIPSTREAM_AM_WETH = 9800;
uint16 internal constant RISK_FAC_STAKED_SLIPSTREAM_AM_USDC = 9800;
uint112 internal constant EXPOSURE_STAKED_SLIPSTREAM_AM_CBBTC = uint112(4_000_000 * 1e18);
uint112 internal constant EXPOSURE_STAKED_SLIPSTREAM_AM_WETH = uint112(4_000_000 * 1e18);
uint112 internal constant EXPOSURE_STAKED_SLIPSTREAM_AM_USDC = uint112(4_000_000 * 1e18);

// Staked Stargate Asset Module
uint16 internal constant RISK_FAC_STAKED_STARGATE_AM_WETH = 9800;
Expand All @@ -389,21 +409,11 @@ library RiskParameters {
uint112 internal constant EXPOSURE_UNISWAPV3_AM_WETH = uint112(2_000_000 * 1e18);
uint112 internal constant EXPOSURE_UNISWAPV3_AM_USDC = uint112(2_000_000 * 1e18);

// Slipstream Asset Module
uint16 internal constant RISK_FAC_SLIPSTREAM_CBBTC = 9800;
uint16 internal constant RISK_FAC_SLIPSTREAM_WETH = 9800;
uint16 internal constant RISK_FAC_SLIPSTREAM_USDC = 9800;
uint112 internal constant EXPOSURE_SLIPSTREAM_CBBTC = uint112(2_000_000 * 1e18);
uint112 internal constant EXPOSURE_SLIPSTREAM_WETH = uint112(2_000_000 * 1e18);
uint112 internal constant EXPOSURE_SLIPSTREAM_USDC = uint112(2_000_000 * 1e18);

// Staked Slipstream Asset Module
uint16 internal constant RISK_FAC_STAKED_SLIPSTREAM_AM_CBBTC = 9800;
uint16 internal constant RISK_FAC_STAKED_SLIPSTREAM_AM_WETH = 9800;
uint16 internal constant RISK_FAC_STAKED_SLIPSTREAM_AM_USDC = 9800;
uint112 internal constant EXPOSURE_STAKED_SLIPSTREAM_AM_CBBTC = uint112(4_000_000 * 1e18);
uint112 internal constant EXPOSURE_STAKED_SLIPSTREAM_AM_WETH = uint112(4_000_000 * 1e18);
uint112 internal constant EXPOSURE_STAKED_SLIPSTREAM_AM_USDC = uint112(4_000_000 * 1e18);
// Wrapped Aerodrome Pool Asset Module
uint16 internal constant RISK_FAC_WRAPPED_AERO_AM_WETH = 9800;
uint16 internal constant RISK_FAC_WRAPPED_AERO_AM_USDC = 9800;
uint112 internal constant EXPOSURE_WRAPPED_AERO_AM_WETH = uint112(2_000_000 * 1e18);
uint112 internal constant EXPOSURE_WRAPPED_AERO_AM_USDC = uint112(2_000_000 * 1e18);

// cbBTC Lending Pool
uint128 internal constant MIN_USD_VALUE_CBBTC = 1 * 1e18;
Expand All @@ -430,6 +440,7 @@ library ExternalContracts {
address internal constant STARGATE_FACTORY = 0xAf5191B0De278C7286d6C7CC6ab6BB8A73bA2Cd6;
address internal constant STARGATE_LP_STAKING = 0x06Eb48763f117c7Be887296CDcdfad2E4092739C;
address internal constant UNISWAPV3_POS_MNGR = 0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1;
address internal constant UNISWAPV4_POS_MNGR = address(0);
}

library StargatePoolIds {
Expand Down
Loading