passed vault addr in params

This commit is contained in:
bhavik-m 2022-04-02 22:41:33 +05:30
parent 10c1872885
commit dfb2c8132d
3 changed files with 28 additions and 27 deletions

View File

@ -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);
}

View File

@ -6,19 +6,20 @@ pragma solidity ^0.7.0;
* @dev Supply and Withdraw * @dev Supply and Withdraw
*/ */
import { TokenInterface } from "../../common/interfaces.sol"; import { TokenInterface } from "../../../common/interfaces.sol";
import { DSMath } from "../../common/math.sol"; import { DSMath } from "../../../common/math.sol";
import { Basic } from "../../common/basic.sol"; import { Basic } from "../../../common/basic.sol";
import { Events } from "./events.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 * @dev Supply
* @notice Supply eth/weth/stEth tokens into instalite. * @notice Supply eth/weth/stEth tokens into instalite.
* @param token The address of token to be supplied. * @param token The address of token to be supplied.
* @param amt The amount 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 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 getId ID to retrieve amt.
* @param setId ID stores the amount of token deposited. * @param setId ID stores the amount of token deposited.
*/ */
@ -26,8 +27,9 @@ abstract contract InstaLiteConnector is Events, Basic, Helpers {
address token, address token,
uint256 amt, uint256 amt,
address to, address to,
address instaLite,
uint256 getId, uint256 getId,
uint256 setId uint256[] memory setId
) )
public public
payable payable
@ -36,9 +38,12 @@ abstract contract InstaLiteConnector is Events, Basic, Helpers {
uint256 _amt = getUint(getId, amt); uint256 _amt = getUint(getId, amt);
bool isEth = token == ethAddr; bool isEth = token == ethAddr;
uint256 vTokenAmt; uint256 vTokenAmt;
instaLiteInterface instaLiteInstance = instaLiteInterface(instaLite);
if (isEth) { if (isEth) {
_amt = _amt == uint256(-1) ? address(this).balance : _amt; _amt = _amt == uint256(-1) ? address(this).balance : _amt;
vTokenAmt = instaLite.supplyEth{ value: amt }(to); vTokenAmt = instaLiteInstance.supplyEth{ value: amt }(to);
} else { } else {
TokenInterface tokenContract = TokenInterface(token); TokenInterface tokenContract = TokenInterface(token);
@ -47,10 +52,11 @@ abstract contract InstaLiteConnector is Events, Basic, Helpers {
: _amt; : _amt;
approve(tokenContract, address(instaLite), _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)"; _eventName = "LogSupply(address,uint256,uint256,address,uint256,uint256)";
_eventParam = abi.encode(token, vTokenAmt, _amt, to, getId, setId); _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. * @notice Withdraw eth/stEth tokens from instalite contract.
* @param amt The amount of the token to withdraw. * @param amt The amount of the token to withdraw.
* @param to The address of the account on behalf of you want 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 getId ID to retrieve amt.
* @param setId ID stores the amount of token withdrawn. * @param setId ID stores the amount of token withdrawn.
*/ */
function withdraw( function withdraw(
uint256 amt, uint256 amt,
address to, address to,
address instaLite,
uint256 getId, uint256 getId,
uint256 setId uint256[] memory setId
) )
external external
payable payable
@ -76,15 +84,18 @@ abstract contract InstaLiteConnector is Events, Basic, Helpers {
{ {
uint256 _amt = getUint(getId, amt); 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)"; _eventName = "LogWithdraw(uint256,uint256,address,uint256,uint256)";
_eventParam = abi.encode(_amt, vTokenAmt, to, getId, setId); _eventParam = abi.encode(_amt, vTokenAmt, to, getId, setId);
} }
} }
contract ConnectV2InstaLiteVault1 is Resolver { contract ConnectV2InstaLiteVault1 is InstaLiteConnector {
string public constant name = "instaLite-v1"; string public constant name = "instaLite-v1";
} }

View File

@ -9,7 +9,7 @@ import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
import { addresses } from "../../../scripts/tests/mainnet/addresses"; import { addresses } from "../../../scripts/tests/mainnet/addresses";
import { addLiquidity } from "../../../scripts/tests/addLiquidity"; import { addLiquidity } from "../../../scripts/tests/addLiquidity";
import { abis } from "../../../scripts/constant/abis"; import { abis } from "../../../scripts/constant/abis";
import { ConnectV2InstaLite__factory } from "../../../typechain"; import { ConnectV2InstaLiteVault1__factory } from "../../../typechain";
// import lido_abi from "./abi.json"; // import lido_abi from "./abi.json";
import type { Signer, Contract } from "ethers"; import type { Signer, Contract } from "ethers";
import { parseEther } from "ethers/lib/utils"; import { parseEther } from "ethers/lib/utils";
@ -41,7 +41,7 @@ describe("instaLite", function () {
instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2);
connector = await deployAndEnableConnector({ connector = await deployAndEnableConnector({
connectorName, connectorName,
contractArtifact: ConnectV2InstaLite__factory, contractArtifact: ConnectV2InstaLiteVault1__factory,
signer: masterSigner, signer: masterSigner,
connectors: instaConnectorsV2 connectors: instaConnectorsV2
}); });
@ -77,7 +77,7 @@ describe("instaLite", function () {
{ {
connector: connectorName, connector: connectorName,
method: "supply", 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()); const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), await wallet1.getAddress());
@ -91,7 +91,7 @@ describe("instaLite", function () {
{ {
connector: connectorName, connector: connectorName,
method: "withdraw", 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()); const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), await wallet1.getAddress());