Skip to content

Фикс баланса USDT ERC20 на 0.00000021

Danil Pismenny edited this page Aug 28, 2021 · 3 revisions

Все остатки балансов пользователей выходящие за пределы 6 знаков после запятой переводим на баланс нашего бота:

bot_member =  Member.find_by_email('[email protected]')  

Account.where(currency_id: 'usdt-erc20').select { |a| a.amount.to_s.split('.').second.length > 6 }.map do |a|
  amount = a.amount.to_s.gsub(/^[0-9]+\.[0-9]{6}/,'0.000000').to_d
  InternalTransfer.create!(currency: a.currency, sender_id: a.member_id, receiver: bot_member, amount: amount); puts amount.to_s
end

Вывод:

0.0000001488
0.00000066
0.00000078
0.00000052018
0.0000005986
0.00000069076
0.00000015
0.00000048424
0.00000065324
0.0000005108
0.00000015238

Делаем псевдо-депозит на 0.00000021 на баланс бота:

extra_amount = bot_member.get_account('usdt-erc20').amount.to_s.gsub(/^[0-9]+\.[0-9]{6}/,'0.000000').to_d
diff_amount= 0.00000021
w=Withdraws::Coin.new(member: bot_member, currency_id: 'usdt-erc20', amount: diff_amount, sum: extra_amount, fee: extra_amount-diff_amount, tid: 'fake-withdraw:1', rid: '/dev/null', blockchain_id: 7)
w.save validate: false
w.send(:lock_funds)
w.send(:unlock_and_sub_funds)
w.update_column :aasm_state, :succeed
w.send(:record_submit_operations!)
w.send(:record_complete_operations!)

Создан withdraw с ID 74