Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/no-cashing-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ jobs:
path: tests/interface
- cmd: cd tests/lockup && anchor test --skip-lint
path: tests/lockup
- cmd: cd tests/swap/deps/serum-dex/dex && cargo build-bpf -- --locked && cd ../../../ && anchor test --skip-lint
- cmd: cd tests/swap/deps/openbook-dex/dex && cargo build-bpf -- --locked && cd ../../../ && anchor test --skip-lint
path: tests/swap
- cmd: cd tests/escrow && anchor test --skip-lint && npx tsc --noEmit
path: tests/escrow
Expand All @@ -271,7 +271,7 @@ jobs:
path: tests/chat
- cmd: cd tests/ido-pool && anchor test --skip-lint
path: tests/ido-pool
- cmd: cd tests/cfo && anchor run test-with-build && cd deps/stake && git checkout Cargo.lock && cd ../swap && git checkout Cargo.lock
- cmd: cd tests/cfo && anchor run test-with-build && cd deps/stake && git checkout Cargo.lock
path: tests/cfo
- cmd: cd tests/auction-house && yarn --frozen-lockfile && anchor test --skip-lint && git checkout Cargo.lock
path: tests/auction-house
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ jobs:
path: tests/interface
- cmd: cd tests/lockup && anchor test --skip-lint
path: tests/lockup
- cmd: cd tests/swap/deps/serum-dex/dex && cargo build-bpf -- --locked && cd ../../../ && anchor test --skip-lint
- cmd: cd tests/swap/deps/openbook-dex/dex && cargo build-bpf -- --locked && cd ../../../ && anchor test --skip-lint
path: tests/swap
- cmd: cd tests/escrow && anchor test --skip-lint && npx tsc --noEmit
path: tests/escrow
Expand All @@ -384,7 +384,7 @@ jobs:
path: tests/chat
- cmd: cd tests/ido-pool && anchor test --skip-lint
path: tests/ido-pool
- cmd: cd tests/cfo && anchor run test-with-build && cd deps/stake && git checkout Cargo.lock && cd ../swap && git checkout Cargo.lock
- cmd: cd tests/cfo && anchor run test-with-build && cd deps/stake && git checkout Cargo.lock
path: tests/cfo
- cmd: cd tests/auction-house && yarn --frozen-lockfile && anchor test --skip-lint && git checkout Cargo.lock
path: tests/auction-house
Expand Down
9 changes: 3 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[submodule "examples/swap/deps/serum-dex"]
path = tests/swap/deps/serum-dex
url = https://github.com/project-serum/serum-dex
[submodule "examples/cfo/deps/serum-dex"]
path = tests/cfo/deps/serum-dex
url = https://github.com/project-serum/serum-dex
[submodule "examples/cfo/deps/swap"]
path = tests/cfo/deps/swap
url = https://github.com/project-serum/swap.git
Expand All @@ -19,3 +13,6 @@
path = tests/auction-house
url = https://github.com/armaniferrante/auction-house
branch = armani/pda
[submodule "tests/swap/deps/openbook-dex"]
path = tests/swap/deps/openbook-dex
url = https://github.com/openbook-dex/program
49 changes: 25 additions & 24 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ members = [
"spl",
]
exclude = [
"tests/swap/deps/serum-dex",
"tests/cfo/deps/serum-dex",
"tests/permissioned-markets/deps/serum-dex",
"tests/swap/deps/openbook-dex",
"tests/cfo/deps/openbook-dex",
"tests/permissioned-markets/deps/openbook-dex",
]
2 changes: 1 addition & 1 deletion docs/src/pages/docs/manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Example

