added harb growth limit of 15
This commit is contained in:
parent
c5f9836d4c
commit
2b3b981bfa
2 changed files with 51 additions and 2 deletions
|
|
@ -50,6 +50,10 @@ contract BaseLineLP {
|
|||
uint256 feeGrowthInside1LastX128;
|
||||
}
|
||||
|
||||
// for minting limits
|
||||
uint256 private lastDay;
|
||||
uint256 private mintedToday;
|
||||
|
||||
mapping(Stage => TokenPosition) positions;
|
||||
|
||||
modifier checkDeadline(uint256 deadline) {
|
||||
|
|
@ -152,6 +156,10 @@ contract BaseLineLP {
|
|||
_outstanding = harb.totalSupply() - harb.balanceOf(address(pool)) - harb.balanceOf(address(this));
|
||||
}
|
||||
|
||||
function spendingLimit() public view returns (uint256, uint256) {
|
||||
return (lastDay, mintedToday);
|
||||
}
|
||||
|
||||
function ethIn(Stage s) public view returns (uint256 _ethInPosition) {
|
||||
uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(positions[s].tickLower);
|
||||
uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(positions[s].tickUpper);
|
||||
|
|
@ -212,6 +220,21 @@ contract BaseLineLP {
|
|||
});
|
||||
}
|
||||
|
||||
/// @dev Returns if amount is within daily limit and resets spentToday after one day.
|
||||
/// @param amount Amount to withdraw.
|
||||
/// @return Returns if amount is under daily limit.
|
||||
function availableMint(uint256 amount) internal returns (uint256) {
|
||||
if (block.timestamp > lastDay + 24 hours) {
|
||||
lastDay = block.timestamp;
|
||||
mintedToday = 0;
|
||||
}
|
||||
uint256 mintLimit = harb.totalSupply() * 3 / 20;
|
||||
if (mintedToday + amount > mintLimit) {
|
||||
return mintLimit - mintedToday;
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
function _set(uint160 sqrtPriceX96, int24 currentTick, uint256 ethInNewAnchor) internal {
|
||||
// ### set Anchor position
|
||||
uint128 anchorLiquidity;
|
||||
|
|
@ -281,7 +304,33 @@ contract BaseLineLP {
|
|||
liquidity
|
||||
);
|
||||
}
|
||||
_mint(tickLower, tickUpper, liquidity);
|
||||
// manage minting limits of harb here
|
||||
if (harbInDiscovery <= harb.balanceOf(address(this))) {
|
||||
_mint(tickLower, tickUpper, liquidity);
|
||||
harb.burn(harb.balanceOf(address(this)));
|
||||
} else {
|
||||
uint256 amount = availableMint(harbInDiscovery - harb.balanceOf(address(this)));
|
||||
harb.mint(amount);
|
||||
mintedToday += amount;
|
||||
amount = harb.balanceOf(address(this));
|
||||
if(amount < harbInDiscovery) {
|
||||
// calculate new ticks so that discovery liquidity is still
|
||||
// deeper than anchor, but less wide
|
||||
int24 tickWidth = int24(int256(11000 * amount / harbInDiscovery)) + 301;
|
||||
tickLower = token0isWeth ? currentTick + 301 : currentTick - tickWidth;
|
||||
tickUpper = token0isWeth ? currentTick + tickWidth : currentTick - 301;
|
||||
sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);
|
||||
sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);
|
||||
liquidity = LiquidityAmounts.getLiquidityForAmounts(
|
||||
sqrtPriceX96,
|
||||
sqrtRatioAX96,
|
||||
sqrtRatioBX96,
|
||||
token0isWeth ? 0 : amount,
|
||||
token0isWeth ? amount: 0
|
||||
);
|
||||
}
|
||||
_mint(tickLower, tickUpper, liquidity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue