dsa-connectors/contracts/fantom/connectors/wftm/main.sol

67 lines
1.9 KiB
Solidity
Raw Normal View History

2022-03-22 14:58:59 +00:00
//SPDX-License-Identifier: MIT
2021-10-02 16:07:42 +00:00
pragma solidity ^0.7.0;
/**
2022-02-15 16:42:44 +00:00
* @title WFTM.
* @dev Wrap and Unwrap WFTM.
2021-10-02 16:07:42 +00:00
*/
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 {
/**
2022-02-15 16:42:44 +00:00
* @dev Deposit FTM into WFTM.
* @notice Wrap FTM into WFTM
* @param amt The amount of FTM to deposit. (For max: `uint256(-1)`)
2021-10-02 16:07:42 +00:00
* @param getId ID to retrieve amt.
2022-02-15 16:42:44 +00:00
* @param setId ID stores the amount of FTM deposited.
2021-10-02 16:07:42 +00:00
*/
function deposit(
uint256 amt,
uint256 getId,
uint256 setId
) public payable returns (string memory _eventName, bytes memory _eventParam) {
uint _amt = getUint(getId, amt);
_amt = _amt == uint(-1) ? address(this).balance : _amt;
wftmContract.deposit{value: _amt}();
setUint(setId, _amt);
_eventName = "LogDeposit(uint256,uint256,uint256)";
_eventParam = abi.encode(_amt, getId, setId);
}
/**
2022-02-15 16:42:44 +00:00
* @dev Withdraw FTM from WFTM from Smart Account
* @notice Unwrap FTM from WFTM
* @param amt The amount of wFTM to withdraw. (For max: `uint256(-1)`)
2021-10-02 16:07:42 +00:00
* @param getId ID to retrieve amt.
2022-02-15 16:42:44 +00:00
* @param setId ID stores the amount of FTM withdrawn.
2021-10-02 16:07:42 +00:00
*/
function withdraw(
uint amt,
uint getId,
uint setId
) public payable returns (string memory _eventName, bytes memory _eventParam) {
uint _amt = getUint(getId, amt);
_amt = _amt == uint(-1) ? wftmContract.balanceOf(address(this)) : _amt;
approve(wftmContract, wftmAddr, _amt);
wftmContract.withdraw(_amt);
setUint(setId, _amt);
_eventName = "LogWithdraw(uint256,uint256,uint256)";
_eventParam = abi.encode(_amt, getId, setId);
}
}
2022-02-15 16:42:44 +00:00
contract ConnectV2WFTMFantom is Resolver {
string constant public name = "WFTM-v1.0";
2021-10-02 16:07:42 +00:00
}