Skip to content

Instantly share code, notes, and snippets.

View tranvictor's full-sized avatar

Victor Tran tranvictor

View GitHub Profile
Contract Addresses
KyberNetworkProxy
0x818E6FECD516Ecc3849DAf6845e3EC868087B755
KyberNetwork
0x91a502C678605fbCe581eae053319747482276b9
KyberReserve
0xEB52Ce516a8d054A574905BDc3D4a176D3a2d51a
@tranvictor
tranvictor / gist:526f791408002a1ba1e65f3758337b2b
Last active November 26, 2018 12:59
Proposed workflow for kotocrypto to use kyber protocol to enable erc20 support

First scenario: A user wants to buy ERC20 (the one that kyber supports) using fiat

  1. 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.
  2. Tokocrypto displays the rate in the way you want (rate to fiat calculation and fee calculation can be done here)
  3. 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)
  4. Up to now, his order is pending
  5. Tokocrypto do balance lockup (for example deduct fiat balance, increase locked balance of token B...)
  6. **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 discu
2018/12/05 11:31:36.186382 reserve_core.go:380: old nonce: <nil>, init price: <nil>, count: 0, err:
2018/12/05 11:31:36.441203 reserve_core.go:409: initial set rate tx, init price: 7000000000
2018/12/05 11:31:40.598151 reserve_core.go:467: Core ----------> Set rates: ==> Result: tx: 0x81348b8ebaa39a27dff9f7bf3c52d8043f6dac785580bac38a6386ed4665edbf, nonce: 230340, price: 7000000000, error: , storing error:
2018/12/05 11:32:46.193758 reserve_core.go:380: old nonce: <nil>, init price: <nil>, count: 0, err:
2018/12/05 11:32:46.450731 reserve_core.go:409: initial set rate tx, init price: 6500000000
2018/12/05 11:32:48.780508 reserve_core.go:467: Core ----------> Set rates: ==> Result: tx: 0x43203d27b244f81c99e587c215f876a1907663935f2d63feeadd50c9329b5dea, nonce: 230341, price: 6500000000, error: , storing error:
2018/12/05 11:33:56.458542 reserve_core.go:380: old nonce: 230341, init price: 6500000000, count: 1, err:
2018/12/05 11:34:02.415530 reserve_core.go:394: Trying to replace old tx with new price: 128763720
#<Thread:0x00007f84812de530@/Users/victor/.rvm/gems/ruby-2.5.1/gems/sshkit-1.16.1/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
1: from /Users/victor/.rvm/gems/ruby-2.5.1/gems/sshkit-1.16.1/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/victor/.rvm/gems/ruby-2.5.1/gems/sshkit-1.16.1/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as [email protected]: /home/ubuntu/user_dashboard/rvm1scripts/install-rvm.sh exit status: 2 (SSHKit::Runner::ExecuteError)
/home/ubuntu/user_dashboard/rvm1scripts/install-rvm.sh stdout: Downloading https://github.com/rvm/rvm/archive/1.29.6.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.6/1.29.6.tar.gz.asc
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. Assuming you trust Michal Papis import the mpapis public key (downloading the signatu
func (tl *TradeLog) UnmarshalJSON(b []byte) error {
type AliasTradeLog TradeLog
type mask struct {
Timestamp int64 `json:"timestamp"`
*AliasTradeLog
}
m := mask{
Timestamp: 0,
AliasTradeLog: (*AliasTradeLog)(tl),
}
production.min.js?v=version15:1 Deprecation warning: use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info.
warn @ production.min.js?v=version15:1
production.min.js?v=version15:1 Download the Vue Devtools extension for a better development experience:
https://github.com/vuejs/vue-devtools
production.min.js?v=version15:1 You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html
(index):1 Failed to decode downloaded font: https://fonts.gstatic.com/stats/Roboto/normal/700
production.min.js?v=version15:1 Object
raw.githubusercontent.com/TrustWallet/tokens/master/tokens/0x79cdfa04e3c4eb58c4f49dae78b322e5b0d38788.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
1) Contract: ConversionRates should get buy rate when compact data has boundary values (-128, 127).:
bad rate
+ expected - actual
-100778143200000000000
+72426017920000000000
at Function.assert.deepEqual (node_modules/truffle/build/cli.bundled.js:216053:32)
at Context.<anonymous> (test/conversionRate.js:434:16)
0x63825c174ab367968EC60f061753D3bbD36A0D8F - FPR
0x4Cb01bd05E4652CbB9F312aE604f4549D2bf2C99 - APR
0x2295fc6BC32cD12fdBb852cFf4014cEAc6d79C10 - Custom (PT)
0x742e8BB8e6bDE9CB2DF5449f8de7510798727fB1 - APR
0x57f8160e1c59D16C01BbE181fD94db4E56b60495 - Utility (WETH)
0x3e9FFBA3C3eB91f501817b031031a71de2d3163B - APR
0x0232Ba609782Cea145Ec3663F52CF7aEb4AC773C - APR
0xa33c7c22d0BB673c2aEa2C048BB883b679fa1BE9 - APR
0x1d57EF26709beB756e026308413f685339A73A9D - APR
0x751Eea622edd1E3D768C18afbCaeC7DcE7750C65 - APR
[{"inputs":[{"internalType":"address","name":"vat_","type":"address"},{"internalType":"address","name":"jar_","type":"address"},{"internalType":"address","name":"spot_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"internalType":"contract DSAuthority","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"cdp","type":"uint256"},{"internalType":"uint256","name":"dart","type":"uint256"},{"internalType":"uint256","name":"minInk","type":"uint256"}],"name":"bite","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"func
[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"internalType":"bytes4","name":"sig","type":"bytes4"},{"indexed":true,"internalType":"bytes32","name":"arg1","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"arg2","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"arg3","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"LogNote","type":"event"},{"constant":true,"inputs":[],"name":"Line","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"cage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"can","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":fal