Code Monkey home page Code Monkey logo

hybrid-exchange-sdk's People

Contributors

andreafspeziale avatar ceres3idoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hybrid-exchange-sdk's Issues

Create order cli command

๐Ÿ“ Feature

The command will create and submit an order creation.

๐Ÿ“– Details

This is a creation order payload:

{
     exchangeAddress: "0xExchangeAddress",
ย ย  ย "expirationBlock": "1000000000",
ย ย  ย "offerTokenAddress": "0x0000000000000000000000000000000000000000",
ย ย  ย "offerTokenAmount": "5742943699999999955", (BASED ON TOKEN DECIMAL)
ย ย  ย "wantTokenAmount": "883000000000000000000",
ย ย  ย "exchangeAddress": "0xbfd9aaac82281b54ecf60b7d53ccc9cdf13cd14e", (?)
ย ย  ย "wantTokenAddress": "0x2b2c319799df9d98b0fd34c961a2e1181239de27",
ย ย  ย "salt": "81861121702282757272785826314277177144908563551874336254236098011739278507166",
ย ย  ย "maker": "0x721adc8c8635d1146b0025c740d094e65f83e49d" (EOA)
}
eidoo-hybrid-exchange-cli os createย 
--cli-input-json <value> 
--prv <privatekeyFilePath>

Keystore generation

๐Ÿ“ Feature

As a user I want to generate my personal keystore file using a cli command.

๐Ÿ“– Details

The command should be:

eidoo-hybrid-exchange-cli ethereum-wallet key-generate
--keystore-file-path The destination file path where keystore will be stored
[--hd-path] The derivation path used to retrieve the private key from seed. (default: m/44'/60'/0/0)

so you need to type your seed (12 words) and after that you have to insert a password (used to build the keystore json file).

The output will be a json file strucred as follows:

{
    "address": "fakeAddress",
    "crypto": {
        "cipher": "aes-128-ctr",
        "ciphertext": "fakeChyper",
        "cipherparams": {
            "iv": "fakeIv"
        },
        "mac": "fakeMac",
        "kdf": "scrypt",
        "kdfparams": {
            "dklen": 32,
            "n": 262144,
            "r": 1,
            "p": 8,
            "salt": "fakesalt"
        }
    },
    "id": "f99105b6-ef46-418c-9811-13a4f6004b70",
    "version": 3
}

Under the hood will be used keythereum dump generating a keystore file.

const options = const options = {
  kdf: "scrypt",
  cipher: "aes-128-ctr",
  kdfparams: {
    c: 262144,
    dklen: 32,
    prf: "hmac-sha256"
  }
}
// privateKey retrieved from hd_path and mnemonic
const iv = randomBytes
const salt = randomBytes
const result = keythereum.dump(password, privateKey, salt, iv, options)

Command Error format

๐Ÿ“ Refactor

Every error at cli level will be wrapped in a CommandError in a proper way.

Enable update exchange

๐Ÿ“ Feature

Enable the update exchange command for trading wallets in the cli.

๐Ÿ“– Details

Add related low level functions.

ERC20 Allowance

๐Ÿ“ Issue

As a user I want to retrieve the ERC20 token allowance.

Given an owner address and a spender address, allowance is the remaining amount that the spender is approved to withdraw from the owner.

The first development part of this issue is a refactor of the Erc20TokenService and It will be added an Erc20TransactionBuilde factory.

The second it s about allowance implementation.

Isolate hybrid exchange cli

๐Ÿ“ Refactor

Move cli and commands directory at the same level of src directory.

๐Ÿ“– Details

If you have time and you should do somenthing perfect you have to create another project, for istance hybrid-exchange-cli which will use the hybrid-exchange-sdk.

Create Order command

๐Ÿ“ Feature

The command will create and submit an order creation.

๐Ÿ“– Details

This is a creation order payload:

{
     exchangeAddress: "0xExchangeAddress",
ย ย  ย "expirationBlock": "1000000000",
ย ย  ย "offerTokenAddress": "0x0000000000000000000000000000000000000000",
ย ย  ย "offerTokenAmount": "5742943699999999955", (BASED ON TOKEN DECIMAL)
ย ย  ย "wantTokenAmount": "883000000000000000000",
ย ย  ย "exchangeAddress": "0xbfd9aaac82281b54ecf60b7d53ccc9cdf13cd14e", (?)
ย ย  ย "wantTokenAddress": "0x2b2c319799df9d98b0fd34c961a2e1181239de27",
ย ย  ย "salt": "81861121702282757272785826314277177144908563551874336254236098011739278507166",
ย ย  ย "maker": "0x721adc8c8635d1146b0025c740d094e65f83e49d" (EOA)
}
eidoo-hybrid-exchange-cli os createย 
--cli-input-json <value> 
--prv <privatekeyFilePath>
[--generate-cli-skeleton <value>]

A good example: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-skeleton.html

Trading Wallet service getAssetBalanceAsync refactor

๐Ÿ“ Refactor

Change trading wallet service getAssetBalanceAsync to eventually accept trading wallet address as input.

๐Ÿ“– Details

Since a trading wallet can be outdated (meaning that it can be still registered on an old Exchange contract) the trading wallet service should not automatically retrieve the trading wallet address during a get asset balance.

Withdraw asset command

๐Ÿ“ Issue

As a user I want to use the cli to withdraw token from trading wallet to my EOA.

๐Ÿ“– Details

Command synopsis

eidoo-hybrid-exchange-cli tws withdraw
--from (should be the EOA aka TW owner)
--toย (should be the TW address)
--quantity (WEI)
--tokenย (ETH - TokenAddress)
[--draft]
[--raw-tx]

If draft is set toi true then it will returns the TramsactionObjectDraft object to eventually execute withdraw asset transaction manually.

