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

VAULT: Mint To should fail if depositor gets 0 VRT for any amount of ST #147

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clients/js/vault_client/errors/jitoVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ export const JITO_VAULT_ERROR__INVALID_DEPOSIT_TOKEN_ACCOUNT = 0x41c; // 1052
export const JITO_VAULT_ERROR__NO_SUPPORTED_MINT_BALANCE_CHANGE = 0x41d; // 1053
/** InvalidEpochLength: InvalidEpochLength */
export const JITO_VAULT_ERROR__INVALID_EPOCH_LENGTH = 0x41e; // 1054
/** NoZeroReturnMintTo: NoZeroReturnMintTo */
export const JITO_VAULT_ERROR__NO_ZERO_RETURN_MINT_TO = 0x41f; // 1055
/** ArithmeticOverflow: ArithmeticOverflow */
export const JITO_VAULT_ERROR__ARITHMETIC_OVERFLOW = 0xbb8; // 3000
/** ArithmeticUnderflow: ArithmeticUnderflow */
Expand All @@ -143,6 +145,7 @@ export type JitoVaultError =
| typeof JITO_VAULT_ERROR__NCN_VAULT_SLASHER_TICKET_UNSLASHABLE
| typeof JITO_VAULT_ERROR__NCN_VAULT_TICKET_UNSLASHABLE
| typeof JITO_VAULT_ERROR__NO_SUPPORTED_MINT_BALANCE_CHANGE
| typeof JITO_VAULT_ERROR__NO_ZERO_RETURN_MINT_TO
| typeof JITO_VAULT_ERROR__OPERATOR_OVERFLOW
| typeof JITO_VAULT_ERROR__OPERATOR_VAULT_TICKET_UNSLASHABLE
| typeof JITO_VAULT_ERROR__SLASHER_OVERFLOW
Expand Down Expand Up @@ -205,6 +208,7 @@ if (process.env.NODE_ENV !== 'production') {
[JITO_VAULT_ERROR__NCN_VAULT_SLASHER_TICKET_UNSLASHABLE]: `NcnVaultSlasherTicketUnslashable`,
[JITO_VAULT_ERROR__NCN_VAULT_TICKET_UNSLASHABLE]: `NcnVaultTicketUnslashable`,
[JITO_VAULT_ERROR__NO_SUPPORTED_MINT_BALANCE_CHANGE]: `NoSupportedMintBalanceChange`,
[JITO_VAULT_ERROR__NO_ZERO_RETURN_MINT_TO]: `NoZeroReturnMintTo`,
[JITO_VAULT_ERROR__OPERATOR_OVERFLOW]: `OperatorOverflow`,
[JITO_VAULT_ERROR__OPERATOR_VAULT_TICKET_UNSLASHABLE]: `OperatorVaultTicketUnslashable`,
[JITO_VAULT_ERROR__SLASHER_OVERFLOW]: `SlasherOverflow`,
Expand Down
3 changes: 3 additions & 0 deletions clients/rust/vault_client/src/generated/errors/jito_vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ pub enum JitoVaultError {
/// 1054 - InvalidEpochLength
#[error("InvalidEpochLength")]
InvalidEpochLength = 0x41E,
/// 1055 - NoZeroReturnMintTo
#[error("NoZeroReturnMintTo")]
NoZeroReturnMintTo = 0x41F,
/// 3000 - ArithmeticOverflow
#[error("ArithmeticOverflow")]
ArithmeticOverflow = 0xBB8,
Expand Down
5 changes: 5 additions & 0 deletions idl/jito_vault.json
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,11 @@
"name": "InvalidEpochLength",
"msg": "InvalidEpochLength"
},
{
"code": 1055,
"name": "NoZeroReturnMintTo",
"msg": "NoZeroReturnMintTo"
},
{
"code": 3000,
"name": "ArithmeticOverflow",
Expand Down
5 changes: 5 additions & 0 deletions vault_program/src/mint_to.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
vrt_to_fee_wallet,
} = vault.mint_with_fee(amount_in, min_amount_out)?;

if vrt_to_depositor == 0 {
msg!("Depositor will not receive any VRT");
return Err(VaultError::NoZeroReturnMintTo.into());

Check warning on line 97 in vault_program/src/mint_to.rs

View check run for this annotation

Codecov / codecov/patch

vault_program/src/mint_to.rs#L96-L97

Added lines #L96 - L97 were not covered by tests
}

// transfer tokens from depositor to vault
{
invoke(
Expand Down
2 changes: 2 additions & 0 deletions vault_sdk/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ pub enum VaultError {
NoSupportedMintBalanceChange,
#[error("InvalidEpochLength")]
InvalidEpochLength,
#[error("NoZeroReturnMintTo")]
NoZeroReturnMintTo,

#[error("ArithmeticOverflow")]
ArithmeticOverflow = 3000,
Expand Down
Loading