eos icon indicating copy to clipboard operation
eos copied to clipboard

Failed to deposit with contract exchange

Open vjoke opened this issue 8 years ago • 3 comments

Hi, guys, I found a wield problem related to 'push action'. I want to have a test with the contract exchange, I can transfer tokens with contract eosio.token, but depositing with contract exchange always reports error. Maybe something is wrong with extended_asset, could you give me some hints about how to debug this problem? here is the log for testing:

$ cleos push action eosio.token transfer '["hsiung", "exchange", "500.00 BTC" "deposit"]' -p hsiung
executed transaction: 7ea81b0b8bf8c5c913f3a5a135825718de57fcd35782cef4cfb1333d9baf1cdc  184 bytes  986 us
 eosio.token <= eosio.token::transfer        ""
warning: transaction executed locally, but may not be confirmed by the network yet
$ cleos push action exchange deposit '{"from": "hsiung", "quantity": {"quantity": "500.00 USD", "contract": "eosio.token"}}' -p hsiung
Error 3090003: provided keys, permissions, and delays do not satisfy declared authorizations
Error Details:
transaction declares authority '{"actor":"hsiung","permission":"active"}', but does not have signatures for it under a provided delay of 0 ms

vjoke avatar May 15 '18 00:05 vjoke

The deposit method is unnecessary, transfer to exchange already did work.

bytemaster avatar May 15 '18 01:05 bytemaster

But if I don't call deposit before calling createx, I cannot create exchange pair.

$ cleos push action exchange createx '{"creator": "hsiung", "initial_supply":"10000000.00 EXC", "fee": 0, "base_deposit": {"quantity": "300.00 USD", "contract": "eosio.token"}, "quote_deposit": {"quantity": "300.00 BTC", "contract": "eosio.token"}}' -p hsiung
1463938ms thread-0   main.cpp:2346                 main                 ] Failed with error: Assert Exception (10)
condition: assertion failed: overdrawn balance 2

in function createx of exchange.cpp

_accounts.adjust_balance( creator, -base_deposit, "new exchange deposit" );
_accounts.adjust_balance( creator, -quote_deposit, "new exchange deposit" );

Note that createx will subtract deposited tokens from its ledger. In fact, deposit in contract exchange maintains a ledger for how much tokens the creator has.

void exchange::deposit( account_name from, extended_asset quantity ) {
      eosio_assert( quantity.is_valid(), "invalid quantity" );
      currency::inline_transfer( from, _this_contract, quantity, "deposit" );
      _accounts.adjust_balance( from, quantity, "deposit" );
   }

That's the reason why I choose to call deposit with contract exchange.

vjoke avatar May 15 '18 01:05 vjoke

Hey. it looks like you have a block of chaos and. does not match the last check of the ./v1/chain/get_info block and does not match the "head_block_num" parameter: 5724745 last block restart node . after checking the conformity, try ---> restart node sudo

Drug0j avatar Jul 13 '18 21:07 Drug0j