use anchor_lang::prelude::*;
use anchor_lang::solana_program;
use static_pubkey::static_pubkey;
use tulipv2_sdk_farms::{lending::Lending, Farm};
use crate::config::deposit_tracking::issue_shares::DepositAddresses;
use crate::config::deposit_tracking::register::RegisterDepositTrackingAddresses;
use crate::config::deposit_tracking::traits::{
IssueShares, RegisterDepositTracking, WithdrawDepositTracking,
};
use crate::config::deposit_tracking::withdraw::WithdrawDepositTrackingAddresses;
use crate::config::lending::traits::WithdrawMultiOptimizerVault;
use crate::config::lending::withdraw::WithdrawAddresses;
use crate::config::lending::Platform;
use crate::config::lending::withdraw::PlatformConfigAddresses;
pub mod multi_deposit {
use super::*;
pub struct ProgramConfig;
pub const TAG_STRING: &str = "usdtv1";
pub const FARM_KEY: Farm = Farm::Lending {
name: Lending::MULTI_DEPOSIT,
};
pub const ACCOUNT: Pubkey = static_pubkey!("BBRkN5paHbHLku4KrZMN8Mc5U3Ygasd4v2FtxdwG7F8F");
pub const PDA: Pubkey = static_pubkey!("DkP2YsqzjiAhnURstef1AmB2EDzRpigbJQuLyNtFcH3Y");
pub const SHARES_MINT: Pubkey = static_pubkey!("AHV6CBjuT7M2HMMKDa5gRSEoBcJGWVjURCBhpgMbyESX");
pub const UNDERLYING_COMPOUND_QUEUE: Pubkey =
static_pubkey!("E8E1Bdhp67tanf4UonTUnAervkhSmYkYkQo2DkxpdVc9");
pub const UNDERLYING_DEPOSIT_QUEUE: Pubkey =
static_pubkey!("2WxVfyi9ps7Ym1jhK43HKVetuxpJwDpaok6AU9T5KKuP");
pub const UNDERLYING_WITHDRAW_QUEUE: Pubkey =
static_pubkey!("4RQC5TorXks2zU7cznQe3FAmdntHkbjoeWW9y5A9WoW4");
pub const UNDERLYING_MINT: Pubkey =
static_pubkey!("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB");
pub const REBALANCE_STATE_TRANSITION: Pubkey =
static_pubkey!("7NFyTU8NnwQ3TWxeLXmHNSbqwP4cF7Tpb5BRgfa5B5MC");
pub const REBALANCE_STATE_TRANSITION_UNDERLYING: Pubkey =
static_pubkey!("B126PNhYa7AgnktVcsvpikXHqdAA3yUDUc5eRgnzLGd");
pub const SOLEND_OPTIMIZER_SHARES_ACCOUNT: Pubkey =
static_pubkey!("5LhLY4tKxeVeqV5P3BdNZvHRePCZxqCM9DgqAEhofjzG");
pub const TULIP_OPTIMIZER_SHARES_ACCOUNT: Pubkey =
static_pubkey!("9vtcrGjfzYkf3R2PNLaayjdTazxAQ7tx6fgSQjXWUkD");
pub const MANGO_OPTIMIZER_SHARES_ACCOUNT: Pubkey =
static_pubkey!("5ai771C6H16dAEXywGz7AyVSXkbaJ5qYA2wfvpLPabn");
impl ProgramConfig {
pub fn issue_shares_ix(user: Pubkey) -> impl IssueShares {
DepositAddresses::new(user, ACCOUNT, PDA, SHARES_MINT, UNDERLYING_MINT)
}
pub fn register_deposit_tracking_ix(user: Pubkey) -> impl RegisterDepositTracking {
RegisterDepositTrackingAddresses::new(user, ACCOUNT, SHARES_MINT, UNDERLYING_MINT)
}
pub fn withdraw_deposit_tracking(user: Pubkey) -> impl WithdrawDepositTracking {
WithdrawDepositTrackingAddresses::new(user, ACCOUNT, SHARES_MINT)
}
pub fn withdraw_multi_deposit_optimizer_vault(
user: Pubkey,
platform: Platform,
) -> std::result::Result<impl WithdrawMultiOptimizerVault, std::io::Error> {
let (standalone_config, platform_config) = if platform.eq(&Platform::MangoV3) {
(
(
ProgramConfig::get_mango_remaining_accounts().to_vec(),
platform,
),
super::mango::platform_config(),
)
} else if platform.eq(&Platform::Solend) {
(
(
ProgramConfig::get_solend_remaining_accounts().to_vec(),
platform,
),
super::solend::platform_config(),
)
} else {
(
(
ProgramConfig::get_tulip_remaining_accounts().to_vec(),
platform,
),
super::tulip::platform_config(),
)
};
WithdrawAddresses::new(
user,
ACCOUNT,
PDA,
SHARES_MINT,
UNDERLYING_MINT,
UNDERLYING_WITHDRAW_QUEUE,
platform_config,
(&standalone_config.0, standalone_config.1),
)
}
pub fn get_tulip_remaining_accounts() -> [Pubkey; 7] {
[
super::tulip::COLLATERAL_TOKEN_ACCOUNT,
super::tulip::RESERVE_ACCOUNT,
super::tulip::RESERVE_LIQUIDITY_ACCOUNT,
super::tulip::COLLATERAL_MINT,
super::tulip::LENDING_MARKET_ACCOUNT,
super::tulip::LENDING_MARKET_AUTHORITY,
super::tulip::PYTH_PRICE_ACCOUNT,
]
}
pub fn get_solend_remaining_accounts() -> [Pubkey; 8] {
[
super::solend::COLLATERAL_TOKEN_ACCOUNT,
super::solend::RESERVE_ACCOUNT,
super::solend::RESERVE_LIQUIDITY_ACCOUNT,
super::solend::COLLATERAL_MINT,
super::solend::LENDING_MARKET_ACCOUNT,
super::solend::LENDING_MARKET_AUTHORITY,
super::solend::PYTH_PRICE_ACCOUNT,
super::solend::SWITCHBOARD_PRICE_ACCOUNT,
]
}
pub fn get_mango_remaining_accounts() -> [Pubkey; 7] {
[
super::mango::GROUP,
super::mango::OPTIMIZER_MANGO_ACCOUNT,
super::mango::CACHE,
super::mango::ROOT_BANK,
super::mango::NODE_BANK,
super::mango::GROUP_TOKEN_ACCOUNT,
super::mango::GROUP_SIGNER,
]
}
}
}
pub mod solend {
use super::*;
pub const TAG_STRING: &str = "solend";
pub const FARM_KEY: Farm = Farm::Lending {
name: Lending::USDT,
};
pub const ACCOUNT: Pubkey = static_pubkey!("4YmXxV6C6MQs3TrZjpH5bw4qTtgZZhVRNfkWEteVXcWX");
pub const PDA: Pubkey = static_pubkey!("GZqAKKd7pApvbe2abgTZs9X7heJxqkYEig5c9CgJCHYD");
pub const SHARES_MINT: Pubkey = static_pubkey!("HYXLSi4xA4GtcUkm5zjRSBf6vVwebYfMfEMjgQiLbYeW");
pub const UNDERLYING_COMPOUND_QUEUE: Pubkey =
static_pubkey!("Fxhy5ShwJq5hXkB8Ch9TFowwuMpW7QA9yMDMvTv7iZJZ");
pub const UNDERLYING_DEPOSIT_QUEUE: Pubkey =
static_pubkey!("AFdRMvwdLfsyLTxGbGYRLYh4Mhqx2bEyYQm9K3wYkFpX");
pub const UNDERLYING_WITHDRAW_QUEUE: Pubkey =
static_pubkey!("87beLgLgD1fdJwBxrL5h9Fb9bjq9bGBJwEMxLss9mwaa");
pub const UNDERLYING_MINT: Pubkey =
static_pubkey!("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB");
pub const CONFIG_DATA_ACCOUNT: Pubkey =
static_pubkey!("A7mxsEKDVYgSgp9n13qbKNAKNxcLF8Df9Rpea3gCzh9p");
pub const INFORMATION_ACCOUNT: Pubkey =
static_pubkey!("4bwpyxZh67UqjgqcK9rxDL7vZwcpe1S6EEZJc59P6bXd");
pub const PROGRAM_ID: Pubkey = static_pubkey!("So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo");
pub const COLLATERAL_MINT: Pubkey =
static_pubkey!("BTsbZDV7aCMRJ3VNy9ygV4Q2UeEo9GpR8D6VvmMZzNr8");
pub const LENDING_MARKET_ACCOUNT: Pubkey =
static_pubkey!("4UpD2fh7xH3VP9QQaXtsS1YY3bxzWhtfpks7FatyKvdY");
pub const LENDING_MARKET_AUTHORITY: Pubkey =
static_pubkey!("DdZR6zRFiUt4S5mg7AV1uKB2z1f1WzcNYCaTEEWPAuby");
pub const PYTH_PRICE_ACCOUNT: Pubkey =
static_pubkey!("3vxLXJqLqF3JG5TCbYycbKWRBbCJQLxQmBGCkyqEEefL");
pub const SWITCHBOARD_PRICE_ACCOUNT: Pubkey =
static_pubkey!("5mp8kbkTYwWWCsKSte8rURjTuyinsqBpJ9xAQsewPDD");
pub const PYTH_PROGRAM_ID: Pubkey =
static_pubkey!("FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH");
pub const SWITCHBOARD_PROGRAM_ID: Pubkey =
static_pubkey!("DtmE9D2CSB4L5D6A15mraeEjrGMm6auWVzgaD8hK2tZM");
pub const RESERVE_ACCOUNT: Pubkey =
static_pubkey!("8K9WC8xoh2rtQNY7iEGXtPvfbDCi563SdWhCAhuMP2xE");
pub const RESERVE_LIQUIDITY_ACCOUNT: Pubkey =
static_pubkey!("3CdpSW5dxM7RTxBgxeyt8nnnjqoDbZe48tsBs9QUrmuN");
pub const COLLATERAL_TOKEN_ACCOUNT: Pubkey =
static_pubkey!("8DPzi8QSpREME7hsFs3Pcf7Uzgi5Ranxe1HvUt8L8jBg");
pub fn platform_config() -> PlatformConfigAddresses {
PlatformConfigAddresses {
vault: ACCOUNT,
vault_pda: PDA,
information_account: INFORMATION_ACCOUNT,
config_data_account: CONFIG_DATA_ACCOUNT,
shares_mint: SHARES_MINT,
underlying_deposit_queue: UNDERLYING_DEPOSIT_QUEUE,
lending_program: PROGRAM_ID,
}
}
}
pub mod tulip {
use super::*;
pub const TAG_STRING: &str = "tulip";
pub const FARM_KEY: Farm = Farm::Lending {
name: Lending::USDT,
};
pub const ACCOUNT: Pubkey = static_pubkey!("HC3ah2Z1VNBHjavM3o9uCWnPniy5g9VgHSzbuuBvTMzT");
pub const PDA: Pubkey = static_pubkey!("GFFHxCNUB3EVUQt73N6E6icaqJUwRLSxHcYpvLvrDry");
pub const SHARES_MINT: Pubkey = static_pubkey!("FNQDs4ub4wFRnspu3JGcH79R2icxCggYm4BRAcc6Mnwp");
pub const UNDERLYING_COMPOUND_QUEUE: Pubkey =
static_pubkey!("Axa64R5SyuQdEkZ9xvAMzrWz5Kf88aPchKAhZQHbCpJG");
pub const UNDERLYING_DEPOSIT_QUEUE: Pubkey =
static_pubkey!("7dJHyjD5MZ2EBZRbe4PdRyKSHj4BuH7nLkV1fjgwU9za");
pub const UNDERLYING_WITHDRAW_QUEUE: Pubkey =
static_pubkey!("BehWgvqQoLdPDB1siPedWjDKgMX8mVrmvESM1bR5oGv4");
pub const UNDERLYING_MINT: Pubkey =
static_pubkey!("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB");
pub const CONFIG_DATA_ACCOUNT: Pubkey =
static_pubkey!("H6vGDBUBtydhDTCzqaGeenZEZVx1goR4Poq1MRAgSfgB");
pub const INFORMATION_ACCOUNT: Pubkey =
static_pubkey!("DpR4xJSoqE1BW7i2bmEkGPhtYpFF4McgM8V6oAgzgBxE");
pub const PROGRAM_ID: Pubkey = static_pubkey!("4bcFeLv4nydFrsZqV5CgwCVrPhkQKsXtzfy2KyMz7ozM");
pub const COLLATERAL_MINT: Pubkey =
static_pubkey!("gLhY2arqFpmVGkpbBbTi3TeWbsWevA8dqrwbKacK3vJ");
pub const LENDING_MARKET_ACCOUNT: Pubkey =
static_pubkey!("D1cqtVThyebK9KXKGXrCEuiqaNf5L4UfM1vHgCqiJxym");
pub const LENDING_MARKET_AUTHORITY: Pubkey =
static_pubkey!("8gEGZbUfVE1poBq71VHKX9LU7ca4x8wTUyZgcbyQe51s");
pub const PYTH_PRICE_ACCOUNT: Pubkey =
static_pubkey!("uo3MK2mD9KogjNLxTWVaB5XqA9Hg4mx4QuRm9SRtKdE");
pub const PYTH_PROGRAM_ID: Pubkey =
static_pubkey!("5JQ8Mhdp2wv3HWcfjq9Ts8kwzCAeBADFBDAgBznzRsE4");
pub const RESERVE_ACCOUNT: Pubkey =
static_pubkey!("Csn3exasdhDzxYApmnci3d8Khb629VmgK4NQqdeyZBNt");
pub const RESERVE_LIQUIDITY_ACCOUNT: Pubkey =
static_pubkey!("124J21csiR1FdDywteXa8LhAmeqBXZRvozhoE7zq9znc");
pub const COLLATERAL_TOKEN_ACCOUNT: Pubkey =
static_pubkey!("BD7AHG6GwNRj4xaTr9RZgJTpWfMJtZsARMzgnFvNYffm");
pub fn platform_config() -> PlatformConfigAddresses {
PlatformConfigAddresses {
vault: ACCOUNT,
vault_pda: PDA,
information_account: INFORMATION_ACCOUNT,
config_data_account: CONFIG_DATA_ACCOUNT,
shares_mint: SHARES_MINT,
underlying_deposit_queue: UNDERLYING_DEPOSIT_QUEUE,
lending_program: PROGRAM_ID,
}
}
}
pub mod mango {
use super::*;
pub const TAG_STRING: &str = "mango";
pub const FARM_KEY: Farm = Farm::Lending {
name: Lending::USDT,
};
pub const ACCOUNT: Pubkey = static_pubkey!("3Y9yqi2K4E4zsthNj2YP4sip59azSHA4qhwMkLxtokFZ");
pub const PDA: Pubkey = static_pubkey!("FQDN8oEuY5umdCjTRFwcxETwCiN9Zw2B92m9DEcvC8Hg");
pub const SHARES_MINT: Pubkey = static_pubkey!("56xxyq9Yi4kmy2WxvsHAKjLudMUorTbpcgQe1Uemt3oJ");
pub const UNDERLYING_COMPOUND_QUEUE: Pubkey =
static_pubkey!("BYamJDsGk6AWoA4z8D4myDNfZeiAqMsJ6B35GG4E6vFy");
pub const UNDERLYING_DEPOSIT_QUEUE: Pubkey =
static_pubkey!("G4EkAvPDjgWRWvweLRx5WJtCbQ5UmJD1JALADUwUNSsW");
pub const UNDERLYING_WITHDRAW_QUEUE: Pubkey =
static_pubkey!("ESMmJBo93jeeyPAcDRrSbLnNwccnyatqh5yV5VuwgpF5");
pub const UNDERLYING_MINT: Pubkey =
static_pubkey!("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB");
pub const CONFIG_DATA_ACCOUNT: Pubkey =
static_pubkey!("2T4fsgXC58v6j45no7SHG3Lfv41EkWyjx7VaMDEcftAK");
pub const INFORMATION_ACCOUNT: Pubkey =
static_pubkey!("3ouKmRBzRiemgHULi13sUxq9unNksHtinUa97g3tJX5c");
pub const PROGRAM_ID: Pubkey = static_pubkey!("mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68");
pub const CACHE: Pubkey = static_pubkey!("EBDRoayCDDUvDgCimta45ajQeXbexv7aKqJubruqpyvu");
pub const GROUP: Pubkey = static_pubkey!("98pjRuQjK3qA6gXts96PqZT4Ze5QmnCmt3QYjhbUSPue");
pub const GROUP_SIGNER: Pubkey = static_pubkey!("9BVcYqEQxyccuwznvxXqDkSJFavvTyheiTYk231T1A8S");
pub const GROUP_TOKEN_ACCOUNT: Pubkey =
static_pubkey!("GZGmwCc3CWrS2guzfTrvQNhiWcW4TVwSPo9Y8VVRxVXY");
pub const ROOT_BANK: Pubkey = static_pubkey!("4GYDmgvMpBx2n2iSmaS1xhZnwebR2gJ5V7UYUBA1PkJi");
pub const NODE_BANK: Pubkey = static_pubkey!("FYFJ4YHDEJnX7yVPoejUTAcKstnovTZpLq5zWAM7c6Uz");
pub const OPTIMIZER_MANGO_ACCOUNT: Pubkey =
static_pubkey!("FhLkZ4krKGzjLzJhMQHJt94gPpWdGNUkqYZKwtUGZFW");
pub fn platform_config() -> PlatformConfigAddresses {
PlatformConfigAddresses {
vault: ACCOUNT,
vault_pda: PDA,
information_account: INFORMATION_ACCOUNT,
config_data_account: CONFIG_DATA_ACCOUNT,
shares_mint: SHARES_MINT,
underlying_deposit_queue: UNDERLYING_DEPOSIT_QUEUE,
lending_program: PROGRAM_ID,
}
}
}