Archon Proposal - Gov Account Sells, Buys, Stakes, Unstakes, Witness Vote, and automation!

in #archon3 years ago

account = "archon-gov"


nodelist = NodeList()
nodelist.update_nodes()
nodes = nodelist.get_nodes(hive=True)
hive = Hive(node=nodes)


def sell_token(symbol, amount, price, account):
    he_market = Market(blockchain_instance=hive)
    market_trans = he_market.sell(account, amount, symbol, price)
    c = Comment(loaded_post, steem_instance=hive)
    c.reply(str(market_trans), "market_tx", account)


def buy_token(symbol, amount, price, account):
    he_market = Market(blockchain_instance=hive)
    market_trans = he_market.buy(account, amount, symbol, price)
    c = Comment(loaded_post, steem_instance=hive)
    c.reply(str(market_trans), "market_tx", account)


def stake_token(amount, symbol, account):
    he_wallet = Wallet(account, blockchain_instance=hive)
    stake_trans = he_wallet.stake(amount=amount, symbol=symbol, receiver=account)
    time.sleep(1)
    c = Comment(loaded_post, steem_instance=hive)
    c.reply(str(stake_trans), "stake_tx", account)


def unstake_token(amount, symbol, account):
    he_wallet = Wallet(account, blockchain_instance=hive)
    unstake_trans = he_wallet.unstake(amount=amount, symbol=symbol)
    time.sleep(1)
    c = Comment(loaded_post, steem_instance=hive)
    c.reply(str(unstake_trans), "stake_tx", account)


def transfer_hive(to, amount, asset, memo, account):
    hive_account = Account(account, blockchain_instance=hive)
    hive_tx = hive_account.transfer(to, amount, asset, memo, account)
    time.sleep(4)
    c = Comment(loaded_post, steem_instance=hive)
    c.reply(str(hive_tx), "hive_tx", account)


def power_up_hive(to, amount, account):
    hive_account = Account(account, blockchain_instance=hive)    
    hive_power_tx = hive_account.transfer_to_vesting(amount, to, account)
    time.sleep(4)
    c = Comment(loaded_post, steem_instance=hive)
    c.reply(str(hive_power_tx), "hive_tx", account)


def power_down_hive(amount, account):
    hive_account = Account(account, blockchain_instance=hive)
    h_v = hive.token_power_to_vests(amount)
    hive_power_tx = hive_account.withdraw_vesting(h_v, account)
    time.sleep(4)
    c = Comment(loaded_post, steem_instance=hive)
    c.reply(str(hive_power_tx), "hive_tx", account)


def approve_witnesses(witness, account):
    hive_account = Account(account, blockchain_instance=hive)
    witness_tx = hive_account.approvewitness(witness, account)
    time.sleep(4)
    c = Comment(loaded_post, steem_instance=hive)
    c.reply(str(witness_tx), "witness_tx", account)


def remove_witnesses(witness, account):
    hive_account = Account(account, blockchain_instance=hive)
    witness_tx = hive_account.disapprovewitness(witness, account)
    time.sleep(4)
    c = Comment(loaded_post, steem_instance=hive)
    c.reply(str(witness_tx), "witness_tx", account)


sell_token("ARCHON", 250.00, 0.45, account)
time.sleep(30)
sell_token("LEO", 1.00, 3.333, account)
time.sleep(30)
sell_token("SIM", 225.00, 0.00495, account)
time.sleep(30)
buy_token("DHEDGE", 500, 0.285, account)
time.sleep(30)
stake_token(100, "ARCHON", account)
time.sleep(30)
stake_token(606, "NEOXAG", account)
time.sleep(30)
unstake_token(22.222, "PAL", account)
time.sleep(30)
transfer_hive("archon-mining", 5, "HIVE", "mining-bump", account)
time.sleep(30)
power_down_hive(1, account)
time.sleep(30)
power_up_hive("archon-gov", 1, account)
time.sleep(30)
power_up_hive("archon-mining", 0.1, account)
time.sleep(30)
approve_witnesses("blocktrades", account)

!end



Last proposal didn't quite work as expected at first, but a fix was added in and code snippets are ready to continue.



This one has a little more to it code-wise, and a little light on hand-holding through the code... but there are 9 functions that can be copied and pasted into proposals to be run. We can't quite use them all yet for the demo as we don't have any witnesses to unvote yet but we did manage to use most of them.

Code snippets need to be contained within a language box, and at the start of the proposal. !end is used to separate the code snippet from normal text and is also required. Finally, a proposal with a code snippet must include #hive-py along with all the usual proposal requirements (100% beneficiary to @archon-gov, #archon-proposal, #archon-gov).

Proposal for humans