If raw-tx is set to true then it will returns the signed transaction data.

Improve issue management

๐Ÿ“ Issue

Improve issue management.

๐Ÿ“– Details

Add more specific issue templates.

CLI installation documentation

๐Ÿ“ Feature

As a user I want to know how to install the cli command of hybrid eidoo exchange, and how to use the commands.

Cancel Order command

๐Ÿ“ Feature

The command will cancel an order.

๐Ÿ“– Details

Command synopsis

eidoo-hybrid-exchange-cli os cancel
--id (the order id you are going to cancel)
--prv (the private key file path)

Enable get-exchange

๐Ÿ“ Feature

Retrieve the exchange smart contract address from a given trading wallet.

๐Ÿ“– Details

Add related low level functions.

Add Service factories

๐Ÿ“ Issue

Add factories for Erc20TokenService and TradingWalletService in order to instiantiate relative objects easier.

Trading Wallet getBalance CLI command

๐Ÿ“ Issue

As a user I want to use the CLI to check the ETH or Token balance of an account.

๐Ÿ“– Details

Command synopsis

eidoo-hybrid-exchange-cli tws get-balance
--from (who is asking for the balance)
--to (trading wallet address to check the balance)
--token (eth 0x0... or tokenAddress)

ERC20 getAllowance CLI command

๐Ÿ“ Issue

As a user I want to use the CLI to check the allowance an owner gave to a spender.

๐Ÿ“– Details

Command synopsis

eidoo-hybrid-exchange-cli tks get-allowance
--from (who is asking for the balance, used also as owner parameter)
--spender (could be the trading wallet address)
--token (it's the token address)
[-- prv] (optional private key)
[-- draft] (optional draft. If set to true shows the transactionObject)

Add Trade service

๐Ÿ“ Feature

Add missing trades endpoints to the Hybrid Exchange SDK.

๐Ÿ“– Details

Add at the lib level a service to retrieve all Eidoo exchange trades and all the trades by pair.

Add a CI

๐Ÿ“ Feature

Add a CI system to reduce the error propagation into dev branch.

Approve Token Command

๐Ÿ“ Feature

As a user I want to use the CLI to approve transfer of ERC20 token from my EOA to my trading.

๐Ÿ“– Details

Command synopsis

eidoo-hybrid-exchange-cli tws approve
--from (should be the EOA aka TW owner)
--toย (should be the TW address)
--quantity (WEI)
--tokenย (ETH - 0xAddress)
[--draft]
[--raw-tx]

If draft is set to true then it will returns the TramsactionObjectDraft object to eventually execute approve transaction manually.

If raw-tx is set to true then it will returns the signed transaction data.

Deposit Token with allowance check

๐Ÿ“ Issue

As a user I want to deposit token without allowance check and manual approve operation.

๐Ÿ“– Details

If you are going to deposit token , you need actually to run the following operations:

  • Approve token transafer ( using Erc20TokenService)
  • Check the allowance calling Erc20 smart contract (using Erc20TokenService)
  • Deposit token (using TradingWalletService)

For this it will be implemented a function which manages the flow described above.

Deposit ETH command

๐Ÿ“ Issue

As a user I want to use the CLI to deposit ETH from my EOA to my trading.

๐Ÿ“– Details

Command synopsis

eidoo-hybrid-exchange-cli tws deposit-eth
--from (should be the EOA aka TW owner)
--toย (should be the TW address)
--quantity (WEI)
[--draft]
[--raw-tx]

If draft is set to true then it will returns the TramsactionObjectDraft object to eventually execute deposit ETH transaction manually.

If raw-tx is set to true then it will returns the signed transaction data.

tokenAddress = 0x00..

Command foldering

๐Ÿ“ Refactor

The commands dir should be structered in the same way the cli command is.

Inject the config

๐Ÿ“ Refactor

The config must be injected to the services to allows a better app development.

Optimize command doExecuteAsync

๐Ÿ“ Refactor

buildTransactionDraft method should be called one and only one time in doExecuteAsync in each command.

๐Ÿ“– Details

In doExecuteAsync buildTransactionDraft was called 2 times.
The first one before draft flag check and the second one inside the specific service method call.
For istance in WithdrawCommand class buildWithdrawTransactionDraft was called in doExecuteAsync and in withdrawAsyncmethod of tradingWalletService.

Deposit Token command

๐Ÿ“ Feature

As a user I want to use the CLI to deposit Tokens from my EOA to my trading wallet.

๐Ÿ“– Details

Command synopsis

eidoo-hybrid-exchange-cli tws deposit-tkn
--from (should be the EOA aka TW owner)
--toย (should be the TW address)
--quantity (WEI)
--token (token address)
[--draft]
[--raw-tx]
[--with-approve] (default true)

If draft is set to true then it will returns the TramsactionObjectDraft object to eventually execute deposit token transaction manually. (it will not consider the --with-approve)

If raw-tx is set to true then it will returns the signed transaction data. (it will not consider the --with-approve)

Enable get-owner feature

๐Ÿ“ Feature

Retrieve the owner address from a given trading wallet.

๐Ÿ“– Details

Add related low level functions.

Refactor deposit ETH command accepting a JSON private key with encrypted password

๐Ÿ“ Feature

Right know the deposit eth command takes as input a private key file path containing the plain private key:

const privateKeyFilePathArg = new CommandArg('private-key-path',
      'string', 'prv', 'The private key file path.', 1, false)

We need to replace it with --keystore-file-path.
Once the command is launched a password prompt must be showed asking the password to unlock the account.

Args:

  --from (EOA - demand)
  --to (Trading Wallet - demand)
  --quantity (Amount - demand)
  --keystore-file-path (demand)
  --draft
  --raw-tx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.