From d15dc2d43ee703637a6fd7388903397d57f83092 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Mon, 18 Nov 2024 16:43:10 -0500 Subject: [PATCH] update IDL v2.100.0 (#2) * IDL update to v2.100.0 * bump version 0.2.0 --- Cargo.lock | 114 ++++++++++++++++++++++++------------------------- Cargo.toml | 4 +- src/exports.rs | 14 ++++-- src/types.rs | 2 +- 4 files changed, 71 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c53204b..63982cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -288,9 +288,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "ark-bn254" @@ -672,18 +672,18 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26" +checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec" dependencies = [ "proc-macro2", "quote", @@ -698,9 +698,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.1.21" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -753,9 +753,9 @@ dependencies = [ [[package]] name = "const_panic" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7782af8f90fe69a4bb41e460abe1727d493403d8b2cc43201a3a3e906b24379f" +checksum = "013b6c2c3a14d678f38cd23994b02da3a1a1b6a5d1eedddfe63a5a5f11b13a81" [[package]] name = "constant_time_eq" @@ -780,9 +780,9 @@ checksum = "69f3b219d28b6e3b4ac87bc1fc522e0803ab22e055da177bff0068c4150c61a6" [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -944,8 +944,8 @@ dependencies = [ [[package]] name = "drift" -version = "2.96.0" -source = "git+https://github.com/drift-labs/protocol-v2.git?tag=v2.96.0#44fd13f7baa904669a8ec5754188358c62f38a30" +version = "2.100.0" +source = "git+https://github.com/drift-labs/protocol-v2.git?tag=v2.100.0#fee7bfa60f52274969500c37acbbe79bea847ba1" dependencies = [ "ahash 0.8.6", "anchor-lang", @@ -977,7 +977,7 @@ dependencies = [ [[package]] name = "drift-ffi-sys" -version = "0.1.0" +version = "0.2.0" dependencies = [ "abi_stable", "drift", @@ -1186,9 +1186,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "heck" @@ -1283,12 +1283,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.1", ] [[package]] @@ -1326,9 +1326,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -1362,9 +1362,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.159" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "libloading" @@ -1645,9 +1645,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "opaque-debug" @@ -1658,7 +1658,7 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openbook-v2-light" version = "0.1.0" -source = "git+https://github.com/drift-labs/protocol-v2.git?tag=v2.96.0#44fd13f7baa904669a8ec5754188358c62f38a30" +source = "git+https://github.com/drift-labs/protocol-v2.git?tag=v2.100.0#fee7bfa60f52274969500c37acbbe79bea847ba1" dependencies = [ "anchor-lang", "borsh 0.10.3", @@ -1953,18 +1953,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -1974,9 +1974,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -1985,9 +1985,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "repr_offset" @@ -2015,9 +2015,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "ryu" @@ -2074,9 +2074,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -2698,7 +2698,7 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "switchboard" version = "0.1.0" -source = "git+https://github.com/drift-labs/protocol-v2.git?tag=v2.96.0#44fd13f7baa904669a8ec5754188358c62f38a30" +source = "git+https://github.com/drift-labs/protocol-v2.git?tag=v2.100.0#fee7bfa60f52274969500c37acbbe79bea847ba1" dependencies = [ "anchor-lang", ] @@ -2706,7 +2706,7 @@ dependencies = [ [[package]] name = "switchboard-on-demand" version = "0.1.0" -source = "git+https://github.com/drift-labs/protocol-v2.git?tag=v2.96.0#44fd13f7baa904669a8ec5754188358c62f38a30" +source = "git+https://github.com/drift-labs/protocol-v2.git?tag=v2.100.0#fee7bfa60f52274969500c37acbbe79bea847ba1" dependencies = [ "anchor-lang", "bytemuck", @@ -2746,18 +2746,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", @@ -2965,9 +2965,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -2976,9 +2976,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", @@ -2991,9 +2991,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3001,9 +3001,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", @@ -3014,15 +3014,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 3eedac2..9b03354 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "drift-ffi-sys" -version = "0.1.0" +version = "0.2.0" edition = "2021" description = "FFI bindings to drift program" @@ -9,7 +9,7 @@ crate-type = ["cdylib"] [dependencies] abi_stable = "0.11" -drift-program = { package = "drift", git = "https://github.com/drift-labs/protocol-v2.git", tag = "v2.96.0", features = [ +drift-program = { package = "drift", git = "https://github.com/drift-labs/protocol-v2.git", tag = "v2.100.0", features = [ "mainnet-beta" ] } hex = "*" diff --git a/src/exports.rs b/src/exports.rs index c1beb27..18af1e1 100644 --- a/src/exports.rs +++ b/src/exports.rs @@ -102,7 +102,6 @@ pub extern "C" fn math_calculate_margin_requirement_and_total_collateral_and_lia let m = margin_calculation.map(|m| MarginCalculation { total_collateral: m.total_collateral.into(), margin_requirement: m.margin_requirement.into(), - all_oracles_valid: m.all_oracles_valid, with_perp_isolated_liability: m.with_perp_isolated_liability, with_spot_isolated_liability: m.with_spot_isolated_liability, total_spot_asset_value: m.total_spot_asset_value.into(), @@ -130,8 +129,9 @@ pub extern "C" fn perp_market_get_margin_ratio( market: &PerpMarket, size: compat::u128, margin_type: MarginRequirementType, + high_leverage_mode: bool, ) -> FfiResult { - to_ffi_result(market.get_margin_ratio(size.0, margin_type)) + to_ffi_result(market.get_margin_ratio(size.0, margin_type, high_leverage_mode)) } #[no_mangle] @@ -145,7 +145,7 @@ pub extern "C" fn perp_position_get_unrealized_pnl( oracle_price: i64, ) -> FfiResult { to_ffi_result(position.get_unrealized_pnl(oracle_price).map(compat::i128)) -} +} #[no_mangle] pub extern "C" fn perp_position_is_available(position: &PerpPosition) -> bool { @@ -195,6 +195,14 @@ pub extern "C" fn spot_market_get_liability_weight( to_ffi_result(market.get_liability_weight(size.0, &margin_requirement_type)) } +#[no_mangle] +pub extern "C" fn spot_market_get_margin_ratio( + market: &SpotMarket, + margin_type: MarginRequirementType, +) -> FfiResult { + to_ffi_result(market.get_margin_ratio(&margin_type)) +} + #[no_mangle] pub extern "C" fn spot_position_is_available(position: &SpotPosition) -> bool { position.is_available() diff --git a/src/types.rs b/src/types.rs index 328157e..2845e69 100644 --- a/src/types.rs +++ b/src/types.rs @@ -76,12 +76,12 @@ impl From for MarginContext { } } + #[repr(C, align(16))] #[derive(Copy, Clone, Debug, PartialEq, TypeLayout)] pub struct MarginCalculation { pub total_collateral: compat::i128, pub margin_requirement: compat::u128, - pub all_oracles_valid: bool, pub with_perp_isolated_liability: bool, pub with_spot_isolated_liability: bool, pub total_spot_asset_value: compat::i128,