This proposal will:

  • demo code snippits
  • sell some ARCHON, LEO and SIM on the hive engine market
  • place a buy for some DHEDGE at a discount
  • stake some ARCHON and NEOXAG
  • un-stake some PAL
  • transfer 5 HIVE to mining account
  • power down 1 hive
  • power up 1 hive
  • approve blocktrades as a witness

@archon-gov will reply tx info for each transaction to this post if it's passed

Vote yes below to approve this proposal and watch some cool stuff happen! This will also test each function (again in live) for use in later proposals by any user (on multiple tribes)!



Yes and No vote options may take some time to load, @archon-gov will post the comment options to vote soon if they are not already loaded.



Image by @seckorama

Sort:  

Out of curiosity how would you define a HE token transfer (let's say 10 ARCHON) to @myfakeuser?

account = "sports-gov"

nodelist = NodeList()
nodelist.update_nodes()
nodes = nodelist.get_nodes(hive=True)
hive = Hive(node=nodes)


def transfer_token(to, amount, symbol, memo, account):
    he_wallet = Wallet(account, blockchain_instance=hive)
    transfer_tx = he_wallet.transfer(to, amount, symbol, memo)
    time.sleep(1)
    c = Comment(loaded_post, steem_instance=hive)
    c.reply(str(transfer_tx), "stake_tx", account)


transfer_token("myfakeuser", 10, "ARCHON", "this is a memo", account)

!end

I can't believe I forgot to define HE transfers! Thank you for pointing that out!

So now I can propose that you vote on @lootkit.witness with the code snippet to do it automatically if its approved? Very cool!

YES!

I think it's pretty f*&%$@g cool

NO

Upvote here to STOP the proposal, any % upvote will trigger 100% GP support.
All rewards from this comment go to the governance fund

We need to VOTE NO !!!
The leo is set at 3.33333 and LEO hit 3.9 today.
Vote NO and redo the proposal with LEO at a higher price.

Here's the thing, if the price is above that price, it will sell at the buy price... so we will still get 3.9 or whatever the buy is at... if the buy is below that price it will post a sell order instead of filling a buy.

OH!!! that makes sense you have it coded like that.
I didn't see that in the code snippet on the post.

I RETRACT MY FOOLISH REMARK! VOTE YES!

It's the market contract that does it (at least it should), when someone tries to sell below the buy price it should fill in orders as it goes at those prices down to the given price, or until the sent TOKEN for the order runs out.

(Confirmed, I just test sold 0.1 BRO @ 0.1 HIVE, received 0.7 SWAP.HIVE)

YES

https://peakd.com/archon/@archon-gov/re-archon-proposal-gov-account-sells-buys-stakes-unstakes-witness-vote-and-automation-20210107t115004z

You have to upvote that comment to use your governance power to vote YES.
(Sorry that my wording doesn't often translate well)

account = "archon-gov"

nodelist = NodeList()
nodelist.update_nodes()
nodes = nodelist.get_nodes(hive=True)
hive = Hive(node=nodes)

def approve_witnesses(witness, account):
hive_account = Account(account, blockchain_instance=hive)
witness_tx = hive_account.approvewitness(witness, account)
time.sleep(4)
c = Comment(loaded_post, steem_instance=hive)
c.reply(str(witness_tx), "witness_tx", account)

approve_witnesses("lootkit.witness", account)

So the only thing I'm not sure about is how to get all the code into that neat little box?

account = "archon-gov"
nodelist = NodeList()
nodelist.update_nodes()
nodes = nodelist.get_nodes(hive=True)
hive = Hive(node=nodes)


def approve_witnesses(witness, account):
    hive_account = Account(account, blockchain_instance=hive)
    witness_tx = hive_account.approvewitness(witness, account)
    time.sleep(4)
    c = Comment(loaded_post, steem_instance=hive)
    c.reply(str(witness_tx), "witness_tx", account)


approve_witnesses("lootkit.witness", account)

!end

Congratulations @taskmanager! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You made more than 1000 comments. Your next target is to reach 1500 comments.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @hivebuzz:

Feedback from the January 1st Hive Power Up Day

Hi @taskmanager man, sorry to disturb, i sent by mistake a bit more than needed DHEDGE to @discohedge trying to link to discord bot, can you help me recover it or they are burned? Appreciate any answer, thank you!

This is the transaction: https://he.dtools.dev/tx/24c324347080b06679c6faee8b107c1220941b31
I was supposed to send only 0.000001.

Refunded

wow, you are the best, no wonder archon and dhedge are my favourite.

Thank you for your witness vote!
Have a !BEER on me!
To Opt-Out of my witness beer program just comment STOP below


Hey @taskmanager, here is a little bit of BEER from @isnochys for you. Enjoy it!

Learn how to earn FREE BEER each day by staking your BEER.