All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- program: calculate_accumulated_interest return early based on ts (#1192)
- program: add logging to pyth pull updates (#1189)
- program: init prediction markets (#1152)
- program: make updateUserQuoteAssetInsuranceStake permissionless (#1187)
- program: fix openbook v2 oom issue (#1186)
- program: look at drift stake to determine fee tier (#1172)
- program: account for direction when looking at max borrow cap (#1169)
- program: call get_token_interface in begin_swap
- program: advance iter in get_token_interface and get_token_mint
- program: add deposit into spot market vault (#1159)
- program: add liquidation via fill (#1106)
- program: add switchboard on demand integration (#1154)
- program: add support for token 2022 (#1125)
- program: track fuel (#1048)
- program: add post multi pyth oracle updates atomic (#1133)
- program: track fuel for if staking (#1127)
- program: validate fee structure (#1075)
- program: check 5 min oracle twap divergence in trigger order (#1116)
- program: openbook v2 integration (#1112)
- program: spot fill checks if withdraws are paused (#881)
- program: more oracle validation in admin fn (#1082)
- program: account for serum already having open order account (#1077)
- program: avoid truncated cast (#1078)
- program: check whitelist token amount (#1076)
- program: program: only let referrer set if number_of_sub_accounts_created is 0 (#1083)
- program: update increment_total_referrer_reward corner-case logic (#1156)
- program: add tx optimized pyth pull (#1111)
- program: migrate all integration tests to bankrun (#1090)
- program: check FillOrderAmm for amm is available (#1107)
- program: add spot borrow insurance limits (#1080)
- program: maker can be rewarded filler returns when amm gets fill (#1093)
- program: avoid overwriting 0 duration auction (#1097)
- program: add pyth pull oracles (#1067)
- program: upgrade to anchor 0.29.0 and solana 1.16
- program: settle pnl block looks at oracle vs oracle 5min twap (#1072)
- program: add settle pnl mode (#1030)
- program: use strict price for maintenance margin check in settle pnl (#1045)
- program: order w ioc can still get auction (#1074)
- program: update_perp_auction_params_limit_orders unwraps oracle_price_offset
- ts-sdk: add market index to logging settle pnl error (#1068)
- program: enforce min price for oracle offsets (#874)
- program: TransferProtocolIfShares constraint (#1055)
- program: sanitize extreme auction end prices (#1031)
- program: add comprehensive admin function logging (#1038)
- ts-sdk: upgrade to node 18 and solana version 1.91.7 (#1036)
- program: fix tracking unsettled quote for lp (#1026)
- program: add ability to pause if operations (#989)
- program: update auction end price in derive_market_order_auction_params (#1022)
- program: admin amm summary stats update and/or reset (#912)
- program: program: let user with positive pnl be settled if being liquidated (#1020)
- program: fix should_expire_order_before_fill (#1021)
- program: set default ContractTier to HighlySpeculative (#1013)
- program: avoid dust borrows not being transferred
- program: lax funding rate update oracle validity criteria (#1009)
- program: fix div by 0 in calculate_liability_transfer_to_cover_margin_shortage
- program: rm admins ability to withdraw from if (#990)
- program: add add ability to delete initialized spot market (#998)
- program: more reliable oracle updates (#1000)
- program: avoid underflow in update pnl (#1002)
- program: add fee adjustment to spot market (#987)
- program: allow multiple makers to be passed into for spot fills (#946)
- ts-sdk: add fn to get admin ix (#980)
- program: add invariant check boolean for attempt settle revenue to insurance (#937)
- program: improve best bid/ask estimate in mark twap update (#975)
- program: add optional margin calculations for drift-rs (#978)
- program: add 'highly speculative' contract tier enum 4 (#968)
- program: expand initialize market parameters (#969)
- program: fix checking isolated tier in add_perp_lp_shares (#965)
- program: fix checking isolated tier in validate spot margin trading
-
program: skip isolated tier for auction start/end sanitize (#958)
-
program: check isolated perp market in validate spot margin trading (#957)
-
program: improve update prelaunch oracles and add ability to delete (#956)
-
program: allow user to settle realized pnl in reduce only market status (#954)
-
sdk: add function for toggling user account to reduceOnly (#966)
- program: update spot index twap ts (#948)
- program: add back switchboard without cargo dependency (#943)
- program: add admin fn to update funding period
- program: add prelaunch oracles (#910)
- program: make isolated perp contract tier more ergonomic (#913)
- program: add per market tier confidence interval guard (#945)
- sdk: account for max confidence in isOracleValid (#949)
- program: fix allowing settle pnl on oracle delays when price is stable (#940)
- program: allow settle pnl on oracle delays when price is stable (#929)
- program: cache validity in oracle map
- program: revert switchboard (#935)
- program: apply auction sanitizer to all contract tiers (#932)
- program: fix flipping funding rates (#931)
- program: don't block oracle order prices when theres solely InsufficientDataPoints (#919)
- program: add pause operation for liquidation (#880)
- program: fix entry/breakeven price calculations for lp remainders (#864)
- program: handle derisk lp when orders array full (#899)
- program: invalid borrow in get_referrer_info when maker is refferer (#900)
- program: make derived auction start more passive (#890)
- program: longer derived auction durations for contract tier B and safer (#889)
- program: always try update market order auction durations (#882)
- program: amm drawdown check (#865)
- program: relax oracle guardrail validity check for init margin calc for positive pnl (#876)
- program: add more max spread baselines (#858)
- sdk: fix bug in changeWallet that doesn't reset the user stats account if switching from a wallet with drift account to one without
- program: more continuous calculation for calculate_jit_amount (#882)
- program: better derivation of perp auction params when missing and for triggers (#869)
- program: calculate whether oracle's num quoters sufficient (#860)
- program: include derisk lp order action explanation
- program: sanitize perp auction params (#859)
- program: add repay borrow explanation (#862)
- program: derisk lp more granularly (#849)
- program: separate out paused operations from market status (#839)
- program: use decayed last_oracle_conf_pct as lower bound for update (#840)
- program: AmmPaused doesnt block all fills
- program: add recenter amm ix (#836)
- program: enable jit maker to fill same slot as taker placed (#835)
- program: standardize lp shares in attempt_burn_user_lp_shares_for_risk_reduction (#826)
- sdk: move bracket orders into single instruction
- sdk: add ability to do placeAndTake order with bracket orders attached
- sdk: add option to cancel existing orders in market for place and take order
- sdk: add option to get signed settlePnl tx back from a market order
- program: auto derisk lp positions in settle pnl (#766)
- program: increase full perp liquidation threshold (#807)
- program: remove spot fee pool transfer (#800)
- program: increase insurance tier max (#784)
- sdk: can specify max custom margin ratio to initialize a new account with
- program: standardize limit auction prices (#790)
- program: improve get_fallback_price(#797)
- program: derive auction for crossing limit with no duration (#802)
- sdk: use tx params passed into deposit and withdraw functions
- program: add ability to reclaim rent without deleting account (#763)
- program: add borrow explanation to DepositRecords (#772)
- sdk: OrderSubscriber has resync option (#780)
- program: only consider recent last_active_slot in qualifies_for_withdraw_feen (#756)
- program: amm can use reference price offset from oracle price based on clamped inventory and persist market premiums (#681)
- program: handle underflow in calculate_liability_transfer_to_cover_margin_shortage (#774)
- program: flip auction flag when trigger order adds auction (#775)
- program: don't perform funding rate updates when slots_since_amm_update is stale (#757)
- program: add update last slot for filler in pay_keeper_flat_reward_for_spot
- program: consistent user of fee budget in calculate_optimal_peg_and_budget (#754)
- program: better account for liquidation fees in calculate_optimal_peg_and_budget (#754)
- program: account for step size when canceling reduce only orders
- sdk: UserStatsMap use bulkAccountLoader (
UserStatsMap.subscribe
andUserStatsMap.sync
now requires list of authorities) (#716)
- program: accelerated idle update for users with <$1000 equity
- ts-sdk: fix to modify order booleans
- program: fill asset weight between init and maintenance (#713)
- program: if order reduces maker position, check maintenance margin requirement (#714)
- program: trigger limits cant make if limit crosses trigger (#707)
- sdk: fix vamm L2asks by using askAmm (#708)
- program: add max_number_of_sub_accounts onto state account (#710)
- program: exhaustively search for referrer account on fill (#702)
- program: accelerate liquidations for tiny accounts (#698)
- program: boost max sub accounts to 20k
- program: allow amm to fill step size (#672)
- program: add add update_liquidation_margin_buffer_ratio (#695)
- program: account for fee pool when settling positive pnl (#687)
- sdk: fix bug which incorrectly calculated leverage after trade for a market with no position but short orders open
- sdk: fix bug in modifying an order that previously had auction params to a non-auction order
- sdk: add delta to calculateDepositRate function
- program: add accelerated user update idle (#669)
- program: make user status a bit flag (#619)
- program: place and take uses auction end price for market orders (#650)
- program: reduce cus for place_spot_order (#662)
- program: bump max sub accounts to 15k
- program: user custom margin ratio works with spot (#633)
- program: add swap price bands (#611)
- program: add 5min twap price bands to liquidate_perp and liquidate_spot (#570)
- program: add positive perp funding rate offset (#576)
- program: add validation check in update max imbalances (#667)
- sdk: remove getMakerLimitBids/Asks from DLOB
- sdk: updateUserMarginEnabled and updateUserCustomMarginRatio now take in an array of params to allow multiple subaccounts to be update in a single tx
- program: order_breaches_maker_oracle_price_bands only uses init margin ratio (#636)
- program: add fee_adjustment to perp market (#629)
- program: add buffer to calculating max perp if fee (#635)
- sdk: remove getMakerLimitBids/Asks (#632)
- program: add ix to transfer protocol if shares (#612)
- program: fix if staking rounding for fee tier selection (#643)
- program: add dynamic liquidation fee (#601)
- sdk: add deriveOracleAuctionParams
- program: update to anchor 0.27.0 (#617)
- sdk: updated anchor to 0.28.1-beta.2
- sdk: add priorityFeeSubscriber
- program: allow up to 12500 users
- program: scale initial asset weight for spot markets based on total deposits (#575)
- program: let auction start/end be the same (#597)
- program: account for reduce only when checking margin in trigger order (#583)
- program: use per_lp_base_unit for calculating base imbalance for lp jit (#604)
- program: add reduce only user status (#560)
- program: add conditionally smaller conf_component logic for amm spread (#577)
- program: add per_lp_base on market/position (#568)
- program: add update_lp_market_position test for big k (#565)
- sdk: fixed divide by 0 bug in withdraw amount when asset weight is 0 (#572)
- program: add deposit_into_spot_market_revenue_pool (#520)
- program: make users w excessive withdraws pay fees (#547)
- program: allow settle pnl and spot fills via match when utilization is 100% (#525)
- program: new update_perp_bid_ask_twap ix (#548)
- program: dont check price bands for place order (#556)
- program: usdt oracle uses pyth stablecoin oracle source
- program: add buffer before limit tif can be expired (#551)
- ts-sdk: fix abs for dustBaseAssetValue in getPerpPositionWithLPSettle (#543)
- program: add a fixed buffer margin requirement for lp_shares (#546)
- program: use fill margin type in fulfill_spot_order
- ts-sdk: add buffer to max leverage for LP contributions
- ts-sdk: account for lp shares in liq price (#522)
- ts-sdk: getPerpPositionWithLPSettle has flag to account for burn lp share (#522)
- program: add cancel orders by ids (#540)
- program: add post only slide for perps (#541)
- program: allow up to 10000 users
- program: if taker increases free colalteral, check maintenance health (#538)
- program: improve bid/ask twap update for infrequent trading (#529)
- sdk: simplify, mirror contract, and write tests for predicting funding rate function (#529)
- program: include amm jit in base used to calculate price band ((#536))
- program: safety improvements for swaps ((#528))
- program: track
total_fee_earned_per_lp
on amm ((#526)) - program: add additional withdraw/borrow guards around fast utilization changes ((#517))
- program: new margin type for when orders are being filled ((#518))
- program: new fill price bands ((#516))
- program: use emit_stack for place orders ((#533))
- program: tweaks for setting init asset weight to 0 ((#523))
- program: add vault invariant to update_spot_market_cumulative_interest ix ((#524))
- program: check oracles valid in meets_withdraw_margin_requirement if number_of_liabilities > 0
- program: only get quote spot market if user has quote position in validate_spot_margin_trading
- program: fix decrement_open_orders for makers
- program: fix margin calculation of unrealized funding pnl for lps ((#513))
- ts-sdk: add getMaxSwapAmount ((#488))
- program: add bulk place orders ix ((#499))
- ts-sdk: add stakeForMSOL to driftClient ((#500))
- ts-sdk: driftClient accepts default txParams ((#496))
- ts-sdk: add method to force inclusion of markets in ix remaining accounts ((#503))
- ts-sdk: remove user.getSpotTokenAmount as its a duplicate
- ts-sdk: remove RetrySender dependency on Provider ((#497))
- program: store if use has open orders/auctions on user account ((#480))
- program: add user perp lp jit liquidity toward a target base ((#448))
- ts-sdk: drift client will query rpc to find all markets/oracles if they're not explicitly specified ((#469))
- ts-sdk: fix client borrow interest rate calculation ((#479))
- program: fix settle lp position math error for large step sizes ((#473))
- ts-sdk: user map default excludes idle users ((#471))
- program: allow up to 7500 subaccounts
- program: allow users to swap on jupiter inside of drift account (#462)
- ts-sdk: add mSOL spot market (#467)
- sdk: expose method in account subscriber to change polling frequency
- program: modify_order and modify_order_by_id now expect a ModifyOrderPolicy (#461)
- program: cancel_order does not fail if order does not exist (#461)
- program: add precision docs to the state accounts (#452)
- ts-sdk: driftClient.getTokenAmount now returns negative for borrows (#452)
- ts-sdk: txSender.sendVersionedTransaction now expects VersionedTransaction (#452)
- ts-sdk: add SUI perp market (#453)
- program: use forked version of anchor 0.26.0 that supports large idls (#451)
- program: add security.txt (#450)
- program: add L2 and L3 view of DLOB (#445)
- ts-sdk: new DLOBSubscriber class to keep updated DLOB (#439)
- program: add support for phoenix spot markets (#437)
- sdk: ability to add stake from subaccount
- ts-sdk: Add phoenix subscriber (#444)
- sdk: driftClient allows subscription to delegate accounts; pass includeDelegates or authoritySubaccountMap to constructor/updateWallet (#432)
- program: check max_token_deposits at the end of fill_spot_order (#441)
- program: force_cancel_orders only skips position reducing orders
- program: allow amm to pull up to FEE_POOL_TO_REVENUE_POOL_THRESHOLD into fee pool (#436)
- program: fix modify order trigger condition
- sdk: fix removing unstaked sol
- program: fix math error in settle_revenue_to_insurance_fund for large sizes (#443)
- program: fix revenue pool corner case for updating last_revenue_withdraw_ts (#447)
- sdk: add BNB perp market
- program: update to anchor 0.26.0 (#428)
- program: add modify_order ix (#422)
- sdk: more accurate calculation of insurance stake value during unstake request (#426)
-
sdk: fix isOracleValid confidenceTooLarge calc (#425)
-
sdk: Remove redundant fetchAccounts in userMap.ts
- program: ability to delete a market that was just initialized (#413)
- program: revenue pool wont settle to IF if utilization unhealthy (#402)
- program: add ctx.accounts.insurance_fund_vault.reload()? after vault updates (#402)
- program: include usdc oracle (#397)
- ts-sdk: add addAllUsers to DriftClient
- program: program: when checking if user is idle, let balanceType be borrow if scaled balance is 0 (#397)
- sdk: fix claimable pnl (#384)
- program: borrow liquidity check accounts for if user has borrow or deposit (#400)
- program: slightly relax withdraw limits (#400)
- sdk: filter undefined accounts (#406)
- program: account for openbook referrer rebate being greater than quote sold (#394)
- sdk: add sync to UserMap and UserStatsMap (#395)
- program: revert fill ix (#391)
- program: flag users as idle on-chain (#386)
- program: add referrer name account to enforce unique referrer names (#357)
- program: only let amm fill up to tick above/below user limit price (#381)
- program: allow multiple makers in fill_perp_order (#341)
- sdk: add getPerpMarketExtendedInfo to drift client
- program: allow post only to match older taker limit orders (#378)
- ts-sdk: serum subscriber supports websockets (#365)
- program: max number of subaccounts to 3000
- program: amm spread logic more consistent across market by using liquidity ratio rather than base asset amount for inventory spread scaling(#374)
- program: add pyth1M/pyth1K as OracleSource (#375)
- program: account for contract tier in liquidate_perp_pnl_for_deposit (#368)
- program: simplifications for order fills (#370)
- program: block atomic fills (#369)
- program: allow limit orders to go through auction (#355)
- program: improve conditions for withdraw/borrow guard (#354)
- ts-sdk: fix resolvePerpBankrupcty to work with all perp market indexes
- ts-sdk: getTokenAmount uses divCeil (#371)
- program: allow limit orders to have explicit zero auction duration passed in params (#373)
- program: order params utilize post only enum (#361)
- program: twap tweaks, update only on new cluster time (#362)
- sdk: add support for market lookup table (#359)
- program: tweak calculate_size_premium_liability_weight to have smaller effect on initial margin (#350)
- ts-sdk: updates for accounting for spot leverage (#295)
- ts-sdk: added new methods for modifying orders to include spot and more params (#353)
- ts-sdk: flagged old modifyPerpOrder and modifyPerpOrderByUserOrderId as deprecated
- ts-sdk: DLOB matching logic accounts for zero-price spot market orders not matching resting limit orders
- ts-sdk: new squareRootBN implementation using bit shifting (2x speed improvement)
- program: fix overflow in calculate_long_short_vol_spread (#352)
- program: dont let users disable margin trading if they have margin orders open
- program: tweaks to fix max leverage order param flag with imf factor (#351)
- program: improve bid/ask twap calculation for funding rate stability (#345)
- ts-sdk: fix borrow limit calc (#356)
- ts-sdk: add aptos
- program: flag to set max leverage for orders (#346)
- program: do imf size discount for maintainance spot asset weight (#343)
- ts-sdk: new liquidation price to account for delta neutral strategies (#340)
- ts-sdk: add txParams to all instructions, bump @solana/web3.js (#344)
- program: extend time before limit order is considered resting (#349)
- ts-sdk: improve funding rate prediction
- program: block jit maker orders from cross vamm
- program: cancel_order_by_user_order_id fails if order is not found
- program: perp bankruptcies pay from fee pool before being socialized (#332)
- ts-sdk: add calculateAvailablePerpLiquidity
- program: enforce min order size when trading against amm (#334)
- ts-sdk: fix the getBuyingPower calculation
- ts-sdk: improved perp estimated liq price formula (#338)
- ts-sdk: update methods to account for new leverage formula (#339)
- program: allow for 2000 users
- program: add resting limit order logic (#328)
- ts-sdk: add calculateEstimatedSpotEntryPrice
- ts-sdk: add ability to add priority fees (#331)
- ts-sdk: new calculateEstimatedPerpEntryPrice that accounts for dlob & vamm (#326)
- program: better rounding for openbook limit price
- program: fix paying fee_pool_delta when filling with open book
- program: bitflags for exchange status (#330)
- program: update fee calculation for filling against openbook
- program: relax conditions for valid oracle price in fulfill_perp_order
- program: handle fallback price when amm has no liquidity (#324)
- sdk: add getRestingLimitBids/Asks to DLOB (#325)
- program: tweak oracle price used for determine_perp_fulfillment_methods
- program: remove canceling market orders with limit price after first fill
- program: try to match against multiple of makers orders (#315)
- program: limit number of users to 1500
- program: more rigorous risk decreasing check in place_perp_order/place_stop_order
- program: avoid overflow when calculating overflow (#322)
- ts-sdk: fix user.getUnrealizedPnl to account for lp position
- program: cancel market order for not satisfying limit price only if there was some base asset amount filled
- program: place order returns early if max ts breached (#317)
- ts-sdk: batch getMultipleAccount calls in bulkAccountLoader (#315)
- program: add clippy deny for panic, expect and unwrap
- program: add market index offset trait (#287)
- program: add size trait to accounts and events (#286)
- program: add access control for spot market updates similar to perp market (#284)
- ts-sdk: allow websocket subscriber to skip getAccount call to rpc (#313)
- ts-sdk: always add market account for cancelOrders if market index included
- anchor tests: make deterministic to run in ci (#289)
- ts-sdk: fix deprecated calls to
@solana/web3.js
(#299) - ts-sdk: fix calculateAssetWeight for Maintenance Margin (#308)
- ts-sdk: fix UserMap for websocket usage (#308)
- program: use vamm price to guard against bad fills for limit orders (#304)
- ts-sdk: expect signTransaction from wallet adapters to return a copy (#299)
- program: add force_cancel_orders to cancel risk-increasing orders for users with excessive leverage (#298)
- program: fix calculate_availability_borrow_liquidity (#301)
- program: fix casting in fulfill_spot_order_with_match to handle implied max_base_asset_amounts
- sdk: fix BulkAccountLoader starvation (#300)
program: more leniency in allowing risk decreasing trades for perps (#297) program: fix is_user_being_liquidated in deposit
program: allow keeper to switch user status to active by calling liquidate perp (#296)
- program: more precise update k in prepeg (#294)
- program: allow duplicative reduce only orders (#293)
- program: fix should_cancel_reduce_only_order
- ts-sdk: add Oracle OrderType to dlob idl
- program: disable lower bound check for update amm once it's already been breached (#292)
- ts-sdk: fix DLOB.updateOrder (#290)
- ts-sdk: make calculateClaimablePnl mirror on-chain logic (#291)
- ts-sdk: add margin trading toggle field to user accounts, update toggle margin trading function to add ability to toggle for any subaccount rather than just the active (#285)
- program: check if place_perp_order can lead to breach in max oi (#283)
- program: find fallback maker order if passed order id doesnt exist (#281)
- program: fix amm-jit so makers can fill the full size of their order after amm-jit occurs (#280)
- program: update the amm min/max_base_asset_reserve upon k decreases within update_amm (#282)
- program: fix amm-jit erroring out when bids/asks are zero (#279)
- ts-sdk: fix overflow in inventorySpreadScale
- ts-sdk: add btc/eth perp market configs for mainnet (#277)
- program: reduce if stake requirement for better fee tier (#275)
- program: new oracle order where auction price is oracle price offset (#269).
- program: block negative pnl settles which would lead to more borrows when quote spot utilization is high (#273).
- ts-sdk: fix bugs in calculateSpreadBN
- ts-sdk: fix additional bug in calculateSpreadBN (negative nums)