# Saves up to N most recent values from an FTSO oracle with a cooldown between each sample. # # The strat takes 0 input and offers an auction as a bounty, paying more the longer the # strat has been off cooldown for. This mitigates unpredictable gas costs without significantly # overpaying the counterparty for the service of sampling the FTSO. # # The strat intentionally does no trading itself, it merely samples data and stores it under # a predictable set of keys. Other strats can then be written that are read-only over these # keys, keeping the overall system decoupled and easy to manage. As long as the sampler # vault has enough WFLR in it to cover gas, there is an incentive for solvers to keep sampling # indefinitely every time the strat comes off cooldown. tokens: eusdt: network: flare address: 0x96B41289D90444B8adD57e6F265DB5aE8651DF29 decimals: 6 wflr: network: flare address: 0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d decimals: 18 orders: flare: orderbook: flare inputs: # Input is irrelevant because we always set the IO ratio to 0. - token: eusdt outputs: - token: wflr scenarios: flare: runs: 1 bindings: samples-count: 5 cooldown: 120 bounty-min: 0.02 bounty-unit-increase: 0.01 bounty-unit-time: 60 bounty-max: 0.1 # There's not really anything to chart without overcomplicating the # strat itself in ways that would obfuscate the core lesson of the example. charts: flare: deployments: flare: order: flare scenario: flare --- #flare-subparser 0x57c613381deadaE520eC33556C1d51c9Dcb0adb3 #raindex-subparser 0x77991674ca8887D4ee1b583DB7324B41d5f894c4 #samples-count !Number of samples to collect from the FTSO. #cooldown !Minimum time in seconds that must elapse between samples. #bounty-min !Minimum bounty to offer for each sample in WFLR. #bounty-unit-increase !Amount to increase bounty per unit time. #bounty-unit-time !Unit of time to increase the bounty. #bounty-max !Maximum bounty that can be offered. Will ALWAYS be offered on first sample. #calculate-io using-words-from flare-subparser raindex-subparser ftso-price: ftso-current-price-usd("FLR" 3600), /* store the sample under a rotating index */ index-key: order-hash(), index: mod(add(get(index-key) 1) samples-count), :set(index-key index), :set(hash(index-key index) ftso-price), /* ensure a cooldown */ last-update-time-key: hash(order-hash() "last-update-time"), time-since-cooldown: saturating-sub(block-timestamp() add(get(last-update-time-key) cooldown)), :ensure(time-since-cooldown "Cooling down."), :set(last-update-time-key block-timestamp()), /* linear auction for the bounty to mitigate unpredictable gas spikes */ bounty: min( linear-growth( bounty-min div(bounty-unit-increase bounty-unit-time) time-since-cooldown) bounty-max ), /* 0 io ratio means no input required from the counterparty for them to receive the bounty */ io-ratio: 0; #handle-io :;