class CoinSync::Importers::EtherDelta

Look up your transactions using DeltaBalances at deltabalances.github.io/history.html, specifying the time range you need, and then download the “Default” CSV in the top-right section

Constants

ETH

Public Instance Methods

read_transaction_list(source) click to toggle source
# File lib/coinsync/importers/etherdelta.rb, line 48
def read_transaction_list(source)
  csv = CSV.new(source, col_sep: ',')

  transactions = []

  csv.each do |line|
    next if line[0] == 'Type'

    entry = HistoryEntry.new(line)

    next if entry.amount.round(8) == 0 || entry.total.round(8) == 0

    if entry.trade == 'Buy'
      if entry.fee_token != ETH
        raise "EtherDelta importer: Unexpected fee currency: #{entry.fee_token.code}"
      end

      transactions << Transaction.new(
        exchange: 'EtherDelta',
        time: entry.date,
        bought_amount: entry.amount,
        bought_currency: entry.token,
        sold_amount: entry.total + entry.fee,
        sold_currency: ETH
      )
    else
      if entry.fee_token != entry.token
        raise "EtherDelta importer: Unexpected fee currency: #{entry.fee_token.code}"
      end

      transactions << Transaction.new(
        exchange: 'EtherDelta',
        time: entry.date,
        bought_amount: entry.total,
        bought_currency: ETH,
        sold_amount: entry.amount + entry.fee,
        sold_currency: entry.token
      )
    end
  end

  transactions.sort_by(&:time)
end