ergoplatform / oracle-core

Core off-chain component of Oracle Pools
Apache License 2.0
62 stars 37 forks source link

Top up the reward tokens in the pool box from a buyback box #254

Closed greenhat closed 1 year ago

greenhat commented 1 year ago

See this giveback test https://github.com/kushti/dexy-stable/blob/85457ff543797212633693445c178818adb6f033/src/test/scala/dexy/BuybackSpec.scala#L93 for the example workflow.

More details - https://www.ergoforum.org/t/buying-back-tokens-from-liqudity-pool/4275

buyback contract on testnet has some ERG to test:

This action should be run as part of refresh tx action.

The buyback nft id should be stored in OracleConfig as an optional value - OracleConfig::buyback_nft_token_id.

The commands::refresh command should be altered to gather oracle reward tokens from the dexy buyback box and add them to the pool box only if OracleConfig::buyback_nft_token_id is set. To find the buyback box, a scan should be added as optional to NodeScanRegistry::dexy_buyback_token_scan and to the OraclePool (see pool nft token for example). In the refresh command implementation check if there is a buyback box with oracle reward tokens (second token in box tokens) and then spend it and put an output buyback box preserving everything besides collected oracle reward tokens.

When oracle is launched with run command check if OracleConfig::buyback_nft_token_id is set and if NodeScanRegistry::dexy_buyback_token_scan is None add it and register new scan with the node.