From 65f3e032349fddbf57ea471f27170e5d72d8653e Mon Sep 17 00:00:00 2001 From: vantessel Date: Fri, 11 Nov 2022 12:14:44 +0100 Subject: [PATCH] remove owner and update ix --- Cargo.lock | 16 +++--- README.md | 16 +++--- programs/redeem-logic-digital/Cargo.toml | 2 +- programs/redeem-logic-digital/src/lib.rs | 29 +---------- programs/redeem-logic-farming/Cargo.toml | 2 +- programs/redeem-logic-farming/src/lib.rs | 43 +--------------- programs/redeem-logic-fila/Cargo.toml | 2 +- programs/redeem-logic-fila/src/lib.rs | 32 +----------- programs/redeem-logic-forward/Cargo.toml | 2 +- programs/redeem-logic-forward/src/lib.rs | 37 +------------- programs/redeem-logic-lending-fee/Cargo.toml | 2 +- programs/redeem-logic-lending-fee/src/lib.rs | 49 +------------------ programs/redeem-logic-lending/Cargo.toml | 2 +- programs/redeem-logic-lending/src/lib.rs | 37 +------------- .../redeem-logic-settled-forward/Cargo.toml | 2 +- .../redeem-logic-settled-forward/src/lib.rs | 39 +-------------- .../redeem-logic-vanilla-option/Cargo.toml | 2 +- .../redeem-logic-vanilla-option/src/lib.rs | 4 +- 18 files changed, 32 insertions(+), 286 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c2579f7..e1d080c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1032,7 +1032,7 @@ dependencies = [ [[package]] name = "redeem-logic-digital" -version = "0.1.0" +version = "1.0.0" dependencies = [ "anchor-lang", "rust_decimal", @@ -1044,7 +1044,7 @@ dependencies = [ [[package]] name = "redeem-logic-farming" -version = "1.0.0" +version = "2.0.0" dependencies = [ "anchor-lang", "rust_decimal", @@ -1056,7 +1056,7 @@ dependencies = [ [[package]] name = "redeem-logic-fila" -version = "0.1.1" +version = "1.0.0" dependencies = [ "anchor-lang", "rust_decimal", @@ -1068,7 +1068,7 @@ dependencies = [ [[package]] name = "redeem-logic-forward" -version = "0.1.1" +version = "1.0.0" dependencies = [ "anchor-lang", "rust_decimal", @@ -1080,7 +1080,7 @@ dependencies = [ [[package]] name = "redeem-logic-lending" -version = "0.1.1" +version = "1.0.0" dependencies = [ "anchor-lang", "rust_decimal", @@ -1092,7 +1092,7 @@ dependencies = [ [[package]] name = "redeem-logic-lending-fee" -version = "0.1.1" +version = "1.0.0" dependencies = [ "anchor-lang", "rust_decimal", @@ -1104,7 +1104,7 @@ dependencies = [ [[package]] name = "redeem-logic-settled-forward" -version = "0.1.1" +version = "1.0.0" dependencies = [ "anchor-lang", "rust_decimal", @@ -1116,7 +1116,7 @@ dependencies = [ [[package]] name = "redeem-logic-vanilla-option" -version = "1.0.0" +version = "2.0.0" dependencies = [ "anchor-lang", "rust_decimal", diff --git a/README.md b/README.md index c3e1d2f..e628eef 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,14 @@ Following the Vyper suite | **Rate Switchboard** | Rate Plugin | `0.1.0` | `programs/rate-switchboard` | | **Rate Pyth** | Rate Plugin | `0.1.0` | `programs/rate-pyth` | | **Rate Mock** | Rate Plugin | `0.1.0` | `programs/rate-mock` | -| **Redeem Logic Lending** | Redeem Logic Plugin | `0.1.1` | `programs/redeem-logic-lending` | -| **Redeem Logic Lending Fee** | Redeem Logic Plugin | `0.1.1` | `programs/redeem-logic-lending-fee` | -| **Redeem Logic Farming** | Redeem Logic Plugin | `1.0.0` | `programs/redeem-logic-farming` | -| **Redeem Logic Vanilla Option** | Redeem Logic Plugin | `1.0.0` | `programs/redeem-logic-vanilla-option` | -| **Redeem Logic Forward** | Redeem Logic Plugin | `0.1.1` | `programs/redeem-logic-forward` | -| **Redeem Logic Settled Forward** | Redeem Logic Plugin | `0.1.1` | `programs/redeem-logic-settled-forward`| -| **Redeem Logic Fila** | Redeem Logic Plugin | `0.1.1` | `programs/redeem-logic-fila` | -| **Redeem Logic Digital** | Redeem Logic Plugin | `0.1.0` | `programs/redeem-logic-digital` | +| **Redeem Logic Lending** | Redeem Logic Plugin | `1.0.0` | `programs/redeem-logic-lending` | +| **Redeem Logic Lending Fee** | Redeem Logic Plugin | `1.0.0` | `programs/redeem-logic-lending-fee` | +| **Redeem Logic Farming** | Redeem Logic Plugin | `2.0.0` | `programs/redeem-logic-farming` | +| **Redeem Logic Vanilla Option** | Redeem Logic Plugin | `2.0.0` | `programs/redeem-logic-vanilla-option` | +| **Redeem Logic Forward** | Redeem Logic Plugin | `1.0.0` | `programs/redeem-logic-forward` | +| **Redeem Logic Settled Forward** | Redeem Logic Plugin | `1.0.0` | `programs/redeem-logic-settled-forward`| +| **Redeem Logic Fila** | Redeem Logic Plugin | `1.0.0` | `programs/redeem-logic-fila` | +| **Redeem Logic Digital** | Redeem Logic Plugin | `1.0.0` | `programs/redeem-logic-digital` | ## Rust Libraries diff --git a/programs/redeem-logic-digital/Cargo.toml b/programs/redeem-logic-digital/Cargo.toml index d4886ce..c71d5bb 100644 --- a/programs/redeem-logic-digital/Cargo.toml +++ b/programs/redeem-logic-digital/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redeem-logic-digital" -version = "0.1.0" +version = "1.0.0" description = "Created with Anchor" edition = "2021" diff --git a/programs/redeem-logic-digital/src/lib.rs b/programs/redeem-logic-digital/src/lib.rs index f9d5d0e..ebb8aea 100644 --- a/programs/redeem-logic-digital/src/lib.rs +++ b/programs/redeem-logic-digital/src/lib.rs @@ -26,17 +26,6 @@ pub mod redeem_logic_digital { use super::*; pub fn initialize(ctx: Context, strike: f64, is_call: bool) -> Result<()> { - let redeem_logic_config = &mut ctx.accounts.redeem_logic_config; - redeem_logic_config.owner = ctx.accounts.owner.key(); - redeem_logic_config.strike = Decimal::from_f64(strike) - .ok_or(RedeemLogicErrors::MathError)? - .serialize(); - redeem_logic_config.is_call = is_call; - - Ok(()) - } - - pub fn update(ctx: Context, strike: f64, is_call: bool) -> Result<()> { let redeem_logic_config = &mut ctx.accounts.redeem_logic_config; redeem_logic_config.strike = Decimal::from_f64(strike) .ok_or(RedeemLogicErrors::MathError)? @@ -91,26 +80,12 @@ pub struct InitializeContext<'info> { #[account(init, payer = payer, space = RedeemLogicConfig::LEN)] pub redeem_logic_config: Box>, - /// CHECK: Owner of the tranche config - #[account()] - pub owner: AccountInfo<'info>, - /// Signer account #[account(mut)] pub payer: Signer<'info>, pub system_program: Program<'info, System>, } -#[derive(Accounts)] -pub struct UpdateContext<'info> { - #[account(mut, has_one = owner)] - pub redeem_logic_config: Account<'info, RedeemLogicConfig>, - - /// CHECK: Owner of the tranche config - #[account()] - pub owner: Signer<'info>, -} - #[derive(Accounts)] pub struct ExecuteContext<'info> { #[account()] @@ -123,14 +98,12 @@ pub struct RedeemLogicConfig { pub is_call: bool, pub strike: [u8; 16], - pub owner: Pubkey, } impl RedeemLogicConfig { pub const LEN: usize = 8 + // discriminator 1 + // pub is_call: bool, - 16 + // pub strike: [u8; 16], - 32 // pub owner: Pubkey, + 16 // pub strike: [u8; 16], ; fn dump(&self) { diff --git a/programs/redeem-logic-farming/Cargo.toml b/programs/redeem-logic-farming/Cargo.toml index 3e1f728..65c698f 100644 --- a/programs/redeem-logic-farming/Cargo.toml +++ b/programs/redeem-logic-farming/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redeem-logic-farming" -version = "1.0.0" +version = "2.0.0" description = "Created with Anchor" edition = "2021" diff --git a/programs/redeem-logic-farming/src/lib.rs b/programs/redeem-logic-farming/src/lib.rs index 1deefe0..8eedccf 100644 --- a/programs/redeem-logic-farming/src/lib.rs +++ b/programs/redeem-logic-farming/src/lib.rs @@ -31,31 +31,6 @@ pub mod redeem_logic_farming { require!(interest_split >= 0., RedeemLogicErrors::InvalidInput); require!(interest_split <= 1., RedeemLogicErrors::InvalidInput); - redeem_logic_config.owner = ctx.accounts.owner.key(); - redeem_logic_config.interest_split = Decimal::from_f64(interest_split) - .ok_or(RedeemLogicErrors::MathError)? - .serialize(); - redeem_logic_config.cap_low = Decimal::from_f64(cap_low) - .ok_or(RedeemLogicErrors::MathError)? - .serialize(); - redeem_logic_config.cap_high = Decimal::from_f64(cap_high) - .ok_or(RedeemLogicErrors::MathError)? - .serialize(); - - Ok(()) - } - - pub fn update( - ctx: Context, - interest_split: f64, - cap_low: f64, - cap_high: f64, - ) -> Result<()> { - let redeem_logic_config = &mut ctx.accounts.redeem_logic_config; - - require!(interest_split >= 0., RedeemLogicErrors::InvalidInput); - require!(interest_split <= 1., RedeemLogicErrors::InvalidInput); - redeem_logic_config.interest_split = Decimal::from_f64(interest_split) .ok_or(RedeemLogicErrors::MathError)? .serialize(); @@ -132,26 +107,12 @@ pub struct InitializeContext<'info> { #[account(init, payer = payer, space = RedeemLogicConfig::LEN)] pub redeem_logic_config: Box>, - /// CHECK: Owner of the tranche config - #[account()] - pub owner: AccountInfo<'info>, - /// Signer account #[account(mut)] pub payer: Signer<'info>, pub system_program: Program<'info, System>, } -#[derive(Accounts)] -pub struct UpdateContext<'info> { - #[account(mut, has_one = owner)] - pub redeem_logic_config: Account<'info, RedeemLogicConfig>, - - /// CHECK: Owner of the tranche config - #[account()] - pub owner: Signer<'info>, -} - #[derive(Accounts)] pub struct ExecuteContext<'info> { #[account()] @@ -163,15 +124,13 @@ pub struct RedeemLogicConfig { pub interest_split: [u8; 16], pub cap_low: [u8; 16], pub cap_high: [u8; 16], - pub owner: Pubkey, } impl RedeemLogicConfig { pub const LEN: usize = 8 + // discriminator 16 + // pub interest_split: [u8; 16], 16 + // cap_low: [u8; 16], - 16 + // pub cap_high: [u8; 16], - 32 // pub owner: Pubkey, + 16 // pub cap_high: [u8; 16], ; fn dump(&self) { diff --git a/programs/redeem-logic-fila/Cargo.toml b/programs/redeem-logic-fila/Cargo.toml index 922c3bc..0319e38 100644 --- a/programs/redeem-logic-fila/Cargo.toml +++ b/programs/redeem-logic-fila/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redeem-logic-fila" -version = "0.1.1" +version = "1.0.0" description = "Created with Anchor" edition = "2021" diff --git a/programs/redeem-logic-fila/src/lib.rs b/programs/redeem-logic-fila/src/lib.rs index 0edb9d9..b4e7664 100644 --- a/programs/redeem-logic-fila/src/lib.rs +++ b/programs/redeem-logic-fila/src/lib.rs @@ -31,20 +31,6 @@ pub mod redeem_logic_fila { let redeem_logic_config = &mut ctx.accounts.redeem_logic_config; - redeem_logic_config.owner = ctx.accounts.owner.key(); - redeem_logic_config.strike = Decimal::from_f64(strike) - .ok_or(RedeemLogicErrors::MathError)? - .serialize(); - redeem_logic_config.notional = notional; - - Ok(()) - } - - pub fn update(ctx: Context, strike: f64, notional: u64) -> Result<()> { - require!(strike >= 0., RedeemLogicErrors::InvalidInput); - - let redeem_logic_config = &mut ctx.accounts.redeem_logic_config; - redeem_logic_config.strike = Decimal::from_f64(strike) .ok_or(RedeemLogicErrors::MathError)? .serialize(); @@ -113,26 +99,12 @@ pub struct InitializeContext<'info> { #[account(init, payer = payer, space = RedeemLogicConfig::LEN)] pub redeem_logic_config: Box>, - /// CHECK: Owner of the tranche config - #[account()] - pub owner: AccountInfo<'info>, - /// Signer account #[account(mut)] pub payer: Signer<'info>, pub system_program: Program<'info, System>, } -#[derive(Accounts)] -pub struct UpdateContext<'info> { - #[account(mut, has_one = owner)] - pub redeem_logic_config: Account<'info, RedeemLogicConfig>, - - /// CHECK: Owner of the tranche config - #[account()] - pub owner: Signer<'info>, -} - #[derive(Accounts)] pub struct ExecuteContext<'info> { #[account()] @@ -143,14 +115,12 @@ pub struct ExecuteContext<'info> { pub struct RedeemLogicConfig { pub notional: u64, pub strike: [u8; 16], - pub owner: Pubkey, } impl RedeemLogicConfig { pub const LEN: usize = 8 + // discriminator 8 + // pub notional: u64, - 16 + // pub strike: [u8; 16], - 32 // pub owner: Pubkey, + 16 // pub strike: [u8; 16], ; fn dump(&self) { diff --git a/programs/redeem-logic-forward/Cargo.toml b/programs/redeem-logic-forward/Cargo.toml index 8478471..0c416d7 100644 --- a/programs/redeem-logic-forward/Cargo.toml +++ b/programs/redeem-logic-forward/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redeem-logic-forward" -version = "0.1.1" +version = "1.0.0" description = "Created with Anchor" edition = "2021" diff --git a/programs/redeem-logic-forward/src/lib.rs b/programs/redeem-logic-forward/src/lib.rs index f8828de..3ebe6e8 100644 --- a/programs/redeem-logic-forward/src/lib.rs +++ b/programs/redeem-logic-forward/src/lib.rs @@ -34,25 +34,6 @@ pub mod redeem_logic_forward { ) -> Result<()> { require!(strike >= 0., RedeemLogicErrors::InvalidInput); - let redeem_logic_config = &mut ctx.accounts.redeem_logic_config; - redeem_logic_config.owner = ctx.accounts.owner.key(); - redeem_logic_config.strike = Decimal::from_f64(strike) - .ok_or(RedeemLogicErrors::MathError)? - .serialize(); - redeem_logic_config.notional = notional; - redeem_logic_config.is_linear = is_linear; - - Ok(()) - } - - pub fn update( - ctx: Context, - strike: f64, - notional: u64, - is_linear: bool, - ) -> Result<()> { - require!(strike >= 0., RedeemLogicErrors::InvalidInput); - let redeem_logic_config = &mut ctx.accounts.redeem_logic_config; redeem_logic_config.strike = Decimal::from_f64(strike) .ok_or(RedeemLogicErrors::MathError)? @@ -123,26 +104,12 @@ pub struct InitializeContext<'info> { #[account(init, payer = payer, space = RedeemLogicConfig::LEN)] pub redeem_logic_config: Box>, - /// CHECK: Owner of the tranche config - #[account()] - pub owner: AccountInfo<'info>, - /// Signer account #[account(mut)] pub payer: Signer<'info>, pub system_program: Program<'info, System>, } -#[derive(Accounts)] -pub struct UpdateContext<'info> { - #[account(mut, has_one = owner)] - pub redeem_logic_config: Account<'info, RedeemLogicConfig>, - - /// CHECK: Owner of the tranche config - #[account()] - pub owner: Signer<'info>, -} - #[derive(Accounts)] pub struct ExecuteContext<'info> { #[account()] @@ -157,15 +124,13 @@ pub struct RedeemLogicConfig { pub is_linear: bool, pub strike: [u8; 16], - pub owner: Pubkey, } impl RedeemLogicConfig { pub const LEN: usize = 8 + // discriminator 8 + // pub notional: u64, 1 + // pub is_linear: bool, - 16 + // pub strike: [u8; 16], - 32 // pub owner: Pubkey, + 16 // pub strike: [u8; 16], ; fn dump(&self) { diff --git a/programs/redeem-logic-lending-fee/Cargo.toml b/programs/redeem-logic-lending-fee/Cargo.toml index afa4a9d..7d555df 100644 --- a/programs/redeem-logic-lending-fee/Cargo.toml +++ b/programs/redeem-logic-lending-fee/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redeem-logic-lending-fee" -version = "0.1.1" +version = "1.0.0" description = "Created with Anchor" edition = "2021" diff --git a/programs/redeem-logic-lending-fee/src/lib.rs b/programs/redeem-logic-lending-fee/src/lib.rs index 49467db..0e94568 100644 --- a/programs/redeem-logic-lending-fee/src/lib.rs +++ b/programs/redeem-logic-lending-fee/src/lib.rs @@ -35,37 +35,6 @@ pub mod redeem_logic_lending_fee { require!(perf_fee >= 0., RedeemLogicErrors::InvalidInput); require!(perf_fee <= 1., RedeemLogicErrors::InvalidInput); - redeem_logic_config.owner = ctx.accounts.owner.key(); - redeem_logic_config.interest_split = Decimal::from_f64(interest_split) - .ok_or(RedeemLogicErrors::MathError)? - .serialize(); - redeem_logic_config.mgmt_fee = Decimal::from_f64(mgmt_fee) - .ok_or(RedeemLogicErrors::MathError)? - .serialize(); - redeem_logic_config.perf_fee = Decimal::from_f64(perf_fee) - .ok_or(RedeemLogicErrors::MathError)? - .serialize(); - - Ok(()) - } - - pub fn update( - ctx: Context, - interest_split: f64, - mgmt_fee: f64, - perf_fee: f64, - ) -> Result<()> { - let redeem_logic_config = &mut ctx.accounts.redeem_logic_config; - - require!(interest_split >= 0., RedeemLogicErrors::InvalidInput); - require!(interest_split <= 1., RedeemLogicErrors::InvalidInput); - - require!(mgmt_fee >= 0., RedeemLogicErrors::InvalidInput); - require!(mgmt_fee <= 1., RedeemLogicErrors::InvalidInput); - - require!(perf_fee >= 0., RedeemLogicErrors::InvalidInput); - require!(perf_fee <= 1., RedeemLogicErrors::InvalidInput); - redeem_logic_config.interest_split = Decimal::from_f64(interest_split) .ok_or(RedeemLogicErrors::MathError)? .serialize(); @@ -140,26 +109,12 @@ pub struct InitializeContext<'info> { #[account(init, payer = payer, space = RedeemLogicConfig::LEN)] pub redeem_logic_config: Box>, - /// CHECK: Owner of the tranche config - #[account()] - pub owner: AccountInfo<'info>, - /// Signer account #[account(mut)] pub payer: Signer<'info>, pub system_program: Program<'info, System>, } -#[derive(Accounts)] -pub struct UpdateContext<'info> { - #[account(mut, has_one = owner)] - pub redeem_logic_config: Account<'info, RedeemLogicConfig>, - - /// CHECK: Owner of the tranche config - #[account()] - pub owner: Signer<'info>, -} - #[derive(Accounts)] pub struct ExecuteContext<'info> { #[account()] @@ -171,15 +126,13 @@ pub struct RedeemLogicConfig { pub interest_split: [u8; 16], pub mgmt_fee: [u8; 16], pub perf_fee: [u8; 16], - pub owner: Pubkey, } impl RedeemLogicConfig { pub const LEN: usize = 8 + // discriminator 16 + // pub interest_split: DecimalWrapper, 16 + // pub mgmt_fee: DecimalWrapper, - 16 + // pub perf_fee: DecimalWrapper, - 32 // pub owner: Pubkey, + 16 // pub perf_fee: DecimalWrapper, ; fn dump(&self) { diff --git a/programs/redeem-logic-lending/Cargo.toml b/programs/redeem-logic-lending/Cargo.toml index 0496b98..5cd81ab 100644 --- a/programs/redeem-logic-lending/Cargo.toml +++ b/programs/redeem-logic-lending/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redeem-logic-lending" -version = "0.1.1" +version = "1.0.0" description = "Created with Anchor" edition = "2021" repository = "https://github.com/vyper-protocol/vyper-core/" diff --git a/programs/redeem-logic-lending/src/lib.rs b/programs/redeem-logic-lending/src/lib.rs index fda5ad0..68f08d7 100644 --- a/programs/redeem-logic-lending/src/lib.rs +++ b/programs/redeem-logic-lending/src/lib.rs @@ -28,25 +28,6 @@ pub mod redeem_logic_lending { require!(interest_split >= 0., RedeemLogicErrors::InvalidInput); require!(interest_split <= 1., RedeemLogicErrors::InvalidInput); - redeem_logic_config.owner = ctx.accounts.owner.key(); - redeem_logic_config.interest_split = Decimal::from_f64(interest_split) - .ok_or(RedeemLogicErrors::MathError)? - .serialize(); - redeem_logic_config.fixed_fee_per_tranche = fixed_fee_per_tranche; - - Ok(()) - } - - pub fn update( - ctx: Context, - interest_split: f64, - fixed_fee_per_tranche: u64, - ) -> Result<()> { - let redeem_logic_config = &mut ctx.accounts.redeem_logic_config; - - require!(interest_split >= 0., RedeemLogicErrors::InvalidInput); - require!(interest_split <= 1., RedeemLogicErrors::InvalidInput); - redeem_logic_config.interest_split = Decimal::from_f64(interest_split) .ok_or(RedeemLogicErrors::MathError)? .serialize(); @@ -115,26 +96,12 @@ pub struct InitializeContext<'info> { #[account(init, payer = payer, space = RedeemLogicConfig::LEN)] pub redeem_logic_config: Box>, - /// CHECK: Owner of the tranche config - #[account()] - pub owner: AccountInfo<'info>, - /// Signer account #[account(mut)] pub payer: Signer<'info>, pub system_program: Program<'info, System>, } -#[derive(Accounts)] -pub struct UpdateContext<'info> { - #[account(mut, has_one = owner)] - pub redeem_logic_config: Account<'info, RedeemLogicConfig>, - - /// CHECK: Owner of the tranche config - #[account()] - pub owner: Signer<'info>, -} - #[derive(Accounts)] pub struct ExecuteContext<'info> { #[account()] @@ -145,14 +112,12 @@ pub struct ExecuteContext<'info> { pub struct RedeemLogicConfig { pub interest_split: [u8; 16], pub fixed_fee_per_tranche: u64, - pub owner: Pubkey, } impl RedeemLogicConfig { pub const LEN: usize = 8 + // discriminator 16 + // pub interest_split: [u8; 16], - 8 + // pub fixed_fee_per_tranche: u64, - 32 // pub owner: Pubkey, + 8 // pub fixed_fee_per_tranche: u64, ; fn dump(&self) { diff --git a/programs/redeem-logic-settled-forward/Cargo.toml b/programs/redeem-logic-settled-forward/Cargo.toml index 60c27f1..456d60e 100644 --- a/programs/redeem-logic-settled-forward/Cargo.toml +++ b/programs/redeem-logic-settled-forward/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redeem-logic-settled-forward" -version = "0.1.1" +version = "1.0.0" description = "Created with Anchor" edition = "2021" diff --git a/programs/redeem-logic-settled-forward/src/lib.rs b/programs/redeem-logic-settled-forward/src/lib.rs index f9edbff..afdc20d 100644 --- a/programs/redeem-logic-settled-forward/src/lib.rs +++ b/programs/redeem-logic-settled-forward/src/lib.rs @@ -38,27 +38,6 @@ pub mod redeem_logic_settled_forward { ) -> Result<()> { require!(strike >= 0., RedeemLogicErrors::InvalidInput); - let redeem_logic_config = &mut ctx.accounts.redeem_logic_config; - redeem_logic_config.owner = ctx.accounts.owner.key(); - redeem_logic_config.strike = Decimal::from_f64(strike) - .ok_or(RedeemLogicErrors::MathError)? - .serialize(); - redeem_logic_config.notional = notional; - redeem_logic_config.is_linear = is_linear; - redeem_logic_config.is_standard = is_standard; - - Ok(()) - } - - pub fn update( - ctx: Context, - strike: f64, - notional: u64, - is_linear: bool, - is_standard: bool, - ) -> Result<()> { - require!(strike >= 0., RedeemLogicErrors::InvalidInput); - let redeem_logic_config = &mut ctx.accounts.redeem_logic_config; redeem_logic_config.strike = Decimal::from_f64(strike) .ok_or(RedeemLogicErrors::MathError)? @@ -132,26 +111,12 @@ pub struct InitializeContext<'info> { #[account(init, payer = payer, space = RedeemLogicConfig::LEN)] pub redeem_logic_config: Box>, - /// CHECK: Owner of the tranche config - #[account()] - pub owner: AccountInfo<'info>, - /// Signer account #[account(mut)] pub payer: Signer<'info>, pub system_program: Program<'info, System>, } -#[derive(Accounts)] -pub struct UpdateContext<'info> { - #[account(mut, has_one = owner)] - pub redeem_logic_config: Account<'info, RedeemLogicConfig>, - - /// CHECK: Owner of the tranche config - #[account()] - pub owner: Signer<'info>, -} - #[derive(Accounts)] pub struct ExecuteContext<'info> { #[account()] @@ -169,7 +134,6 @@ pub struct RedeemLogicConfig { pub is_standard: bool, pub strike: [u8; 16], - pub owner: Pubkey, } impl RedeemLogicConfig { @@ -177,8 +141,7 @@ impl RedeemLogicConfig { 8 + // pub notional: u64, 1 + // pub is_linear: bool, 1 + // pub is_standard: bool, - 16 + // pub strike: [u8; 16], - 32 // pub owner: Pubkey, + 16 // pub strike: [u8; 16], ; fn dump(&self) { diff --git a/programs/redeem-logic-vanilla-option/Cargo.toml b/programs/redeem-logic-vanilla-option/Cargo.toml index 9c74698..cbf52da 100644 --- a/programs/redeem-logic-vanilla-option/Cargo.toml +++ b/programs/redeem-logic-vanilla-option/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redeem-logic-vanilla-option" -version = "1.0.0" +version = "2.0.0" description = "Created with Anchor" edition = "2021" diff --git a/programs/redeem-logic-vanilla-option/src/lib.rs b/programs/redeem-logic-vanilla-option/src/lib.rs index be66746..aa54021 100644 --- a/programs/redeem-logic-vanilla-option/src/lib.rs +++ b/programs/redeem-logic-vanilla-option/src/lib.rs @@ -150,8 +150,6 @@ impl RedeemLogicConfig { } } -#[allow(clippy::collapsible_else_if)] -#[allow(clippy::nonminimal_bool)] fn execute_plugin( old_quantity: [u64; 2], new_spot: Decimal, @@ -166,7 +164,7 @@ fn execute_plugin( let payoff = notional * { if new_spot == Decimal::ZERO && !is_linear { - if !is_call || (is_call && strike > Decimal::ZERO) { + if !is_call || strike > Decimal::ZERO { Decimal::ZERO } else { Decimal::ONE