mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
passed vault addr in params
This commit is contained in:
parent
10c1872885
commit
dfb2c8132d
|
@ -1,10 +0,0 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
import { Basic } from "../../common/basic.sol";
|
||||
import { instaLiteInterface } from "./interface.sol";
|
||||
|
||||
abstract contract Helpers is DSMath, Basic {
|
||||
instaLiteInterface internal constant instaLite =
|
||||
instaLiteInterface(0xc383a3833A87009fD9597F8184979AF5eDFad019);
|
||||
}
|
|
@ -6,19 +6,20 @@ pragma solidity ^0.7.0;
|
|||
* @dev Supply and Withdraw
|
||||
|
||||
*/
|
||||
import { TokenInterface } from "../../common/interfaces.sol";
|
||||
import { DSMath } from "../../common/math.sol";
|
||||
import { Basic } from "../../common/basic.sol";
|
||||
import { TokenInterface } from "../../../common/interfaces.sol";
|
||||
import { DSMath } from "../../../common/math.sol";
|
||||
import { Basic } from "../../../common/basic.sol";
|
||||
import { Events } from "./events.sol";
|
||||
import { Helpers } from "./helpers.sol";
|
||||
import { instaLiteInterface } from "./interface.sol";
|
||||
|
||||
abstract contract InstaLiteConnector is Events, Basic, Helpers {
|
||||
abstract contract InstaLiteConnector is Events, Basic {
|
||||
/**
|
||||
* @dev Supply
|
||||
* @notice Supply eth/weth/stEth tokens into instalite.
|
||||
* @param token The address of token to be supplied.
|
||||
* @param amt The amount of token to be supplied.
|
||||
* @param to The address of the account on behalf of you want to supplied.
|
||||
* @param instaLite Address of instaLite Contract.
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of token deposited.
|
||||
*/
|
||||
|
@ -26,8 +27,9 @@ abstract contract InstaLiteConnector is Events, Basic, Helpers {
|
|||
address token,
|
||||
uint256 amt,
|
||||
address to,
|
||||
address instaLite,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
uint256[] memory setId
|
||||
)
|
||||
public
|
||||
payable
|
||||
|
@ -36,9 +38,12 @@ abstract contract InstaLiteConnector is Events, Basic, Helpers {
|
|||
uint256 _amt = getUint(getId, amt);
|
||||
bool isEth = token == ethAddr;
|
||||
uint256 vTokenAmt;
|
||||
|
||||
instaLiteInterface instaLiteInstance = instaLiteInterface(instaLite);
|
||||
|
||||
if (isEth) {
|
||||
_amt = _amt == uint256(-1) ? address(this).balance : _amt;
|
||||
vTokenAmt = instaLite.supplyEth{ value: amt }(to);
|
||||
vTokenAmt = instaLiteInstance.supplyEth{ value: amt }(to);
|
||||
} else {
|
||||
TokenInterface tokenContract = TokenInterface(token);
|
||||
|
||||
|
@ -47,10 +52,11 @@ abstract contract InstaLiteConnector is Events, Basic, Helpers {
|
|||
: _amt;
|
||||
|
||||
approve(tokenContract, address(instaLite), _amt);
|
||||
vTokenAmt = instaLite.supply(token, _amt, to);
|
||||
vTokenAmt = instaLiteInstance.supply(token, _amt, to);
|
||||
}
|
||||
|
||||
setUint(setId, _amt);
|
||||
setUint(setId[0], _amt);
|
||||
setUint(setId[1], vTokenAmt);
|
||||
|
||||
_eventName = "LogSupply(address,uint256,uint256,address,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, vTokenAmt, _amt, to, getId, setId);
|
||||
|
@ -61,14 +67,16 @@ abstract contract InstaLiteConnector is Events, Basic, Helpers {
|
|||
* @notice Withdraw eth/stEth tokens from instalite contract.
|
||||
* @param amt The amount of the token to withdraw.
|
||||
* @param to The address of the account on behalf of you want to withdraw.
|
||||
* @param instaLite Address of instaLite Contract.
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of token withdrawn.
|
||||
*/
|
||||
function withdraw(
|
||||
uint256 amt,
|
||||
address to,
|
||||
address instaLite,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
uint256[] memory setId
|
||||
)
|
||||
external
|
||||
payable
|
||||
|
@ -76,15 +84,18 @@ abstract contract InstaLiteConnector is Events, Basic, Helpers {
|
|||
{
|
||||
uint256 _amt = getUint(getId, amt);
|
||||
|
||||
unit256 vTokenAmt = instaLite.withdraw(_amt, to);
|
||||
instaLiteInterface instaLiteInstance = instaLiteInterface(instaLite);
|
||||
|
||||
setUint(setId, _amt);
|
||||
uint256 vTokenAmt = instaLiteInstance.withdraw(_amt, to);
|
||||
|
||||
setUint(setId[0], _amt);
|
||||
setUint(setId[1], vTokenAmt);
|
||||
|
||||
_eventName = "LogWithdraw(uint256,uint256,address,uint256,uint256)";
|
||||
_eventParam = abi.encode(_amt, vTokenAmt, to, getId, setId);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV2InstaLiteVault1 is Resolver {
|
||||
contract ConnectV2InstaLiteVault1 is InstaLiteConnector {
|
||||
string public constant name = "instaLite-v1";
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
|
|||
import { addresses } from "../../../scripts/tests/mainnet/addresses";
|
||||
import { addLiquidity } from "../../../scripts/tests/addLiquidity";
|
||||
import { abis } from "../../../scripts/constant/abis";
|
||||
import { ConnectV2InstaLite__factory } from "../../../typechain";
|
||||
import { ConnectV2InstaLiteVault1__factory } from "../../../typechain";
|
||||
// import lido_abi from "./abi.json";
|
||||
import type { Signer, Contract } from "ethers";
|
||||
import { parseEther } from "ethers/lib/utils";
|
||||
|
@ -41,7 +41,7 @@ describe("instaLite", function () {
|
|||
instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2);
|
||||
connector = await deployAndEnableConnector({
|
||||
connectorName,
|
||||
contractArtifact: ConnectV2InstaLite__factory,
|
||||
contractArtifact: ConnectV2InstaLiteVault1__factory,
|
||||
signer: masterSigner,
|
||||
connectors: instaConnectorsV2
|
||||
});
|
||||
|
@ -77,7 +77,7 @@ describe("instaLite", function () {
|
|||
{
|
||||
connector: connectorName,
|
||||
method: "supply",
|
||||
args: [ethAddr, _amt, dsaWallet0.address, 0, 0]
|
||||
args: [ethAddr, _amt, dsaWallet0.address, "0xc383a3833a87009fd9597f8184979af5edfad019", 0, [0, 0]]
|
||||
}
|
||||
];
|
||||
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), await wallet1.getAddress());
|
||||
|
@ -91,7 +91,7 @@ describe("instaLite", function () {
|
|||
{
|
||||
connector: connectorName,
|
||||
method: "withdraw",
|
||||
args: [_amt, dsaWallet0.address, 0, 0]
|
||||
args: [_amt, dsaWallet0.address, "0xc383a3833a87009fd9597f8184979af5edfad019", 0, [0, 0]]
|
||||
}
|
||||
];
|
||||
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), await wallet1.getAddress());
|
||||
|
|
Loading…
Reference in New Issue
Block a user