I can have only a fraction of shares in a validator. But I can not stake fractions of atoms.
If I POST /stake/delegators/cosmosaccaddr1xlkl78w5cs5rd0tqxjla2pqqd82v57yj70r0d3/delegations the body:
{"delegations":[{"delegator_addr":"cosmosaccaddr1xlkl78w5cs5rd0tqxjla2pqqd82v57yj70r0d3","validator_addr":"cosmosaccaddr126ayk3hse5zvk9gxfmpsjr9565ef72pv9g20yx","delegation":{"denom":"steak","amount":"0.9999999998"}}],"begin_unbondings":[],"sequence":"6","name":"TEST3","password":"1234567890","account_number":"567","chain_id":"gaia-8001","gas":"50000000"}
The LCD returns the error:
math/big: cannot unmarshal "0.9999999998" into a *big.Int
GET /stake/delegators/cosmosaccaddr1xlkl78w5cs5rd0tqxjla2pqqd82v57yj70r0d3
Try to undelegate the shows shares: POST /stake/delegators/cosmosaccaddr1xlkl78w5cs5rd0tqxjla2pqqd82v57yj70r0d3/delegations
{"delegations":[],"begin_unbondings":[{"delegator_addr":"cosmosaccaddr1xlkl78w5cs5rd0tqxjla2pqqd82v57yj70r0d3","validator_addr":"cosmosaccaddr126ayk3hse5zvk9gxfmpsjr9565ef72pv9g20yx","shares":"0.0000000014"}],"sequence":"3","name":"TEST3","password":"1234567890","account_number":"567","chain_id":"gaia-8001","gas":"50000000"}
Error:
Couldn't decode shares amount. Error: Error{1:6,--= Error =--Data: common.FmtError{format:"string has too many decimals", args:[]interface {}(nil)}Msg Traces:--= /Error =--}
It is intended that you are not permitted to stake fractions of any token, all tokens used are intended to represent the smallest denomination of that token (aka the units we should actually be using are the equivalent of "a satoshi")... So this is in fact not a bug but the intended functionality.
There have been some discussions of allowing for multiple units of the same token to be submitted through the API - however this is a post-launch concern.
@faboweb
What happens if my 0.67 shares I unbond are worth 0.85 atoms?
Do I have then 0.85 atoms on my account
That scenario should never come up as validator’s (soon) will be holding whole atoms not fractions of atoms. Even slashing events will only take place on full atoms… I guess there is the situation in which after a slashing event your shares become worth a fraction of an atoms - those atoms should probably just be slashed I guess or just left in the pool for the other delegators maybe… I’ll open an issue for this, interesting edge case. https://github.com/cosmos/cosmos-sdk/issues/2327
BUT either way - this edge case is independent to your issue as 0.67 shares I unbond are worth 0.85 atoms is equivalent to saying 0.67 decimal shares I unbond are worth 85000000 sub-atoms which is actually how the computations will actually be performed
related #2327
thx
are worth 85000000 sub-atoms
Do we have sub-atoms already? Undelegation still returns atoms, am I mistaken?
it's just the name of the denom - but yet we should probably rename the denom in gaia ASAP just to get the testnets looking more like the hub. Everything should be using sub-atoms within the UI we should obviously still just display things as decimal's with atoms however (but the CLI and LCD will use subatoms)
How do you exchange sub-atoms for atoms? Or are there just no atoms anymore?
iirc, atoms are just another way to represent a quantity of whole atoms. e.g. 1000000000 wei == 1 ETH.
@alexanderbez is correct - An atom is just a concept representing 100000000 sub-atoms. Sub-atom is the only unit used in the SDK. To determine the amount of "atoms" you have you just perform a calculation in the UI or on a Napkin in the Joe's Dinner
Most helpful comment
@alexanderbez is correct - An atom is just a concept representing 100000000 sub-atoms. Sub-atom is the only unit used in the SDK. To determine the amount of "atoms" you have you just perform a calculation in the UI or on a Napkin in the Joe's Dinner