enforce oracle check
This commit is contained in:
parent
ec71bcd287
commit
0d7a8e4814
2 changed files with 27 additions and 25 deletions
|
|
@ -347,7 +347,7 @@ contract BaseLineLP {
|
|||
}
|
||||
|
||||
|
||||
function _checkPriceStability(int24 currentTick) internal view returns (bool) {
|
||||
function _isPriceStable(int24 currentTick) internal view returns (bool) {
|
||||
uint32 timeInterval = 300; // 5 minutes in seconds
|
||||
uint32[] memory secondsAgo = new uint32[](2);
|
||||
secondsAgo[0] = timeInterval; // 5 minutes ago
|
||||
|
|
@ -366,7 +366,7 @@ contract BaseLineLP {
|
|||
// Fetch the current tick from the Uniswap V3 pool
|
||||
(uint160 sqrtPriceX96, int24 currentTick, , , , , ) = pool.slot0();
|
||||
// check slippage with oracle
|
||||
_checkPriceStability(currentTick);
|
||||
require(_isPriceStable(currentTick), "price deviated from oracle");
|
||||
|
||||
// ## check price moved up
|
||||
{
|
||||
|
|
@ -423,7 +423,7 @@ contract BaseLineLP {
|
|||
// Fetch the current tick from the Uniswap V3 pool
|
||||
(uint160 sqrtPriceX96, int24 currentTick, , , , , ) = pool.slot0();
|
||||
// check slippage with oracle
|
||||
_checkPriceStability(currentTick);
|
||||
require(_isPriceStable(currentTick), "price deviated from oracle");
|
||||
|
||||
// ## check price moved down
|
||||
if (positions[Stage.ANCHOR].liquidity > 0) {
|
||||
|
|
|
|||
|
|
@ -116,31 +116,33 @@ contract Stake is IStake {
|
|||
// TODO: check that position size is multiple of minStake
|
||||
|
||||
uint256 smallestPositionShare = totalSupply;
|
||||
|
||||
// run through all suggested positions to snatch
|
||||
for (uint256 i = 0; i < positionsToSnatch.length - 1; i++) {
|
||||
StakingPosition storage pos = positions[positionsToSnatch[i]];
|
||||
if (pos.creationTime == 0) {
|
||||
//TODO:
|
||||
revert PositionNotFound();
|
||||
}
|
||||
// check that tax lower
|
||||
if (taxRate <= pos.taxRate) {
|
||||
revert TaxTooLow(receiver, taxRate, pos.taxRate, i);
|
||||
}
|
||||
if (pos.share < smallestPositionShare) {
|
||||
smallestPositionShare = pos.share;
|
||||
}
|
||||
// dissolve position
|
||||
// TODO: what if someone calls payTax and exitPosition in the same transaction?
|
||||
_payTax(positionsToSnatch[i], pos, 0);
|
||||
_exitPosition(positionsToSnatch[i], pos);
|
||||
}
|
||||
|
||||
uint256 availableStake = authorizedStake() - outstandingStake;
|
||||
|
||||
// handle last position
|
||||
if (positionsToSnatch.length > 0) {
|
||||
// run through all suggested positions to snatch
|
||||
for (uint256 i = 0; i < positionsToSnatch.length - 1; i++) {
|
||||
StakingPosition storage pos = positions[positionsToSnatch[i]];
|
||||
if (pos.creationTime == 0) {
|
||||
//TODO:
|
||||
revert PositionNotFound();
|
||||
}
|
||||
// check that tax lower
|
||||
if (taxRate <= pos.taxRate) {
|
||||
revert TaxTooLow(receiver, taxRate, pos.taxRate, i);
|
||||
}
|
||||
if (pos.share < smallestPositionShare) {
|
||||
smallestPositionShare = pos.share;
|
||||
}
|
||||
// dissolve position
|
||||
// TODO: what if someone calls payTax and exitPosition in the same transaction?
|
||||
_payTax(positionsToSnatch[i], pos, 0);
|
||||
_exitPosition(positionsToSnatch[i], pos);
|
||||
}
|
||||
|
||||
availableStake = authorizedStake() - outstandingStake;
|
||||
|
||||
// handle last position
|
||||
|
||||
uint256 index = positionsToSnatch.length - 1;
|
||||
StakingPosition storage pos = positions[positionsToSnatch[index]];
|
||||
if (pos.creationTime == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue