Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post refresh wallets is overadding to pending deposits #171

Open
Exalovic opened this issue Mar 4, 2018 · 0 comments
Open

post refresh wallets is overadding to pending deposits #171

Exalovic opened this issue Mar 4, 2018 · 0 comments

Comments

@Exalovic
Copy link

Exalovic commented Mar 4, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant