Preparing search index...
The search index is not available
@drift-labs/sdk
@drift-labs/sdk
calculatePositionFundingPNL
Function calculatePositionFundingPNL
calculate
Position
FundingPNL
(
market
:
PerpMarketAccount
, perpPosition
:
PerpPosition
)
:
BN
Returns
// QUOTE_PRECISION
Parameters
market:
PerpMarketAccount
perpPosition:
PerpPosition
Returns
BN
Settings
Member Visibility
Protected
Private
Inherited
External
Theme
OS
Light
Dark
Modules
@drift-
labs/sdk
BN
pyth
Confirmation
Strategy
Delisted
Market
Setting
Exchange
Status
Helius
Priority
Level
Insurance
Fund
Operation
Perp
Operation
Place
And
Take
Order
Success
Condition
Priority
Fee
Method
Spot
Operation
Trade
Side
User
Status
Admin
Client
Asset
Tier
Auction
Subscriber
Average
Over
Slots
Strategy
Average
Strategy
BN
Basic
User
Account
Subscriber
Big
Num
Blockhash
Subscriber
Bulk
Account
Loader
Chain
Clock
Clock
Subscriber
Contract
Tier
Contract
Type
DLOB
DLOBApi
Client
DLOBOrders
Coder
DLOBSubscriber
Deposit
Direction
Deposit
Explanation
Drift
Client
Event
Subscriber
Ewma
Strategy
Fast
Single
Tx
Sender
Floating
Limit
Order
Node
Forward
Only
Tx
Sender
Jupiter
Client
LPAction
Liquidation
Type
Log
Parser
Market
Order
Node
Market
Status
Market
Type
Max
Over
Slots
Strategy
Max
Strategy
Modify
Order
Policy
Node
List
Not
Subscribed
Error
One
Shot
User
Account
Subscriber
Openbook
V2
Fulfillment
Config
Map
Openbook
V2
Subscriber
Oracle
Source
Order
Action
Order
Action
Explanation
Order
Node
Order
Status
Order
Subscriber
Order
Trigger
Condition
Order
Type
Phoenix
Fulfillment
Config
Map
Phoenix
Subscriber
Polling
Drift
Client
Account
Subscriber
Polling
Insurance
Fund
Stake
Account
Subscriber
Polling
Log
Provider
Polling
Oracle
Account
Subscriber
Polling
Token
Account
Subscriber
Polling
User
Account
Subscriber
Polling
User
Stats
Account
Subscriber
Position
Direction
Post
Only
Params
Priority
Fee
Calculator
Priority
Fee
Subscriber
Priority
Fee
Subscriber
Map
Public
Key
Pyth
Client
Resting
Limit
Order
Node
Retry
Tx
Sender
Serum
Fulfillment
Config
Map
Serum
Subscriber
Settle
Pnl
Explanation
Settle
Pnl
Mode
Slot
Subscriber
Spot
Balance
Type
Spot
Fulfillment
Config
Status
Spot
Fulfillment
Status
Spot
Fulfillment
Type
Stake
Action
Strict
Oracle
Price
Swap
Direction
Swap
Reduce
Only
Taking
Limit
Order
Node
Test
Client
Token
Faucet
Transaction
Confirmation
Manager
Trigger
Order
Node
Tx
Event
Cache
Tx
Handler
Tx
Send
Error
User
User
Map
User
Stats
User
Stats
Map
Wallet
Web
Socket
Drift
Client
Account
Subscriber
Web
Socket
Insurance
Fund
Stake
Account
Subscriber
Web
Socket
Log
Provider
While
Valid
Tx
Sender
Account
Subscriber
Auction
Subscriber
Events
Clock
Subscriber
Event
DLOBNode
DLOBNode
Generator
DLOBSource
DLOBSubscriber
Events
Drift
Client
Account
Events
Drift
Client
Account
Subscriber
Drift
Client
Metrics
Events
Event
Subscriber
Events
Fee
IVersioned
Wallet
IWallet
Insurance
Fund
Stake
Account
Events
Insurance
Fund
Stake
Account
Subscriber
L2
Order
Book
Generator
Log
Provider
Market
Info
Oracle
Account
Subscriber
Oracle
Client
Oracle
Events
Order
Subscriber
Events
Platform
Fee
Priority
Fee
Strategy
Program
Account
Subscriber
Quote
Response
Route
Route
Plan
Step
Slot
Source
Slot
Subscriber
Events
Swap
Info
Token
Account
Events
Token
Account
Subscriber
Tx
Sender
User
Account
Events
User
Account
Subscriber
User
Map
Interface
User
Stats
Account
Events
User
Stats
Account
Subscriber
AMM
Account
To
Load
Account
To
Poll
Asset
Type
Auction
Subscriber
Config
BSOL_
EMISSIONS_
API_
RESPONSE
BSOL_
STATS_
API_
RESPONSE
Base
Tx
Params
Buffer
And
Slot
Candle
Resolution
Chain
Click
Initialisation
Props
Chain
Clock
Progress
Chain
Clock
State
Chain
Clock
Update
Props
Curve
Record
DLOBFilter
Fcn
DLOBNode
Map
DLOBNode
Type
DLOBOrder
DLOBOrders
DLOBSubscription
Config
Data
And
Slot
Deposit
Record
Drift
Client
Config
Drift
Client
Subscription
Config
Drift
Env
Drift
Event
Drift
Market
Info
Drift
Priority
Fee
Levels
Drift
Priority
Fee
Response
Event
Event
Map
Event
Subscription
Options
Event
Subscription
Order
By
Event
Subscription
Order
Direction
Event
Type
Events
Server
Log
Provider
Config
Fee
Structure
Fee
Tier
Funding
Payment
Record
Funding
Rate
Record
Health
Component
Health
Components
Helius
Priority
Fee
Levels
Helius
Priority
Fee
Response
Historical
Index
Data
Historical
Oracle
Data
Insurance
Fund
Record
Insurance
Fund
Stake
Insurance
Fund
Stake
Record
JITO_
SOL_
METRICS_
ENDPOINT_
RESPONSE
L2
Level
L2
Order
Book
L3
Level
L3
Order
Book
LPRecord
Liquidate
Borrow
For
Perp
Pnl
Record
Liquidate
Perp
Pnl
For
Deposit
Record
Liquidate
Perp
Record
Liquidate
Spot
Record
Liquidation
Record
Log
Provider
Config
Log
Provider
Type
MSOL_
METRICS_
ENDPOINT_
RESPONSE
Maker
Info
Mapped
Record
Margin
Category
Market
Node
Lists
Market
Type
Str
Modify
Order
Params
Necessary
Order
Params
New
User
Record
Node
To
Fill
Node
To
Trigger
Openbook
V2
Fulfillment
Config
Account
Openbook
V2
Subscriber
Config
Optional
Order
Params
Oracle
Guard
Rails
Oracle
Info
Oracle
Price
Data
Oracles
To
Poll
Order
Order
Action
Record
Order
Fill
Simulation
Order
Filler
Reward
Structure
Order
Params
Order
Record
Order
Subscriber
Config
Perp
Bankruptcy
Record
Perp
Market
Account
Perp
Market
Config
Perp
Market
Extended
Info
Perp
Position
Phoenix
Market
Subscriber
Config
Phoenix
V1
Fulfillment
Config
Account
Polling
Log
Provider
Config
Pool
Balance
Prelaunch
Oracle
Price
Impact
Unit
Priority
Fee
Subscriber
Config
Priority
Fee
Subscriber
Map
Config
Processing
Tx
Params
Referrer
Info
Referrer
Name
Account
Resub
Opts
Serum
V3
Fulfillment
Config
Account
Settle
Pnl
Record
Signed
Tx
Data
Solana
Priority
Fee
Response
Sort
Direction
Sort
Fn
Spot
Bankruptcy
Record
Spot
Interest
Record
Spot
Market
Account
Spot
Market
Config
Spot
Market
Vault
Deposit
Record
Spot
Position
State
Account
Streaming
Log
Provider
Config
Swap
Mode
Swap
Record
Swift
Order
Params
Message
Swift
Server
Message
Swift
Trigger
Order
Params
Taker
Info
Tx
Building
Props
Tx
Handler
Config
Tx
Params
Tx
Sig
And
Slot
User
Account
User
Config
User
Stats
Account
User
Stats
Config
User
Stats
Subscription
Config
User
Subscription
Config
Web
Socket
Log
Provider
Config
Wrapped
Event
Wrapped
Events
log
Provider
Callback
ACCOUNT_
AGE_
DELETION_
CUTOFF_
SECONDS
AMM_
RESERVE_
PRECISION
AMM_
RESERVE_
PRECISION_
EXP
AMM_
TIMES_
PEG_
TO_
QUOTE_
PRECISION_
RATIO
AMM_
TO_
QUOTE_
PRECISION_
RATIO
ANCHOR_
TEST_
SWIFT_
ID
BASE_
PRECISION
BASE_
PRECISION_
EXP
BID_
ASK_
SPREAD_
PRECISION
BN_
MAX
COMPUTE_
UNITS_
DEFAULT
CONCENTRATION_
PRECISION
DEFAULT_
CONFIRMATION_
OPTS
DEFAULT_
MARKET_
NAME
DEFAULT_
PRIORITY_
FEE_
MAP_
FREQUENCY_
MS
DEFAULT_
REVENUE_
SINCE_
LAST_
FUNDING_
SPREAD_
RETREAT
DEFAULT_
TOP_
OF_
BOOK_
QUOTE_
AMOUNTS
DEFAULT_
USER_
NAME
DRIFT_
ORACLE_
RECEIVER_
ID
DRIFT_
PROGRAM_
ID
DUST_
POSITION_
SIZE
Default
Event
Subscription
Options
Default
Order
Params
Devnet
Perp
Markets
Devnet
Spot
Markets
EIGHT
FIVE
FIVE_
MINUTE
FOUR
FUEL_
START_
TS
FUEL_
WINDOW
FUNDING_
RATE_
BUFFER_
PRECISION
FUNDING_
RATE_
BUFFER_
PRECISION_
EXP
FUNDING_
RATE_
OFFSET_
DENOMINATOR
FUNDING_
RATE_
PRECISION
FUNDING_
RATE_
PRECISION_
EXP
GOV_
SPOT_
MARKET_
INDEX
IDLE_
TIME_
SLOTS
LAMPORTS_
EXP
LAMPORTS_
PRECISION
LIQUIDATION_
FEE_
PRECISION
LIQUIDATION_
PCT_
PRECISION
MARGIN_
PRECISION
MAX_
LEVERAGE
MAX_
LEVERAGE_
ORDER_
SIZE
MAX_
NAME_
LENGTH
MAX_
PREDICTION_
PRICE
Mainnet
Perp
Markets
Mainnet
Spot
Markets
NINE
ONE
ONE_
HOUR
ONE_
YEAR
OPEN_
ORDER_
MARGIN_
REQUIREMENT
PEG_
PRECISION
PEG_
PRECISION_
EXP
PERCENTAGE_
PRECISION
PERCENTAGE_
PRECISION_
EXP
PRICE_
DIV_
PEG
PRICE_
PRECISION
PRICE_
PRECISION_
EXP
PRICE_
TO_
QUOTE_
PRECISION
Perp
Markets
QUOTE_
PRECISION
QUOTE_
PRECISION_
EXP
QUOTE_
SPOT_
MARKET_
INDEX
SEVEN
SIX
SLOT_
TIME_
ESTIMATE_
MS
SPOT_
MARKET_
BALANCE_
PRECISION
SPOT_
MARKET_
BALANCE_
PRECISION_
EXP
SPOT_
MARKET_
CUMULATIVE_
INTEREST_
PRECISION
SPOT_
MARKET_
CUMULATIVE_
INTEREST_
PRECISION_
EXP
SPOT_
MARKET_
IMF_
PRECISION
SPOT_
MARKET_
IMF_
PRECISION_
EXP
SPOT_
MARKET_
RATE_
PRECISION
SPOT_
MARKET_
RATE_
PRECISION_
EXP
SPOT_
MARKET_
UTILIZATION_
PRECISION
SPOT_
MARKET_
UTILIZATION_
PRECISION_
EXP
SPOT_
MARKET_
WEIGHT_
PRECISION
SWIFT_
ID
Spot
Markets
TEN
TEN_
MILLION
TEN_
THOUSAND
THREE
TWO
WRAPPED_
SOL_
MINT
ZERO
configs
amm
Paused
bulk
Polling
User
Stats
Subscribe
bulk
Polling
User
Subscribe
calculate
AdjustKCost
calculate
All
Estimated
Funding
Rate
calculate
Amm
Reserves
After
Swap
calculate
Ask
Price
calculate
Asset
Weight
calculate
Available
Perp
Liquidity
calculate
Base
Asset
Amount
For
Amm
To
Fulfill
calculate
Base
Asset
Amount
To
Fill
Up
To
Limit
Price
calculate
Base
Asset
Value
calculate
Base
Asset
Value
With
Oracle
calculate
Bid
Ask
Price
calculate
Bid
Price
calculate
Borrow
Rate
calculate
Break
Even
Price
calculate
BudgetedK
calculate
BudgetedKBN
calculate
Budgeted
Peg
calculate
Claimable
Pnl
calculate
Collateral
Deposit
Required
For
Trade
calculate
Collateral
Value
Of
Deposit
calculate
Cost
Basis
calculate
Deposit
Rate
calculate
Effective
Leverage
calculate
Entry
Price
calculate
Estimated
Entry
Price
With
L2
calculate
Estimated
Perp
Entry
Price
calculate
Estimated
Spot
Entry
Price
calculate
Estimated
Super
Stake
Liquidation
Price
calculate
Funding
Pool
calculate
Init
User
Fee
calculate
Insurance
Fuel
Bonus
calculate
Interest
Accumulated
calculate
Interest
Rate
calculate
Inventory
Liquidity
Ratio
calculate
Inventory
Scale
calculate
Liability
Weight
calculate
Liquidation
Price
calculate
Live
Oracle
Std
calculate
Live
Oracle
Twap
calculate
Long
Short
Funding
Rate
calculate
Long
Short
Funding
Rate
And
Live
Twaps
calculate
MarginUSDCRequired
For
Trade
calculate
Market
AvailablePNL
calculate
Market
Margin
Ratio
calculate
Market
Max
Available
Insurance
calculate
Market
Open
Bid
Ask
calculate
Max
Base
Asset
Amount
Fillable
calculate
Max
Base
Asset
Amount
To
Trade
calculate
Max
Remaining
Deposit
calculate
Max
Spread
calculate
Net
User
Pnl
calculate
Net
User
Pnl
Imbalance
calculate
New
Amm
calculate
New
Market
After
Trade
calculate
Optimal
Peg
And
Budget
calculate
Oracle
Price
For
Perp
Margin
calculate
Oracle
Reserve
Spread
calculate
Oracle
Spread
calculate
Peg
From
Target
Price
calculate
Perp
Fuel
Bonus
calculate
Perp
Liability
Value
calculate
Position
FundingPNL
calculate
PositionPNL
calculate
Price
calculate
Quote
Asset
Amount
Swapped
calculate
Reference
Price
Offset
calculate
Repeg
Cost
calculate
Reserve
Price
calculate
Scaled
Initial
Asset
Weight
calculate
Size
Discount
Asset
Weight
calculate
Size
Premium
Liability
Weight
calculate
Sol
Earned
calculate
Spot
Fuel
Bonus
calculate
Spot
Market
Borrow
Capacity
calculate
Spot
Market
Margin
Ratio
calculate
Spread
calculate
SpreadBN
calculate
Spread
Reserves
calculate
Swap
Output
calculate
Target
Price
Trade
calculate
Terminal
Price
calculate
Token
Utilization
Limits
calculate
Trade
Acquired
Amounts
calculate
Trade
Slippage
calculate
Unrealized
Asset
Weight
calculate
UpdatedAMM
calculate
UpdatedAMMSpread
Reserves
calculate
Utilization
calculate
Vol
SpreadBN
calculate
Weighted
Token
Value
calculate
Withdraw
Limit
calculate
Worst
Case
Base
Asset
Amount
calculate
Worst
Case
Perp
Liability
Value
cast
Number
To
Spot
Precision
check
Same
Date
clampBN
contains
Compute
Unit
Ixs
convert
Pyth
Price
convert
To
Number
create
L2
Levels
create
Node
decode
Name
decode
User
derive
Oracle
Auction
Params
div
Ceil
encode
Name
estimate
Tps
exchange
Paused
fetchBSol
Drift
Emissions
fetchBSol
Metrics
fetch
Drift
Priority
Fee
fetch
Helius
Priority
Fee
fetch
Jito
Sol
Metrics
fetch
Logs
fetchMSol
Metrics
fetch
Solana
Priority
Fee
fetch
Transaction
Logs
fetch
User
Accounts
fetch
User
Accounts
Using
Keys
fetch
User
Stats
Account
fill
Paused
find
All
Market
And
Oracles
find
Best
Jito
Sol
Super
Stake
Ixs
find
Best
Lst
Super
Stake
Ixs
find
BestMSol
Super
Stake
Ixs
find
Best
Super
Stake
Ixs
find
Compute
Unit
Consumption
find
Direction
To
Close
get
Auction
Price
get
Auction
Price
For
Fixed
Auction
get
Auction
Price
For
Oracle
Offset
Auction
get
Balance
get
Config
get
Drift
Signer
Public
Key
get
Drift
State
Account
Public
Key
get
Drift
State
Account
Public
Key
And
Nonce
get
Insurance
Fund
Stake
Account
Public
Key
get
Insurance
Fund
Vault
Public
Key
get
L2
Generator
FromDLOBNodes
get
Limit
Order
Params
get
Limit
Price
get
Marinade
Deposit
Ix
get
Marinade
Finance
Program
get
MarinadeMSol
Price
get
Market
Order
Params
get
Markets
And
Oracles
For
Subscription
get
Max
Confidence
Interval
Multiplier
get
Max
Number
Of
Sub
Accounts
get
New
Oracle
Conf
Pct
get
Non
Idle
User
Filter
get
Openbook
V2
Fulfillment
Config
Public
Key
get
Oracle
Client
get
Order
Params
get
Order
Signature
get
Perp
Market
Public
Key
get
Perp
Market
Public
Key
Sync
get
Phoenix
Fulfillment
Config
Public
Key
get
Prelaunch
Oracle
Public
Key
get
Protocol
If
Shares
Transfer
Config
Public
Key
get
Pyth
Pull
Oracle
Public
Key
get
Quote
Asset
Reserve
Prediction
Market
Bounds
get
Referrer
Name
Public
Key
Sync
get
Serum
Fulfillment
Config
Public
Key
get
Serum
Open
Orders
Public
Key
get
Serum
Signer
Public
Key
get
Signed
Token
Amount
get
Spot
Market
Public
Key
get
Spot
Market
Public
Key
Sync
get
Spot
Market
Vault
Public
Key
get
Strict
Token
Value
get
Swap
Direction
get
Token
Amount
get
Token
Program
For
Spot
Market
get
Token
Value
get
Trigger
Limit
Order
Params
get
Trigger
Market
Order
Params
get
User30d
Rolling
Volume
Estimate
get
User
Account
Public
Key
get
User
Account
Public
Key
And
Nonce
get
User
Account
Public
Key
Sync
get
User
Filter
get
User
Stats
Account
Public
Key
get
User
That
Has
BeenLP
get
User
With
Auction
Filter
get
User
With
Name
get
User
With
Order
Filter
get
Vamm
L2
Generator
get
Vamm
Node
Generator
get
Variant
get
Worst
Case
Token
Amounts
group
L2
has
Auction
Price
has
Limit
Price
has
Open
Orders
initialize
is
Amm
Drawdown
Pause
is
Auction
Complete
isBNSafe
is
Empty
Position
is
Fallback
Available
Liquidity
Source
is
Fillable
ByVAMM
is
Limit
Order
is
Market
Order
is
One
Of
Variant
is
Operation
Paused
is
Oracle
Too
Divergent
is
Oracle
Valid
is
Order
Expired
is
Order
Reduce
Only
is
Order
Risk
Increasing
is
Order
Risk
Increasing
In
Same
Direction
is
Resting
Limit
Order
is
Set
Compute
Unit
Price
Ix
is
Set
Compute
Units
Ix
is
Spot
Position
Available
is
Taking
Order
is
Triggered
is
User
Bankrupt
is
Variant
load
Keypair
merge
L2
Level
Generators
must
Be
Triggered
next
Revenue
Pool
Settle
Apr
number
To
SafeBN
oracle
Price
Bands
parse
Logs
parse
Logs
With
Raw
position
Current
Direction
position
Is
Available
promise
Timeout
sig
Num
simulate
Order
Fill
square
RootBN
stake
Amount
To
Shares
standardize
Base
Asset
Amount
standardize
Price
time
Remaining
Until
Update
trim
Vaa
Signatures
uncross
L2
unstake
Shares
To
Amount
unstake
Shares
To
Amount
With
Open
Request
Generated using
TypeDoc
Returns
// QUOTE_PRECISION