-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathBoundedVRGDA.sol
More file actions
47 lines (38 loc) · 2 KB
/
BoundedVRGDA.sol
File metadata and controls
47 lines (38 loc) · 2 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
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import {wadExp, wadLn, wadMul, unsafeWadMul, toWadUnsafe} from "solmate/utils/SignedWadMath.sol";
import {VRGDA} from "./VRGDA.sol";
/// @title Bounded Variable Rate Gradual Dutch Auction
/// @author transmissions11 <t11s@paradigm.xyz>
/// @author FrankieIsLost <frankie@paradigm.xyz>
/// @notice Sell tokens roughly according to an issuance schedule.
abstract contract BoundedVRGDA is VRGDA {
/*//////////////////////////////////////////////////////////////
VRGDA PARAMETERS
//////////////////////////////////////////////////////////////*/
/// @dev The minimum sale price of a token.
/// @dev Represented as an 18 decimal fixed point number.
uint256 public immutable min;
/// @notice Sets pricing parameters for the VRGDA.
/// @param _targetPrice The target price for a token if sold on pace, scaled by 1e18.
/// @param _priceDecayPercent The percent price decays per unit of time with no sales, scaled by 1e18.
/// @param _min minimum price to be paid for a token, scaled by 1e18
constructor(
int256 _targetPrice,
int256 _priceDecayPercent,
uint256 _min
) VRGDA(_targetPrice, _priceDecayPercent) {
min = _min;
}
/*//////////////////////////////////////////////////////////////
PRICING LOGIC
//////////////////////////////////////////////////////////////*/
/// @notice Calculate the price of a token according to the VRGDA formula, bounded by min value.
/// @param timeSinceStart Time passed since the VRGDA began, scaled by 1e18.
/// @param sold The total number of tokens that have been sold so far.
/// @return The price of a token according to VRGDA, scaled by 1e18.
function getVRGDAPrice(int256 timeSinceStart, uint256 sold) public view virtual override returns (uint256) {
uint256 VRGDAPrice = super.getVRGDAPrice(timeSinceStart, sold);
return VRGDAPrice > min ? VRGDAPrice : min;
}
}