```toml
[[test.genesis]]
address = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"
address = "srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"
program = "dex.so"

[[test.genesis]]
Expand Down
4 changes: 2 additions & 2 deletions spl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ shmem = []
stake = ["borsh"]
devnet = []
metadata = ["mpl-token-metadata"]
dex = ["serum_dex"]
dex = ["openbook_dex"]

[dependencies]
anchor-lang = { path = "../lang", version = "0.25.0", features = ["derive"] }
borsh = { version = "^0.9", optional = true }
serum_dex = { git = "https://github.com/project-serum/serum-dex", rev = "1be91f2", version = "0.4.0", features = ["no-entrypoint"], optional = true }
openbook_dex = { version = "0.5.6", features = ["no-entrypoint"], optional = true }
solana-program = "1.13.5"
spl-token = { version = "3.5.0", features = ["no-entrypoint"], optional = true }
spl-associated-token-account = { version = "1.1.1", features = ["no-entrypoint"], optional = true }
Expand Down
28 changes: 16 additions & 12 deletions spl/src/dex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ 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 openbook_dex::instruction::SelfTradeBehavior;
use openbook_dex::matching::{OrderType, Side};
use std::num::NonZeroU64;

pub use serum_dex;
pub use openbook_dex;

#[cfg(not(feature = "devnet"))]
anchor_lang::solana_program::declare_id!("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin");
anchor_lang::solana_program::declare_id!("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX");

#[cfg(feature = "devnet")]
anchor_lang::solana_program::declare_id!("DESVgJVGajEgKGXhb6XmqDHGz3VjdgP7rEVESBgxmroY");
anchor_lang::solana_program::declare_id!("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj");

#[allow(clippy::too_many_arguments)]
pub fn new_order_v3<'info>(
Expand All @@ -25,9 +25,10 @@ pub fn new_order_v3<'info>(
order_type: OrderType,
client_order_id: u64,
limit: u16,
max_ts: i64,
) -> Result<()> {
let referral = ctx.remaining_accounts.get(0);
let ix = serum_dex::instruction::new_order(
let ix = openbook_dex::instruction::new_order(
ctx.accounts.market.key,
ctx.accounts.open_orders.key,
ctx.accounts.request_queue.key,
Expand All @@ -50,6 +51,7 @@ pub fn new_order_v3<'info>(
self_trade_behavior,
limit,
max_native_pc_qty_including_fees,
max_ts,
)
.map_err(|pe| ProgramError::from(pe))?;
solana_program::program::invoke_signed(
Expand All @@ -65,7 +67,7 @@ pub fn cancel_order_v2<'info>(
side: Side,
order_id: u128,
) -> Result<()> {
let ix = serum_dex::instruction::cancel_order(
let ix = openbook_dex::instruction::cancel_order(
&ID,
ctx.accounts.market.key,
ctx.accounts.market_bids.key,
Expand All @@ -87,7 +89,7 @@ pub fn cancel_order_v2<'info>(

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(
let ix = openbook_dex::instruction::settle_funds(
&ID,
ctx.accounts.market.key,
ctx.accounts.token_program.key,
Expand All @@ -112,7 +114,7 @@ pub fn settle_funds<'info>(ctx: CpiContext<'_, '_, '_, 'info, SettleFunds<'info>
pub fn init_open_orders<'info>(
ctx: CpiContext<'_, '_, '_, 'info, InitOpenOrders<'info>>,
) -> Result<()> {
let ix = serum_dex::instruction::init_open_orders(
let ix = openbook_dex::instruction::init_open_orders(
&ID,
ctx.accounts.open_orders.key,
ctx.accounts.authority.key,
Expand All @@ -131,7 +133,7 @@ pub fn init_open_orders<'info>(
pub fn close_open_orders<'info>(
ctx: CpiContext<'_, '_, '_, 'info, CloseOpenOrders<'info>>,
) -> Result<()> {
let ix = serum_dex::instruction::close_open_orders(
let ix = openbook_dex::instruction::close_open_orders(
&ID,
ctx.accounts.open_orders.key,
ctx.accounts.authority.key,
Expand All @@ -148,7 +150,7 @@ pub fn close_open_orders<'info>(
}

pub fn sweep_fees<'info>(ctx: CpiContext<'_, '_, '_, 'info, SweepFees<'info>>) -> Result<()> {
let ix = serum_dex::instruction::sweep_fees(
let ix = openbook_dex::instruction::sweep_fees(
&ID,
ctx.accounts.market.key,
ctx.accounts.pc_vault.key,
Expand All @@ -175,7 +177,8 @@ pub fn initialize_market<'info>(
) -> Result<()> {
let authority = ctx.remaining_accounts.get(0);
let prune_authority = ctx.remaining_accounts.get(1);
let ix = serum_dex::instruction::initialize_market(
let consume_events_authority = ctx.remaining_accounts.get(2);
let ix = openbook_dex::instruction::initialize_market(
ctx.accounts.market.key,
&ID,
ctx.accounts.coin_mint.key,
Expand All @@ -184,6 +187,7 @@ pub fn initialize_market<'info>(
ctx.accounts.pc_vault.key,
authority.map(|r| r.key),
prune_authority.map(|r| r.key),
consume_events_authority.map(|r| r.key),
ctx.accounts.bids.key,
ctx.accounts.asks.key,
ctx.accounts.req_q.key,
Expand Down
7 changes: 3 additions & 4 deletions tests/cfo/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ test-with-build = "anchor run build && anchor test --skip-build --skip-lint"
# Build the program and all CPI dependencies.
#
build = "anchor run build-deps && anchor build --skip-lint"
build-deps = "anchor run build-dex && anchor run build-swap && anchor run build-stake"
build-dex = "pushd deps/serum-dex/dex/ && cargo build-bpf && popd"
build-deps = "anchor run build-swap && anchor run build-stake"
build-swap = "cd deps/swap && pwd && anchor build --skip-lint && cd ../../"
build-stake = "pushd deps/stake && anchor build --skip-lint && popd"
#
Expand All @@ -27,8 +26,8 @@ build-stake = "pushd deps/stake && anchor build --skip-lint && popd"
localnet = "./scripts/localnet.sh"

[[test.genesis]]
address = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"
program = "./deps/serum-dex/dex/target/deploy/serum_dex.so"
address = "srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"
program = "./deps/openbook-dex/dex/target/deploy/openbook_dex.so"

[[test.genesis]]
address = "22Y43yTVxuUkoRKdm9thyRhQ3SdgQS7c7kB6UNCiaczD"
Expand Down
2 changes: 1 addition & 1 deletion tests/cfo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [
"programs/*"
]
exclude = [
"deps/serum-dex",
"deps/openbook-dex",
"deps/stake",
"deps/swap"
]
1 change: 0 additions & 1 deletion tests/cfo/deps/serum-dex
Submodule serum-dex deleted from ed9d54
2 changes: 1 addition & 1 deletion tests/cfo/programs/cfo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ anchor-lang = { path = "../../../../lang" }
anchor-spl = { path = "../../../../spl" }
spl-token = { version = "3.5.0", features = ["no-entrypoint"] }
swap = { path = "../../deps/swap/programs/swap", features = ["cpi"] }
serum_dex = { path = "../../deps/serum-dex/dex", features = ["no-entrypoint"] }
openbook_dex = { version = "0.5.6", features = ["no-entrypoint"] }
registry = { path = "../../deps/stake/programs/registry", features = ["cpi"] }
lockup = { path = "../../deps/stake/programs/lockup", features = ["cpi"] }
2 changes: 1 addition & 1 deletion tests/cfo/programs/cfo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use anchor_lang::solana_program::sysvar::instructions as tx_instructions;
use anchor_spl::dex::{self, Dex};
use anchor_spl::token::{self, Mint, Token, TokenAccount};
use lockup::program::Lockup;
use openbook_dex::state::OpenOrders;
use registry::program::Registry;
use registry::{Registrar, RewardVendorKind};
use serum_dex::state::OpenOrders;
use std::convert::TryInto;
use std::mem::size_of;
use swap::program::Swap;
Expand Down
2 changes: 1 addition & 1 deletion tests/cfo/scripts/fees.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const secret = JSON.parse(fs.readFileSync("./scripts/market-maker.json"));
const MARKET_MAKER = new Account(secret);
const PublicKey = anchor.web3.PublicKey;

const DEX_PID = new PublicKey("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin");
const DEX_PID = new PublicKey("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX");

async function main() {
const market = new PublicKey(process.argv[2]);
Expand Down
4 changes: 2 additions & 2 deletions tests/cfo/scripts/localnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

source scripts/common.sh

DEX_PID="9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"
DEX_PID="srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"
PAYER_FILEPATH="$HOME/.config/solana/id.json"
CRANK="/home/armaniferrante/Documents/code/src/github.com/project-serum/serum-dex/target/debug/crank"
VALIDATOR_OUT="./validator-stdout.txt"
Expand All @@ -23,7 +23,7 @@ main () {

echo "Starting local network..."
solana-test-validator \
--bpf-program 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin ./deps/serum-dex/dex/target/deploy/serum_dex.so \
--bpf-program srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX ./deps/serum-dex/dex/target/deploy/serum_dex.so \
--bpf-program 22Y43yTVxuUkoRKdm9thyRhQ3SdgQS7c7kB6UNCiaczD ./deps/swap/target/deploy/swap.so \
--bpf-program GrAkKfEpTKQuVHG2Y97Y2FF4i7y7Q5AHLK94JBy7Y5yv ./deps/stake/target/deploy/registry.so \
--bpf-program 6ebQNeTPZ1j7k3TtkCCtEPRvG7GQsucQrZ7sSEDQi9Ks ./deps/stake/target/deploy/lockup.so \
Expand Down
2 changes: 1 addition & 1 deletion tests/cfo/tests/cfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { PublicKey, SystemProgram, Keypair, SYSVAR_RENT_PUBKEY } = anchor.web3;
const utils = require("./utils");
const { setupStakePool } = require("./utils/stake");

const DEX_PID = new PublicKey("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin");
const DEX_PID = new PublicKey("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX");
const SWAP_PID = new PublicKey("22Y43yTVxuUkoRKdm9thyRhQ3SdgQS7c7kB6UNCiaczD");
const TOKEN_PID = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
const REGISTRY_PID = new PublicKey(
Expand Down
2 changes: 1 addition & 1 deletion tests/cfo/tests/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Account = web3.Account;
const Transaction = web3.Transaction;
const PublicKey = web3.PublicKey;
const SystemProgram = web3.SystemProgram;
const DEX_PID = new PublicKey("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin");
const DEX_PID = new PublicKey("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX");
const secret = JSON.parse(
require("fs").readFileSync("./scripts/market-maker.json")
);
Expand Down
4 changes: 2 additions & 2 deletions tests/swap/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ wallet = "~/.config/solana/id.json"
swap = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"

[[test.genesis]]
address = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"
program = "./deps/serum-dex/dex/target/deploy/serum_dex.so"
address = "srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"
program = "./deps/openbook-dex/dex/target/deploy/openbook_dex.so"

[scripts]
test = "yarn run mocha -t 1000000 tests/"
Expand Down
2 changes: 1 addition & 1 deletion tests/swap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ members = [
"programs/*"
]
exclude = [
"deps/serum-dex"
"deps/opendex-dex"
]
2 changes: 1 addition & 1 deletion tests/swap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ git submodule update
Build it

```
cd deps/serum-dex/dex/ && cargo build-bpf && cd ../../../
cd deps/openbook-dex/dex/ && cargo build-bpf && cd ../../../
```

### Run the Test
Expand Down
1 change: 1 addition & 0 deletions tests/swap/deps/openbook-dex
Submodule openbook-dex added at 719147
1 change: 0 additions & 1 deletion tests/swap/deps/serum-dex
Submodule serum-dex deleted from 542064
2 changes: 1 addition & 1 deletion tests/swap/programs/swap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ default = []
[dependencies]
anchor-lang = { path = "../../../../lang" }
anchor-spl = { path = "../../../../spl", features = ["dex"] }
serum_dex = { git = "https://github.com/project-serum/serum-dex", rev = "1be91f2", version = "0.4.0", features = ["no-entrypoint"] }
openbook_dex = { version = "0.5.6", features = ["no-entrypoint"] }
Loading