Skip to content

Latest commit

 

History

History
340 lines (291 loc) · 9.71 KB

File metadata and controls

340 lines (291 loc) · 9.71 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.getNpmPriceOracle());
  }

setNpmPrice

function setNpmPrice(IStore s) internal nonpayable

Arguments

Name Type Description
s IStore
Source Code
function setNpmPrice(IStore s) internal {
    getPriceOracleInternal(s).update();
  }

convertNpmLpUnitsToStabelcoin

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

Arguments

Name Type Description
s IStore
amountIn uint256
Source Code
function convertNpmLpUnitsToStabelcoin(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 = getLastUpdateKey(coverKey);
    return s.getUintByKey(key);
  }

setLastUpdatedOn

function setLastUpdatedOn(IStore s, bytes32 coverKey) external nonpayable

Arguments

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

getLastUpdateKey

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

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

Arguments

Name Type Description
coverKey bytes32 Enter cover key
Source Code
function getLastUpdateKey(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.getNpmTokenAddress(), amountIn);
  }

Contracts