KomodoPlatform / komodo-defi-framework

This is the official Komodo DeFi Framework repository
https://komodoplatform.com/en/docs/komodo-defi-framework/
104 stars 95 forks source link

Implement SLP, tendermint, ERC-20, ZHTLC activation using wallet protocol v2 #1806

Open rozhkovdmitrii opened 1 year ago

rozhkovdmitrii commented 1 year ago

Impact

There is a bunch of methods have been introduced by protocol version 2.0 are aimed to enable bcs (slp), tendermint, ethereum (erc20) tokens, including possibility to enable multiple per one transaction.

That is why it's needed to analyze them and introduce the most seamless way to utilize them, perhaps using extended activation scheme to keep command line interface simple if it's possible.

Todo:

ZHTLC:

ZHTLC coins, like Pirate (ARRR) and the test coin ZOMBIE take a little longer to enable, and use a new two step method to enable. Activation can take a little while the first time, as we need to download some block cache data, and build a wallet database.

rozhkovdmitrii commented 1 year ago

Testing enable_erc20

enabling platform coin
$ release/komodefi-cli enable ETH
Enabling coin: ETH
coin: ETH
address: 0x224050fb7EB13Fa0D342F5b245f1237bAB531650
balance: 0.043332961727987327
unspendable_balance: 0
required_confirmations: 3
requires_notarization: No
activation_scheme.json manually changed
{
  "platform": "ETH",
  "coin": "BAT-ERC20",
  "command": {
    "mmrpc": "2.0",
    "method": "enable_erc20",
    "ticker": "BAT-ERC20",
    "params": {
      "ticker":"BAT-ERC20",
      "activation_params": {
        "required_confirmations": 3
      }
    }, 
    "userpass": "'$userpass'"
  }
},
enabling
$ release/komodefi-cli balance BAT-ERC20
Getting balance, coin: BAT-ERC20
coin: BAT-ERC20
balance: 0
unspendable: 0
address: 0x224050fb7EB13Fa0D342F5b245f1237bAB531650
rozhkovdmitrii commented 1 year ago

Testing enable_eth_with_tokens

$ release/komodefi-cli enable ETH
Enabling coin: ETH
current_block: 17783997
eth_addresses_infos: 
│ address, pubkey                                                                                                                    │ method │ balance(sp,unsp) │ tickers │
│ 0x224050fb7EB13Fa0D342F5b245f1237bAB531650                                                                                         │ Iguana │ 0.04:0           │ none    │
│ 04264fcd9401d797c50fe2f1c7d5fe09bbc10f3838c1d8d6f793061fa5f38b2b4dd3ce99de66ad77c4ed33c9801777de4a4f730e635cd5c3a530a8a57a21376e26 │        │                  │         │

erc20_addresses_infos: 
│ address, pubkey                                                                                                                    │ method │ balance(sp,unsp) │ tickers │
│ 0x224050fb7EB13Fa0D342F5b245f1237bAB531650                                                                                         │ Iguana │ BCH-ERC20: 0:0   │ none    │
│ 04264fcd9401d797c50fe2f1c7d5fe09bbc10f3838c1d8d6f793061fa5f38b2b4dd3ce99de66ad77c4ed33c9801777de4a4f730e635cd5c3a530a8a57a21376e26 │        │ APE-ERC20: 0:0   │         │
│                                                                                                                                    │        │ MINDS-ERC20: 0:0 │         │
│                                                                                                                                    │        │ BUSD-ERC20: 0:0  │         │
│                                                                                                                                    │        │ BAT-ERC20: 0:0   │         │
│                                                                                                                                    │        │                  │         │
activation_scheme.json manually changed
    {
      "platform": null,
      "coin": "ETH",
      "command": {
        "params": {
          "ticker": "ETH",
          "gas_station_url": "https://ethgasstation.info/json/ethgasAPI.json",
          "gas_station_decimals": 8,
          "gas_station_policy": { "policy": "MeanAverageFast" },
          "mm2": 1,
          "priv_key_policy": "ContextPrivKey",
          "swap_contract_address": "0x24ABE4c71FC658C91313b6552cd40cD808b3Ea80",
          "fallback_swap_contract": "0x8500AFc0bc5214728082163326C2FF0C73f4a871",
            "nodes": [ { "url": "http://eth1.cipig.net:8555", "gui_auth": false }, { "url": "http://eth2.cipig.net:8555", "gui_auth": false },
                       { "url": "http://eth3.cipig.net:8555", "gui_auth": false }, { "url": "https://node.komodo.earth:8080/ethereum", "gui_auth": true } ],
            "rpc_mode": "Http",
            "tx_history": true,
            "erc20_tokens_requests": [ { "ticker": "APE-ERC20", "required_confirmations": 4 }, { "ticker": "BCH-ERC20", "required_confirmations": 4 },
                                       { "ticker": "MINDS-ERC20", "required_confirmations": 4 }, { "ticker": "BUSD-ERC20", "required_confirmations": 4 } ],
            "required_confirmations": 5,
            "requires_notarization": false
        },
        "method": "enable_eth_with_tokens",
        "mmrpc": "2.0",
        "userpass": "'$userpass'"
      }
    },