dsa-connectors/contracts/mainnet/connectors/universeFinance/helpers.sol

45 lines
1.3 KiB
Solidity
Raw Normal View History

2022-03-22 15:24:40 +00:00
//SPDX-License-Identifier: MIT
2021-11-15 10:29:08 +00:00
pragma solidity ^0.7.6;
import {TokenInterface} from "../../common/interfaces.sol";
import {DSMath} from "../../common/math.sol";
import {Basic} from "../../common/basic.sol";
import "./interface.sol";
abstract contract Helpers is DSMath, Basic {
2021-11-23 11:51:12 +00:00
IUniverseAdapter constant universeAdapter = IUniverseAdapter(0x876861Ad49f911442720cF97c9b3fCe4070F07d5);
2021-11-15 10:29:08 +00:00
function _deposit(
address universeVault,
uint256 amount0,
uint256 amount1
) internal returns(uint256, uint256){
return universeAdapter.depositProxy(universeVault, amount0, amount1);
}
function _withdraw(
address universeVault,
uint256 share0,
uint256 share1
) internal returns(uint256, uint256){
require(share0 > 0 || share1 > 0, "ZERO");
2021-11-23 11:51:12 +00:00
return IVaultV3(universeVault).withdraw(share0, share1);
2021-11-15 10:29:08 +00:00
}
2021-11-25 05:20:41 +00:00
function _approve(address universeVault, uint256 amount0, uint256 amount1) internal {
IVaultV3 universe = IVaultV3(universeVault);
TokenInterface token;
if (amount0 > 0) {
token = universe.token0();
token.approve(address(universeAdapter), amount0);
}
if (amount1 > 0) {
token = universe.token1();
token.approve(address(universeAdapter), amount1);
}
}
2021-11-15 10:29:08 +00:00
}