{"action":"created","issue":{"url":"https://api.github.com/repos/OmniLayer/omnicore/issues/22","labels_url":"https://api.github.com/repos/OmniLayer/omnicore/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/OmniLayer/omnicore/issues/22/comments","events_url":"https://api.github.com/repos/OmniLayer/omnicore/issues/22/events","html_url":"https://github.com/OmniLayer/omnicore/issues/22","id":70130064,"number":22,"title":"Honoring the original unit price in updated offers","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/meta%20dex","name":"meta dex","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-22T13:44:24Z","updated_at":"2015-04-23T23:42:25Z","closed_at":null,"body":"When calculating the amounts to trade on the meta DEx, the applied unit price of an order may be rounded to the next tradable unit, constrained by the amounts available, however, the original unit price should be honored in subsequent trades.\r\n\r\nExample trade:\r\n```\r\nA1 offers 100.00000000 SPX for 10.00000000 MSC\r\nA2 offers 0.80000000 MSC for 7.27272727 SPX\r\n\r\nA1 receives 0.80000000 MSC, and has 9.272727273 SPX left for sale (A1's offer is updated)\r\nA2 receives 7.27272727, and has 0 SPX left for sale (A2's offer is erased completely)\r\n\r\nA1's offer is updated to: 92.72727273 SPX for 9.27272727 MSC\r\n```\r\n\r\nFrom the debug log:\r\n> PRICE CHECK TRADED_MOREINBUYER: buyer = 0.10000000000000000000000000000000000000000000000000 , inserted = 0.09999999996764705882448096885810350091593813232600 : PROBLEM!\r\n\r\nThis slightly off unit price is due to the ratio of `9.27272727/92.72727273`.\r\n\r\nAs consequence, the unit price starts to drift, and may be significantly different after one or more trades.\r\n\r\n---\r\n\r\nA straight forward fix requires two additional fields for [CMPMetaDEx](https://github.com/OmniLayer/omnicore/blob/701ca0a2110bfe1526bb567a37db301ed52e4e1b/src/mastercore_dex.h#L200) objects, `original_amount_forsale` and `original_amount_desired`, which shall be used to calculate the unit price for (subsequent) offers.\r\n\r\nThis likely introduces the requirement of further adjustments to [CMPMetaDEx::effectivePrice()](https://github.com/OmniLayer/omnicore/blob/701ca0a2110bfe1526bb567a37db301ed52e4e1b/src/mastercore_dex.h#L268), maybe to the core meta DEx logic, and certainly to the persistence of data, in particular [CMPMetaDEx::saveOffer()](https://github.com/OmniLayer/omnicore/blob/701ca0a2110bfe1526bb567a37db301ed52e4e1b/src/mastercore_dex.cpp#L990).\r\n\r\nAs far as I can see, no change of [CMPTradeList::recordTrade()](https://github.com/OmniLayer/omnicore/blob/701ca0a2110bfe1526bb567a37db301ed52e4e1b/src/mastercore.cpp#L3823) is necessary, but this *hidden, or original unit price* should be clearly reflected in all user faced channels (i.e. `gettrade_MP`, `getorderbook_MP`, ... ?)."},"comment":{"url":"https://api.github.com/repos/OmniLayer/omnicore/issues/comments/95749815","html_url":"https://github.com/OmniLayer/omnicore/issues/22#issuecomment-95749815","issue_url":"https://api.github.com/repos/OmniLayer/omnicore/issues/22","id":95749815,"user":{"login":"CraigSellars","id":6528096,"avatar_url":"https://avatars.githubusercontent.com/u/6528096?v=3","gravatar_id":"","url":"https://api.github.com/users/CraigSellars","html_url":"https://github.com/CraigSellars","followers_url":"https://api.github.com/users/CraigSellars/followers","following_url":"https://api.github.com/users/CraigSellars/following{/other_user}","gists_url":"https://api.github.com/users/CraigSellars/gists{/gist_id}","starred_url":"https://api.github.com/users/CraigSellars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CraigSellars/subscriptions","organizations_url":"https://api.github.com/users/CraigSellars/orgs","repos_url":"https://api.github.com/users/CraigSellars/repos","events_url":"https://api.github.com/users/CraigSellars/events{/privacy}","received_events_url":"https://api.github.com/users/CraigSellars/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T23:42:25Z","updated_at":"2015-04-23T23:42:25Z","body":"Good catch.  This is something that Zathras mentioned during the all-hands earlier this week.  Thanks!"}}