{"action":"created","issue":{"url":"https://api.github.com/repos/OmniLayer/omnicore/issues/195","labels_url":"https://api.github.com/repos/OmniLayer/omnicore/issues/195/labels{/name}","comments_url":"https://api.github.com/repos/OmniLayer/omnicore/issues/195/comments","events_url":"https://api.github.com/repos/OmniLayer/omnicore/issues/195/events","html_url":"https://github.com/OmniLayer/omnicore/pull/195","id":102660989,"number":195,"title":"Refine amount recalculations of traditional DEx via RPC","user":{"login":"dexX7","id":5836089,"avatar_url":"https://avatars.githubusercontent.com/u/5836089?v=3","gravatar_id":"","url":"https://api.github.com/users/dexX7","html_url":"https://github.com/dexX7","followers_url":"https://api.github.com/users/dexX7/followers","following_url":"https://api.github.com/users/dexX7/following{/other_user}","gists_url":"https://api.github.com/users/dexX7/gists{/gist_id}","starred_url":"https://api.github.com/users/dexX7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dexX7/subscriptions","organizations_url":"https://api.github.com/users/dexX7/orgs","repos_url":"https://api.github.com/users/dexX7/repos","events_url":"https://api.github.com/users/dexX7/events{/privacy}","received_events_url":"https://api.github.com/users/dexX7/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/OmniLayer/omnicore/labels/ready%20for%20review","name":"ready for review","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-23T21:01:31Z","updated_at":"2015-08-24T11:16:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/OmniLayer/omnicore/pulls/195","html_url":"https://github.com/OmniLayer/omnicore/pull/195","diff_url":"https://github.com/OmniLayer/omnicore/pull/195.diff","patch_url":"https://github.com/OmniLayer/omnicore/pull/195.patch"},"body":"The original DEx calculations of Master Core 0.0.9 were restored, which seems safer, if we consider all aspects and mirror it to 100 %.\r\n\r\nAs temporary solution the core calculation is exposed, so it can be used in other places. The additional \"divide by zero\" protection was added, because the function is now exposed.\r\n\r\nWhen using `\"omni_gettransaction\"` in combination with a DEx sell offer, which was adjusted, because the seller offered more than available, then the amounts returned via RPC reflect the adjustment properly, and it's no longer one sided, i.e. previously only the amount for sale was adjusted, but not the desired amount. This resolves #188.\r\n\r\nThe use of `{ }` solely serves as hint, to point out that these parts shouldn't be done on the RPC layer.\r\n\r\nMore information is returned for active accept orders on the traditional DEx, when using `\"omni_getactivedexsells\"`. It also replaces the amount recalculations with the original function that is also used for the core logic."},"comment":{"url":"https://api.github.com/repos/OmniLayer/omnicore/issues/comments/134156318","html_url":"https://github.com/OmniLayer/omnicore/pull/195#issuecomment-134156318","issue_url":"https://api.github.com/repos/OmniLayer/omnicore/issues/195","id":134156318,"user":{"login":"dexX7","id":5836089,"avatar_url":"https://avatars.githubusercontent.com/u/5836089?v=3","gravatar_id":"","url":"https://api.github.com/users/dexX7","html_url":"https://github.com/dexX7","followers_url":"https://api.github.com/users/dexX7/followers","following_url":"https://api.github.com/users/dexX7/following{/other_user}","gists_url":"https://api.github.com/users/dexX7/gists{/gist_id}","starred_url":"https://api.github.com/users/dexX7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dexX7/subscriptions","organizations_url":"https://api.github.com/users/dexX7/orgs","repos_url":"https://api.github.com/users/dexX7/repos","events_url":"https://api.github.com/users/dexX7/events{/privacy}","received_events_url":"https://api.github.com/users/dexX7/received_events","type":"User","site_admin":false},"created_at":"2015-08-24T11:16:58Z","updated_at":"2015-08-24T11:16:58Z","body":"Thanks!\r\n\r\n> Here zathras-crypto@81d0db0 is a small patch .. though I'm not sure how to get around that without doing it at the RPC layer instead\r\n\r\nThat's a neat idea! Though I also see the problem. If we think in layers, where parsing is level 0, interpretation level 1, the logic on level 2 and finally RPC on level 3, then I'd argue it would be a lesser evil, if it's done on the higher levels. Then again, on the other hand: if we had access to the subaction byte, we may simplify the [switch in the logicMath](https://github.com/zathras-crypto/omnicore/blob/81d0db05816f2a92dbc4e4a3f32972b1a6590791/src/omnicore/tx.cpp#L997-L1061) significantly. I'd further point out that we also manipulate the `CMPTransaction` in the [logicMath of simple sends](https://github.com/zathras-crypto/omnicore/blob/81d0db05816f2a92dbc4e4a3f32972b1a6590791/src/omnicore/tx.cpp#L846), which may be seen as precedence, so i'd say, ideally we'd do something like you proposed in the logicMath, however, this does not even partially solve our initial problem for unconfirmed transactions.\r\n\r\nUltimately, unrelated to the \"how we do it\", then:\r\n\r\n- v0: we can determine whether it the `subaction` is, or is not, `cancel` at any time based on `nValue`\r\n- v0: we can't determine whether the `subaction` is `new` or `update`, until the transaction confirms\r\n- v1: we can determine the subaction at any time\r\n\r\nWhat would you consider as ideal solution (unrelated to \"how\")? I tend to believe it would be to strictly differentiate between v0 and v1, because even if they are similar, they are not the same thing, so maybe the flaw is inherited, because we try to treat them the same. [Here](http://verraes.net/2014/08/dry-is-about-knowledge/) is an interesting blog post discussing \"similar\" things.\r\n\r\nI'm really twisted here, hehe. I'd say, let's choose the way of the least friction for now: doing nothing, but let's go back to the topic, and take another serious look, the first time we stumble upon it, maybe in a new context or during some refactoring, where we may have new insights."}}