mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Merge branch 'deployment' into mapping-updates
This commit is contained in:
commit
7651a6d098
|
@ -1,4 +1,5 @@
|
|||
ETHERSCAN_API_KEY=""
|
||||
PRIVATE_KEY=""
|
||||
TENDERLY_PROJECT=""
|
||||
TENDERLY_USERNAME=""
|
||||
TENDERLY_USERNAME=""
|
||||
ALCHEMY_ID=""
|
|
@ -1,7 +1,5 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
import { OneProtoData, OneProtoMultiData, OneInchData} from "./interface.sol";
|
||||
|
||||
contract Events {
|
||||
event LogSell(
|
||||
address indexed buyToken,
|
||||
|
@ -12,21 +10,6 @@ contract Events {
|
|||
uint256 setId
|
||||
);
|
||||
|
||||
function emitLogSell(
|
||||
OneProtoData memory oneProtoData,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) internal {
|
||||
emit LogSell(
|
||||
address(oneProtoData.buyToken),
|
||||
address(oneProtoData.sellToken),
|
||||
oneProtoData._buyAmt,
|
||||
oneProtoData._sellAmt,
|
||||
getId,
|
||||
setId
|
||||
);
|
||||
}
|
||||
|
||||
event LogSellTwo(
|
||||
address indexed buyToken,
|
||||
address indexed sellToken,
|
||||
|
@ -36,21 +19,6 @@ contract Events {
|
|||
uint256 setId
|
||||
);
|
||||
|
||||
function emitLogSellTwo(
|
||||
OneProtoData memory oneProtoData,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) internal {
|
||||
emit LogSellTwo(
|
||||
address(oneProtoData.buyToken),
|
||||
address(oneProtoData.sellToken),
|
||||
oneProtoData._buyAmt,
|
||||
oneProtoData._sellAmt,
|
||||
getId,
|
||||
setId
|
||||
);
|
||||
}
|
||||
|
||||
event LogSellMulti(
|
||||
address[] tokens,
|
||||
address indexed buyToken,
|
||||
|
@ -61,22 +29,6 @@ contract Events {
|
|||
uint256 setId
|
||||
);
|
||||
|
||||
function emitLogSellMulti(
|
||||
OneProtoMultiData memory oneProtoData,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) internal {
|
||||
emit LogSellMulti(
|
||||
oneProtoData.tokens,
|
||||
address(oneProtoData.buyToken),
|
||||
address(oneProtoData.sellToken),
|
||||
oneProtoData._buyAmt,
|
||||
oneProtoData._sellAmt,
|
||||
getId,
|
||||
setId
|
||||
);
|
||||
}
|
||||
|
||||
event LogSellThree(
|
||||
address indexed buyToken,
|
||||
address indexed sellToken,
|
||||
|
@ -85,19 +37,4 @@ contract Events {
|
|||
uint256 getId,
|
||||
uint256 setId
|
||||
);
|
||||
|
||||
|
||||
function emitLogSellThree(
|
||||
OneInchData memory oneInchData,
|
||||
uint256 setId
|
||||
) internal {
|
||||
emit LogSellThree(
|
||||
address(oneInchData.buyToken),
|
||||
address(oneInchData.sellToken),
|
||||
oneInchData._buyAmt,
|
||||
oneInchData._sellAmt,
|
||||
0,
|
||||
setId
|
||||
);
|
||||
}
|
||||
}
|
|
@ -141,7 +141,7 @@ abstract contract OneProtoResolverHelpers is OneInchResolver {
|
|||
OneProtoData memory oneProtoData,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) internal {
|
||||
) internal returns (OneProtoData memory) {
|
||||
uint _sellAmt = getUint(getId, oneProtoData._sellAmt);
|
||||
|
||||
oneProtoData._sellAmt = _sellAmt == uint(-1) ?
|
||||
|
@ -165,7 +165,7 @@ abstract contract OneProtoResolverHelpers is OneInchResolver {
|
|||
|
||||
setUint(setId, oneProtoData._buyAmt);
|
||||
|
||||
emitLogSell(oneProtoData, getId, setId);
|
||||
return oneProtoData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,7 +178,7 @@ abstract contract OneProtoResolverHelpers is OneInchResolver {
|
|||
OneProtoData memory oneProtoData,
|
||||
uint getId,
|
||||
uint setId
|
||||
) internal {
|
||||
) internal returns (OneProtoData memory) {
|
||||
uint _sellAmt = getUint(getId, oneProtoData._sellAmt);
|
||||
|
||||
oneProtoData._sellAmt = _sellAmt == uint(-1) ?
|
||||
|
@ -191,7 +191,8 @@ abstract contract OneProtoResolverHelpers is OneInchResolver {
|
|||
);
|
||||
|
||||
setUint(setId, oneProtoData._buyAmt);
|
||||
emitLogSellTwo(oneProtoData, getId, setId);
|
||||
|
||||
return oneProtoData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -204,7 +205,7 @@ abstract contract OneProtoResolverHelpers is OneInchResolver {
|
|||
OneProtoMultiData memory oneProtoData,
|
||||
uint getId,
|
||||
uint setId
|
||||
) internal {
|
||||
) internal returns (OneProtoMultiData memory) {
|
||||
uint _sellAmt = getUint(getId, oneProtoData._sellAmt);
|
||||
|
||||
oneProtoData._sellAmt = _sellAmt == uint(-1) ?
|
||||
|
@ -214,7 +215,9 @@ abstract contract OneProtoResolverHelpers is OneInchResolver {
|
|||
oneProtoData._buyAmt = oneProtoSwapMulti(oneProtoData);
|
||||
setUint(setId, oneProtoData._buyAmt);
|
||||
|
||||
emitLogSellMulti(oneProtoData, getId, setId);
|
||||
// emitLogSellMulti(oneProtoData, getId, setId);
|
||||
|
||||
return oneProtoData;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,7 +231,7 @@ abstract contract OneInchResolverHelpers is OneProtoResolverHelpers {
|
|||
function _sellThree(
|
||||
OneInchData memory oneInchData,
|
||||
uint setId
|
||||
) internal {
|
||||
) internal returns (OneInchData memory) {
|
||||
TokenInterface _sellAddr = oneInchData.sellToken;
|
||||
|
||||
uint ethAmt;
|
||||
|
@ -243,7 +246,9 @@ abstract contract OneInchResolverHelpers is OneProtoResolverHelpers {
|
|||
oneInchData._buyAmt = oneInchSwap(oneInchData, ethAmt);
|
||||
setUint(setId, oneInchData._buyAmt);
|
||||
|
||||
emitLogSellThree(oneInchData, setId);
|
||||
return oneInchData;
|
||||
|
||||
// emitLogSellThree(oneInchData, setId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +269,7 @@ abstract contract OneProto is OneInchResolverHelpers {
|
|||
uint unitAmt,
|
||||
uint getId,
|
||||
uint setId
|
||||
) external payable {
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
OneProtoData memory oneProtoData = OneProtoData({
|
||||
buyToken: TokenInterface(buyAddr),
|
||||
sellToken: TokenInterface(sellAddr),
|
||||
|
@ -275,7 +280,10 @@ abstract contract OneProto is OneInchResolverHelpers {
|
|||
disableDexes: 0
|
||||
});
|
||||
|
||||
_sell(oneProtoData, getId, setId);
|
||||
oneProtoData = _sell(oneProtoData, getId, setId);
|
||||
|
||||
_eventName = "LogSell(address,address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(buyAddr, sellAddr, oneProtoData._buyAmt, oneProtoData._sellAmt, getId, setId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,7 +306,7 @@ abstract contract OneProto is OneInchResolverHelpers {
|
|||
uint disableDexes,
|
||||
uint getId,
|
||||
uint setId
|
||||
) external payable {
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
OneProtoData memory oneProtoData = OneProtoData({
|
||||
buyToken: TokenInterface(buyAddr),
|
||||
sellToken: TokenInterface(sellAddr),
|
||||
|
@ -309,7 +317,10 @@ abstract contract OneProto is OneInchResolverHelpers {
|
|||
_buyAmt: 0
|
||||
});
|
||||
|
||||
_sellTwo(oneProtoData, getId, setId);
|
||||
oneProtoData = _sellTwo(oneProtoData, getId, setId);
|
||||
|
||||
_eventName = "LogSellTwo(address,address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(buyAddr, sellAddr, oneProtoData._buyAmt, oneProtoData._sellAmt, getId, setId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -330,10 +341,11 @@ abstract contract OneProto is OneInchResolverHelpers {
|
|||
uint[] calldata disableDexes,
|
||||
uint getId,
|
||||
uint setId
|
||||
) external payable {
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _length = tokens.length;
|
||||
OneProtoMultiData memory oneProtoData = OneProtoMultiData({
|
||||
tokens: tokens,
|
||||
buyToken: TokenInterface(address(tokens[tokens.length - 1])),
|
||||
buyToken: TokenInterface(address(tokens[_length - 1])),
|
||||
sellToken: TokenInterface(address(tokens[0])),
|
||||
unitAmt: unitAmt,
|
||||
distribution: distribution,
|
||||
|
@ -342,7 +354,18 @@ abstract contract OneProto is OneInchResolverHelpers {
|
|||
_buyAmt: 0
|
||||
});
|
||||
|
||||
_sellMulti(oneProtoData, getId, setId);
|
||||
oneProtoData = _sellMulti(oneProtoData, getId, setId);
|
||||
|
||||
_eventName = "LogSellMulti(address[],address,address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(
|
||||
tokens,
|
||||
address(oneProtoData.buyToken),
|
||||
address(oneProtoData.sellToken),
|
||||
oneProtoData._buyAmt,
|
||||
oneProtoData._sellAmt,
|
||||
getId,
|
||||
setId
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,7 +386,7 @@ abstract contract OneInch is OneProto {
|
|||
uint unitAmt,
|
||||
bytes calldata callData,
|
||||
uint setId
|
||||
) external payable {
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
OneInchData memory oneInchData = OneInchData({
|
||||
buyToken: TokenInterface(buyAddr),
|
||||
sellToken: TokenInterface(sellAddr),
|
||||
|
@ -373,10 +396,13 @@ abstract contract OneInch is OneProto {
|
|||
_buyAmt: 0
|
||||
});
|
||||
|
||||
_sellThree(oneInchData, setId);
|
||||
oneInchData = _sellThree(oneInchData, setId);
|
||||
|
||||
_eventName = "LogSellThree(address,address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(buyAddr, sellAddr, oneInchData._buyAmt, oneInchData._sellAmt, 0, setId);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectOne is OneInch {
|
||||
contract ConnectV2OneInch is OneInch {
|
||||
string public name = "1inch-1proto-v1";
|
||||
}
|
||||
|
|
|
@ -86,6 +86,6 @@ abstract contract CompResolver is Events, Helpers {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectCOMP is CompResolver {
|
||||
contract ConnectV2COMP is CompResolver {
|
||||
string public name = "COMP-v1";
|
||||
}
|
||||
|
|
|
@ -154,6 +154,6 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectAave is AaveResolver {
|
||||
string public name = "Aave-v1.1";
|
||||
contract ConnectV2AaveV1 is AaveResolver {
|
||||
string public name = "AaveV1-v1";
|
||||
}
|
||||
|
|
|
@ -178,6 +178,6 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectAave is AaveResolver {
|
||||
string public name = "AaveV2-v1.1";
|
||||
contract ConnectV2AaveV2 is AaveResolver {
|
||||
string public name = "AaveV2-v1";
|
||||
}
|
||||
|
|
|
@ -33,6 +33,6 @@ abstract contract AuthorityResolver is Events, Helpers {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectAuth is AuthorityResolver {
|
||||
contract ConnectV2Auth is AuthorityResolver {
|
||||
string public constant name = "Auth-v1";
|
||||
}
|
||||
|
|
|
@ -69,6 +69,6 @@ abstract contract BasicResolver is Events, DSMath, Basic {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectBasic is BasicResolver {
|
||||
string public constant name = "Basic-v1.1";
|
||||
contract ConnectV2Basic is BasicResolver {
|
||||
string public constant name = "Basic-v1";
|
||||
}
|
||||
|
|
|
@ -8,22 +8,28 @@ abstract contract ChiResolver is Events, Helpers {
|
|||
* @dev Mint CHI token.
|
||||
* @param amt token amount to mint.
|
||||
*/
|
||||
function mint(uint amt) public payable {
|
||||
function mint(uint amt) public payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _amt = amt == uint(-1) ? 140 : amt;
|
||||
require(_amt <= 140, "Max minting is 140 chi");
|
||||
chi.mint(_amt);
|
||||
|
||||
_eventName = "LogMint(uint256)";
|
||||
_eventParam = abi.encode(_amt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev burn CHI token.
|
||||
* @param amt token amount to burn.
|
||||
*/
|
||||
function burn(uint amt) public payable {
|
||||
function burn(uint amt) public payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _amt = amt == uint(-1) ? chi.balanceOf(address(this)) : amt;
|
||||
chi.approve(address(chi), _amt);
|
||||
chi.free(_amt);
|
||||
|
||||
_eventName = "LogBurn(uint256)";
|
||||
_eventParam = abi.encode(_amt);
|
||||
}
|
||||
}
|
||||
contract ConnectCHI is ChiResolver {
|
||||
contract ConnectV2CHI is ChiResolver {
|
||||
string public name = "CHI-v1";
|
||||
}
|
||||
|
|
|
@ -155,6 +155,6 @@ abstract contract DyDxResolver is Events, Helpers {
|
|||
|
||||
}
|
||||
|
||||
contract ConnectDydx is DyDxResolver {
|
||||
contract ConnectV2Dydx is DyDxResolver {
|
||||
string public name = "Dydx-v1";
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
contract Events {
|
||||
event LogDydxFlashLoan(address indexed token, uint256 tokenAmt);
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
interface DydxFlashInterface {
|
||||
function initiateFlashLoan(address _token, uint256 _amount, bytes calldata data) external;
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
pragma solidity ^0.7.0;
|
||||
|
||||
import { DSMath } from "../../common/math.sol";
|
||||
import { Basic } from "../../common/basic.sol";
|
||||
import { TokenInterface, AccountInterface } from "../../common/interfaces.sol";
|
||||
import { Events } from "./events.sol";
|
||||
import { DydxFlashInterface } from "./interface.sol";
|
||||
|
||||
abstract contract FlashLoanResolver is DSMath, Basic, Events {
|
||||
address internal constant dydxAddr = address(0); // check9898 - change to dydx flash contract address
|
||||
|
||||
/**
|
||||
* @dev Borrow Flashloan and Cast spells.
|
||||
* @param token Token Address.
|
||||
* @param tokenAmt Token Amount.
|
||||
* @param data targets & data for cast.
|
||||
*/
|
||||
function borrowAndCast(
|
||||
address token,
|
||||
uint tokenAmt,
|
||||
bytes memory data
|
||||
) public payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
AccountInterface(address(this)).enable(dydxAddr);
|
||||
|
||||
address _token = token == ethAddr ? wethAddr : token;
|
||||
|
||||
DydxFlashInterface(dydxAddr).initiateFlashLoan(_token, tokenAmt, data);
|
||||
|
||||
AccountInterface(address(this)).disable(dydxAddr);
|
||||
|
||||
_eventName = "LogDydxFlashLoan(address,uint256)";
|
||||
_eventParam = abi.encode(token, tokenAmt);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectDydxFlashLoan is FlashLoanResolver {
|
||||
string public constant name = "dydx-flashloan-v1";
|
||||
}
|
|
@ -25,6 +25,6 @@ abstract contract FeeResolver is DSMath, Basic {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectFee is FeeResolver {
|
||||
contract ConnectV2Fee is FeeResolver {
|
||||
string public constant name = "Fee-v1";
|
||||
}
|
||||
|
|
|
@ -162,6 +162,6 @@ abstract contract GelatoResolver is DSMath, Basic, Events {
|
|||
|
||||
}
|
||||
|
||||
contract ConnectGelato is GelatoResolver {
|
||||
string public name = "Gelato-v1.0";
|
||||
contract ConnectV2Gelato is GelatoResolver {
|
||||
string public name = "Gelato-v1";
|
||||
}
|
||||
|
|
|
@ -272,6 +272,6 @@ contract LiquidityAccessMulti is LiquidityAccess {
|
|||
// }
|
||||
}
|
||||
|
||||
contract ConnectInstaPool is LiquidityAccessMulti {
|
||||
string public name = "InstaPool-v2.1";
|
||||
contract ConnectV2InstaPool is LiquidityAccessMulti {
|
||||
string public name = "InstaPool-v2";
|
||||
}
|
||||
|
|
|
@ -49,4 +49,8 @@ abstract contract KyberResolver is Helpers, Events {
|
|||
_eventName = "LogSell(address,address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(buyAddr, sellAddr, _buyAmt, _sellAmt, getId, setId);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV2Kyber is KyberResolver {
|
||||
string public name = "Kyber-v2";
|
||||
}
|
|
@ -227,7 +227,7 @@ abstract contract MakerResolver is Helpers, Events {
|
|||
|
||||
setUint(setId, _amt);
|
||||
|
||||
_eventName = "LogBorrow(uint256,bytes32,uint256,uint256,uint256)";
|
||||
_eventName = "LogPayback(uint256,bytes32,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(_vault, ilk, _amt, getId, setId);
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,7 @@ abstract contract MakerResolver is Helpers, Events {
|
|||
|
||||
setUint(setId, _amt);
|
||||
|
||||
_eventName = "LogBorrow(uint256,bytes32,uint256,uint256,uint256)";
|
||||
_eventName = "LogWithdrawLiquidated(uint256,bytes32,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(vault, ilk, _amt, getId, setId);
|
||||
}
|
||||
|
||||
|
@ -483,6 +483,6 @@ abstract contract MakerResolver is Helpers, Events {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectMaker is MakerResolver {
|
||||
string public constant name = "MakerDao-v1.4";
|
||||
contract ConnectV2Maker is MakerResolver {
|
||||
string public constant name = "MakerDao-v1";
|
||||
}
|
||||
|
|
|
@ -117,6 +117,6 @@ contract OasisResolver is DSMath, Basic, Events {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectOasis is OasisResolver {
|
||||
string public name = "Oasis-v1.1";
|
||||
contract ConnectV2Oasis is OasisResolver {
|
||||
string public name = "Oasis-v1";
|
||||
}
|
||||
|
|
|
@ -178,6 +178,6 @@ abstract contract UniswapResolver is Helpers, Events {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectUniswapV2 is UniswapResolver {
|
||||
contract ConnectV2UniswapV2 is UniswapResolver {
|
||||
string public name = "UniswapV2-v1";
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
require("@nomiclabs/hardhat-ethers");
|
||||
require("@tenderly/hardhat-tenderly");
|
||||
require("@nomiclabs/hardhat-etherscan");
|
||||
require('dotenv').config();
|
||||
|
||||
const PRIVATE_KEY = process.env.PRIVATE_KEY;
|
||||
const ALCHEMY_ID = process.env.ALCHEMY_ID;
|
||||
|
||||
/**
|
||||
* @type import('hardhat/config').HardhatUserConfig
|
||||
*/
|
||||
|
@ -27,17 +31,22 @@ module.exports = {
|
|||
url: process.env.ETH_NODE_URL,
|
||||
chainId: 1,
|
||||
timeout: 500000,
|
||||
accounts: [`0x${PRIVATE_KEY}`]
|
||||
},
|
||||
kovan: {
|
||||
url: `https://eth-kovan.alchemyapi.io/v2/${ALCHEMY_ID}`,
|
||||
accounts: [`0x${PRIVATE_KEY}`]
|
||||
},
|
||||
tenderlyMainnet: {
|
||||
url: 'https://mainnet.tenderly.co',
|
||||
accounts: [process.env.PRIVATE_KEY],
|
||||
accounts: [`0x${PRIVATE_KEY}`],
|
||||
chainId: 1,
|
||||
gasPrice: 25120000000,
|
||||
timeout: 500000
|
||||
},
|
||||
tenderlyKovan: {
|
||||
url: 'https://kovan.tenderly.co',
|
||||
accounts: [process.env.PRIVATE_KEY],
|
||||
accounts: [`0x${PRIVATE_KEY}`],
|
||||
chainId: 42,
|
||||
gasPrice: 40000000000,
|
||||
timeout: 50000
|
||||
|
|
1417
package-lock.json
generated
1417
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -39,10 +39,12 @@
|
|||
"@nomiclabs/buidler": "^1.3.8",
|
||||
"@nomiclabs/buidler-truffle5": "^1.3.4",
|
||||
"@nomiclabs/buidler-web3": "^1.3.4",
|
||||
"@nomiclabs/hardhat-ethers": "^2.0.2",
|
||||
"@nomiclabs/hardhat-etherscan": "^2.1.1",
|
||||
"@openzeppelin/test-helpers": "^0.5.6",
|
||||
"@studydefi/money-legos": "^2.3.7",
|
||||
"@tenderly/hardhat-tenderly": "^1.0.6",
|
||||
"ethers": "^5.0.32",
|
||||
"ganache-cli": "^6.10.0-beta.2",
|
||||
"hardhat": "^2.0.8",
|
||||
"sol-merger": "^2.0.1",
|
||||
|
|
46
scripts/deploy.js
Normal file
46
scripts/deploy.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
const hre = require("hardhat");
|
||||
const { ethers } = hre;
|
||||
|
||||
const deployConnector = require("./deployConnector");
|
||||
|
||||
async function main() {
|
||||
const accounts = await hre.ethers.getSigners()
|
||||
const wallet = accounts[0]
|
||||
|
||||
const connectMapping = {
|
||||
'1inch': 'ConnectV2OneInch',
|
||||
'aaveV1': 'ConnectV2AaveV1',
|
||||
'aaveV2': 'ConnectV2AaveV2',
|
||||
'auth': 'ConnectV2Auth',
|
||||
'basic': 'ConnectV2Basic',
|
||||
'comp': 'ConnectV2COMP',
|
||||
'compound': 'ConnectV2Compound',
|
||||
'dydx': 'ConnectV2Dydx',
|
||||
'fee': 'ConnectV2Fee',
|
||||
'gelato': 'ConnectV2Gelato',
|
||||
'maker': 'ConnectV2Maker',
|
||||
'uniswap': 'ConnectV2UniswapV2'
|
||||
}
|
||||
|
||||
const addressMapping = {}
|
||||
|
||||
for (const key in connectMapping) {
|
||||
addressMapping[key] = await deployConnector(connectMapping[key])
|
||||
}
|
||||
|
||||
const connectorsAbi = [
|
||||
"function addConnectors(string[] _connectorNames, address[] _connectors)"
|
||||
]
|
||||
|
||||
// Replace the address with correct v2 connectors registry address
|
||||
const connectorsContract = new ethers.Contract("0x84b457c6D31025d56449D5A01F0c34bF78636f67", connectorsAbi, wallet)
|
||||
|
||||
await connectorsContract.addConnectors(Object.keys(addressMapping), Object.values(addressMapping))
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
24
scripts/deployConnector.js
Normal file
24
scripts/deployConnector.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const hre = require("hardhat");
|
||||
const { ethers } = hre;
|
||||
|
||||
module.exports = async (connectorName) => {
|
||||
const Connector = await ethers.getContractFactory(connectorName);
|
||||
const connector = await Connector.deploy();
|
||||
await connector.deployed();
|
||||
|
||||
console.log(`${connectorName} Deployed: ${connector.address}`);
|
||||
|
||||
try {
|
||||
await hre.run("verify:verify", {
|
||||
address: connector.address,
|
||||
constructorArguments: []
|
||||
}
|
||||
)
|
||||
} catch (error) {
|
||||
console.log(`Failed to verify: ${connectorName}@${connector.address}`)
|
||||
console.log(error)
|
||||
console.log()
|
||||
}
|
||||
|
||||
return connector.address
|
||||
}
|
23
scripts/deploySingle.js
Normal file
23
scripts/deploySingle.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const hre = require("hardhat");
|
||||
const { ethers } = hre;
|
||||
|
||||
const deployConnector = require("./deployConnector");
|
||||
|
||||
async function main() {
|
||||
const address = await deployConnector("ConnectOne") // Example
|
||||
|
||||
const connectorsAbi = [
|
||||
"function addConnectors(string[] _connectorNames, address[] _connectors)"
|
||||
]
|
||||
|
||||
const connectorsContract = new ethers.Contract("0x84b457c6D31025d56449D5A01F0c34bF78636f67", connectorsAbi, ethers.provider);
|
||||
|
||||
await connectorsContract.addConnectors(['1inch'], [address])
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
Loading…
Reference in New Issue
Block a user