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

93 lines
2.8 KiB
Solidity
Raw Normal View History

2021-11-15 10:29:08 +00:00
pragma solidity ^0.7.6;
pragma abicoder v2;
2021-12-07 17:41:58 +00:00
/**
* @title Universe finance
* @dev Maximising uniswap v3 returns
*/
2021-12-07 17:44:19 +00:00
import {TokenInterface} from "../../common/interfaces.sol";
import {Helpers} from "./helpers.sol";
import {Events} from "./events.sol";
2021-11-23 11:52:05 +00:00
abstract contract UniverseFinanceConnect is Helpers, Events {
2021-11-15 10:29:08 +00:00
/**
* @notice Deposit in Universe Vault by Adapter
2021-12-07 17:41:58 +00:00
* @dev Deposit in universe vault
2021-11-15 10:29:08 +00:00
* @param universeVault Universe Official Vault Address
* @param amountA Amount of tokenA
* @param amountB Amount of tokenB
* @param getIds ID to retrieve amountA and amountB
2021-12-07 17:41:58 +00:00
* @param setIds ID to store amountA and amountB
2021-11-15 10:29:08 +00:00
*/
function deposit(
address universeVault,
uint256 amountA,
uint256 amountB,
2021-11-27 14:29:23 +00:00
uint256[] calldata getIds,
uint256[] calldata setIds
2021-12-07 17:41:58 +00:00
)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
2021-11-15 10:29:08 +00:00
amountA = getUint(getIds[0], amountA);
amountB = getUint(getIds[1], amountB);
2021-11-25 05:22:10 +00:00
_approve(universeVault, amountA, amountB);
2021-12-07 17:41:58 +00:00
(uint256 share0, uint256 share1) = _deposit(
universeVault,
amountA,
amountB
);
2021-11-27 14:29:23 +00:00
setUint(setIds[0], share0);
setUint(setIds[1], share1);
2021-11-15 10:29:08 +00:00
// EVENT
_eventName = "LogDeposit(address,uint256,uint256,uint256,uint256)";
2021-12-07 17:41:58 +00:00
_eventParam = abi.encode(
universeVault,
amountA,
amountB,
share0,
share1
);
2021-11-15 10:29:08 +00:00
}
/**
* @notice Withdraw Token0 & Token1 From Universe Vault
2021-12-07 17:41:58 +00:00
* @dev Withdraw supplied token0 and token1 from universe vault
2021-11-15 10:29:08 +00:00
* @param universeVault Universe Official Vault Address
* @param share0 Amount of uToken0.
* @param share1 Amount of uToken1.
2021-12-07 17:41:58 +00:00
* @param getIds ID to retrieve amount of output token
2021-11-15 10:29:08 +00:00
* @param setIds stores the amount of output tokens
*/
function withdraw(
address universeVault,
uint256 share0,
uint256 share1,
2021-11-27 14:29:23 +00:00
uint256[] calldata getIds,
2021-11-15 10:29:08 +00:00
uint256[] calldata setIds
2021-12-07 17:41:58 +00:00
)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
2021-11-27 14:29:23 +00:00
share0 = getUint(getIds[0], share0);
share1 = getUint(getIds[1], share1);
2021-12-07 17:41:58 +00:00
(uint256 _amtA, uint256 _amtB) = _withdraw(
universeVault,
share0,
share1
);
2021-11-15 10:29:08 +00:00
setUint(setIds[0], _amtA);
setUint(setIds[1], _amtB);
// EVENT
_eventName = "LogWithdraw(address,uint256,uint256,uint256,uint256)";
_eventParam = abi.encode(universeVault, _amtA, _amtB, share0, share1);
}
}
2021-11-23 11:52:05 +00:00
contract ConnectV2UniverseFinance is UniverseFinanceConnect {
2021-11-15 10:29:08 +00:00
string public constant name = "UniverseFinance-v1";
2021-11-23 11:52:05 +00:00
}