Class: Pricer

lib/contract_interact/pricer~ Pricer


new Pricer(pricerAddress, chainId)

Parameters:
Name Type Description
pricerAddress string Pricer contract address
chainId string chain ID

Methods


_asyncPay(spenderAddress, senderPassphrase, beneficiaryAddress, transferAmount, commissionBeneficiaryAddress, commissionAmount, currency, intendedPricePoint, gasPrice, options)

Actual Pay - can give rejections of promise
Parameters:
Name Type Description
spenderAddress string address of sender
senderPassphrase string passphrase of sender
beneficiaryAddress string address of beneficiary account
transferAmount BigNumber transfer amount (in wei)
commissionBeneficiaryAddress string address of commision beneficiary account
commissionAmount BigNumber commission amount (in wei)
currency string quote currency
intendedPricePoint BigNumber price point at which the pay is intended (in wei)
gasPrice BigNumber gas price
options object for params like returnType, tag.
Returns:
Type
promise.<result>

acceptedMargins(currency)

Get acceptable margin for the given currency
Parameters:
Name Type Description
currency string quote currency
Returns:
Type
promise.<result>

baseCurrency()

Get base currency of pricer
Returns:
Type
promise.<result>

brandedToken()

Get branded token address of pricer from cache, if not found in cache get from contract
Returns:
Type
promise.<result>

conversionRate()

Get conversion rate of pricer
Returns:
Type
promise.<result>

conversionRateDecimals()

Get conversion rate decimals of pricer
Returns:
Type
promise.<result>

decimals()

Get decimal of pricer
Returns:
Type
promise.<result>

getAcceptedMarginsFromContract(currency)

Get acceptable margin for the given currency from contract
Parameters:
Name Type Description
currency string quote currency
Returns:
Type
promise.<result>

getBalanceOf(owner)

Get balance of the account
Parameters:
Name Type Description
owner string account address
Returns:
10^18
Type
BigNumer

getBrandedTokenAddressFromContract()

Get branded token address of pricer from contract
Returns:
Type
promise.<result>

getConversionRateDecimalsFromContract()

Get conversion rate decimals of pricer from contract
Returns:
Type
promise.<result>

getConversionRateFromContract()

Get conversion rate of pricer from contract
Returns:
Type
promise.<result>

getDecimalsFromContract()

Get decimal of pricer from contract
Returns:
Type
promise.<result>

getEstimatedTotalAmount(transferAmount, commissionAmount, intendedPricePoint)

Get estimated total amount
Parameters:
Name Type Description
transferAmount BigNumber Transfer amount
commissionAmount BigNumber Commission amount
intendedPricePoint BigNumber Intended price point
Returns:
Type
BigNumber

getPriceOraclesFromContract(currency)

Get address of price oracle for the given currency from contract
Parameters:
Name Type Description
currency string quote currency
Returns:
Type
promise.<result>

getPricePoint(currency)

Get current price point from the price oracle for the give currency
Parameters:
Name Type Description
currency string quote currency
Returns:
Type
promise.<result>

getPricePointAndCalculatedAmounts(transferAmount, commissionAmount, currency)

Get current price point and calculated token amounts
Parameters:
Name Type Description
transferAmount BigNumber transfer amount (in wei)
commissionAmount BigNumber commision amount (in wei)
currency string quote currency
Returns:
Type
promise.<result>

getPricePointFromContract(currency)

Get current price point from the price oracle for the give currency from contract
Parameters:
Name Type Description
currency string quote currency
Returns:
Type
promise.<result>

getTxReceipt(transactionHash)

Get transaction receipt from transaction hash
Parameters:
Name Type Description
transactionHash string transaction hash
Returns:
10^18
Type
BigNumer

pay(spenderAddress, senderPassphrase, beneficiaryAddress, transferAmount, commissionBeneficiaryAddress, commissionAmount, currency, intendedPricePoint, gasPrice, options)

Pay
Parameters:
Name Type Description
spenderAddress string address of sender
senderPassphrase string passphrase of sender
beneficiaryAddress string address of beneficiary account
transferAmount BigNumber transfer amount (in wei)
commissionBeneficiaryAddress string address of commision beneficiary account
commissionAmount BigNumber commission amount (in wei)
currency string quote currency
intendedPricePoint BigNumber price point at which the pay is intended (in wei)
gasPrice BigNumber gas price
options object for params like returnType, tag.
Returns:
Type
promise.<result>

priceOracles(currency)

Get address of price oracle for the given currency
Parameters:
Name Type Description
currency string quote currency
Returns:
Type
promise.<result>

setAcceptedMargin(senderAddress, senderPassphrase, currency, acceptedMargin, gasPrice, options)

Set or update the acceptable margin range for a given currency
Parameters:
Name Type Description
senderAddress string address of sender
senderPassphrase string passphrase of sender
currency string quote currency
acceptedMargin BigNumber accepted margin for the given currency (in wei)
gasPrice BigNumber gas price
options object for params like returnType, tag.
Returns:
Type
promise.<result>

setAddressToNameMap()

set address to name map
Returns:
Type
promise.<result>

setPriceOracle(senderAddress, senderPassphrase, currency, address, gasPrice, options)

Set or updates the price oracle address for a given currency
Parameters:
Name Type Description
senderAddress string address of sender
senderPassphrase string passphrase of sender
currency string quote currency
address string address of price pracle
gasPrice BigNumber gas price
options object for params like returnType, tag.
Returns:
Type
promise.<result>

setTokenObj()

set token object
Returns:
Type
promise.<result>

toWei(value)

Convert value in wei
Parameters:
Name Type Description
value BigNumber amount in decimal
Returns:
10^18
Type
BigNumer

unsetPriceOracle(senderAddress, senderPassphrase, currency, gasPrice, options)

Remove the price oracle address for a given currency
Parameters:
Name Type Description
senderAddress string address of sender
senderPassphrase string passphrase of sender
currency string quote currency
gasPrice BigNumber gas price
options object for params like returnType, tag.
Returns:
Type
promise.<result>

validateSetAcceptedMarginParams(senderAddress, currency, acceptedMargin, gasPrice)

Validate set accepted margin params parameters
Parameters:
Name Type Description
senderAddress string address of sender
currency string quote currency
acceptedMargin BigNumber accepted margin for the given currency (in wei)
gasPrice BigNumber gas price
Returns:
Type
result

validateSetPriceOracleParams(senderAddress, currency, address, gasPrice)

Validate set price oracle parameters
Parameters:
Name Type Description
senderAddress string address of sender
currency string quote currency
address string address of price pracle
gasPrice BigNumber gas price
Returns:
Type
result

validateUnsetPriceOracleParams(senderAddress, currency, gasPrice)

Validate unset price oracle parameters
Parameters:
Name Type Description
senderAddress string address of sender
currency string quote currency
gasPrice BigNumber gas price
Returns:
Type
promise.<result>

verifyReceiptAndUpdateAcceptedMarginCache(acceptedMargin, currency, receipt)

Verify receipt and update accepted margin in cache
Parameters:
Name Type Description
acceptedMargin BigNumber accepted margin for the given currency (in wei)
currency string quote currency
receipt Object transaction receipt
Returns:
Type
promise.<result>