Skip to content

project 10: liquidate misuse amount and value #60

@baiwfg2

Description

@baiwfg2

In project 10 process_liquidate function, I think there's a big error in calculating and transferring.

let total_collateral = (sol_price.price as u64 * user.deposited_sol) + (usdc_price.price as u64 * user.deposited_usdc);
let total_borrowed = (sol_price.price as u64 * user.borrowed_sol) + (usdc_price.price as u64 * user.borrowed_usdc);

These two indicates value totalled in $, so they are not parameters for token_interface::transfer_checked which needs an amount parameter.

In order to calculate amount of liquidation_tokens to transfer, we need divide liquidation_value by borrowed_price. The same goes for collateral.

I know the lending protocol is kind of simplified, but the mistake of API calling should be remedied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions