Skip to content

Commit

Permalink
fix: failure minting to treasury (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed May 4, 2023
1 parent d69a5a8 commit 89d2fde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/zklend/internals/Market/functions.cairo
Expand Up @@ -571,6 +571,10 @@ namespace Internal {
}(token: felt, amount: felt) {
alloc_locals;

with_attr error_message("Market: zero amount") {
assert_not_zero(amount);
}

let (caller) = get_caller_address();
let (this_address) = get_contract_address();

Expand Down
9 changes: 6 additions & 3 deletions src/zklend/internals/ZToken/functions.cairo
Expand Up @@ -203,13 +203,16 @@ namespace External {
with_attr error_message("ZToken: cannot mint to the zero address") {
assert_not_zero(to);
}
with_attr error_message("ZToken: invalid mint amount") {
assert_not_zero(amount);
}

let (accumulator) = Internal.get_accumulator();

// We're disallowing zero `amount` but allowing zero `scaled_down_amount` here, because it
// would be difficult for callers to determine whether the amount would be zero after
// scaling down.
let scaled_down_amount = SafeDecimalMath.div(amount, accumulator);
with_attr error_message("ZToken: invalid mint amount") {
assert_not_zero(scaled_down_amount);
}

let (raw_balance_before) = raw_balances.read(to);
let raw_balance_after = SafeMath.add(raw_balance_before, scaled_down_amount);
Expand Down

0 comments on commit 89d2fde

Please sign in to comment.