forked from dydxfoundation/governance-contracts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStarkProxyV1.sol
73 lines (65 loc) · 2.16 KB
/
StarkProxyV1.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
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.7.5;
pragma abicoder v2;
import { IERC20 } from '../../interfaces/IERC20.sol';
import { ILiquidityStakingV1 } from '../../interfaces/ILiquidityStakingV1.sol';
import { IMerkleDistributorV1 } from '../../interfaces/IMerkleDistributorV1.sol';
import { IStarkPerpetual } from '../../interfaces/IStarkPerpetual.sol';
import { SafeERC20 } from '../../dependencies/open-zeppelin/SafeERC20.sol';
import { SP1Withdrawals } from './impl/SP1Withdrawals.sol';
import { SP1Getters } from './impl/SP1Getters.sol';
import { SP1Guardian } from './impl/SP1Guardian.sol';
import { SP1Owner } from './impl/SP1Owner.sol';
/**
* @title StarkProxyV1
* @author dYdX
*
* @notice Proxy contract allowing a LiquidityStaking borrower to use borrowed funds (as well as
* their own funds, if desired) on the dYdX L2 exchange. Restrictions are put in place to
* prevent borrowed funds being used outside the exchange. Furthermore, a guardian address is
* specified which has the ability to restrict borrows and make repayments.
*
* Owner actions may be delegated to various roles as defined in SP1Roles. Other actions are
* available to guardian roles, to be nominated by dYdX governance.
*/
contract StarkProxyV1 is
SP1Guardian,
SP1Owner,
SP1Withdrawals,
SP1Getters
{
using SafeERC20 for IERC20;
// ============ Constructor ============
constructor(
ILiquidityStakingV1 liquidityStaking,
IStarkPerpetual starkPerpetual,
IERC20 token,
IMerkleDistributorV1 merkleDistributor
)
SP1Guardian(liquidityStaking, starkPerpetual, token)
SP1Withdrawals(merkleDistributor)
{}
// ============ External Functions ============
function initialize(address guardian)
external
initializer
{
__SP1Roles_init(guardian);
TOKEN.safeApprove(address(LIQUIDITY_STAKING), uint256(-1));
TOKEN.safeApprove(address(STARK_PERPETUAL), uint256(-1));
}
// ============ Internal Functions ============
/**
* @dev Returns the revision of the implementation contract.
*
* @return The revision number.
*/
function getRevision()
internal
pure
override
returns (uint256)
{
return 1;
}
}