Skip to content

post refresh wallets is overadding to pending deposits #171

Open
@Exalovic

Description

@Exalovic

People are experiencing the bot giving incorrect balances after the pending deposits update.

After looking at trade data I have identified that the function responsible for the problem is this one:

starts on line 268 in exchange.php

protected function postRefreshWallets( $tradesMade ) {
$id = $this->getID();
foreach ( $this->wallets as $coin => $balance ) {
if ( !isset( $this->walletsBackup[ $coin ] ) ) {
$this->walletsBackup[ $coin ] = 0;
}
if ( $balance != $this->walletsBackup[ $coin ] ) {
// Assume that a change in the balance when we aren't trading may be an incoming
// deposit being credited, look for one!
$change = $balance - $this->walletsBackup[ $coin ];
if ( isset( $tradesMade[ $id ][ $coin ] ) ) {
// If we have made a trade at this exchange of this coin, make sure to discount
// the change if it's less than the trade amount.
if ( abs( $change ) < abs( $tradesMade[ $id ][ $coin ] ) ) {
$change = 0;
} else {
$change += -$tradesMade[ $id ][ $coin ];
}
}
$pendingDeposit = Database::getPendingDeposit( $coin, $id );
if ( $pendingDeposit > 0 && $change != 0 ) {
Database::savePendingDeposit( $coin, -$change, $id );
}
}
}
Database::saveWallets( $id, $this->wallets );

However I'm unsure how to deal with fixing it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions