- Tokocrypto keeps monitoring ETH-ERC20 rate on Kyber using either Kyber's trading APIs or reading it directly on Ethereum blockchain, Kyber provides the rates here.
- Tokocrypto displays the rate in the way you want (rate to fiat calculation and fee calculation can be done here)
- The user submits an order to buy ERC20 using fiat according to the rate Tokocrypto shows, lets say the rate is R (mean he needs to spend R amount of fiat A in order to buy 1 token B)
- Up to now, his order is pending
- Tokocrypto do balance lockup (for example deduct fiat balance, increase locked balance of token B...)
- Tokocrypto do a transaction to Kyber's smart contract in order to convert necessary amount of eth to token B (at this step, there are several things you can do like specifying which address you will receive the tokens, which rate you want to proceed and will you still want to proceed if the rate goes down but lets discuss on this after we are clear about the overal flow)
- Tokocrypt monitors the tx to see if it is successful or failed (this would take up a minute)
- If it is successful, unlock the balance of token B, change order status and notify users
- If it is not, wipe out the locked balance of token B, change order status refund fiat balancee and notify users.
Note 1: This is the overall full flow that i can imagine, those steps in bold are the steps that need integration between Tokocrypto and Kyber
Note 2: On step 5, about balance lockup, there are 2 transactions involved in the settlement, 1 is fiat to eth, 1 is eth to erc20, both of them need time to process and especially the transaction to convert eth to erc20 takes around 16s-1min to be mined.
The basic flow is the same to the first scenario except that at step 1, 3, and 6, Tokocrypto should monitor ERC20-ETH rate and do a transaction with kyber in order to convert erc20 to eth.