Rates

The GraphQL queries that can be performed on the Rates ADO.

Response Interface

export interface RatesResponse<T> {
  rates: T;
}

queryPayments

Queries a rates contract for its stored rate info

export async function queryPayments(
  contractAddress: string
): Promise<RateInfo[]> {
  const resp = await query<QueryRatesPayments, QueryRatesPaymentsResponse>(
    QUERY_RATES_PAYMENTS,
    { contractAddress }
  );

  return resp.rates.payments;
}
NameTypeDescription

contractAddress

string

The address of the rates contract to get the rates for.

QueryRatesPayments

export interface QueryRatesPayments extends ContractAddressQuery {}

QueryRatesPaymentsResponse

export type QueryRatesPaymentsResponse = RatesResponse<{
  payments: RateInfo[];
}>;
NameTypeDescription

payments

Vector of RateInfo containing information on the rates applied by the contract.

RateInfo

export interface RateInfo {
  description: string;
  is_additive: boolean;
  rate: Rate;
  receivers: Recipient[];
}
NameTypeDescription

description

string

Description for the rate.

is_additive

boolean

An indicator to whether the rate being taken is tax. If tax, is_additive is true.

rate

The type of rate being taken.

receivers

The addresses to receive the rate specified.

Rate

export interface Rate {
  external: ADORate;
  flat: Coin;
  percent: DecimalRate;
}
export interface ADORate {
  address: string;
  key: string;
}
export interface DecimalRate {
  decimal: number;
}

The Rate can be one of the three option seen above:

  • Flat: A fixed amount to be taken (Coin).

  • Percent: A percentage based rate.

  • External: This refers to a rate that is saved in a primitive contract.

Last updated