flash loan: Add a "swap without fees" option (#882)
This commit is contained in:
parent
5d29eb2f0b
commit
8a3a3bf70b
|
@ -10580,6 +10580,9 @@
|
|||
},
|
||||
{
|
||||
"name": "Swap"
|
||||
},
|
||||
{
|
||||
"name": "SwapWithoutFee"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -92,6 +92,12 @@ pub struct FlashLoanEnd<'info> {
|
|||
#[derive(PartialEq, Copy, Clone, Debug, AnchorSerialize, AnchorDeserialize)]
|
||||
#[repr(u8)]
|
||||
pub enum FlashLoanType {
|
||||
/// An arbitrary flash loan
|
||||
Unknown,
|
||||
/// A flash loan used for a swap where one token is exchanged for another.
|
||||
///
|
||||
/// Deposits in this type get charged the flash_loan_swap_fee_rate
|
||||
Swap,
|
||||
/// Like Swap, but without the flash_loan_swap_fee_rate
|
||||
SwapWithoutFee,
|
||||
}
|
||||
|
|
|
@ -378,10 +378,10 @@ pub fn flash_loan_end<'key, 'accounts, 'remaining, 'info>(
|
|||
|
||||
match flash_loan_type {
|
||||
FlashLoanType::Unknown => {}
|
||||
FlashLoanType::Swap => {
|
||||
FlashLoanType::Swap | FlashLoanType::SwapWithoutFee => {
|
||||
require_msg!(
|
||||
changes.len() == 2,
|
||||
"when flash_loan_type is Swap there must be exactly 2 token vault changes"
|
||||
"when flash_loan_type is Swap or SwapWithoutFee there must be exactly 2 token vault changes"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10580,6 +10580,9 @@ export type MangoV4 = {
|
|||
},
|
||||
{
|
||||
"name": "Swap"
|
||||
},
|
||||
{
|
||||
"name": "SwapWithoutFee"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -24755,6 +24758,9 @@ export const IDL: MangoV4 = {
|
|||
},
|
||||
{
|
||||
"name": "Swap"
|
||||
},
|
||||
{
|
||||
"name": "SwapWithoutFee"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -9,11 +9,13 @@ export class FlashLoanWithdraw {
|
|||
|
||||
export type FlashLoanType =
|
||||
| { unknown: Record<string, never> }
|
||||
| { swap: Record<string, never> };
|
||||
| { swap: Record<string, never> }
|
||||
| { swapWithoutFee: Record<string, never> };
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
export namespace FlashLoanType {
|
||||
export const unknown = { unknown: {} };
|
||||
export const swap = { swap: {} };
|
||||
export const swapWithoutFee = { swapWithoutFee: {} };
|
||||
}
|
||||
|
||||
export class InterestRateParams {
|
||||
|
|
Loading…
Reference in New Issue