mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Basic changes
This commit is contained in:
parent
aceb55ac94
commit
a3cc3ca88a
|
@ -12,63 +12,63 @@ abstract contract BasicResolver is Events, DSMath, Basic {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Deposit Assets To Smart Account.
|
* @dev Deposit Assets To Smart Account.
|
||||||
* @param erc20 Token Address.
|
* @param token Token Address.
|
||||||
* @param tokenAmt Token Amount.
|
* @param amt Token Amount.
|
||||||
* @param getId Get Storage ID.
|
* @param getId Get Storage ID.
|
||||||
* @param setId Set Storage ID.
|
* @param setId Set Storage ID.
|
||||||
*/
|
*/
|
||||||
function deposit(
|
function deposit(
|
||||||
address erc20,
|
address token,
|
||||||
uint tokenAmt,
|
uint256 amt,
|
||||||
uint getId,
|
uint256 getId,
|
||||||
uint setId
|
uint256 setId
|
||||||
) public payable returns (string memory _eventName, bytes memory _eventParam) {
|
) public payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
uint amt = getUint(getId, tokenAmt);
|
uint _amt = getUint(getId, amt);
|
||||||
if (erc20 != ethAddr) {
|
if (token != ethAddr) {
|
||||||
IERC20 token = IERC20(erc20);
|
IERC20 tokenContract = IERC20(token);
|
||||||
amt = amt == uint(-1) ? token.balanceOf(msg.sender) : amt;
|
_amt = _amt == uint(-1) ? tokenContract.balanceOf(msg.sender) : _amt;
|
||||||
token.safeTransferFrom(msg.sender, address(this), amt);
|
tokenContract.safeTransferFrom(msg.sender, address(this), _amt);
|
||||||
} else {
|
} else {
|
||||||
require(msg.value == amt || amt == uint(-1), "invalid-ether-amount");
|
require(msg.value == _amt || _amt == uint(-1), "invalid-ether-amount");
|
||||||
amt = msg.value;
|
_amt = msg.value;
|
||||||
}
|
}
|
||||||
setUint(setId, amt);
|
setUint(setId, _amt);
|
||||||
|
|
||||||
_eventName = "LogDeposit(address,uint256,uint256,uint256)";
|
_eventName = "LogDeposit(address,uint256,uint256,uint256)";
|
||||||
_eventParam = abi.encode(erc20, amt, getId, setId);
|
_eventParam = abi.encode(token, _amt, getId, setId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Withdraw Assets To Smart Account.
|
* @dev Withdraw Assets To Smart Account.
|
||||||
* @param erc20 Token Address.
|
* @param token Token Address.
|
||||||
* @param tokenAmt Token Amount.
|
* @param amt Token Amount.
|
||||||
* @param to Withdraw token address.
|
* @param to Withdraw token address.
|
||||||
* @param getId Get Storage ID.
|
* @param getId Get Storage ID.
|
||||||
* @param setId Set Storage ID.
|
* @param setId Set Storage ID.
|
||||||
*/
|
*/
|
||||||
function withdraw(
|
function withdraw(
|
||||||
address erc20,
|
address token,
|
||||||
uint tokenAmt,
|
uint amt,
|
||||||
address payable to,
|
address payable to,
|
||||||
uint getId,
|
uint getId,
|
||||||
uint setId
|
uint setId
|
||||||
) public payable returns (string memory _eventName, bytes memory _eventParam) {
|
) public payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
uint amt = getUint(getId, tokenAmt);
|
uint _amt = getUint(getId, amt);
|
||||||
if (erc20 == ethAddr) {
|
if (token == ethAddr) {
|
||||||
amt = amt == uint(-1) ? address(this).balance : amt;
|
_amt = _amt == uint(-1) ? address(this).balance : _amt;
|
||||||
to.transfer(amt);
|
to.call{value: _amt}("");
|
||||||
} else {
|
} else {
|
||||||
IERC20 token = IERC20(erc20);
|
IERC20 tokenContract = IERC20(token);
|
||||||
amt = amt == uint(-1) ? token.balanceOf(address(this)) : amt;
|
_amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt;
|
||||||
token.safeTransfer(to, amt);
|
tokenContract.safeTransfer(to, _amt);
|
||||||
}
|
}
|
||||||
setUint(setId, amt);
|
setUint(setId, _amt);
|
||||||
|
|
||||||
_eventName = "LogWithdraw(address,uint256,address,uint256,uint256)";
|
_eventName = "LogWithdraw(address,uint256,address,uint256,uint256)";
|
||||||
_eventParam = abi.encode(erc20, amt, to, getId, setId);
|
_eventParam = abi.encode(token, _amt, to, getId, setId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract ConnectV2Basic is BasicResolver {
|
contract ConnectV2Basic is BasicResolver {
|
||||||
string public constant name = "Basic-v1";
|
string constant public name = "Basic-v1";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user