-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathHyperdriveTarget3.sol
More file actions
105 lines (98 loc) · 4.34 KB
/
HyperdriveTarget3.sol
File metadata and controls
105 lines (98 loc) · 4.34 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.24;
import { IHyperdrive } from "../interfaces/IHyperdrive.sol";
import { IHyperdriveAdminController } from "../interfaces/IHyperdriveAdminController.sol";
import { HyperdriveAdmin } from "../internal/HyperdriveAdmin.sol";
import { HyperdriveCheckpoint } from "../internal/HyperdriveCheckpoint.sol";
import { HyperdriveLong } from "../internal/HyperdriveLong.sol";
import { HyperdriveLP } from "../internal/HyperdriveLP.sol";
import { HyperdriveMultiToken } from "../internal/HyperdriveMultiToken.sol";
import { HyperdrivePair } from "../internal/HyperdrivePair.sol";
import { HyperdriveShort } from "../internal/HyperdriveShort.sol";
import { HyperdriveStorage } from "../internal/HyperdriveStorage.sol";
/// @author DELV
/// @title HyperdriveTarget3
/// @notice Hyperdrive's target 3 logic contract.
/// @custom:disclaimer The language used in this code is for coding convenience
/// only, and is not intended to, and does not, have any
/// particular legal or regulatory significance.
abstract contract HyperdriveTarget3 is
HyperdriveAdmin,
HyperdriveMultiToken,
HyperdriveLP,
HyperdriveLong,
HyperdriveShort,
HyperdrivePair,
HyperdriveCheckpoint
{
/// @notice Instantiates target3.
/// @param _config The configuration of the Hyperdrive pool.
/// @param __adminController The admin controller that will specify the
/// admin parameters for this contract.
constructor(
IHyperdrive.PoolConfig memory _config,
IHyperdriveAdminController __adminController
) HyperdriveStorage(_config, __adminController) {}
/// LPs ///
/// @notice Allows the first LP to initialize the market with a target APR.
/// @param _contribution The amount of capital to supply. The units of this
/// quantity are either base or vault shares, depending on the value
/// of `_options.asBase`.
/// @param _apr The target APR.
/// @param _options The options that configure how the operation is settled.
/// @return The initial number of LP shares created.
function initialize(
uint256 _contribution,
uint256 _apr,
IHyperdrive.Options calldata _options
) external payable returns (uint256) {
return _initialize(_contribution, _apr, _options);
}
/// @notice Allows LPs to supply liquidity for LP shares.
/// @param _contribution The amount of capital to supply. The units of this
/// quantity are either base or vault shares, depending on the value
/// of `_options.asBase`.
/// @param _minLpSharePrice The minimum LP share price the LP is willing
/// to accept for their shares. LPs incur negative slippage when
/// adding liquidity if there is a net curve position in the market,
/// so this allows LPs to protect themselves from high levels of
/// slippage. The units of this quantity are either base or vault
/// shares, depending on the value of `_options.asBase`.
/// @param _minApr The minimum APR at which the LP is willing to supply.
/// @param _maxApr The maximum APR at which the LP is willing to supply.
/// @param _options The options that configure how the operation is settled.
/// @return The number of LP tokens created.
function addLiquidity(
uint256 _contribution,
uint256 _minLpSharePrice,
uint256 _minApr,
uint256 _maxApr,
IHyperdrive.Options calldata _options
) external payable returns (uint256) {
return
_addLiquidity(
_contribution,
_minLpSharePrice,
_minApr,
_maxApr,
_options
);
}
/// MultiToken ///
/// @dev Safely transfers tokens, checking if recipient is a contract and
/// can handle ERC1155 tokens.
/// @param _from The source address.
/// @param _to The destination address.
/// @param _id The token identifier.
/// @param _amount The amount to transfer.
/// @param _data Additional data to pass to recipient if it's a contract.
function safeTransferFrom(
address _from,
address _to,
uint256 _id,
uint256 _amount,
bytes calldata _data
) external {
_safeTransferFrom(_from, _to, _id, _amount, _data);
}
}