1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
use crate::instructions::*;

use crate::state::SundialBumps;
use crate::state::SundialCollateralBumps;
use anchor_lang::prelude::*;

use sundial_derives::process;

#[macro_use]
pub mod helpers;
pub mod instructions;
pub mod state;

declare_id!("SDLxV7m1qmoqkytqYRGY1x438AbYCqekPsPxK4kvwuk");

#[program]
pub mod sundial {
    use super::*;

    use vipers::Validate;

    #[process]
    fn initialize_sundial(
        ctx: Context<InitializeSundial>,
        bumps: SundialBumps,
        duration_in_seconds: i64,
        port_lending_program: Pubkey,
        config: SundialInitConfigParams,
        oracle: Pubkey,
        _name: String,
        _pda_bump: u8,
    ) {
    }

    #[process]
    fn mint_principle_tokens_and_yield_tokens(ctx: Context<DepositAndMintTokens>, amount: u64) {}

    #[process]
    fn redeem_principle_tokens(ctx: Context<RedeemPrincipleToken>, amount: u64) {}

    #[process]
    fn redeem_yield_tokens(ctx: Context<RedeemYieldToken>, amount: u64) {}

    #[process]
    fn redeem_lp(ctx: Context<RedeemLp>) -> ProgramResult {}

    #[process]
    fn initialize_sundial_collateral(
        ctx: Context<InitializeSundialCollateral>,
        bumps: SundialCollateralBumps,
        config: SundialCollateralConfigParams,
        _name: String,
        _pda_bump: u8,
    ) {
    }

    #[process]
    fn refresh_sundial_profile<'info>(
        ctx: Context<'_, '_, '_, 'info, RefreshSundialProfile<'info>>,
    ) {
    }

    #[process]
    fn deposit_sundial_collateral<'info>(
        ctx: Context<'_, '_, '_, 'info, DepositSundialCollateral<'info>>,
        amount: u64,
    ) {
    }

    #[process]
    fn withdraw_sundial_collateral(
        ctx: Context<WithdrawSundialCollateral>,
        max_withdraw_amount: u64,
    ) {
    }

    #[process]
    fn mint_sundial_liquidity_with_collateral<'info>(
        ctx: Context<'_, '_, '_, 'info, MintSundialLiquidityWithCollateral<'info>>,
        amount: u64,
    ) {
    }

    #[process]
    fn repay_sundial_liquidity(ctx: Context<RepaySundialLiquidity>, max_repay_amount: u64) {}

    #[process]
    fn liquidate_sundial_profile(ctx: Context<LiquidateSundialProfile>) {}

    #[process]
    fn initialize_sundial_profile(
        ctx: Context<InitializeSundialProfile>,
        sundial_market: Pubkey,
        _bump: u8,
    ) {
    }

    #[process]
    fn refresh_sundial_collateral(ctx: Context<RefreshSundialCollateral>) {}

    #[process]
    fn change_sundial_collateral_config(
        ctx: Context<ChangeSundialCollateralConfig>,
        config: SundialCollateralConfigParams,
    ) {
    }

    #[process]
    fn change_sundial_config(ctx: Context<ChangeSundialConfig>, config: SundialInitConfigParams) {}

    #[process]
    fn initialize_sundial_market(ctx: Context<InitializeSundialMarket>, owner: Pubkey) {}
}

#[error]
pub enum ErrorCode {
    // 300
    #[msg("End Time Earlier Than CurrentTime")]
    EndTimeTooEarly,
    InvalidPortLiquidityMint,
    InvalidPortLpMint,
    #[msg("Please refresh reserve before deposit")]
    ReserveIsNotRefreshed,
    #[msg("Please call redeem before first redeem of principle or yield")]
    NotRedeemLpYet,

    //305
    #[msg("Not the redeem time yet")]
    NotEndYet,
    #[msg("SundialPool has already ended")]
    AlreadyEnd,
    ExceedLiquidityCap,
    InvalidOracleConfig,
    #[msg("Reserve should be passed in")]
    ReserveNeeded,

    //310
    InvalidMintAmount,
    #[msg("Oracle should be passed in")]
    OracleNeeded,
    WithdrawTooMuchCollateral,
    RepayTooMuchLoan,
    InvalidLiquidation,

    //315
    InvalidOwner,
    InvalidProfileUser,
    #[msg("Sundial's market does not match the on in sundial profile")]
    SundialMarketNotMatch,
    #[msg("The state is stale")]
    StateStale,
    OwnerNotSigned,

    //320
    InvalidPortReserve,
    InvalidTokenProgram,
    InvalidPortLendingProgram,
    InvalidSundialCollateralConfig,
}