kaimen-sano / astroport-dca

GNU General Public License v3.0
3 stars 8 forks source link

DCA Order and Execution #1

Open kailust opened 2 years ago

kailust commented 2 years ago

If you create a DCA order https://github.com/kaimen-sano/astroport-dca/tree/master/contracts/dca#create_dca_order for example "Example: Purchase 5 UST worth of Luna each day, with 15 UST."

How does the contract check the time and execute the order automatically? Don't we need an outside message sent via bot to the smart contract to "check and execute" for example check if its time to to run the DCA function https://github.com/kaimen-sano/astroport-dca/tree/master/contracts/dca#perform_dca_purchase

kaimen-sano commented 2 years ago

cosmwasm implementation allows contracts to access some verified data produced at call-time. For more information, please see here.

In most cosmos-based chains (such as Terra), this is produced by the median block time of the validator set.

kailust commented 2 years ago

I understand the contracts can access verified data produced at call-time.. my question is how does the smart contract automatically perform "call-time" itself without a third party or someone else running a command. Smart contracts are not self running, so does this contract need an outside cron job or bot to send messages to the smart contract for example every minute or every hour and retieve verfied data from such as block height and time, and compare it to user dca order configuration, then run execution. Or does this contract have the ability to self run and do call-time verifications itself?

kaimen-sano commented 2 years ago

It does not. An external user has to call ExecuteMsg::PerformDcaPurchase in order to invoke purchases.

kailust commented 2 years ago

ok thats what I thought, so a bot needs to run, and check for example every hour and check each users configurations with

QueryMsg::UserDcaOrders

then if the users orders are valid based on time and balance, then it needs to execute

ExecuteMsg::PerformDcaPurchase

Is this correct?

kaimen-sano commented 2 years ago

Yep!

kailust commented 2 years ago

Also can you update the https://github.com/kaimen-sano/astroport-dca/tree/master/contracts/dca#create_dca_order to use Luna and another cw20 token because UST is not on Terra 2.0

Thanks

kaimen-sano commented 2 years ago

The underlying process is still the same, so there is no need to update it

kailust commented 2 years ago

https://github.com/kaimen-sano/astroport-dca/tree/master/contracts/dca#instantiatemsg

"contract_ddr should be "contract_addr"

also it missing "whitelisted_fee_assets" attributes