Skip to content

init - initialize oracle contract

Initializes tables and values for oracle contract to be able to start normal operation.

Technical Behavior

Will initialize oraclestate singleton and feeddata, finalrates and finalaverage tables.

Values for interval, cache_window and ultra_comprehensive_rate_weight provided will be ignored but must be specified in the interface.

final_price_table_size must have 4 elements, each corresponding to a different time unit (seconds, minutes, hours and days).

Action Parameters

intervaluint8_tWill be forced to be 1. This means that rates are expected to be pushed to the oracle once every 1 second
cache_windowuint32_tWill be forced to be 60. This means that for each exchange 60 seconds of rates will be stored in a rotating bucket
final_price_table_sizestd::vector<eosio::asset>Cache size for individual oracle time unit levels (first element is for seconds level, second for minutes, third for hours, fourth for days). Capped at 365 per level
final_moving_average_settingsstd::vector<eosio::asset>List of moving averages to register by default. Refer to addma for details
ultra_comprehensive_rate_weightuint32_tUnused, but must be provided

Required Permissions:

CLI - cleos

cleos push action init '[1, 60, [240, 360, 240, 365], ["1.0000 MINUTES","60.0000 MINUTES","24.0000 HOURS","7.0000 DAYS","14.0000 DAYS"], 1]' -p

JavaScript - eosjs

(async () => {
    const result = await api.transact(
            actions: [
                    account: '',
                    name: 'init',
                    authorization: [
                            actor: '',
                            permission: 'active',
                    data: {
                        interval: 1,
                        cache_window: 60,
                        final_price_table_size: [240, 360, 240, 365],
                        final_moving_average_settings: ['1.0000 MINUTES','60.0000 MINUTES','24.0000 HOURS','7.0000 DAYS','14.0000 DAYS'],
                        ultra_comprehensive_rate_weight: 0
            blocksBehind: 3,
            expireSeconds: 30,