mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
added connector
This commit is contained in:
parent
91e0ba0031
commit
7ac94a3db3
13
contracts/mainnet/connectors/instaLite/events.sol
Normal file
13
contracts/mainnet/connectors/instaLite/events.sol
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
//SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
contract Events {
|
||||||
|
event LogSupply(
|
||||||
|
address token,
|
||||||
|
uint256 amt,
|
||||||
|
address to,
|
||||||
|
uint256 getId,
|
||||||
|
uint256 setId
|
||||||
|
);
|
||||||
|
event LogWithdraw(uint256 amt, address to, uint256 getId, uint256 setId);
|
||||||
|
}
|
11
contracts/mainnet/connectors/instaLite/helpers.sol
Normal file
11
contracts/mainnet/connectors/instaLite/helpers.sol
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
//SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
import { DSMath } from "../../common/math.sol";
|
||||||
|
import { Basic } from "../../common/basic.sol";
|
||||||
|
import { instaLiteInterface } from "./interface.sol";
|
||||||
|
|
||||||
|
abstract contract Helpers is DSMath, Basic {
|
||||||
|
instaLiteInterface internal constant instaLite =
|
||||||
|
instaLiteInterface(0xc383a3833A87009fD9597F8184979AF5eDFad019);
|
||||||
|
}
|
14
contracts/mainnet/connectors/instaLite/interface.sol
Normal file
14
contracts/mainnet/connectors/instaLite/interface.sol
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
//SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
interface instaLiteInterface {
|
||||||
|
function supplyEth(address to_) external payable returns (uint256);
|
||||||
|
|
||||||
|
function supply(
|
||||||
|
address token_,
|
||||||
|
uint256 amount_,
|
||||||
|
address to_
|
||||||
|
) external returns (uint256);
|
||||||
|
|
||||||
|
function withdraw(uint256 amount_, address to_) external returns (uint256);
|
||||||
|
}
|
90
contracts/mainnet/connectors/instaLite/main.sol
Normal file
90
contracts/mainnet/connectors/instaLite/main.sol
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
//SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title InstaLite Connector
|
||||||
|
* @dev
|
||||||
|
|
||||||
|
*/
|
||||||
|
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";
|
||||||
|
|
||||||
|
abstract contract Resolver is Events, DSMath, Basic, Helpers {
|
||||||
|
/**
|
||||||
|
* @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 getId ID to retrieve amt.
|
||||||
|
* @param setId ID stores the amount of token deposited.
|
||||||
|
*/
|
||||||
|
function supply(
|
||||||
|
address token,
|
||||||
|
uint256 amt,
|
||||||
|
address to,
|
||||||
|
uint256 getId,
|
||||||
|
uint256 setId
|
||||||
|
)
|
||||||
|
public
|
||||||
|
payable
|
||||||
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
|
{
|
||||||
|
uint256 _amt = getUint(getId, amt);
|
||||||
|
bool isEth = token == ethAddr;
|
||||||
|
|
||||||
|
if (isEth) {
|
||||||
|
_amt = _amt == uint256(-1) ? address(this).balance : _amt;
|
||||||
|
uint256 vTokenAmt = instaLite.supplyEth{ value: amt }(to);
|
||||||
|
} else {
|
||||||
|
TokenInterface tokenContract = TokenInterface(token);
|
||||||
|
|
||||||
|
_amt = _amt == uint256(-1)
|
||||||
|
? tokenContract.balanceOf(address(this))
|
||||||
|
: _amt;
|
||||||
|
|
||||||
|
approve(tokenContract, address(instaLite), _amt);
|
||||||
|
uint256 vTokenAmt = instaLite.supply(token, _amt, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
setUint(setId, _amt);
|
||||||
|
|
||||||
|
_eventName = "LogSupply(address,uint256,address,uint256,uint256)";
|
||||||
|
_eventParam = abi.encode(token, _amt, to, getId, setId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Withdraw
|
||||||
|
* @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 getId ID to retrieve amt.
|
||||||
|
* @param setId ID stores the amount of token withdrawn.
|
||||||
|
*/
|
||||||
|
function withdraw(
|
||||||
|
uint256 amt,
|
||||||
|
address to,
|
||||||
|
uint256 getId,
|
||||||
|
uint256 setId
|
||||||
|
)
|
||||||
|
external
|
||||||
|
payable
|
||||||
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
|
{
|
||||||
|
uint256 _amt = getUint(getId, amt);
|
||||||
|
|
||||||
|
instaLite.withdraw(_amt, to);
|
||||||
|
|
||||||
|
setUint(setId, _amt);
|
||||||
|
|
||||||
|
_eventName = "LogWithdraw(uint256,address,uint256,uint256)";
|
||||||
|
_eventParam = abi.encode(_amt, to, getId, setId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract ConnectV2InstaLite is Resolver {
|
||||||
|
string public constant name = "instaLite-v1";
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user