forked from dfinity/exchange-rate-canister
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxrc.did
83 lines (76 loc) · 3.08 KB
/
xrc.did
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
type AssetClass = variant { Cryptocurrency; FiatCurrency; };
type Asset = record {
symbol: text;
class: AssetClass;
};
// The parameters for the `get_exchange_rate` API call.
type GetExchangeRateRequest = record {
base_asset: Asset;
quote_asset: Asset;
// An optional timestamp to get the rate for a specific time period.
timestamp: opt nat64;
};
type ExchangeRateMetadata = record {
decimals: nat32;
base_asset_num_received_rates: nat64;
base_asset_num_queried_sources: nat64;
quote_asset_num_received_rates: nat64;
quote_asset_num_queried_sources: nat64;
standard_deviation: nat64;
forex_timestamp: opt nat64;
};
type ExchangeRate = record {
base_asset: Asset;
quote_asset: Asset;
timestamp: nat64;
rate: nat64;
metadata: ExchangeRateMetadata;
};
type ExchangeRateError = variant {
// Returned when the canister receives a call from the anonymous principal.
AnonymousPrincipalNotAllowed: null;
/// Returned when the canister is in process of retrieving a rate from an exchange.
Pending: null;
// Returned when the base asset rates are not found from the exchanges HTTP outcalls.
CryptoBaseAssetNotFound: null;
// Returned when the quote asset rates are not found from the exchanges HTTP outcalls.
CryptoQuoteAssetNotFound: null;
// Returned when the stablecoin rates are not found from the exchanges HTTP outcalls needed for computing a crypto/fiat pair.
StablecoinRateNotFound: null;
// Returned when there are not enough stablecoin rates to determine the forex/USDT rate.
StablecoinRateTooFewRates: null;
// Returned when the stablecoin rate is zero.
StablecoinRateZeroRate: null;
// Returned when a rate for the provided forex asset could not be found at the provided timestamp.
ForexInvalidTimestamp: null;
// Returned when the forex base asset is found.
ForexBaseAssetNotFound: null;
// Returned when the forex quote asset is found.
ForexQuoteAssetNotFound: null;
// Returned when neither forex asset is found.
ForexAssetsNotFound: null;
// Returned when the caller is not the CMC and there are too many active requests.
RateLimited: null;
// Returned when the caller does not send enough cycles to make a request.
NotEnoughCycles: null;
// Returned when the canister fails to accept enough cycles.
FailedToAcceptCycles: null;
/// Returned if too many collected rates deviate substantially.
InconsistentRatesReceived: null;
// Until candid bug is fixed, new errors after launch will be placed here.
Other: record {
// The identifier for the error that occurred.
code: nat32;
// A description of the error that occurred.
description: text;
}
};
type GetExchangeRateResult = variant {
// Successfully retrieved the exchange rate from the cache or API calls.
Ok: ExchangeRate;
// Failed to retrieve the exchange rate due to invalid API calls, invalid timestamp, etc.
Err: ExchangeRateError;
};
service : {
"get_exchange_rate": (GetExchangeRateRequest) -> (GetExchangeRateResult);
}