Перейти к содержанию

Rate Info Service

Обзор

Сервис отвечает за следующие функции:

  • Маппинг информации о валютах с данными провайдера;
  • Получение информации о текущем курсе всех известных валют;
  • Сохранение курсов валют в постоянное хранилище;
  • Генерацию JSON кэшей из данных из хранилища исторических курсов.

Основные понятия и термины

Маппинг

В рамках сервиса требуется соотнесение информации об активах (ассетах) в сервисе Asset info с внутренними идентификаторами валют провайдеров. Сервис поддерживает следующие виды ассетов:

  • Коины (Coin) - основные криптовалюты блокчейнов, поддерживаемых сервисом;
  • Токены ERC-20 (Erc20Token) - криптовалюты на основе Ethereum и Ethereum-подобных блокчейнов, определяемые адресом контракта.
  • Ассеты Stellar (StellarAsset) - криптовалюты на основе блокчейна Stellar, определяемые адресом эмитента данного актива и кодом актива.

Курс валюты

Цена единицы криптовалюты, выраженная в денежной единице фиатной валюты.

Кэширование курсов

Конечный пользователь (клиент) получает данные с сервиса о курсах валют в виде статических JSON файлов.

Пример структуры исторических курсов

rate-history-day-btc.json
[
    {
        "date": 1680159600,
        "rates": {
            "usd": "28650.00000000",
            "aed": "105217.00000000",
            "ars": "5967523.00000000",
            "aud": "42747.00000000",
            "bdt": "3060738.00000000",
            "bhd": "10802.40000000",
            "bmd": "28650.00000000",
            "brl": "147124.00000000",
            "cad": "38817.00000000",
            "chf": "26289.00000000",
            "clp": "22694370.00000000",
            "cny": "197122.00000000",
            "czk": "622909.00000000",
            "dkk": "196912.00000000",
            "eur": "26434.00000000",
            "gbp": "23252.00000000",
            "hkd": "224900.00000000",
            "huf": "10061079.00000000",
            "idr": "431249469.00000000",
            "ils": "102312.00000000",
            "inr": "2354806.00000000",
            "jpy": "3797436.00000000",
            "krw": "37223653.00000000",
            "kwd": "8784.08000000",
            "lkr": "9305105.00000000",
            "mmk": "60151241.00000000",
            "mxn": "518312.00000000",
            "myr": "126662.00000000",
            "ngn": "13188245.00000000",
            "nok": "299033.00000000",
            "nzd": "45977.00000000",
            "php": "1558211.00000000",
            "pkr": "8120030.00000000",
            "pln": "123909.00000000",
            "rub": "2210661.00000000",
            "sar": "107586.00000000",
            "sek": "298429.00000000",
            "sgd": "38078.00000000",
            "thb": "980409.00000000",
            "try": "548691.00000000",
            "twd": "873529.00000000",
            "uah": "1057844.00000000",
            "vef": "2868.74000000",
            "vnd": "672539157.00000000",
            "zar": "519406.00000000",
            "xdr": "21351.00000000"
        }
    },
    {
        "date": 1680161400,
        "rates": {
            "usd": "28630.00000000",
            "aed": "105148.00000000",
            "ars": "5963420.00000000",
            "aud": "42666.00000000",
            "bdt": "3058620.00000000",
            "bhd": "10795.93000000",
            "bmd": "28630.00000000",
            "brl": "147043.00000000",
            "cad": "38778.00000000",
            "chf": "26262.00000000",
            "clp": "22678665.00000000",
            "cny": "196814.00000000",
            "czk": "621722.00000000",
            "dkk": "196711.00000000",
            "eur": "26411.00000000",
            "gbp": "23206.00000000",
            "hkd": "224747.00000000",
            "huf": "10044430.00000000",
            "idr": "430789284.00000000",
            "ils": "102440.00000000",
            "inr": "2352698.00000000",
            "jpy": "3787459.00000000",
            "krw": "37149887.00000000",
            "kwd": "8781.41000000",
            "lkr": "9298666.00000000",
            "mmk": "60109616.00000000",
            "mxn": "517435.00000000",
            "myr": "126489.00000000",
            "ngn": "13179118.00000000",
            "nok": "298552.00000000",
            "nzd": "45853.00000000",
            "php": "1557047.00000000",
            "pkr": "8114411.00000000",
            "pln": "123841.00000000",
            "rub": "2207686.00000000",
            "sar": "107489.00000000",
            "sek": "298507.00000000",
            "sgd": "38023.00000000",
            "thb": "981047.00000000",
            "try": "548532.00000000",
            "twd": "871980.00000000",
            "uah": "1057112.00000000",
            "vef": "2866.76000000",
            "vnd": "672073762.00000000",
            "zar": "518255.00000000",
            "xdr": "21336.00000000"
        }
    },
    ...
]

