spl: Remove `dex` feature (#3257)
This commit is contained in:
parent
e25918c609
commit
8d52c1c244
|
@ -395,10 +395,9 @@ jobs:
|
|||
path: tests/multisig
|
||||
# - cmd: cd tests/lockup && anchor test --skip-lint
|
||||
# path: tests/lockup
|
||||
# TODO: Remove `1.14.18` installation if/when https://github.com/solana-labs/solana/issues/31960 is solved
|
||||
# `swap` tests don't work with Solana `1.16.0`, downgrade to `1.14.18`
|
||||
- cmd: cd tests/swap/deps/openbook-dex/dex && solana-install init 1.14.18 && cargo build-bpf -- --locked && cd ../../../ && solana-install init $SOLANA_CLI_VERSION && anchor test --skip-lint
|
||||
path: tests/swap
|
||||
# TODO: Re-enable after making it work with Solana v2
|
||||
# - cmd: cd tests/swap/deps/openbook-dex/dex && solana-install init 1.14.18 && cargo build-bpf -- --locked && cd ../../../ && solana-install init $SOLANA_CLI_VERSION && anchor test --skip-lint
|
||||
# path: tests/swap
|
||||
- cmd: cd tests/escrow && anchor test --skip-lint && npx tsc --noEmit
|
||||
path: tests/escrow
|
||||
- cmd: cd tests/pyth && anchor test --skip-lint && npx tsc --noEmit
|
||||
|
|
|
@ -94,6 +94,7 @@ The minor version will be incremented upon a breaking change and the patch versi
|
|||
- ts: Remove `StateCoder`([#3224](https://github.com/coral-xyz/anchor/pull/3224)).
|
||||
- cli: Accept integers for `warp_slot` ([#3235](https://github.com/coral-xyz/anchor/pull/3235)).
|
||||
- lang: Remove `EventIndex` ([#3244](https://github.com/coral-xyz/anchor/pull/3244)).
|
||||
- spl: Remove `dex` feature ([#3257](https://github.com/coral-xyz/anchor/pull/3257)).
|
||||
|
||||
## [0.30.1] - 2024-06-20
|
||||
|
||||
|
|
|
@ -111,12 +111,6 @@ dependencies = [
|
|||
"alloc-no-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alloc-traits"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b2d54853319fd101b8dd81de382bcbf3e03410a64d8928bbee85a3e7dcde483"
|
||||
|
||||
[[package]]
|
||||
name = "anchor-attribute-access-control"
|
||||
version = "0.30.1"
|
||||
|
@ -314,11 +308,10 @@ dependencies = [
|
|||
"anchor-lang",
|
||||
"borsh 0.10.3",
|
||||
"mpl-token-metadata",
|
||||
"serum_dex",
|
||||
"spl-associated-token-account 3.0.2",
|
||||
"spl-memo",
|
||||
"spl-pod 0.2.2",
|
||||
"spl-token 4.0.0",
|
||||
"spl-token",
|
||||
"spl-token-2022 3.0.2",
|
||||
"spl-token-group-interface 0.2.3",
|
||||
"spl-token-metadata-interface 0.3.3",
|
||||
|
@ -1670,26 +1663,6 @@ dependencies = [
|
|||
"syn 2.0.55",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enumflags2"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83c8d82922337cd23a15f88b70d8e4ef5f11da38dd7cdb55e84dd5de99695da0"
|
||||
dependencies = [
|
||||
"enumflags2_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enumflags2_derive"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.3"
|
||||
|
@ -1748,16 +1721,6 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da"
|
||||
|
||||
[[package]]
|
||||
name = "field-offset"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
|
||||
dependencies = [
|
||||
"memoffset 0.9.0",
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filetime"
|
||||
version = "0.2.22"
|
||||
|
@ -2282,15 +2245,6 @@ version = "1.70.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
|
@ -2734,15 +2688,6 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9"
|
||||
dependencies = [
|
||||
"num_enum_derive 0.5.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.6.1"
|
||||
|
@ -2761,18 +2706,6 @@ dependencies = [
|
|||
"num_enum_derive 0.7.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799"
|
||||
dependencies = [
|
||||
"proc-macro-crate 1.3.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.6.1"
|
||||
|
@ -3563,12 +3496,6 @@ version = "1.0.15"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
||||
|
||||
[[package]]
|
||||
name = "safe-transmute"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98a01dab6acf992653be49205bdd549f32f17cb2803e8eacf1560bf97259aae8"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
|
@ -3748,29 +3675,6 @@ dependencies = [
|
|||
"unsafe-libyaml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serum_dex"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/openbook-dex/program/?rev=1be91f2#1be91f2863d8ecede32daaae7e768034e24bbc79"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"bincode",
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
"enumflags2",
|
||||
"field-offset",
|
||||
"itertools 0.9.0",
|
||||
"num-traits",
|
||||
"num_enum 0.5.11",
|
||||
"safe-transmute",
|
||||
"serde",
|
||||
"solana-program",
|
||||
"spl-token 3.5.0",
|
||||
"static_assertions",
|
||||
"thiserror",
|
||||
"without-alloc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.10.6"
|
||||
|
@ -3926,7 +3830,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"solana-config-program",
|
||||
"solana-sdk",
|
||||
"spl-token 4.0.0",
|
||||
"spl-token",
|
||||
"spl-token-2022 1.0.0",
|
||||
"spl-token-group-interface 0.1.0",
|
||||
"spl-token-metadata-interface 0.2.0",
|
||||
|
@ -4575,7 +4479,7 @@ dependencies = [
|
|||
"solana-sdk",
|
||||
"spl-associated-token-account 2.3.0",
|
||||
"spl-memo",
|
||||
"spl-token 4.0.0",
|
||||
"spl-token",
|
||||
"spl-token-2022 1.0.0",
|
||||
"thiserror",
|
||||
]
|
||||
|
@ -4728,7 +4632,7 @@ dependencies = [
|
|||
"num-derive 0.4.0",
|
||||
"num-traits",
|
||||
"solana-program",
|
||||
"spl-token 4.0.0",
|
||||
"spl-token",
|
||||
"spl-token-2022 1.0.0",
|
||||
"thiserror",
|
||||
]
|
||||
|
@ -4744,7 +4648,7 @@ dependencies = [
|
|||
"num-derive 0.4.0",
|
||||
"num-traits",
|
||||
"solana-program",
|
||||
"spl-token 4.0.0",
|
||||
"spl-token",
|
||||
"spl-token-2022 3.0.2",
|
||||
"thiserror",
|
||||
]
|
||||
|
@ -4932,21 +4836,6 @@ dependencies = [
|
|||
"spl-type-length-value 0.4.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spl-token"
|
||||
version = "3.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e85e168a785e82564160dcb87b2a8e04cee9bfd1f4d488c729d53d6a4bd300d"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"bytemuck",
|
||||
"num-derive 0.3.3",
|
||||
"num-traits",
|
||||
"num_enum 0.5.11",
|
||||
"solana-program",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spl-token"
|
||||
version = "4.0.0"
|
||||
|
@ -4978,7 +4867,7 @@ dependencies = [
|
|||
"solana-zk-token-sdk",
|
||||
"spl-memo",
|
||||
"spl-pod 0.1.1",
|
||||
"spl-token 4.0.0",
|
||||
"spl-token",
|
||||
"spl-token-group-interface 0.1.0",
|
||||
"spl-token-metadata-interface 0.2.0",
|
||||
"spl-transfer-hook-interface 0.4.1",
|
||||
|
@ -5002,7 +4891,7 @@ dependencies = [
|
|||
"solana-zk-token-sdk",
|
||||
"spl-memo",
|
||||
"spl-pod 0.2.2",
|
||||
"spl-token 4.0.0",
|
||||
"spl-token",
|
||||
"spl-token-group-interface 0.2.3",
|
||||
"spl-token-metadata-interface 0.3.3",
|
||||
"spl-transfer-hook-interface 0.6.3",
|
||||
|
@ -5122,12 +5011,6 @@ dependencies = [
|
|||
"spl-program-error 0.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "string_cache"
|
||||
version = "0.8.7"
|
||||
|
@ -5695,15 +5578,6 @@ version = "0.2.11"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
||||
|
||||
[[package]]
|
||||
name = "unsize"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fa7a7a734c1a5664a662ddcea0b6c9472a21da8888c957c7f1eaa09dba7a939"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
version = "0.7.1"
|
||||
|
@ -6080,16 +5954,6 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "without-alloc"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "375db0478b203b950ef10d1cce23cdbe5f30c2454fd9e7673ff56656df23adbb"
|
||||
dependencies = [
|
||||
"alloc-traits",
|
||||
"unsize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x509-parser"
|
||||
version = "0.14.0"
|
||||
|
|
|
@ -13,7 +13,6 @@ rustdoc-args = ["--cfg", "docsrs"]
|
|||
[features]
|
||||
default = ["associated_token", "mint", "token", "token_2022", "token_2022_extensions"]
|
||||
associated_token = ["spl-associated-token-account"]
|
||||
dex = ["serum_dex"]
|
||||
devnet = []
|
||||
governance = []
|
||||
idl-build = ["anchor-lang/idl-build"]
|
||||
|
@ -29,7 +28,6 @@ token_2022_extensions = ["spl-token-2022", "spl-token-group-interface", "spl-tok
|
|||
anchor-lang = { path = "../lang", version = "0.30.1", features = ["derive"] }
|
||||
borsh = { version = "0.10.3", optional = true }
|
||||
mpl-token-metadata = { version = "4", optional = true }
|
||||
serum_dex = { git = "https://github.com/openbook-dex/program/", rev = "1be91f2", version = "0.4.0", features = ["no-entrypoint"], optional = true }
|
||||
spl-associated-token-account = { version = "3", features = ["no-entrypoint"], optional = true }
|
||||
spl-memo = { version = "4", features = ["no-entrypoint"], optional = true }
|
||||
spl-token = { version = "4", features = ["no-entrypoint"], optional = true }
|
||||
|
|
299
spl/src/dex.rs
299
spl/src/dex.rs
|
@ -1,299 +0,0 @@
|
|||
use anchor_lang::solana_program::account_info::AccountInfo;
|
||||
use anchor_lang::solana_program::program_error::ProgramError;
|
||||
use anchor_lang::solana_program::pubkey::Pubkey;
|
||||
use anchor_lang::{context::CpiContext, Accounts, Result, ToAccountInfos};
|
||||
use serum_dex::instruction::SelfTradeBehavior;
|
||||
use serum_dex::matching::{OrderType, Side};
|
||||
use std::num::NonZeroU64;
|
||||
|
||||
pub use serum_dex;
|
||||
|
||||
#[cfg(not(feature = "devnet"))]
|
||||
anchor_lang::declare_id!("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX");
|
||||
|
||||
#[cfg(feature = "devnet")]
|
||||
anchor_lang::declare_id!("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj");
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new_order_v3<'info>(
|
||||
ctx: CpiContext<'_, '_, '_, 'info, NewOrderV3<'info>>,
|
||||
side: Side,
|
||||
limit_price: NonZeroU64,
|
||||
max_coin_qty: NonZeroU64,
|
||||
max_native_pc_qty_including_fees: NonZeroU64,
|
||||
self_trade_behavior: SelfTradeBehavior,
|
||||
order_type: OrderType,
|
||||
client_order_id: u64,
|
||||
limit: u16,
|
||||
) -> Result<()> {
|
||||
let referral = ctx.remaining_accounts.get(0);
|
||||
let ix = serum_dex::instruction::new_order(
|
||||
ctx.accounts.market.key,
|
||||
ctx.accounts.open_orders.key,
|
||||
ctx.accounts.request_queue.key,
|
||||
ctx.accounts.event_queue.key,
|
||||
ctx.accounts.market_bids.key,
|
||||
ctx.accounts.market_asks.key,
|
||||
ctx.accounts.order_payer_token_account.key,
|
||||
ctx.accounts.open_orders_authority.key,
|
||||
ctx.accounts.coin_vault.key,
|
||||
ctx.accounts.pc_vault.key,
|
||||
ctx.accounts.token_program.key,
|
||||
ctx.accounts.rent.key,
|
||||
referral.map(|r| r.key),
|
||||
&ID,
|
||||
side,
|
||||
limit_price,
|
||||
max_coin_qty,
|
||||
order_type,
|
||||
client_order_id,
|
||||
self_trade_behavior,
|
||||
limit,
|
||||
max_native_pc_qty_including_fees,
|
||||
)
|
||||
.map_err(|pe| ProgramError::from(pe))?;
|
||||
anchor_lang::solana_program::program::invoke_signed(
|
||||
&ix,
|
||||
&ToAccountInfos::to_account_infos(&ctx),
|
||||
ctx.signer_seeds,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cancel_order_v2<'info>(
|
||||
ctx: CpiContext<'_, '_, '_, 'info, CancelOrderV2<'info>>,
|
||||
side: Side,
|
||||
order_id: u128,
|
||||
) -> Result<()> {
|
||||
let ix = serum_dex::instruction::cancel_order(
|
||||
&ID,
|
||||
ctx.accounts.market.key,
|
||||
ctx.accounts.market_bids.key,
|
||||
ctx.accounts.market_asks.key,
|
||||
ctx.accounts.open_orders.key,
|
||||
ctx.accounts.open_orders_authority.key,
|
||||
ctx.accounts.event_queue.key,
|
||||
side,
|
||||
order_id,
|
||||
)
|
||||
.map_err(|pe| ProgramError::from(pe))?;
|
||||
anchor_lang::solana_program::program::invoke_signed(
|
||||
&ix,
|
||||
&ToAccountInfos::to_account_infos(&ctx),
|
||||
ctx.signer_seeds,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn settle_funds<'info>(ctx: CpiContext<'_, '_, '_, 'info, SettleFunds<'info>>) -> Result<()> {
|
||||
let referral = ctx.remaining_accounts.get(0);
|
||||
let ix = serum_dex::instruction::settle_funds(
|
||||
&ID,
|
||||
ctx.accounts.market.key,
|
||||
ctx.accounts.token_program.key,
|
||||
ctx.accounts.open_orders.key,
|
||||
ctx.accounts.open_orders_authority.key,
|
||||
ctx.accounts.coin_vault.key,
|
||||
ctx.accounts.coin_wallet.key,
|
||||
ctx.accounts.pc_vault.key,
|
||||
ctx.accounts.pc_wallet.key,
|
||||
referral.map(|r| r.key),
|
||||
ctx.accounts.vault_signer.key,
|
||||
)
|
||||
.map_err(|pe| ProgramError::from(pe))?;
|
||||
anchor_lang::solana_program::program::invoke_signed(
|
||||
&ix,
|
||||
&ToAccountInfos::to_account_infos(&ctx),
|
||||
ctx.signer_seeds,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn init_open_orders<'info>(
|
||||
ctx: CpiContext<'_, '_, '_, 'info, InitOpenOrders<'info>>,
|
||||
) -> Result<()> {
|
||||
let ix = serum_dex::instruction::init_open_orders(
|
||||
&ID,
|
||||
ctx.accounts.open_orders.key,
|
||||
ctx.accounts.authority.key,
|
||||
ctx.accounts.market.key,
|
||||
ctx.remaining_accounts.first().map(|acc| acc.key),
|
||||
)
|
||||
.map_err(|pe| ProgramError::from(pe))?;
|
||||
anchor_lang::solana_program::program::invoke_signed(
|
||||
&ix,
|
||||
&ToAccountInfos::to_account_infos(&ctx),
|
||||
ctx.signer_seeds,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn close_open_orders<'info>(
|
||||
ctx: CpiContext<'_, '_, '_, 'info, CloseOpenOrders<'info>>,
|
||||
) -> Result<()> {
|
||||
let ix = serum_dex::instruction::close_open_orders(
|
||||
&ID,
|
||||
ctx.accounts.open_orders.key,
|
||||
ctx.accounts.authority.key,
|
||||
ctx.accounts.destination.key,
|
||||
ctx.accounts.market.key,
|
||||
)
|
||||
.map_err(|pe| ProgramError::from(pe))?;
|
||||
anchor_lang::solana_program::program::invoke_signed(
|
||||
&ix,
|
||||
&ToAccountInfos::to_account_infos(&ctx),
|
||||
ctx.signer_seeds,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn sweep_fees<'info>(ctx: CpiContext<'_, '_, '_, 'info, SweepFees<'info>>) -> Result<()> {
|
||||
let ix = serum_dex::instruction::sweep_fees(
|
||||
&ID,
|
||||
ctx.accounts.market.key,
|
||||
ctx.accounts.pc_vault.key,
|
||||
ctx.accounts.sweep_authority.key,
|
||||
ctx.accounts.sweep_receiver.key,
|
||||
ctx.accounts.vault_signer.key,
|
||||
ctx.accounts.token_program.key,
|
||||
)
|
||||
.map_err(|pe| ProgramError::from(pe))?;
|
||||
anchor_lang::solana_program::program::invoke_signed(
|
||||
&ix,
|
||||
&ToAccountInfos::to_account_infos(&ctx),
|
||||
ctx.signer_seeds,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn initialize_market<'info>(
|
||||
ctx: CpiContext<'_, '_, '_, 'info, InitializeMarket<'info>>,
|
||||
coin_lot_size: u64,
|
||||
pc_lot_size: u64,
|
||||
vault_signer_nonce: u64,
|
||||
pc_dust_threshold: u64,
|
||||
) -> Result<()> {
|
||||
let authority = ctx.remaining_accounts.get(0);
|
||||
let prune_authority = ctx.remaining_accounts.get(1);
|
||||
let ix = serum_dex::instruction::initialize_market(
|
||||
ctx.accounts.market.key,
|
||||
&ID,
|
||||
ctx.accounts.coin_mint.key,
|
||||
ctx.accounts.pc_mint.key,
|
||||
ctx.accounts.coin_vault.key,
|
||||
ctx.accounts.pc_vault.key,
|
||||
authority.map(|r| r.key),
|
||||
prune_authority.map(|r| r.key),
|
||||
ctx.accounts.bids.key,
|
||||
ctx.accounts.asks.key,
|
||||
ctx.accounts.req_q.key,
|
||||
ctx.accounts.event_q.key,
|
||||
coin_lot_size,
|
||||
pc_lot_size,
|
||||
vault_signer_nonce,
|
||||
pc_dust_threshold,
|
||||
)
|
||||
.map_err(|pe| ProgramError::from(pe))?;
|
||||
anchor_lang::solana_program::program::invoke_signed(
|
||||
&ix,
|
||||
&ToAccountInfos::to_account_infos(&ctx),
|
||||
ctx.signer_seeds,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct NewOrderV3<'info> {
|
||||
pub market: AccountInfo<'info>,
|
||||
pub open_orders: AccountInfo<'info>,
|
||||
pub request_queue: AccountInfo<'info>,
|
||||
pub event_queue: AccountInfo<'info>,
|
||||
pub market_bids: AccountInfo<'info>,
|
||||
pub market_asks: AccountInfo<'info>,
|
||||
// Token account where funds are transferred from for the order. If
|
||||
// posting a bid market A/B, then this is the SPL token account for B.
|
||||
pub order_payer_token_account: AccountInfo<'info>,
|
||||
pub open_orders_authority: AccountInfo<'info>,
|
||||
// Also known as the "base" currency. For a given A/B market,
|
||||
// this is the vault for the A mint.
|
||||
pub coin_vault: AccountInfo<'info>,
|
||||
// Also known as the "quote" currency. For a given A/B market,
|
||||
// this is the vault for the B mint.
|
||||
pub pc_vault: AccountInfo<'info>,
|
||||
pub token_program: AccountInfo<'info>,
|
||||
pub rent: AccountInfo<'info>,
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct CancelOrderV2<'info> {
|
||||
pub market: AccountInfo<'info>,
|
||||
pub market_bids: AccountInfo<'info>,
|
||||
pub market_asks: AccountInfo<'info>,
|
||||
pub open_orders: AccountInfo<'info>,
|
||||
pub open_orders_authority: AccountInfo<'info>,
|
||||
pub event_queue: AccountInfo<'info>,
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct SettleFunds<'info> {
|
||||
pub market: AccountInfo<'info>,
|
||||
pub open_orders: AccountInfo<'info>,
|
||||
pub open_orders_authority: AccountInfo<'info>,
|
||||
pub coin_vault: AccountInfo<'info>,
|
||||
pub pc_vault: AccountInfo<'info>,
|
||||
pub coin_wallet: AccountInfo<'info>,
|
||||
pub pc_wallet: AccountInfo<'info>,
|
||||
pub vault_signer: AccountInfo<'info>,
|
||||
pub token_program: AccountInfo<'info>,
|
||||
}
|
||||
|
||||
/// To use an (optional) market authority, add it as the first account of the
|
||||
/// CpiContext's `remaining_accounts` Vec.
|
||||
#[derive(Accounts)]
|
||||
pub struct InitOpenOrders<'info> {
|
||||
pub open_orders: AccountInfo<'info>,
|
||||
pub authority: AccountInfo<'info>,
|
||||
pub market: AccountInfo<'info>,
|
||||
pub rent: AccountInfo<'info>,
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct CloseOpenOrders<'info> {
|
||||
pub open_orders: AccountInfo<'info>,
|
||||
pub authority: AccountInfo<'info>,
|
||||
pub destination: AccountInfo<'info>,
|
||||
pub market: AccountInfo<'info>,
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct SweepFees<'info> {
|
||||
pub market: AccountInfo<'info>,
|
||||
pub pc_vault: AccountInfo<'info>,
|
||||
pub sweep_authority: AccountInfo<'info>,
|
||||
pub sweep_receiver: AccountInfo<'info>,
|
||||
pub vault_signer: AccountInfo<'info>,
|
||||
pub token_program: AccountInfo<'info>,
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct InitializeMarket<'info> {
|
||||
pub market: AccountInfo<'info>,
|
||||
pub coin_mint: AccountInfo<'info>,
|
||||
pub pc_mint: AccountInfo<'info>,
|
||||
pub coin_vault: AccountInfo<'info>,
|
||||
pub pc_vault: AccountInfo<'info>,
|
||||
pub bids: AccountInfo<'info>,
|
||||
pub asks: AccountInfo<'info>,
|
||||
pub req_q: AccountInfo<'info>,
|
||||
pub event_q: AccountInfo<'info>,
|
||||
pub rent: AccountInfo<'info>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Dex;
|
||||
|
||||
impl anchor_lang::Id for Dex {
|
||||
fn id() -> Pubkey {
|
||||
ID
|
||||
}
|
||||
}
|
|
@ -20,9 +20,6 @@ pub mod token_2022_extensions;
|
|||
#[cfg(feature = "token_2022")]
|
||||
pub mod token_interface;
|
||||
|
||||
#[cfg(feature = "dex")]
|
||||
pub mod dex;
|
||||
|
||||
#[cfg(feature = "governance")]
|
||||
pub mod governance;
|
||||
|
||||
|
|
|
@ -17,5 +17,5 @@ idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]
|
|||
|
||||
[dependencies]
|
||||
anchor-lang = { path = "../../../../lang" }
|
||||
anchor-spl = { path = "../../../../spl", features = ["dex"] }
|
||||
anchor-spl = { path = "../../../../spl" }
|
||||
serum_dex = { git = "https://github.com/openbook-dex/program", rev = "1be91f2", version = "0.4.0", features = ["no-entrypoint"] }
|
||||
|
|
Loading…
Reference in New Issue