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

Experimental: Immutable launcher with dex liquidity transfer #692

Draft
wants to merge 62 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e7c6d89
chore: removes generalized factory
fabianschu Aug 27, 2024
01db865
chore: adds restricted factory
fabianschu Aug 27, 2024
dca69bc
chore: adds interface for curve interaction role
fabianschu Aug 27, 2024
1c45ac5
chore: adds restricted curve setup to e2e reg
fabianschu Aug 27, 2024
d501244
chore: adds immutable factory
fabianschu Aug 27, 2024
e150d64
chore: adds NatSpec for immutable factory
fabianschu Aug 27, 2024
103a7e3
chore: adds more comments
fabianschu Aug 27, 2024
fa4f312
chore: adds deploy scripts for both factories
fabianschu Aug 27, 2024
d9b9266
chore: use generalized deployment script
fabianschu Aug 27, 2024
7ddd82c
chore: formatting
fabianschu Aug 27, 2024
ea1d5d1
chore: sends issuance supply to deployer
fabianschu Aug 30, 2024
90ef5f4
feat: adds `addFunding` method
fabianschu Aug 30, 2024
b052f9b
feat: adds `withdrawFunding`
fabianschu Aug 30, 2024
58cf29e
chore: adds more tests
fabianschu Aug 30, 2024
8983149
chore: adds comments & NatSpec
fabianschu Aug 30, 2024
0f8bc50
chore: fmt
fabianschu Aug 30, 2024
eac6777
chore: validates inputs in deployment script
fabianschu Aug 30, 2024
f0e17b4
chore: marvin feedback I
fabianschu Aug 30, 2024
679aa83
chore: fmt
fabianschu Aug 30, 2024
691250c
chore: feedback Marvin II
fabianschu Aug 30, 2024
a08f750
fix: event param
fabianschu Sep 3, 2024
65b80cd
chore: rename `paymaster` => `sponsor`
fabianschu Sep 3, 2024
6058229
chore: adds PR feedback
fabianschu Sep 11, 2024
44e728c
chore: fmt
fabianschu Sep 11, 2024
0fb72a0
chore: deploy specific factories in general testnet deployment script
fabianschu Sep 25, 2024
97065d0
chore: rename workflow-specific => custom
fabianschu Sep 25, 2024
61836a9
chore: make fmt
fabianschu Sep 25, 2024
b7ab71e
Feat: Mint wrapper (#663)
fabianschu Oct 8, 2024
f66b2bd
Script: Streamline deployment script
marvinkruse Oct 8, 2024
c64ed3e
chore: separates deployer from beneficiary (#671)
fabianschu Oct 11, 2024
70c3e31
chore: adds symbol & name to MintWrapper
fabianschu Oct 12, 2024
7cc89b8
chore: removes all reference to immutable factory
fabianschu Oct 14, 2024
b66808e
Audit: fix: assigns payment pusher role to beneficiary (#673)
fabianschu Oct 15, 2024
733eb99
chore: audit feedback 21/10/24
fabianschu Oct 21, 2024
e61df61
chore: modifies funding logic
fabianschu Oct 24, 2024
82d2d00
fix: removes PAYMENT_PUSHER from interface
fabianschu Oct 24, 2024
60ed160
chore: remove redundant backslashes
fabianschu Oct 24, 2024
3749f39
chore: uses sponsorships to make fundings withdrawable
fabianschu Nov 10, 2024
a112329
chore: format
fabianschu Nov 10, 2024
6f369f0
feat: immutable factory
fabianschu Nov 10, 2024
1d50c16
fix: copy/paste wrong contract
fabianschu Nov 10, 2024
1d3f21d
chore: adds test skeletton
fabianschu Nov 10, 2024
f3ca9de
forge install: v2-core
fabianschu Nov 10, 2024
a382ae0
forge install: v2-periphery
fabianschu Nov 10, 2024
fd4f561
chore: adds migration module and integrates with immutable factory
fabianschu Nov 11, 2024
a1c6dbf
feat: closes buy if threshold reached
fabianschu Nov 11, 2024
ebb99fe
tmp
fabianschu Nov 13, 2024
64c3612
tmp
fabianschu Nov 18, 2024
9b07bd9
chore: changes folder structure
fabianschu Nov 18, 2024
6755746
fix: immutable factory tests
fabianschu Nov 18, 2024
0aee03a
chore: cleanup
fabianschu Nov 18, 2024
d55286e
chore: exposes sell function
fabianschu Nov 19, 2024
e5d660e
chore: adapts factory deployment script
fabianschu Nov 19, 2024
6346c13
chore: uses restricted curve in immutable factory
fabianschu Nov 19, 2024
e55de97
chore: adds buy to factory
fabianschu Nov 19, 2024
95e3a03
feat: reimbursement
fabianschu Nov 19, 2024
2cfc5cf
feat: adds selling
fabianschu Nov 21, 2024
e23bccb
feat: liquidity transfer
fabianschu Nov 21, 2024
1b0e76f
chore: removes module references
fabianschu Nov 21, 2024
57a15d0
chore: make fmt
fabianschu Nov 21, 2024
952bfe8
test: add immutable factory to testnet deployment script
mguleryuz Nov 22, 2024
ef93d12
Uniswap addresses have been added
DogaOztuzun Nov 28, 2024
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
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
[submodule "lib/uma-protocol"]
path = lib/uma-protocol
url = https://github.com/UMAprotocol/protocol
[submodule "lib/v2-core"]
path = lib/v2-core
url = https://github.com/Uniswap/v2-core
[submodule "lib/v2-periphery"]
path = lib/v2-periphery
url = https://github.com/Uniswap/v2-periphery
1 change: 1 addition & 0 deletions lib/v2-core
Submodule v2-core added at 4dd590
1 change: 1 addition & 0 deletions lib/v2-periphery
Submodule v2-periphery added at 0335e8
2 changes: 2 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
@lm/=src/modules/logicModule/
@lm_pc/=src/modules/logicModule/paymentClient/
@aut/=src/modules/authorizer/
@univ2core/=lib/v2-core/contracts/
@univ2peri/=lib/v2-periphery/contracts/
125 changes: 125 additions & 0 deletions script/deploymentScript/CustomFactoryDeploymentScript.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import "forge-std/Script.sol";

import {Restricted_PIM_Factory_v1} from
"src/factories/custom/Restricted_PIM_Factory_v1.sol";
import {Immutable_PIM_Factory_v1} from
"src/experimental/factories/Immutable_PIM_Factory_v1.sol";
import {UniswapV2Adapter} from
"src/experimental/modules/ImmutableMigration/UniswapV2Adapter.sol";

import {ERC2771Context} from "@oz/metatx/ERC2771Context.sol";

contract CustomFactoryDeploymentScript is Script {
address public orchestratorFactory =
vm.envOr("ORCHESTRATOR_FACTORY_ADDRESS", address(0));

address public uniswapAdapter;

function run() public virtual {
console2.log(
"Deploying Custom Factory, attached to Orchestrator Factory at %s:",
orchestratorFactory
);

uniswapAdapter = deployUniswapAdapter();

_deploy(vm.envString("FACTORY_TYPE"));
}

function deploy(address orchestratorFactory_) public {
// Take Orchestrator Factory from function parameter
// and not from the env file.
orchestratorFactory = orchestratorFactory_;

console2.log();
console2.log(
"================================================================================"
);
console2.log("Start Custom Factory Deployment Script");
console2.log(
"================================================================================"
);
console2.log(
"--------------------------------------------------------------------------------"
);
console2.log(" Deploying Custom Factories:");

_deploy("RESTRICTED");

_deploy("IMMUTABLE");

console2.log(
"--------------------------------------------------------------------------------"
);
}

function _deploy(string memory factoryType_) public validateInputs {
// Obtain the correct trusted forwarder from the orchestrator factory.
address trustedForwarder =
ERC2771Context(orchestratorFactory).trustedForwarder();
require(
trustedForwarder != address(0),
"Trusted Forwarder address not set - aborting!"
);

vm.startBroadcast(vm.envUint("DEPLOYER_PRIVATE_KEY"));
if (_isEqual(factoryType_, "RESTRICTED")) {
{
console2.log(
"\tRestricted_PIM_Factory_v1: %s",
address(
new Restricted_PIM_Factory_v1(
orchestratorFactory, trustedForwarder
)
)
);
}
} else if (_isEqual(factoryType_, "IMMUTABLE")) {
{
console2.log(
"\tImmutable_PIM_Factory_v1: %s",
address(
new Immutable_PIM_Factory_v1(
orchestratorFactory,
trustedForwarder,
uniswapAdapter
)
)
);
}
} else {
revert("Invalid factory type - aborting!");
}

vm.stopBroadcast();
}

function deployUniswapAdapter() internal returns (address) {
address uniswapFactoryAddress = vm.envAddress("UNISWAPFACTORY");
address uniswapRouterAddress = vm.envAddress("UNISWAPROUTER");

return address(
new UniswapV2Adapter(uniswapFactoryAddress, uniswapRouterAddress)
);
}

function _isEqual(string memory a_, string memory b_)
internal
pure
returns (bool)
{
return
keccak256(abi.encodePacked(a_)) == keccak256(abi.encodePacked(b_));
}

modifier validateInputs() {
require(
orchestratorFactory != address(0),
"Orchestrator Factory address not set - aborting!"
);
_;
}
}
72 changes: 50 additions & 22 deletions script/deploymentScript/TestnetDeploymentScript.s.sol
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import "forge-std/Script.sol";
import 'forge-std/Script.sol';

// Scripts
import {DeploymentScript} from "script/deploymentScript/DeploymentScript.s.sol";
import {DeploymentScript} from 'script/deploymentScript/DeploymentScript.s.sol';
import {CustomFactoryDeploymentScript} from 'script/deploymentScript/CustomFactoryDeploymentScript.s.sol';

// Contracts
import {DeterministicFactory_v1} from "@df/DeterministicFactory_v1.sol";
import {DeterministicFactory_v1} from '@df/DeterministicFactory_v1.sol';

// Interfaces
import {IERC20} from "@oz/token/ERC20/IERC20.sol";
import {IERC20} from '@oz/token/ERC20/IERC20.sol';

// Mocks
import {
OptimisticOracleV3Mock,
OptimisticOracleV3Interface
} from "test/modules/logicModule/oracle/utils/OptimisiticOracleV3Mock.sol";
import {ERC20Mock} from "test/utils/mocks/ERC20Mock.sol";
import {OptimisticOracleV3Mock, OptimisticOracleV3Interface} from 'test/modules/logicModule/oracle/utils/OptimisiticOracleV3Mock.sol';
import {ERC20Mock} from 'test/utils/mocks/ERC20Mock.sol';
import {uniswapFactoryAddress, uniswapRouterAddress, uniswapFactoryBytecode, uniswapRouterBytecode} from 'test/experimental/factories/Immutable_PIM_Factory_v1.t.sol';
import {UniswapV2Adapter} from 'src/experimental/modules/ImmutableMigration/UniswapV2Adapter.sol';

/**
* @title Inverter Testnet Deployment Script
Expand All @@ -33,14 +33,14 @@ contract TestnetDeploymentScript is DeploymentScript {

uint64 immutable DEFAULT_LIVENESS = 25_000;

function run() public virtual override {
function run() public virtual override(DeploymentScript) {
console2.log();
console2.log(
"================================================================================"
'================================================================================'
);
console2.log("Start Testnet Deployment Script");
console2.log('Start Testnet Deployment Script');
console2.log(
"================================================================================"
'================================================================================'
);

// Set required parameters to testnet values
Expand All @@ -58,27 +58,34 @@ contract TestnetDeploymentScript is DeploymentScript {

vm.startBroadcast(deployerPrivateKey);
{
console2.log(" Set up dependency contracts ");
console2.log(' Set up dependency contracts ');

// Deploy and setup DeterministicFactory
deterministicFactory =
address(new DeterministicFactory_v1(deployer));
deterministicFactory = address(
new DeterministicFactory_v1(deployer)
);
DeterministicFactory_v1(deterministicFactory).setAllowedDeployer(
deployer
);
console2.log("\tDeterministic Factory: %s", deterministicFactory);
console2.log('\tDeterministic Factory: %s', deterministicFactory);

console2.log(" Set up mocks");
console2.log(' Set up mocks');

// Deploy and setup UMA's OptimisticOracleV3Mock
ooV3 = new OptimisticOracleV3Mock(
IERC20(address(mockCollateralToken)), DEFAULT_LIVENESS
IERC20(address(mockCollateralToken)),
DEFAULT_LIVENESS
); // @note FeeToken?
console2.log("\tOptimisticOracleV3Mock: %s", address(ooV3));
console2.log('\tOptimisticOracleV3Mock: %s', address(ooV3));

// Deploy and setup Mock Collateral Token
mockCollateralToken = new ERC20Mock("Inverter USD", "iUSD");
console2.log("\tERC20Mock iUSD: %s", address(mockCollateralToken));
mockCollateralToken = new ERC20Mock('Inverter USD', 'iUSD');
console2.log('\tERC20Mock iUSD: %s', address(mockCollateralToken));

// Deploy uniswap v2 adapter
address uniswapV2Adapter = deployUniswapAdapter();
vm.setEnv('DEX_ADAPTER', vm.toString(uniswapV2Adapter));
console2.log('\tUniswapV2Adapter: %s', uniswapV2Adapter);
}
vm.stopBroadcast();

Expand All @@ -88,5 +95,26 @@ contract TestnetDeploymentScript is DeploymentScript {
proxyAndBeaconDeployer.setFactory(deterministicFactory);

super.run();

CustomFactoryDeploymentScript customFactoryDeploymentScript = new CustomFactoryDeploymentScript();
customFactoryDeploymentScript.deploy(orchestratorFactory);
}

//--------------------------------------------------------------------------
// Utils
//--------------------------------------------------------------------------

function deployUniswapAdapter() internal returns (address) {
vm.etch(uniswapFactoryAddress, uniswapFactoryBytecode);
vm.etch(uniswapRouterAddress, uniswapRouterBytecode);

// Deploy UniswapV2Adapter
return
address(
new UniswapV2Adapter(
uniswapFactoryAddress,
uniswapRouterAddress
)
);
}
}
Loading
Loading