This repository has been archived by the owner on May 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
DNGMXVaultController.sol
89 lines (69 loc) · 2.85 KB
/
DNGMXVaultController.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import {IController} from "../core/IController.sol";
/**
@title Rage Trade delta netural gmx vault controller
*/
contract DNGMXVaultController is IController {
/* -------------------------------------------------------------------------- */
/* CONSTANT VARIABLES */
/* -------------------------------------------------------------------------- */
/// @notice depositToken(address,address,uint256)
bytes4 constant DEPOSIT = 0xfb0f97a8;
/// @notice redeemToken(address,address,uint256)
bytes4 constant REDEEM = 0x0d71bdc3;
/// @notice withdrawToken(address,address,uint256)
bytes4 constant WITHDRAW = 0x01e33667;
/// @notice rage trade delta netural jr vault
address[] public vault;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/**
@param _vault rage trade delta netural jr vault
*/
constructor(address _vault) {
vault.push(_vault);
}
/* -------------------------------------------------------------------------- */
/* PUBLIC FUNCTIONS */
/* -------------------------------------------------------------------------- */
/// @inheritdoc IController
function canCall(address, bool, bytes calldata data)
external
view
returns (bool, address[] memory, address[] memory)
{
bytes4 sig = bytes4(data);
if (sig == DEPOSIT) return canDeposit(data[4:]);
if (sig == REDEEM || sig == WITHDRAW) return canWithdraw(data[4:]);
return (false, new address[](0), new address[](0));
}
/* -------------------------------------------------------------------------- */
/* INTERNAL FUNCTIONS */
/* -------------------------------------------------------------------------- */
function canDeposit(bytes calldata data)
internal
view
returns (bool, address[] memory, address[] memory)
{
(address token,,) = abi.decode(
data, (address, address, uint256)
);
address[] memory tokensOut = new address[](1);
tokensOut[0] = token;
return (true, vault, tokensOut);
}
function canWithdraw(bytes calldata data)
internal
view
returns (bool, address[] memory, address[] memory)
{
(address token,,) = abi.decode(
data, (address, address, uint256)
);
address[] memory tokensIn = new address[](1);
tokensIn[0] = token;
return (true, tokensIn, vault);
}
}