Пример структуры последних курсов Coin

rates-coin.json
{
    "eth": {
        "usd": "1902.85000000",
        "aed": "6987.84000000",
        "ars": "428478.00000000",
        "aud": "2855.48000000",
        "bdt": "201883.00000000",
        "bhd": "717.34000000",
        "bmd": "1902.85000000",
        "brl": "9502.65000000",
        "cad": "2590.84000000",
        "chf": "1688.65000000",
        "clp": "1528420.00000000",
        "cny": "13162.98000000",
        "czk": "40477.00000000",
        "dkk": "12836.46000000",
        "eur": "1722.71000000",
        "gbp": "1514.30000000",
        "hkd": "14933.50000000",
        "huf": "643413.00000000",
        "idr": "28023705.00000000",
        "ils": "6932.26000000",
        "inr": "155668.00000000",
        "jpy": "256187.00000000",
        "krw": "2518514.00000000",
        "kwd": "582.85000000",
        "lkr": "608351.00000000",
        "mmk": "3995043.00000000",
        "mxn": "34145.00000000",
        "myr": "8473.40000000",
        "ngn": "872574.00000000",
        "nok": "20396.00000000",
        "nzd": "3051.89000000",
        "php": "105472.00000000",
        "pkr": "537616.00000000",
        "pln": "7900.71000000",
        "rub": "149585.00000000",
        "sar": "7136.21000000",
        "sek": "19533.20000000",
        "sgd": "2528.22000000",
        "thb": "64412.00000000",
        "try": "37076.00000000",
        "twd": "58394.00000000",
        "uah": "70009.00000000",
        "vef": "190.53000000",
        "vnd": "44617128.00000000",
        "zar": "34803.00000000",
        "xdr": "1409.64000000"
    },
    "btc": {
        "usd": "29088.00000000",
        "aed": "106821.00000000",
        "ars": "6549990.00000000",
        "aud": "43651.00000000",
        "bdt": "3086118.00000000",
        "bhd": "10965.76000000",
        "bmd": "29088.00000000",
        "brl": "145264.00000000",
        "cad": "39605.00000000",
        "chf": "25814.00000000",
        "clp": "23364391.00000000",
        "cny": "201218.00000000",
        "czk": "618764.00000000",
        "dkk": "196226.00000000",
        "eur": "26334.00000000",
        "gbp": "23149.00000000",
        "hkd": "228283.00000000",
        "huf": "9835617.00000000",
        "idr": "428387997.00000000",
        "ils": "105971.00000000",
        "inr": "2379633.00000000",
        "jpy": "3916231.00000000",
        "krw": "38499595.00000000",
        "kwd": "8909.80000000",
        "lkr": "9299631.00000000",
        "mmk": "61070747.00000000",
        "mxn": "521961.00000000",
        "myr": "129530.00000000",
        "ngn": "13338718.00000000",
        "nok": "311792.00000000",
        "nzd": "46653.00000000",
        "php": "1612315.00000000",
        "pkr": "8218334.00000000",
        "pln": "120775.00000000",
        "rub": "2286653.00000000",
        "sar": "109089.00000000",
        "sek": "298597.00000000",
        "sgd": "38648.00000000",
        "thb": "984635.00000000",
        "try": "566768.00000000",
        "twd": "892644.00000000",
        "uah": "1070200.00000000",
        "vef": "2912.60000000",
        "vnd": "682045501.00000000",
        "zar": "532022.00000000",
        "xdr": "21549.00000000"
    },
    ...
}

