mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Merge branch 'Instadapp:main' into pooltogether-connector
This commit is contained in:
commit
e3ddf057cf
412
README.md
412
README.md
|
@ -4,391 +4,53 @@ Connectors are standard proxy logics contract that let DeFi Smart Account (DSA)
|
|||
|
||||
DSAs are powerful because they can easily be extended with connectors. Every new connector that is added is immediately usable by any developer building on top of DSAs. Connectors can either be base connectors to protocols, auth connectors, higher level connectors with more specific use cases like optimized lending, or connectors to native liquidity pools.
|
||||
|
||||
You can create a PR to request a support for specific protocol or external contracts. The process to add a new connector is explained [here](docs/how-to-add-new-connector.md). Following is the list of all the supported connectors. Following is the list of all the primary connectors used to cast spells:
|
||||
You can create a PR to request a support for specific protocol or external contracts. The process to add a new connector is explained below.
|
||||
|
||||
[Read this post to learn about getId and setId used in the connectors](https://discuss.instadapp.io/t/how-to-use-getid-setid/104)
|
||||
List of all the mainnet connector for referrence is [here](https://github.com/Instadapp/dsa-connectors/tree/main/contracts/mainnet/connectors)
|
||||
|
||||
## Authority
|
||||
## How to add a new connector
|
||||
|
||||
[Code](contracts/mainnet/connectors/authority/main.sol)
|
||||
You can create a new PR to add a new connector. To get the PR merged, certain requirements needs to be met which will be explained here.
|
||||
|
||||
### `add(authority)`
|
||||
### New connector should follow the current directory structure
|
||||
|
||||
**Add an address authority**
|
||||
Common files for all connectors are in `contracts/common` directory.
|
||||
|
||||
`authority` - Address of the authority to add
|
||||
* `math.sol` has methods for mathematical operations (`DSMath`)
|
||||
* `interfaces.sol` contains the common interfaces
|
||||
* `TokenInterface` for ERC-20 interface including WETH
|
||||
* `stores.sol` contains the global constants as well as methods `getId` & `setId` (`Stores`)
|
||||
* `basic.sol` inherits `DSMath` & `Stores` contracts. This contains few details explained below
|
||||
* Wrapping & unwrapping ETH (`convertEthToWeth` & `convertWethToEth`)
|
||||
* Getting token & ETH balance of DSA
|
||||
|
||||
### `remove(authority)`
|
||||
Connectors are under `contracts/connectors` directory, and should be formatted as follows:
|
||||
|
||||
**Remove an address authority**
|
||||
* Connector events should be in a separate contract: `events.sol`
|
||||
* Interfaces should be defined in a seperate file: `interface.sol`
|
||||
* If the connector has helper methods & constants (including interface instances), this should be defined in a separate file: `helpers.sol`
|
||||
* `Helpers` contract should inherit `Basic` contract from common directory
|
||||
* If the connector doesn't have any helper methods, the main contract should inherit `Basic` contract
|
||||
* The main logic of the contract should be under `main.sol`, and the contract should inherit `Helpers` (if exists, otherwise `Basic`) & `Events`
|
||||
|
||||
`authority` - Address of the authority to remove
|
||||
Few things to consider while writing the connector:
|
||||
|
||||
## Basic
|
||||
* Connector should have a public constant string declared `name`, which will be the name of the connector. This will be versioned. Ex: `Compound-v1`
|
||||
* Contract name should start with `ConnectV2` appended with protocol name. Eg: `ConnectV2Compound`
|
||||
* User interacting methods (`external` methods) will not be emitting events, rather the methods will be returning 2 variables:
|
||||
* `_eventName` of `string` type: This will be the event signture defined in the `Events` contract. Ex: `LogDeposit(address,address,uint256,uint256,uint256)`
|
||||
* `_eventParam` of `bytes` type: This will be the abi encoded event parameters
|
||||
* The contracts should not have `selfdestruct()`
|
||||
* The contracts should not have `delegatecall()`
|
||||
* Use `uint(-1)` of `type(uint256).max` for maximum amount everywhere
|
||||
* Use `ethAddr` (declared in `Stores`) to denote Ethereum (non-ERC20)
|
||||
* Use `address(this)` instead of `msg.sender` for fetching balance on-chain, etc
|
||||
* Only `approve()` (declared in `Basic`) limited amount while giving ERC20 allowance, which strictly needs to be 0 by the end of the spell.
|
||||
* User interacting functions should have natspec comments(@dev, @notice, @param).
|
||||
* Use `getUint()` (declared in `Stores`) for getting value that saved from previous spell
|
||||
* Use `setUint()` (declared in `Stores`) for setting value to save for the future spell
|
||||
|
||||
[Code](contracts/mainnet/connectors/basic/main.sol)
|
||||
### Support
|
||||
|
||||
### `deposit(erc20, amt, getId, setId)`
|
||||
If you can't find something you're looking for or have any questions, ask them at our developers community on [Discord](https://discord.gg/83vvrnY) or simply send an [Email](mailto:info@instadapp.io).
|
||||
|
||||
**Deposit a token or ETH to DSA.**
|
||||
|
||||
`erc20` - Address of the token to deposit. ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
|
||||
|
||||
`amt` - Amount of token to deposit
|
||||
|
||||
In case of an ERC20 Token, allowance must be given to DSA before depositing
|
||||
|
||||
### `withdraw(erc20, amt, getId, setId)`
|
||||
|
||||
**Withdraw a token or ETH from DSA.**
|
||||
|
||||
`erc20` - Address of the token to withdraw. ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
|
||||
|
||||
`amt` - Amount of token to withdraw
|
||||
|
||||
`to` - Address to which token will be withdrawn
|
||||
|
||||
## MakerDAO
|
||||
|
||||
[Code](contracts/mainnet/connectors/makerdao/main.sol)
|
||||
|
||||
### `open(collateralType)`
|
||||
|
||||
**Open a Maker vault** of the `collateralType`. E.g. "ETH-A", "USDC-B", etc...
|
||||
|
||||
### `close(vault)`
|
||||
|
||||
**Close a Maker vault**
|
||||
|
||||
`vault` - Vault ID (Use 0 for last opened vault)
|
||||
|
||||
### `deposit(vault, amt, getId, setId)`
|
||||
|
||||
**Deposit collateral to a Maker vault.**
|
||||
|
||||
`vault` - Vault ID (Use 0 for last opened vault)
|
||||
|
||||
`amt` - Amount of collteral to deposit
|
||||
|
||||
### `withdraw(vault, amt, getId, setId)`
|
||||
|
||||
**Withdraw collateral from a Maker vault.**
|
||||
|
||||
`vault` - Vault ID (Use 0 for last opened vault)
|
||||
|
||||
`amt` - Amount of collteral to withdraw
|
||||
|
||||
### `borrow(vault, amt, getId, setId)`
|
||||
|
||||
**Borrow DAI from a Maker vault.**
|
||||
|
||||
`vault` - Vault ID (Use 0 for last opened vault)
|
||||
|
||||
`amt` - Amount of DAI to borrow
|
||||
|
||||
### `payback(vault, amt, getId, setId)`
|
||||
|
||||
**Payback DAI to a Maker vault.**
|
||||
|
||||
`vault` - Vault ID (Use 0 for last opened vault)
|
||||
|
||||
`amt` - Amount of DAI to payback
|
||||
|
||||
### `withdrawLiquidated(vault, amt, getId, setId)`
|
||||
|
||||
**Withdraw leftover collateral after liquidation.**
|
||||
|
||||
`vault` - Vault ID (Use 0 for last opened vault)
|
||||
|
||||
`amt` - Amount of collateral to withdraw
|
||||
|
||||
### `depositAndBorrow(vault, depositAmt, borrowAmt, getIdDeposit, getIdBorrow, setIdDeposit, setIdBorrow)`
|
||||
|
||||
**Deposit collateral & borrow DAI from a vault.**
|
||||
|
||||
`vault` - Vault ID (Use 0 for last opened vault)
|
||||
|
||||
`depositAmt` - Amount of collateral to deposit
|
||||
|
||||
`borrowAmt` - Amount of DAI to borrow
|
||||
|
||||
## Compound
|
||||
|
||||
[Code](contracts/mainnet/connectors/compound/main.sol)
|
||||
|
||||
### `deposit(token, amt, getId, setId)`
|
||||
|
||||
**Deposit token to Compound.**
|
||||
|
||||
`token` - Address of the token to deposit
|
||||
|
||||
`amt` - Amount of token to deposit
|
||||
|
||||
### `withdraw(token, amt, getId, setId)`
|
||||
|
||||
**Withdraw token from Compound.**
|
||||
|
||||
`token` - Address of the token to withdraw
|
||||
|
||||
`amt` - Amount of token to withdraw
|
||||
|
||||
### `borrow(token, amt, getId, setId)`
|
||||
|
||||
**Borrow token from Compound.**
|
||||
|
||||
`token` - Address of the token to borrow
|
||||
|
||||
`amt` - Amount of token to borrow
|
||||
|
||||
### `payback(token, amt, getId, setId)`
|
||||
|
||||
**Payback debt to Compound.**
|
||||
|
||||
`token` - Address of the token to payback
|
||||
|
||||
`amt` - Amount of token to payback
|
||||
|
||||
## COMP
|
||||
|
||||
[Code](contracts/mainnet/connectors/COMP/main.sol)
|
||||
|
||||
### `ClaimComp(setId)`
|
||||
|
||||
**Claim unclaimed COMP**
|
||||
|
||||
### `ClaimCompTwo(tokens, setId)`
|
||||
|
||||
**Claim unclaimed COMP**
|
||||
|
||||
`tokens` - List of tokens supplied or borrowed
|
||||
|
||||
### `ClaimCompThree(supplyTokens, borrowTokens, setId)`
|
||||
|
||||
**Claim unclaimed COMP**
|
||||
|
||||
`supplyTokens` - List of tokens supplied
|
||||
|
||||
`borrowTokens` - List of tokens borrowed
|
||||
|
||||
### `delegate(delegatee)`
|
||||
|
||||
**Delegate COMP votes**
|
||||
|
||||
`delegatee` - Address of the delegatee
|
||||
|
||||
## Aave v1
|
||||
|
||||
[Code](contracts/mainnet/connectors/aave/main.sol)
|
||||
|
||||
### `deposit(token, amt, getId, setId)`
|
||||
|
||||
**Deposit token to Aave.**
|
||||
|
||||
`token` - Address of the token to deposit
|
||||
|
||||
`amt` - Amount of token to deposit
|
||||
|
||||
### `withdraw(token, amt, getId, setId)`
|
||||
|
||||
**Withdraw token from Aave.**
|
||||
|
||||
`token` - Address of the token to withdraw
|
||||
|
||||
`amt` - Amount of token to withdraw
|
||||
|
||||
### `borrow(token, amt, getId, setId)`
|
||||
|
||||
**Borrow token from Aave.**
|
||||
|
||||
`token` - Address of the token to borrow
|
||||
|
||||
`amt` - Amount of token to borrow
|
||||
|
||||
### `payback(token, amt, getId, setId)`
|
||||
|
||||
**Payback debt to Aave.**
|
||||
|
||||
`token` - Address of the token to payback
|
||||
|
||||
`amt` - Amount of token to payback
|
||||
|
||||
## Aave v2
|
||||
|
||||
[Code](contracts/mainnet/connectors/aave_v2/main.sol)
|
||||
|
||||
### `deposit(token, amt, getId, setId)`
|
||||
|
||||
**Deposit token to Aave.**
|
||||
|
||||
`token` - Address of the token to deposit
|
||||
|
||||
`amt` - Amount of token to deposit
|
||||
|
||||
### `withdraw(token, amt, getId, setId)`
|
||||
|
||||
**Withdraw token from Aave.**
|
||||
|
||||
`token` - Address of the token to withdraw
|
||||
|
||||
`amt` - Amount of token to withdraw
|
||||
|
||||
### `borrow(token, amt, rateMode, getId, setId)`
|
||||
|
||||
**Borrow token from Aave.**
|
||||
|
||||
`token` - Address of the token to borrow
|
||||
|
||||
`amt` - Amount of token to borrow
|
||||
|
||||
`rateMode` - Borrow interest rate mode (1 = Stable & 2 = Variable)
|
||||
|
||||
### `payback(token, amt, rateMode, getId, setId)`
|
||||
|
||||
**Payback debt to Aave.**
|
||||
|
||||
`token` - Address of the token to payback
|
||||
|
||||
`amt` - Amount of token to payback
|
||||
|
||||
`rateMode` - Borrow interest rate mode (1 = Stable & 2 = Variable)
|
||||
|
||||
## dYdX
|
||||
|
||||
[Code](contracts/mainnet/connectors/dydx/main.sol)
|
||||
|
||||
### `deposit(token, amt, getId, setId)`
|
||||
|
||||
**Deposit token to dYdX.**
|
||||
|
||||
`token` - Address of the token to deposit
|
||||
|
||||
`amt` - Amount of token to deposit
|
||||
|
||||
### `withdraw(token, amt, getId, setId)`
|
||||
|
||||
**Withdraw token from dYdX.**
|
||||
|
||||
`token` - Address of the token to withdraw
|
||||
|
||||
`amt` - Amount of token to withdraw
|
||||
|
||||
### `borrow(token, amt, getId, setId)`
|
||||
|
||||
**Borrow token from dYdX.**
|
||||
|
||||
`token` - Address of the token to borrow
|
||||
|
||||
`amt` - Amount of token to borrow
|
||||
|
||||
### `payback(token, amt, getId, setId)`
|
||||
|
||||
**Payback debt to dYdX.**
|
||||
|
||||
`token` - Address of the token to payback
|
||||
|
||||
`amt` - Amount of token to payback
|
||||
|
||||
## Uniswap
|
||||
|
||||
[Code](contracts/mainnet/connectors/uniswap/main.sol)
|
||||
|
||||
### `deposit(tokenA, tokenB, amtA, unitAmt, slippage, getId, setId)`
|
||||
|
||||
**Deposit liquidity to tokenA/tokenB pool**
|
||||
|
||||
`tokenA` - Address of token A
|
||||
|
||||
`tokenB` - Address of token B
|
||||
|
||||
`amtA` - Amount of token A to deposit
|
||||
|
||||
`unitAmt` - Unit amount of amtB/amtA with slippage.
|
||||
|
||||
`slippage` - Slippage amount in wei
|
||||
|
||||
|
||||
### `withdraw(tokenA, tokenB, uniAmt, unitAmtA, unitAmtB, getId, setId)`
|
||||
|
||||
**Withdraw liquidity from tokenA/tokenB pool**
|
||||
|
||||
`tokenA` - Address of token A
|
||||
|
||||
`tokenB` - Address of token B
|
||||
|
||||
`uniAmt` - Amount of LP tokens to withdraw
|
||||
|
||||
`unitAmtA` - Unit amount of amtA/uniAmt with slippage.
|
||||
|
||||
`unitAmtB` - Unit amount of amtB/uniAmt with slippage.
|
||||
|
||||
### `buy(buyAddr, sellAddr, buyAmt, unitAmt, getId, setId)`
|
||||
|
||||
**Buy a token/ETH**
|
||||
|
||||
`buyAddr` - Address of the buying token
|
||||
|
||||
`sellAddr` - Address of the selling token
|
||||
|
||||
`buyAmt` - Amount of tokens to buy
|
||||
|
||||
`unitAmt` - Unit amount of sellAmt/buyAmt with slippage
|
||||
|
||||
### `sell(buyAddr, sellAddr, sellAmt, unitAmt, getId, setId)`
|
||||
|
||||
**Sell a token/ETH**
|
||||
|
||||
`buyAddr` - Address of the buying token
|
||||
|
||||
`sellAddr` - Address of the selling token
|
||||
|
||||
`sellAmt` - Amount of tokens to sell
|
||||
|
||||
`unitAmt` - Unit amount of buyAmt/sellAmt with slippage
|
||||
|
||||
## 1Inch
|
||||
|
||||
[Code](contracts/mainnet/connectors/1inch/main.sol)
|
||||
|
||||
### `sell(buyAddr, sellAddr, sellAmt, unitAmt, getId, setId)`
|
||||
|
||||
**Sell ETH/ERC20 using 1proto**
|
||||
|
||||
`buyAddr` - Address of the buying token
|
||||
|
||||
`sellAddr` - Address of the selling token
|
||||
|
||||
`sellAmt` - Amount of tokens to sell
|
||||
|
||||
`unitAmt` - Unit amount of buyAmt/sellAmt with slippage
|
||||
|
||||
### `sellTwo(buyAddr, sellAddr, sellAmt, unitAmt, getId, setId)`
|
||||
|
||||
**Sell ETH/ERC20 using 1proto**
|
||||
|
||||
`buyAddr` - Address of the buying token
|
||||
|
||||
`sellAddr` - Address of the selling token
|
||||
|
||||
`sellAmt` - Amount of tokens to sell
|
||||
|
||||
`unitAmt` - Unit amount of buyAmt/sellAmt with slippage
|
||||
|
||||
`[]distribution` - Distribution of swap across different dex.
|
||||
|
||||
`disableDexes` - Disable a dex. (To disable none: 0)
|
||||
|
||||
### `sellTwo(buyAddr, sellAddr, sellAmt, unitAmt, getId, setId)`
|
||||
|
||||
**Sell ETH/ERC20 using 1inch**
|
||||
|
||||
Use [1Inch API](https://docs.1inch.exchange/api/) for calldata
|
||||
|
||||
`buyAddr` - Address of the buying token
|
||||
|
||||
`sellAddr` - Address of the selling token
|
||||
|
||||
`sellAmt` - Amount of tokens to sell
|
||||
|
||||
`unitAmt` - Unit amount of buyAmt/sellAmt with slippage
|
||||
|
||||
`callData` - Data from 1inch API
|
||||
|
|
|
@ -19,7 +19,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
/**
|
||||
* @dev Compound Mapping
|
||||
*/
|
||||
CompoundMappingInterface internal constant compMapping = CompoundMappingInterface(0xA8F9D4aA7319C54C04404765117ddBf9448E2082);
|
||||
CompoundMappingInterface internal constant compMapping = CompoundMappingInterface(0xe7a85d0adDB972A4f0A4e57B698B37f171519e88);
|
||||
|
||||
function getMergedCTokens(
|
||||
string[] calldata supplyIds,
|
||||
|
|
|
@ -99,5 +99,5 @@ abstract contract CompResolver is Events, Helpers {
|
|||
}
|
||||
|
||||
contract ConnectV2COMP is CompResolver {
|
||||
string public constant name = "COMP-v1";
|
||||
string public constant name = "COMP-v1.1";
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ abstract contract BasicResolver is Events, DSMath, Basic {
|
|||
|
||||
/**
|
||||
* @dev Deposit Assets To Smart Account.
|
||||
* @notice Deposit a token to DSA
|
||||
* @param token The address of the token to deposit. (For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @notice Deposit a token to DSA.
|
||||
* @param token The address of the token to deposit.<br>(For <b>ETH</b>: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE and need to pass `value` parameter equal to `amt` in cast function ```dsa.cast({..., value: amt})```.<br>For <b>ERC20</b>: Need to give allowance prior casting spells.)
|
||||
* @param amt The amount of tokens to deposit. (For max: `uint256(-1)` (Not valid for ETH))
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of tokens deposited.
|
||||
|
|
|
@ -13,7 +13,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
/**
|
||||
* @dev Compound Mapping
|
||||
*/
|
||||
CompoundMappingInterface internal constant compMapping = CompoundMappingInterface(0xA8F9D4aA7319C54C04404765117ddBf9448E2082);
|
||||
CompoundMappingInterface internal constant compMapping = CompoundMappingInterface(0xe7a85d0adDB972A4f0A4e57B698B37f171519e88);
|
||||
|
||||
/**
|
||||
* @dev enter compound market
|
||||
|
|
|
@ -23,6 +23,7 @@ contract LiquidityResolver is DSMath, Stores, Variables, Events {
|
|||
* @dev Borrow Flashloan and Cast spells.
|
||||
* @param token Token Address.
|
||||
* @param amt Token Amount.
|
||||
* @param route Flashloan source route. (0: dYdX(ETH,DAI,USDC only), 1: MakerDAO(DAI only), 2: Compound(All borrowable tokens in Compound), 3: AaveV2(All borrowable tokens in AaveV2))
|
||||
* @param data targets & data for cast.
|
||||
*/
|
||||
function flashBorrowAndCast(
|
||||
|
@ -74,4 +75,4 @@ contract LiquidityResolver is DSMath, Stores, Variables, Events {
|
|||
|
||||
contract ConnectV2InstaPool is LiquidityResolver {
|
||||
string public name = "Instapool-v1.1";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
uint maxFeePercentage;
|
||||
uint withdrawAmount;
|
||||
uint depositAmount;
|
||||
uint borrowAmount;
|
||||
uint repayAmount;
|
||||
uint lusdChange;
|
||||
bool isBorrow;
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ abstract contract LiquityResolver is Events, Helpers {
|
|||
withdrawAmount = getUint(getIds[1], withdrawAmount);
|
||||
adjustTrove.withdrawAmount = withdrawAmount == uint(-1) ? troveManager.getTroveColl(address(this)) : withdrawAmount;
|
||||
|
||||
adjustTrove.borrowAmount = getUint(getIds[2], borrowAmount);
|
||||
borrowAmount = getUint(getIds[2], borrowAmount);
|
||||
|
||||
repayAmount = getUint(getIds[3], repayAmount);
|
||||
if (repayAmount == uint(-1)) {
|
||||
|
@ -234,14 +234,14 @@ abstract contract LiquityResolver is Events, Helpers {
|
|||
uint _totalDebt = troveManager.getTroveDebt(address(this));
|
||||
repayAmount = _lusdBal > _totalDebt ? _totalDebt : _lusdBal;
|
||||
}
|
||||
adjustTrove.repayAmount = repayAmount;
|
||||
|
||||
adjustTrove.isBorrow = borrowAmount > 0;
|
||||
|
||||
adjustTrove.lusdChange = adjustTrove.isBorrow ? borrowAmount : repayAmount;
|
||||
|
||||
borrowerOperations.adjustTrove{value: adjustTrove.depositAmount}(
|
||||
adjustTrove.maxFeePercentage,
|
||||
adjustTrove.withdrawAmount,
|
||||
adjustTrove.borrowAmount,
|
||||
adjustTrove.lusdChange,
|
||||
adjustTrove.isBorrow,
|
||||
upperHint,
|
||||
lowerHint
|
||||
|
@ -249,11 +249,11 @@ abstract contract LiquityResolver is Events, Helpers {
|
|||
|
||||
setUint(setIds[0], adjustTrove.depositAmount);
|
||||
setUint(setIds[1], adjustTrove.withdrawAmount);
|
||||
setUint(setIds[2], adjustTrove.borrowAmount);
|
||||
setUint(setIds[3], adjustTrove.repayAmount);
|
||||
setUint(setIds[2], borrowAmount);
|
||||
setUint(setIds[3], repayAmount);
|
||||
|
||||
_eventName = "LogAdjust(address,uint256,uint256,uint256,uint256,uint256,uint256[],uint256[])";
|
||||
_eventParam = abi.encode(address(this), maxFeePercentage, adjustTrove.depositAmount, adjustTrove.withdrawAmount, adjustTrove.borrowAmount, adjustTrove.repayAmount, getIds, setIds);
|
||||
_eventParam = abi.encode(address(this), maxFeePercentage, adjustTrove.depositAmount, adjustTrove.withdrawAmount, borrowAmount, repayAmount, getIds, setIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,7 @@ contract Helpers is Basic {
|
|||
/**
|
||||
* @dev Return InstaDApp Mapping Address
|
||||
*/
|
||||
address constant internal getMappingAddr = 0xA8F9D4aA7319C54C04404765117ddBf9448E2082; // CompoundMapping Address
|
||||
address constant internal getMappingAddr = 0xe7a85d0adDB972A4f0A4e57B698B37f171519e88; // CompoundMapping Address
|
||||
|
||||
/**
|
||||
* @dev Return Compound Comptroller Address
|
||||
|
|
|
@ -335,5 +335,5 @@ contract RefinanceResolver is CompoundHelpers, AaveV1Helpers, AaveV2Helpers {
|
|||
}
|
||||
|
||||
contract ConnectV2Refinance is RefinanceResolver {
|
||||
string public name = "Refinance-v1.0";
|
||||
string public name = "Refinance-v1.1";
|
||||
}
|
|
@ -5,12 +5,12 @@
|
|||
"BASIC-A": "0x9926955e0Dd681Dc303370C52f4Ad0a4dd061687",
|
||||
"1INCH-A": "0x235fca310ac7be45c7ad45f111203468743e4b7c",
|
||||
"1INCH-B": "0xaBac3dCf164eD827EAfda8e05eCc8208D6bc5E04",
|
||||
"COMPOUND-A": "0xbb153cf09a123746e0eb3b3a436c544a7eeb24b6",
|
||||
"COMPOUND-A": "0x1B1EACaa31abbE544117073f6F8F658a56A3aE25",
|
||||
"AAVE-V1-A": "0x612c5CA43230D9F97a0ac87E4420F66b8DF97e9D",
|
||||
"AAVE-V2-A": "0x68b27A84101ac5120bBAb7Ce8d6b096C961df52C",
|
||||
"MAKERDAO-A": "0x4049db23c605b197f764072569b8db2464653ef6",
|
||||
"UNISWAP-V2-A": "0x1E5CE41BdB653734445FeC3553b61FebDdaFC43c",
|
||||
"COMP-A": "0xB446e325D44C52b93eC122Bf76301f235f90B9c9",
|
||||
"COMP-A": "0x907F0C8c99B08606eE0A51ec5Bc3dFdbFC2d92f3",
|
||||
"UNISWAP-A": "0xA4BF319968986D2352FA1c550D781bBFCCE3FcaB",
|
||||
"POLYGON-BRIDGE-A": "0x1b79B302132370B434fb7807b36CB72FB0510aD5",
|
||||
"AAVE-CLAIM-A": "0x611C1FA59Aa1d6352c4C8bD44882063c6aEE85E0",
|
||||
|
@ -22,9 +22,10 @@
|
|||
"INSTAPOOL-A": "0x5806Af7AB22E2916fA582Ff05731Bf7C682387B2",
|
||||
"MAKERDAO-CLAIM-A": "0x2f8cBE650af98602a215b6482F2aD60893C5A4E8",
|
||||
"WETH-A": "0x22075fa719eFb02Ca3cF298AFa9C974B7465E5D3",
|
||||
"REFINANCE-A": "0x9eA34bE6dA51aa9F6408FeA79c946FDCFA424442",
|
||||
"REFINANCE-A": "0x6f22931423e8ffC8d51f6E5aF73118fC64b27856",
|
||||
"INST-A": "0x52C2C4a0db049255fF345EB9D3Fb1f555b7a924A",
|
||||
"REFLEXER-A": "0xaC6dc28a6251F49Bbe5755E630107Dccde9ae2C8"
|
||||
"REFLEXER-A": "0xaC6dc28a6251F49Bbe5755E630107Dccde9ae2C8",
|
||||
"LIQUITY-A": "0x3643bA40B8e2bd8F77233BDB6abe38c218f31bFe"
|
||||
},
|
||||
"137" : {
|
||||
"1INCH-A": "0xC0d9210496afE9763F5d8cEb8deFfBa817232A9e",
|
||||
|
@ -37,6 +38,7 @@
|
|||
},
|
||||
"mappings": {
|
||||
"InstaMappingController": "0xDdd075D5e1024901E4038461e1e4BbC3A48a08d4",
|
||||
"InstaCompoundMapping": "0xe7a85d0adDB972A4f0A4e57B698B37f171519e88",
|
||||
"InstaReflexerGebMapping": "0x573e5132693C046D1A9F75Bac683889164bA41b4"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ Few things to consider while writing the connector:
|
|||
* `_eventParam` of `bytes` type: This will be the abi encoded event parameters
|
||||
* The contracts should not have `selfdestruct()`
|
||||
* The contracts should not have `delegatecall()`
|
||||
* Use `uint(-1)` for maximum amount everywhere
|
||||
* Use `uint(-1)` of `type(uint256).max` for maximum amount everywhere
|
||||
* Use `ethAddr` (declared in `Stores`) to denote Ethereum (non-ERC20)
|
||||
* Use `address(this)` instead of `msg.sender` for fetching balance on-chain, etc
|
||||
* Only `approve()` limited amount while giving ERC20 allowance, which strictly needs to be 0 by the end of the spell.
|
||||
|
|
|
@ -3,7 +3,7 @@ const { ethers } = hre;
|
|||
|
||||
async function main() {
|
||||
|
||||
const CONNECTORS_V2 = "0xFE2390DAD597594439f218190fC2De40f9Cf1179";
|
||||
const CONNECTORS_V2 = "0x97b0B3A8bDeFE8cB9563a3c610019Ad10DB8aD11";
|
||||
|
||||
const ctokenMapping = {
|
||||
"ETH-A": "0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5",
|
||||
|
@ -16,7 +16,13 @@ async function main() {
|
|||
"USDT-A": "0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9",
|
||||
"WBTC-A": "0xc11b1268c1a384e55c48c2391d8d480264a3a7f4",
|
||||
"WBTC-B": "0xccF4429DB6322D5C611ee964527D42E5d685DD6a",
|
||||
"ZRX-A": "0xb3319f5d18bc0d84dd1b4825dcde5d5f7266d407"
|
||||
"ZRX-A": "0xb3319f5d18bc0d84dd1b4825dcde5d5f7266d407",
|
||||
"YFI-A": "0x80a2ae356fc9ef4305676f7a3e2ed04e12c33946",
|
||||
"SUSHI-A": "0x4b0181102a0112a2ef11abee5563bb4a3176c9d7",
|
||||
"MKR-A": "0x95b4ef2869ebd94beb4eee400a99824bf5dc325b",
|
||||
"AAVE-A": "0xe65cdb6479bac1e22340e4e755fae7e509ecd06c",
|
||||
"TUSD-A": "0x12392f67bdf24fae0af363c24ac620a2f67dad86",
|
||||
"LINK-A": "0xface851a4921ce59e912d19329929ce6da6eb0c7",
|
||||
}
|
||||
|
||||
const tokenMapping = {
|
||||
|
@ -30,7 +36,13 @@ async function main() {
|
|||
"USDT-A": "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
||||
"WBTC-A": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
|
||||
"WBTC-B": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
|
||||
"ZRX-A": "0xe41d2489571d322189246dafa5ebde1f4699f498"
|
||||
"ZRX-A": "0xe41d2489571d322189246dafa5ebde1f4699f498",
|
||||
"YFI-A": "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e",
|
||||
"SUSHI-A": "0x6B3595068778DD592e39A122f4f5a5cF09C90fE2",
|
||||
"MKR-A": "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2",
|
||||
"AAVE-A": "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9",
|
||||
"TUSD-A": "0x0000000000085d4780B73119b644AE5ecd22b376",
|
||||
"LINK-A": "0x514910771af9ca656af840dff83e8264ecf986ca",
|
||||
}
|
||||
|
||||
const Mapping = await ethers.getContractFactory("InstaCompoundMapping");
|
||||
|
|
|
@ -1208,7 +1208,7 @@ describe("Liquity", () => {
|
|||
const depositAmount = 0;
|
||||
const borrowAmount = 0;
|
||||
const withdrawAmount = ethers.utils.parseEther("1"); // 1 ETH;
|
||||
const repayAmount = ethers.utils.parseUnits("500", 18); // 500 LUSD;
|
||||
const repayAmount = ethers.utils.parseUnits("10", 18); // 10 LUSD;
|
||||
const { upperHint, lowerHint } = await helpers.getTroveInsertionHints(
|
||||
troveCollateralBefore.sub(withdrawAmount),
|
||||
troveDebtBefore.sub(repayAmount),
|
||||
|
@ -1256,7 +1256,7 @@ describe("Liquity", () => {
|
|||
|
||||
expect(
|
||||
troveDebt,
|
||||
`Trove debt should have increased by at least ${borrowAmount} ETH`
|
||||
`Trove debt should have decreased by at least ${repayAmount} LUSD`
|
||||
).to.gte(expectedTroveDebt);
|
||||
});
|
||||
|
||||
|
@ -1273,7 +1273,7 @@ describe("Liquity", () => {
|
|||
const depositAmount = ethers.utils.parseEther("1"); // 1 ETH
|
||||
const borrowAmount = 0;
|
||||
const withdrawAmount = 0;
|
||||
const repayAmount = ethers.utils.parseUnits("100", 18); // 100 lUSD
|
||||
const repayAmount = ethers.utils.parseUnits("10", 18); // 10 lUSD
|
||||
const upperHint = ethers.constants.AddressZero;
|
||||
const lowerHint = ethers.constants.AddressZero;
|
||||
const maxFeePercentage = ethers.utils.parseUnits("0.5", 18); // 0.5% max fee
|
||||
|
@ -1304,7 +1304,7 @@ describe("Liquity", () => {
|
|||
0, // Repay amount comes from a previous spell's storage slot
|
||||
upperHint,
|
||||
lowerHint,
|
||||
[ethDepositId, 0, 0, 0],
|
||||
[ethDepositId, 0, 0, lusdRepayId],
|
||||
[0, 0, 0, 0],
|
||||
],
|
||||
};
|
||||
|
@ -1323,7 +1323,7 @@ describe("Liquity", () => {
|
|||
.connect(userWallet)
|
||||
.approve(dsa.address, repayAmount);
|
||||
|
||||
// Adjust Trove by depositing ETH and borrowing LUSD
|
||||
// Adjust Trove by depositing ETH and repaying LUSD
|
||||
await dsa
|
||||
.connect(userWallet)
|
||||
.cast(...encodeSpells(spells), userWallet.address, {
|
||||
|
@ -1338,7 +1338,7 @@ describe("Liquity", () => {
|
|||
dsa.address
|
||||
);
|
||||
const expectedTroveColl = troveCollateralBefore.add(depositAmount);
|
||||
const expectedTroveDebt = troveDebtBefore.add(borrowAmount);
|
||||
const expectedTroveDebt = troveDebtBefore.sub(repayAmount);
|
||||
|
||||
expect(
|
||||
troveCollateral,
|
||||
|
@ -1347,7 +1347,7 @@ describe("Liquity", () => {
|
|||
|
||||
expect(
|
||||
troveDebt,
|
||||
`Trove debt should have increased by at least ${borrowAmount} ETH`
|
||||
`Trove debt (${troveDebtBefore}) should have decreased by at least ${repayAmount} LUSD`
|
||||
).to.eq(expectedTroveDebt);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user