Skip to content

Latest commit

 

History

History
346 lines (295 loc) · 9.98 KB

File metadata and controls

346 lines (295 loc) · 9.98 KB

PriceLibV1.sol

View Source: contracts/libraries/PriceLibV1.sol

PriceLibV1

Functions

getPriceOracleInternal

function getPriceOracleInternal(IStore s) public view
returns(contract IPriceOracle)

Arguments

Name Type Description
s IStore
Source Code
function getPriceOracleInternal(IStore s) public view returns (IPriceOracle) {
    return IPriceOracle(s.getNpmPriceOracleInternal());
  }

setNpmPrice

function setNpmPrice(IStore s) internal nonpayable

Arguments

Name Type Description
s IStore
Source Code
function setNpmPrice(IStore s) internal {
    IPriceOracle oracle = getPriceOracleInternal(s);

    if (address(oracle) == address(0)) {
      return;
    }

    oracle.update();
  }

convertNpmLpUnitsToStabelcoinInternal

function convertNpmLpUnitsToStabelcoinInternal(IStore s, uint256 amountIn) external view
returns(uint256)

Arguments

Name Type Description
s IStore
amountIn uint256
Source Code
function convertNpmLpUnitsToStabelcoinInternal(IStore s, uint256 amountIn) external view returns (uint256) {
    return getPriceOracleInternal(s).consultPair(amountIn);
  }

getLastUpdatedOnInternal

function getLastUpdatedOnInternal(IStore s, bytes32 coverKey) external view
returns(uint256)

Arguments

Name Type Description
s IStore
coverKey bytes32
Source Code
function getLastUpdatedOnInternal(IStore s, bytes32 coverKey) external view returns (uint256) {
    bytes32 key = getLastUpdateKeyInternal(coverKey);
    return s.getUintByKey(key);
  }

setLastUpdatedOnInternal

function setLastUpdatedOnInternal(IStore s, bytes32 coverKey) external nonpayable

Arguments

Name Type Description
s IStore
coverKey bytes32
Source Code
function setLastUpdatedOnInternal(IStore s, bytes32 coverKey) external {
    bytes32 key = getLastUpdateKeyInternal(coverKey);
    s.setUintByKey(key, block.timestamp); // solhint-disable-line
  }

getLastUpdateKeyInternal

Hash key of the "last state update" for the given cover. Warning: this function does not validate the cover key supplied.

function getLastUpdateKeyInternal(bytes32 coverKey) public pure
returns(bytes32)

Arguments

Name Type Description
coverKey bytes32 Enter cover key
Source Code
function getLastUpdateKeyInternal(bytes32 coverKey) public pure returns (bytes32) {
    return keccak256(abi.encodePacked(ProtoUtilV1.NS_LAST_LIQUIDITY_STATE_UPDATE, coverKey));
  }

getNpmPriceInternal

function getNpmPriceInternal(IStore s, uint256 amountIn) external view
returns(uint256)

Arguments

Name Type Description
s IStore
amountIn uint256
Source Code
function getNpmPriceInternal(IStore s, uint256 amountIn) external view returns (uint256) {
    return getPriceOracleInternal(s).consult(s.getNpmTokenAddressInternal(), amountIn);
  }

Contracts