Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DCA Order and Execution #1

Open
kailust opened this issue Aug 25, 2022 · 8 comments
Open

DCA Order and Execution #1

kailust opened this issue Aug 25, 2022 · 8 comments

Comments

@kailust
Copy link

kailust commented Aug 25, 2022

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
Copy link
Owner

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
Copy link
Author

kailust commented Aug 26, 2022

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
Copy link
Owner

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

@kailust
Copy link
Author

kailust commented Aug 26, 2022

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
Copy link
Owner

Yep!

@kailust
Copy link
Author

kailust commented Aug 27, 2022

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
Copy link
Owner

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

@kailust
Copy link
Author

kailust commented Aug 27, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants