-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix oiShares calculation on build * Add oi to position info for oiInitial calc, fix multiple build test * Fix gh actions to clear cache and recompile all contracts * Change Position.Info to use oiToSharesRatio for initial oi calc * Update Position.Info for frac remaining, store ticks, mulDiv w oiShares * Fix oiShares calculation on build * Add oi to position info for oiInitial calc, fix multiple build test * Fix gh actions to clear cache and recompile all contracts * Change Position.Info to use oiToSharesRatio for initial oi calc * Update Position.Info for frac remaining, store ticks, mulDiv w oiShares * Fix gh actions * Update README for Position.Info changes * Add balancer github ref for FixedPoint, LogExpMath.sol * Update docs README * Fix pos lib getter tests * Fix TODO in market unwind * Fix pos lib value tests * Fix pos lib trading fee tests * Fix pos lib liquidatable tests * Fix market build tests * Fix market slippage tests * Fix market liquidate tests * Fix market unwind tests: update_pos, removes_oi, multiple_pos * Fix market unwind tests: reg_vol, reg_mint, exec_transfer * Fix remaining market unwind tests * Pay funding when set risk param * Fix market liquidate tests * Fix market interface for positions(), fix comment for midPriceAtEntry * Fix calcOiShares * Add round trip test for fixed cast * Add checks of pos.oiShares vs oiShares to market tests * Make pos.oiShares mutable to fix oiShares rounding issues * Fix README * Remove subfloor for aggregate oi shares on unwind, liquidate * Fix market interface returns
- Loading branch information
Showing
45 changed files
with
3,137 additions
and
1,456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.10; | ||
|
||
library FixedCast { | ||
uint256 internal constant ONE_256 = 1e18; // 18 decimal places | ||
uint256 internal constant ONE_16 = 1e4; // 4 decimal places | ||
|
||
/// @dev casts a uint16 to a FixedPoint uint256 with 18 decimals | ||
function toUint256Fixed(uint16 value) internal pure returns (uint256) { | ||
uint256 multiplier = ONE_256 / ONE_16; | ||
return (uint256(value) * multiplier); | ||
} | ||
|
||
/// @dev casts a FixedPoint uint256 to a uint16 with 4 decimals | ||
function toUint16Fixed(uint256 value) internal pure returns (uint16) { | ||
uint256 divisor = ONE_256 / ONE_16; | ||
uint256 ret256 = value / divisor; | ||
require(ret256 <= type(uint16).max, "OVLV1: FixedCast out of bounds"); | ||
return uint16(ret256); | ||
} | ||
} |
Oops, something went wrong.