Пример структуры последних курсов ERC20 Token

rates-erc20.json
{
    "eth-0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9": {
        "usd": "71.53000000",
        "aed": "262.67000000",
        "ars": "16106.59000000",
        "aud": "107.34000000",
        "bdt": "7588.84000000",
        "bhd": "26.97000000",
        "bmd": "71.53000000",
        "brl": "357.21000000",
        "cad": "97.39000000",
        "chf": "63.48000000",
        "clp": "57454.00000000",
        "cny": "494.80000000",
        "czk": "1521.56000000",
        "dkk": "482.53000000",
        "eur": "64.76000000",
        "gbp": "56.92000000",
        "hkd": "561.35000000",
        "huf": "24186.00000000",
        "idr": "1053417.00000000",
        "ils": "260.59000000",
        "inr": "5851.58000000",
        "jpy": "9630.11000000",
        "krw": "94671.00000000",
        "kwd": "21.91000000",
        "lkr": "22868.00000000",
        "mmk": "150175.00000000",
        "mxn": "1283.52000000",
        "myr": "318.52000000",
        "ngn": "32800.00000000",
        "nok": "766.70000000",
        "nzd": "114.72000000",
        "php": "3964.72000000",
        "pkr": "20209.00000000",
        "pln": "296.99000000",
        "rub": "5622.94000000",
        "sar": "268.25000000",
        "sek": "734.26000000",
        "sgd": "95.04000000",
        "thb": "2421.24000000",
        "try": "1393.70000000",
        "twd": "2195.03000000",
        "uah": "2631.65000000",
        "vef": "7.16000000",
        "vnd": "1677167.00000000",
        "zar": "1308.25000000",
        "xdr": "52.99000000"
    },
    "avax-0xd6070ae98b8069de6b494332d1a1a81b6179d960": {
        "usd": "450.82000000",
        "aed": "1655.56000000",
        "ars": "101515.00000000",
        "aud": "676.52000000",
        "bdt": "47830.00000000",
        "bhd": "169.95000000",
        "bmd": "450.82000000",
        "brl": "2251.37000000",
        "cad": "613.82000000",
        "chf": "400.08000000",
        "clp": "362113.00000000",
        "cny": "3118.57000000",
        "czk": "9589.92000000",
        "dkk": "3041.21000000",
        "eur": "408.14000000",
        "gbp": "358.77000000",
        "hkd": "3538.04000000",
        "huf": "152437.00000000",
        "idr": "6639371.00000000",
        "ils": "1642.39000000",
        "inr": "36881.00000000",
        "jpy": "60696.00000000",
        "krw": "596686.00000000",
        "kwd": "138.09000000",
        "lkr": "144130.00000000",
        "mmk": "946505.00000000",
        "mxn": "8089.62000000",
        "myr": "2007.52000000",
        "ngn": "206730.00000000",
        "nok": "4832.30000000",
        "nzd": "723.05000000",
        "php": "24988.00000000",
        "pkr": "127372.00000000",
        "pln": "1871.84000000",
        "rub": "35440.00000000",
        "sar": "1690.71000000",
        "sek": "4627.80000000",
        "sgd": "598.99000000",
        "thb": "15260.37000000",
        "try": "8784.05000000",
        "twd": "13834.64000000",
        "uah": "16586.50000000",
        "vef": "45.14000000",
        "vnd": "10570682.00000000",
        "zar": "8245.54000000",
        "xdr": "333.97000000"
    },
    ...
}

Подробное описание кэшей курсов см. Раздел JSON кэши.