Repository
https://github.com/holgern/steemengine
steemengine
steemengine is a python library for working with steem-engine.com tokens.
I released version 0.4.1 which can be installed by
pip install steemengine
New features
The token precision is taken into account for transfer, issue, buy, sell, withdraw and deposit
I added a new quantize
function to the Token class.
def quantize(self, amount):
"""Round down a amount using the token precision and returns a Decimal object"""
amount = decimal.Decimal(amount)
places = decimal.Decimal(10) ** (-self["precision"])
return amount.quantize(places, rounding=decimal.ROUND_DOWN)
This function returns a rounded Decimal object, which takes the token precision into account. The amount is rounded down to a valid amount.
from steemengine.tokenobject import Token
steemp = Token("STEEMP")
steemp.quantize(1.0001)
Decimal('1.000')
steemp.quantize(0.999999)
Decimal('0.999')
steemp.quantize(0.0001)
Decimal('0.000')
This function is then used in transfer, issue, buy, sell, withdraw and deposit:
token = Token(symbol)
quant_amount = token.quantize(amount)
if quant_amount <= decimal.Decimal("0"):
raise InvalidTokenAmount("Amount to transfer is below token precision of %d" % token["precision"])
If the quantized amount is zero, an InvalidTokenAmount exception is raised.
New commands for the CLI
The acting account, which needs an active key stored in the beem wallet, is either the default beempy account or set by -a
, e.g. steemengine transfer -a holger80 beembot 0.001 DRAGON test
.
The default account can be set by beempy set default_account holger80
and checked by beempy config
.
steemengine transfer
This command can be used to sent token to other steem accounts.
steemengine transfer -a holger80 beembot 0.001 DRAGON test
Password to unlock wallet:
Wallet Unlocked!
{
"expiration": "2019-03-20T10:12:49",
"ref_block_num": 55237,
"ref_block_prefix": 1423306811,
"operations": [
[
"custom_json",
{
"required_auths": [
"holger80"
],
"required_posting_auths": [],
"id": "ssc-mainnet1",
"json": "{\"contractName\":\"tokens\",\"contractAction\":\"transfer\",\"contractPayload\":{\"symbol\":\"DRAGON\",\"to\":\"beembot\",\"quantity\":\"0.0010000\",\"memo\":\"test\"}}"
}
]
],
"extensions": [],
"signatures": [
"206b0d9b6d0939108c2156cefbafa99bccb5bb206c2ca129ebb2cf336112abbaab0ff1151917bec552357d400b6d72b98425f2052735c723522a9537589046b1e7"
]
}
steemengine issue
Issues new token, only possible when the active account is also the issuer of the token.
steemengine deposit
This command can be used to deposit STEEM and receive STEEMP for buying token.
The following command transfers 0.1 STEEM to steem-peg and 0.1 STEEMP are transferred to the account in return.
steemengine deposit -a holger80 0.1
steemengine withdraw
This command can be used to withdraw STEEMP and receive STEEM.
steemengine withdraw -a holger80 0.1
steemengine buy
This command can be used to place buy orders.
steemengine buy -a holger80 1 JAR 0.9
This places a buy order, for buying 1 JAR for 0.9 STEEMP. The accounts must have 0.9 STEEMP, otherwise a InsufficientTokenAmount exception will be raised. The 0.9 STEEMP are locked until the order is fullfilled or canceled.
steemengine sell
This command can be used to place a sell order.
steemengine sell -a holger80 1 JAR 3
In this examle, holger80 creates a sell order for selling 1 JAR for 3 STEEMP. The accounts needs 1 JAR to broadcast this, otherwise a InsufficientTokenAmount exception is raised. The 1 JAR is locked until the order is fullfilled or canceled.
steemengine cancel
In order to cancel, the order id must be know. It can be checked with the buybook command.
steemengine buybook -a holger80 JAR
The buy order can then be canceled by:
steemengine cancel -a holger80 buy 1824
A sell order is canceled by
steemengine cancel -a holger80 sell 923
steemengine buybook
steemengine buybook -a holger80 JAR
returns the buybook for account holger80 and token JAR.
steemengine buybook JAR
returns the complete buy book.
steemengine sellbook
steemengine sellbook -a holger80 JAR
returns the sellbook for account holger80 and token JAR.
steemengine sellbook JAR
returns the complete sell book.
Commits
Fix cancel order id (cast to int)
Add changelog
Add transfer, issue, withdraw, deposit, buy, sell, cancel, buybook, sellbook to CLI
Add amount quantization to deposit, withdraw, buy and sell
Add token amount quantize and add issue to wallet
- commit c0b7e8d
- quantize added to Token class
- TokenDoesNotExists is raised in the Token class when token does not exists
- Exception InvalidTokenAmount is raised when amount to transfer or to issue is below precision
- new issue function added to wallet
- token precision is taken into account for transfer and issue
- TokenIssueNotPermitted is raised when an account which is not the token issuer tries to issue
Cool update. I always like seeing others using Click, as it was my first introduction to creating CLIs and I think it's a great package.
I don't really have much to say about the code as everything looks great, but here goes:
if not bool(memo):
does this needbool()
?Was also wondering if you have a roadmap for this project?
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Chat with us on Discord.
[utopian-moderator]
Thank you for your review, @amosbastian! Keep up the good work!
Any changes that have been requested for the interface. If i'm not mistaken that's where most of the requests are.
Hi @holger80!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
@tipu send 50 tokens ;)
Success! 50.0 @tipU tokens worth of 50.0 STEEM POWER have just been sent to @holger80.
@holger80 - you can check out your new investment at: https://tipu.online.
Please validate the transfer at steem-engine wallet.
Hi, @holger80!
You just got a 2.72% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.
Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!
Hey, @holger80!
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Congratulations @holger80!
Your post was mentioned in the Steem Hit Parade in the following category:
This post has been included in the latest edition of SoS Daily News - a digest of all the latest news on the Steem blockchain.