@@ -15,11 +15,11 @@ use drift_program::{
1515 oracle:: { get_oracle_price as get_oracle_price_, OraclePriceData , OracleSource } ,
1616 oracle_map:: OracleMap ,
1717 order_params:: PlaceOrderOptions ,
18- perp_market:: { ContractType , PerpMarket } ,
18+ perp_market:: { ContractType , PerpMarket , AMM } ,
1919 perp_market_map:: PerpMarketMap ,
2020 protected_maker_mode_config:: ProtectedMakerParams ,
2121 revenue_share:: RevenueShareOrder ,
22- spot_market:: SpotMarket ,
22+ spot_market:: { SpotBalanceType , SpotMarket } ,
2323 spot_market_map:: SpotMarketMap ,
2424 state:: { FeeTier , State , ValidityGuardRails } ,
2525 user:: { Order , PerpPosition , SpotPosition , User } ,
@@ -149,6 +149,16 @@ pub extern "C" fn math_calculate_margin_requirement_and_total_collateral_and_lia
149149 to_ffi_result ( m)
150150}
151151
152+ #[ no_mangle]
153+ pub extern "C" fn math_calculate_net_user_pnl (
154+ amm : & AMM ,
155+ oracle_price : i64 ,
156+ ) -> FfiResult < compat:: i128 > {
157+ to_ffi_result (
158+ drift_program:: math:: amm:: calculate_net_user_pnl ( amm, oracle_price) . map ( compat:: i128) ,
159+ )
160+ }
161+
152162#[ no_mangle]
153163pub extern "C" fn simulate_update_amm (
154164 market : & mut PerpMarket ,
@@ -413,6 +423,19 @@ pub extern "C" fn perp_position_get_unrealized_pnl(
413423 to_ffi_result ( position. get_unrealized_pnl ( oracle_price) . map ( compat:: i128) )
414424}
415425
426+ #[ no_mangle]
427+ pub extern "C" fn perp_position_get_claimable_pnl (
428+ position : & PerpPosition ,
429+ oracle_price : i64 ,
430+ pnl_pool_excess : compat:: i128 ,
431+ ) -> FfiResult < compat:: i128 > {
432+ to_ffi_result (
433+ position
434+ . get_claimable_pnl ( oracle_price, pnl_pool_excess. 0 )
435+ . map ( compat:: i128) ,
436+ )
437+ }
438+
416439#[ no_mangle]
417440pub extern "C" fn perp_position_is_available ( position : & PerpPosition ) -> bool {
418441 position. is_available ( )
@@ -481,6 +504,18 @@ pub extern "C" fn spot_position_get_token_amount(
481504 to_ffi_result ( position. get_token_amount ( market) . map ( compat:: u128) )
482505}
483506
507+ #[ no_mangle]
508+ pub extern "C" fn spot_balance_get_token_amount (
509+ balance : compat:: u128 ,
510+ spot_market : & SpotMarket ,
511+ balance_type : & SpotBalanceType ,
512+ ) -> FfiResult < compat:: u128 > {
513+ to_ffi_result (
514+ drift_program:: math:: spot_balance:: get_token_amount ( balance. 0 , spot_market, balance_type)
515+ . map ( compat:: u128) ,
516+ )
517+ }
518+
484519#[ no_mangle]
485520pub extern "C" fn user_get_spot_position (
486521 user : & User ,
0 commit comments