Skip to content

Commit

Permalink
Merge pull request #84 from vyper-protocol/rm-owner
Browse files Browse the repository at this point in the history
remove owner and update ix
  • Loading branch information
thegreat-vanderlinde authored Nov 11, 2022
2 parents 6a5d0ce + 65f3e03 commit da36b6a
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 286 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion programs/redeem-logic-digital/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "redeem-logic-digital"
version = "0.1.0"
version = "1.0.0"
description = "Created with Anchor"
edition = "2021"

Expand Down
29 changes: 1 addition & 28 deletions programs/redeem-logic-digital/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ pub mod redeem_logic_digital {
use super::*;

pub fn initialize(ctx: Context<InitializeContext>, 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<UpdateContext>, 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)?
Expand Down Expand Up @@ -91,26 +80,12 @@ pub struct InitializeContext<'info> {
#[account(init, payer = payer, space = RedeemLogicConfig::LEN)]
pub redeem_logic_config: Box<Account<'info, RedeemLogicConfig>>,

/// 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()]
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion programs/redeem-logic-farming/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "redeem-logic-farming"
version = "1.0.0"
version = "2.0.0"
description = "Created with Anchor"
edition = "2021"

Expand Down
43 changes: 1 addition & 42 deletions programs/redeem-logic-farming/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UpdateContext>,
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();
Expand Down Expand Up @@ -132,26 +107,12 @@ pub struct InitializeContext<'info> {
#[account(init, payer = payer, space = RedeemLogicConfig::LEN)]
pub redeem_logic_config: Box<Account<'info, RedeemLogicConfig>>,

/// 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()]
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion programs/redeem-logic-fila/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "redeem-logic-fila"
version = "0.1.1"
version = "1.0.0"
description = "Created with Anchor"
edition = "2021"

Expand Down
32 changes: 1 addition & 31 deletions programs/redeem-logic-fila/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UpdateContext>, 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();
Expand Down Expand Up @@ -113,26 +99,12 @@ pub struct InitializeContext<'info> {
#[account(init, payer = payer, space = RedeemLogicConfig::LEN)]
pub redeem_logic_config: Box<Account<'info, RedeemLogicConfig>>,

/// 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()]
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion programs/redeem-logic-forward/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "redeem-logic-forward"
version = "0.1.1"
version = "1.0.0"
description = "Created with Anchor"
edition = "2021"

Expand Down
37 changes: 1 addition & 36 deletions programs/redeem-logic-forward/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UpdateContext>,
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)?
Expand Down Expand Up @@ -123,26 +104,12 @@ pub struct InitializeContext<'info> {
#[account(init, payer = payer, space = RedeemLogicConfig::LEN)]
pub redeem_logic_config: Box<Account<'info, RedeemLogicConfig>>,

/// 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()]
Expand All @@ -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) {
Expand Down
Loading

0 comments on commit da36b6a

Please sign in to comment.