Skip to content

API ReferencePricing and oraclesFunction

calculatePairPrice()

function calculatePairPrice(ctx, inputToken, inputUsdPrice, outputToken, outputUsdPrice): Price;

Computes the price of a pair of tokens prices in relation to each other. This is the same logic that exists in the contract methods to calculate prices.

Parameters

ParameterTypeDescription
ctxSDKContextThe SDK context.
inputTokenTokenThe input Token.
inputUsdPricePythPriceThe input token OraclePrice.
outputTokenTokenThe output Token.
outputUsdPricePythPriceThe output token OraclePrice.

Returns

Price

The computed price.