Skip to content

No fee exchange will set fee in transfer table #101

@haojingliu

Description

@haojingliu

As title.

After some investigation, the cause is from the forceExchange() in canExchange.php. The forceExchange uses

  $transfers = app(CommonService::class)->multiBrings([
                    (new Bring())
                        ->setStatus(Transfer::STATUS_EXCHANGE)
                        ->setDeposit($deposit)
                        ->setWithdraw($withdraw)
                        ->setFrom($from)
                        ->setTo($to)
                ]);

and in Bring.php

    public function toArray(): array
    {
        return [
            'status' => $this->getStatus(),
            'deposit_id' => $this->getDeposit()->getKey(),
            'withdraw_id' => $this->getWithdraw()->getKey(),
            'from_type' => $this->getFrom()->getMorphClass(),
            'from_id' => $this->getFrom()->getKey(),
            'to_type' => $this->getTo()->getMorphClass(),
            'to_id' => $this->getTo()->getKey(),
             // THE CAUSE IS HERE
            'fee' => abs($this->getWithdraw()->amount) - abs($this->getDeposit()->amount), 
            'uuid' => $this->getUuid(),
        ];
    }

The transfer's deposit and withdraw are from different wallet (or currency) with rate. So the minus result here usually not correct.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions