Skip to content

Commit

Permalink
feat: add minimum limit for burn amount (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 authored Jan 2, 2025
1 parent ee2bc04 commit f470ce5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"concurrently": "^8.2.2",
"d3": "^7.9.0",
"decimal.js": "^10.4.3",
"dlc-btc-lib": "2.5.1",
"dlc-btc-lib": "2.5.4",
"dotenv": "^16.3.1",
"ethers": "5.7.2",
"formik": "^2.4.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ function validateDepositAmount(
return error;
}

function validateBurnAmount(value: number, valueMinted: number): string | undefined {
function validateBurnAmount(
value: number,
valueMinted: number,
depositLimit: { minimumDeposit: number; maximumDeposit: number }
): string | undefined {
let error;

if (!value) {
error = 'Please enter a valid amount of iBTC';
} else if (depositLimit && value < depositLimit.minimumDeposit) {
error = `You can't burn less than ${depositLimit.minimumDeposit} BTC`;
} else if (valueMinted && value > valueMinted) {
error = `You can't burn more than ${valueMinted} iBTC`;
}
Expand All @@ -61,7 +67,7 @@ function validateFormAmount(
case 'mint':
return validateDepositAmount(value, depositLimit);
case 'burn':
return validateBurnAmount(value, vault.valueMinted);
return validateBurnAmount(value, vault.valueMinted, depositLimit);
}
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5220,10 +5220,10 @@ dir-glob@^3.0.1:
dependencies:
path-type "^4.0.0"

[email protected].1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/dlc-btc-lib/-/dlc-btc-lib-2.5.1.tgz#b1eb33c0a56a244fcb109da4704854cf8a585c15"
integrity sha512-YRfIsfsgzmUcepowZYaLjY/1E2MJbN5zIhEhS1NgiJsDBjNVAiZTHLY7RiX3eNValgFSnsY3IpUyF6piPap72A==
[email protected].4:
version "2.5.4"
resolved "https://registry.yarnpkg.com/dlc-btc-lib/-/dlc-btc-lib-2.5.4.tgz#265dcc14f3a6f090bb19dbb9753c36359f65b615"
integrity sha512-EYm7pupdooxexGlTuljsCU31hl3v0OoA4Oers8Anwf4FkZPsItIxFMV2HpFy/cmDlGuwtzKw9RNLXun10KcLLg==
dependencies:
"@dfns/sdk" "^0.5.9"
"@dfns/sdk-browser" "^0.5.9"
Expand Down

0 comments on commit f470ce5

Please sign in to comment.