Archon Proposal: Sell Extra Tokens (first code snippit!)

in #archon3 years ago (edited)
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)


##sell_token("LEO", 70.3, 1.999, "archon-gov")
time.sleep(30)
sell_token("SIM", 1250, 0.00495, "archon-gov")
time.sleep(30)
sell_token("GAMER", 204353, 0.000128, "archon-gov")

!end


So what's that little jumble of mess up there you say?? Doesn't seem like much of a big deal right? Well, that's the actual code that will be run if the proposal is passed! If the pass conditions are met, the proposal layer will load that code, use some of its own local variables (like "loaded_post" and gov account keys), and then run it.

So what exactly is that little "code snippit" going to do?

First, it defines a function, within that function, it loads the Hive-Engine market, and posts a sell order based on the inputted variables. The details of that sell order are then placed in the local variable "market_trans", and finally the governance account is called to reply to this post with the details of the transaction.

OK, what about the bit under that?

Under the function, we can then call it, and set the variables needed for each call. For the first one we are calling a sell function, we set the symbol to "LEO", set 70.3 as the amount to sell, 1.99 HIVE was set as the price, and lastly we provided the "archon-gov" account as the source of the sales.

Between each call, we added a 30-second sleep, to account for transaction and reply limits.

We could have made a more complicated function to example what we are working on, but for the first go I figured it would be best to keep it simple.

Fantastic, where are your examples and definitions, and how do I put this to use?



Well, I haven't gotten that far yet. ATM it's using a wide open python 3, hopefully before New Years, we can call it a full launch, with definitions, and many layers of safety nets.

I also need to setup read access to the Archon governance DB, allowing these functions to call on the DB for user info like Governance Power.


In summary, vote "Yes" to move forward with code snippet testing, and use this code snippet to sell off some of our unused tokens for SWAP.HIVE. We can decide what to do with that SWAP.HIVE later.

Sort:  

This is amazing that you have this type of thing automated. to trigger off of a succesful vote!

Super exciting!

{'expiration': '2021-01-04T03:22:09', 'ref_block_num': 64516, 'ref_block_prefix': 3696381307, 'operations': [['custom_json', {'required_auths': ['archon-gov'], 'required_posting_auths': [], 'id': 'ssc-mainnet-hive', 'json': '{"contractName":"market","contractAction":"sell","contractPayload":{"symbol":"SIM","quantity":"1250.000","price":"0.00495"}}'}]], 'extensions': [], 'signatures': ['1f676a3a9c937dc712ceb4f1ac207addfcaae26b1b452ec71d6dc68c394e0b1c752dbf33d86f8864fb52be7a641caa96068945dcb6556b1771adcc55e438dc3d7e'], 'trx_id': '33f0b7cf80fd16c4ecf1d95de4ba4f068dc77899'}

YES!

{'expiration': '2021-01-04T03:22:42', 'ref_block_num': 64530, 'ref_block_prefix': 612393590, 'operations': [['custom_json', {'required_auths': ['archon-gov'], 'required_posting_auths': [], 'id': 'ssc-mainnet-hive', 'json': '{"contractName":"market","contractAction":"sell","contractPayload":{"symbol":"GAMER","quantity":"204353.0000","price":"0.000128"}}'}]], 'extensions': [], 'signatures': ['203305ec01e7c6f426a0444bbea9ad0a84bdc3768f346605a082023962cc1497a122319c13c1395518b0a6cd0f0492c1cdc3b80f9059b86b850ff8a1c63e99bf3f'], 'trx_id': '4c7ae300d6e1718402c6fd17ecf84db08ff46c9c'}

NO

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

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

You received more than 15000 upvotes. Your next target is to reach 20000 upvotes.

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:

Offer a gift to your friends for Christmas
HiveFest⁵ feedback and contest results