Skip to content

Commit 1fb6e52

Browse files
moosecat20xbigzwphancrispheaneyLukasDeco
authored
DLP (#1885)
* Bigz/init lp pool (#1884) * program: init lp pool * cargo fmt -- * add total fee fields * add update_target_weights math * program: use sparse matrix for constituent map and update tests * zero copy accounts, init ix (#1578) * update accounts (#1580) * zero copy + permissionless crank ixs (#1581) * program: support negative target weights for borrow-lend * fix tests to work with zero copy * few comment changes * remove discriminator from impl macro * add get_swap_amount, get_swap_fees, get_weight (#1579) * add get_swap_amount, get_swap_fees, get_weight * update accounts * add back ts * rebase * add constituent swap fees * fix swap fee calc (#1582) * add init amm mapping to lp context (#1583) * init constituent * add initializeLpPool test (#1585) * add initializeLpPool test * add check for constituent target weights * add add datum ix * add init tests and invariant checks * rename data to more useful names * dlp use spl token program (#1588) * add crank ix * update total_weight for validation_flags check * push test so far * overriding perp position works * remove message * fix dup total_weight add * constituent map remaining accounts * compiles * bankrun tests pass * compiles but casting failure in overflow protection test * address comment and change token arguments from u64 to u128 * bankrun tests pass * init constituent token account (#1596) * update aum calc * add update /remove mapping ixs * fix test - init constituent spot market * add crank improvements * passes tests * precision fix crank aum * precision fixes and constituent map check for account owner * add passthrough account logic (#1602) * add passthrough account logic * cant read yet * fix all zc alignment issues * make oracle source a u8 on zc struct * Wphan/dlp-swap-ixs (#1592) * add lp_swap ix * rebase * test helpers * swap works * fix swaps, add more cargo tests for fees n swap amt * remove console.logs * address PR comments * merge upstream * post-merge fixes * store bumps on accounts (#1604) * store bumps on accounts * do pda check in constituent map * address comments * Wphan/add liquidity (#1607) * add add remove liquidity fees calc * add liquidity ix * fix init mint and lppool token account, refactor test fees * add removeLiquidity bankrun test * merge upstream * add LPPool.next_mint_redeem_id * program: lp-pool-to-use-target-base-vector (#1615) * init lp pool target-base matrix * working target-base logic * add todos for add/remove liquidity aum * add renames + fix test * add beta and cost to trade in bps to target datum * add more tests * add fields to LP events, fix tests (#1620) * add fields to LP events, fix tests * revert target weight calc * add constituent.next_swap_id, fix cost_to_trade math * dlp jup swap (#1636) * dlp jup swap * add admin client ixs * almost fixed * test working? * update begin and end swap * tweaks * fix math on how much was swapped * remove unnecessary lp pool args * extra account validation * added token account pda checks in other ixs * stablecoin targets (#1638) * is stablecoin * address comments --------- Co-authored-by: Chris Heaney <[email protected]> * cleanup * transfer oracle data ix to constituent (#1643) * transfer oracle data ix to constituent * add lib entrypoint * simplify more * add spot market constraint * big cargo test (#1644) * derivative constituents + better testing + bug fixes (#1657) * all tests technically pass * update tests + prettify * bug fixes and tests pass * fix many bugs and finalize logic * deposit/borrow working and changing positions (#1652) * sdk: allow custom coder * program: dlp add upnl for settles to amm cache (#1659) * program: dlp add-upnl-for-settles-to-amm-cache * finish up lp pool transfer from perp market * add amount_to_transfer using diff * merge * add pnl and fee pool accounting + transfer from dlp to perp market --------- Co-authored-by: Nour Alharithi <[email protected]> * remove unused accounts coder * move customCoder into sdk, lint * testing: ix: settle perp to dlp, insufficient balance edge case and improvements (#1688) * finish edge case test * aum check also passes * prettify * added more settle test coverage and squash bugs (#1689) * dlp: add constituentMap (#1699) * Nour/gauntlet fee impl (#1698) * added correlation matrix infra * refactor builds * mint redeem handled for usdc * remove liquidity also should work * all tests pass * bankrun tests pass too * update aum considers amm cache (#1701) * prettify (#1702) * Wphan/merge master dlp (#1703) * feat: init swift user orders on user account creation if needed * fix: wrong pushing of swift user orders ixs * fix: broken swift tests * fix: swift -> signed msg * refactor(sdk): update jupiter's api url * fix(sdk): remove error thrown * indicative qutoes server changes * sdk: release v2.121.0-beta.7 * sdK: update market index 33 oracle rr (#1606) * sdk: add to spot constants market index 34 * revert adminClient.ts change * sdk: update spot market constants oracle index 33 * sdk: release v2.121.0-beta.8 * sdk: high leverage mode updates (#1605) * sdk: high leverage mode updates * add optional param for fee calc * update changelog * sdk: release v2.121.0-beta.9 * getPlaceSignedMsgTakerPerpOrderIxs infer HLM mode from bitflags (#1608) * sdk: release v2.121.0-beta.10 * fix: dehexify in getPlaceSignedMsgTakerPerpOrderIxs (#1610) * fix: dehexify in getPlaceSignedMsgTakerPerpOrderIxs * bankrun test * sdk: release v2.121.0-beta.11 * sdk: round tick/step size for getVammL2Generateor (#1612) * sdk: round tick/step size for etVammL2Generateor * use standard functions, include in all fcns * fix const declare, rm whitespace * fix posdir sign * sdk: release v2.121.0-beta.12 * sdk: release v2.121.0-beta.13 * sdk: constants market-index-45-46 (#1618) * sdk: release v2.121.0-beta.14 * robustness check for indicative quotes sender (#1621) * robustness check for indicative quotes sender * delete quote from market index of bad quote * sdk: release v2.121.0-beta.15 * Added launchTs for ZEUS, zBTC * sdk: release v2.121.0-beta.16 * sdk: bigz/fix-vamm-l2-generator-baseSwapped var assign (#1622) * sdk: release v2.121.0-beta.17 * sdk: fix vamm l2 generator base swapped (#1623) * sdk: bigz/fix-vamm-l2-generator-baseSwapped var assign * fix ask book else baseSwapped calc * sdk: release v2.121.0-beta.18 * sdk: revert vamm l2 gen (#1624) * Revert "sdk: fix vamm l2 generator base swapped (#1623)" This reverts commit 56bc78d70e82cb35a90f12f73162bffb640cb655. * Revert "sdk: bigz/fix-vamm-l2-generator-baseSwapped var assign (#1622)" This reverts commit e49cfd554cc44cd8d7770184f02f6ddb0bfc92f1. * Revert "sdk: round tick/step size for getVammL2Generateor (#1612)" This reverts commit f932a4ea2afcae314e406b7c7ee35e55b36043ad. * sdk: release v2.121.0-beta.19 * sdk: show protected-asset have zero-borrow-limit (#1603) * sdk: show protected-asset have zero-borrow-limit * rm unused AssetTier import * sdk: release v2.121.0-beta.20 * sdk: market-constants-index-74 (#1629) * sdk: release v2.121.0-beta.21 * program: use saturating_sub for number_of_users (#1616) * program: use saturating_sub for number_of_users * update CHANGELOG.md * program: allow fixing hlm num users (#1630) * sdk: release v2.121.0-beta.22 * sdk: fix switchboard on demand client to use landed at * sdk: release v2.121.0-beta.23 * sdk: spot-market-poolid-4 constants (#1631) * sdk: release v2.121.0-beta.24 * fix high lev mode liq price (#1632) * sdk: release v2.121.0-beta.25 * replace deprecated solana install scripts (#1634) * sdk: release v2.121.0-beta.26 * refactor(sdk): use ReturnType for Timeout types (#1637) * sdk: release v2.121.0-beta.27 * auction price sdk fix * sdk: release v2.121.0-beta.28 * program: multi piecewise interest rate curve (#1560) * program: multi-piecewise-interest-rate-curve * update tests * widen out borrow limits/healthy util check * add break, use array of array for borrow slope segments * program: fix cargo test * sdk: add segmented IR curve to interest rate calc * clean up unusded var, make interest rate segment logic a const * incorp efficiency feedback points * test: add sol realistic market example * cargo fmt -- * CHANGELOG --------- Co-authored-by: Chris Heaney <[email protected]> * sdk: release v2.121.0-beta.29 * program: allow hot admin to update market fuel params (#1640) * v2.121.0 * sdk: release v2.122.0-beta.0 * sdk: fix nullish coalescing * sdk: release v2.122.0-beta.1 * program: add logging for wrong perp market mutability * sdk: check free collateral change in maxTradeSizeUsdcForPerp (#1645) * sdk: check free collateral change in maxTradeSizeUsdcForPerp * update changelog * sdk: release v2.122.0-beta.2 * refactor(sdk): emit newSlot event on initial subscribe call (#1646) * sdk: release v2.122.0-beta.3 * sdk: spot-market-constants-pool-id-2 (#1647) * sdk: release v2.122.0-beta.4 * sdk: add-spot-market-index-52-constants (#1649) * sdk: release v2.122.0-beta.5 * program: add existing position fields to order records (#1614) * program: add quote entry amount to order records * fix cargo fmt and test * more reusable code * more reusable code * add another comment * fix math * account for pos flip * fix typo * missed commit * more fixes * align naming * fix typo * CHANGELOG * program: check limit price after applying buffer in trigger limit ord… (#1648) * program: check limit price after applying buffer in trigger limit order auction * program: reduce duplicate code * fix tests * CHANGELOG --------- Co-authored-by: 0xbigz <[email protected]> * program: fix cargo tests * program: check limit price when setting auction for limit order (#1650) * program: check limit price after applying buffer in trigger limit order auction * program: reduce duplicate code * program: check limit price when setting limit auction params * cargo fmt -- * fix CHANGELOG * tests: updates switchboardTxCus.ts * program: try to fix iteration for max order size (#1651) * Revert "program: try to fix iteration for max order size (#1651)" This reverts commit 3f0eab39ed23fa4a9c41cbab9af793c60b50a239. * disable debug logging in bankrun tests * v2.122.0 * sdk: release v2.123.0-beta.0 * sdk: constants-spot-market-index-53 (#1655) * sdk: release v2.123.0-beta.1 * sdk: idl for new existing position order action records * fix: protocol test prettier fix * make ci lut checks not shit * sdk: release v2.123.0-beta.2 * sdk: fix vamm l2 generator base swapped and add new top of book (#1626) * sdk: bigz/fix-vamm-l2-generator-baseSwapped var assign * fix ask book else baseSwapped calc * use proper quoteAmount with baseSwap for top of book orders * clean up console.log * sdk: getVammL2Generator reduce loc (#1628) * sdk: getVammL2Generator-reduce-loc * add MAJORS_TOP_OF_BOOK_QUOTE_AMOUNTS * add marketindex check topOfBookAmounts * yarn lint/prettier * sdk: release v2.123.0-beta.3 * program: allow all limit orders to go through swift (#1661) * program: allow all limit orders to go through swift * add anchor test * CHANGELOG * sdk: add optional initSwiftAccount on existing account deposits (#1660) * sdk: release v2.123.0-beta.4 * program: add taker_speed_bump_override and amm_spread_adjustment * Revert "program: add taker_speed_bump_override and amm_spread_adjustment" This reverts commit 1e19b7e7a6c5cecebdbfb3a9e224a0d4471ba6d2. * program: tests-fee-adjustment-neg-100 (#1656) * program: tests-fee-adjustment-neg-100 * add HLM field to test * cargo fmt -- --------- Co-authored-by: Chris Heaney <[email protected]> * program: simplify user can skip duration (#1668) * program: simplify user can skip duration * update context * CHANGELOG * fix test * fix pmm tests --------- Co-authored-by: Chris Heaney <[email protected]> * program: add taker_speed_bump_override and amm_spread_adjustment (#1665) * program: add taker_speed_bump_override and amm_spread_adjustment * add admin client * cargo test * add impl for amm_spread_adjustment * ensure no overflows * CHANGELOG * cargo fmt -- * sdk types * prettify --------- Co-authored-by: 0xbigz <[email protected]> * program: update-amm-spread-and-availability-constraints (#1663) * program: update-amm-spread-and-availability-constraints * fix cargo tests * program: use saturating mul for amm spread adj * nour/indic-quotes-sender-v2 (#1667) * nour/indic-quotes-sender-v2 * prettify * pass margin category into calculateEntriesEffectOnFreeCollateral (#1669) * fix cargo test * tests: fix oracle guardrail test * sdk: update idl * yarn prettify:fix * tests: fix a few more place and make tests * prettify fix * whitespace readme change * sdk: release v2.123.0-beta.5 * v2.123.0 * sdk: release v2.124.0-beta.0 * v2.123.0-1 * sdk: calculateVolSpreadBN-sync (#1671) * sdk: release v2.124.0-beta.1 * sdk: calculate-spread-bn-add-amm-spread-adjustment (#1672) * sdk: calculate-spread-bn-add-amm-spread-adjustment * corect sign * add math max 1 * prettify * sdk: release v2.124.0-beta.2 * sdk: correct calculateVolSpreadBN reversion * sdk: release v2.124.0-beta.3 * sdk: add getTriggerAuctionStartPrice (#1654) * sdk: add getTriggerAuctionStartPrice * updates * precisions * remove startBuffer param --------- Co-authored-by: Chris Heaney <[email protected]> * sdk: release v2.124.0-beta.4 * feat: customized cadence account loader (#1666) * feat: customized cadence account loader bby * feat: method to read account cadence on custom cadence account loader * feat: PR feedback on customized loader cleaup code and better naming * fix: lint and prettify * feat: more efficient rpc polling on custom polling intervals * feat: custom cadence acct loader override load * chore: prettify * sdk: release v2.124.0-beta.5 * sdk: sync-user-trade-tier-calcs (#1673) * sdk: sync-user-trade-tier-calcs * prettify --------- Co-authored-by: Nick Caradonna <[email protected]> * sdk: release v2.124.0-beta.6 * sdk: add new admin client fn * Revert "sdk: add new admin client fn" This reverts commit c7a4f0b174858048bd379f2f2bb0e63595949921. * sdk: release v2.124.0-beta.7 * refactor(ui): add callback logic, fix polling frequency update * sdk: release v2.124.0-beta.8 * program: less order param sanitization for long tail perps (#1680) * program: allow-auction-start-buffer-on-tail-mkt * fix test * cargo fmt -- * CHANGELOG --------- Co-authored-by: 0xbigz <[email protected]> * Wphan/custom coder (#1682) * sdk: allow custom coder * remove unused accounts coder * linter * move customCoder into sdk, lint * update test helpers * update testhelpers.ts * sdk: release v2.124.0-beta.9 * update sdk exports * sdk: release v2.124.0-beta.10 * sdk: safer-calculate-spread-reserve-math (#1681) * sdk: release v2.124.0-beta.11 * update getMaxLeverageForPerp to use usdc logic (#1678) * sdk: release v2.124.0-beta.12 * program: override for oracle delay (#1679) * programy: override for oracle delay * update impl * switch to i8 * CHANGELOG * program: programmatic rebalance between protocol owned if holdings (#1653) * program: if swap * program: add initial config * add update * more * moar * moar * moar * program: update how swap epoch works * add test * add an invariant * cargo fmt -- * add transfer to rev pool * add mint validation * cargo fmt -- * track in amount between tranfsers * add to ci tests * separate key * program: always transfer max amount to rev pool * CHANGELOG * sdk: release v2.124.0-beta.13 * sdk: improve-aclient-accounts-logic (#1684) * sdk: release v2.124.0-beta.14 * program: improve-amm-spread-validates (#1685) * program: let hot wallet update amm jit intensity * sdk: hot wallet can update amm jit intensity * program: hot wallet can update curve intensity * program: fix build * sdk: update idl * sdk: release v2.124.0-beta.15 * v2.124.0 * sdk: release v2.125.0-beta.0 * program: three-point-std-estimator (#1686) * program: three-point-std-estimator * update tests and add sdk * update changelog * sdk: add-updatePerpMarketOracleSlotDelayOverride (#1691) * sdk: release v2.125.0-beta.1 * program: add-amm-inventory-spread-adjustment-param (#1690) * program: add-amm-inventory-spread-adjustment-param * cargo fmt -- * update sdk * prettier * fix syntax { --------- Co-authored-by: Chris Heaney <[email protected]> * program: max-apr-rev-settle-by-spot-market (#1692) * program: max-apr-rev-settle-by-spot-market * update max * default to u128 to avoid casts * changelog * sdk: release v2.125.0-beta.2 * program: better account for imf in calculate_max_perp_order_size (#1693) * program: better account for imf in calculate_max_perp_order_size * CHANGELOG * v2.125.0 * sdk: release v2.126.0-beta.0 * sdk: only count taker fee in calculateEntriesEffectOnFreeCollateral for maintenance (#1694) * sdk: release v2.126.0-beta.1 * Separate getAddInsuranceFundStakeIxs (#1695) * sdk: release v2.126.0-beta.2 * idl: amm-inv-adj-latest-idl (#1697) * sdk: release v2.126.0-beta.3 * sdk: spot-market-index-54 constants (#1696) * sdk: release v2.126.0-beta.4 * sdk: update spot market index 54 pythlazer id * sdk: release v2.126.0-beta.5 * Update spotMarkets.ts * sdk: release v2.126.0-beta.6 * prettify --------- Co-authored-by: Lukas deConantsesznak <[email protected]> Co-authored-by: Chester Sim <[email protected]> Co-authored-by: Nour Alharithi <[email protected]> Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bigz_Pubkey <[email protected]> Co-authored-by: lowkeynicc <[email protected]> Co-authored-by: jordy25519 <[email protected]> Co-authored-by: Luke Steyn <[email protected]> Co-authored-by: lil perp <[email protected]> Co-authored-by: LukasDeco <[email protected]> Co-authored-by: Nick Caradonna <[email protected]> Co-authored-by: Jesse Cha <[email protected]> * slot staleness checks (#1705) * slot staleness checks * update aum ix to use constituent oracles * Nour/derivative constituent testing (#1708) * slot staleness checks * update aum ix to use constituent oracles * constituent test works when adjusting derivative index * constituent depeg kill switch works * works with multiple derivatives on the same parent * remove incorrect usage of nav * fix adminClient and tests * Nour/fee grid search testing (#1714) * grid search * grid search swap test * Nour/address comments (#1715) * low hanging fruit comments * remove pda checks and store lp pool on zero copy accounts * parameterize depeg threshold * make description in lp pool event * update idl for event change * add swap fee unit tests (#1713) * add swap fee unit tests * remove linear inventory fee component * Nour/settle accounting (#1723) * fixing the main settle test and settle function * all current tests pass * update msg occurrences * dont update lp quote owed unless collateralized * Nour/settle testing (#1725) * refactor settle pnl to modularize and add tests * more cargo tests * prettify * Nour/address more comments (#1726) * use oracle staleness threshold for staleness * add spot market vault invariant * refactor update_aum, add unit tests (#1727) * refactor update_aum, add unit tests * add constituent target base tests * update doc * Nour/parameterize dlp (#1731) * add validates and test for withdraw limit * settlement max * update idl * merge conflicts * fixes * update idl * bug fixes * mostly sdk fixes * bug fixes * bug fix and deploy script * program: new amm oracle (#1738) * zero unused amm fields * cargo fmt * bare bones ix * minimal anchor mm oracle impl * update test file * only do admin validate when not anchor test * updates * generalize native entry * fix weird function name chop off * make it compile for --feature cpi (#1748) Co-authored-by: jordy25519 <[email protected]> * more efficeint clock and state bit flags check * vamm uses mm oracle (#1747) * add offset * working tests * refactor to use MM oracle as its own type * remove weird preface * sdk updates * bankrun tests all pass * fix test * changes and fixes * widen confidence if mm oracle too diff * sdk side for confidence adjust * changelog * fix lint * fix cargo tests * address comments * add conf check * remove anchor ix and cache oracle confidence * only state admin can reenable mm oracle kill switch * cargo fmt --------- Co-authored-by: jordy25519 <[email protected]> * fix tests (#1764) * Nour/move ixs around (#1766) * move around ixs * remove message * add devnet oracle crank wallet * refactored mm oracle * sdk changes + cargo fmt * fix tests * validate price bands with fill fix * normalize fill within price bands * add sdk warning * updated type * undefined guard so anchor tests pass * accept vec for update amm and view amm * adjust test to work with new price bands * Revert "adjust test to work with new price bands" This reverts commit ee40ac8799fa2f6222ea7d0e9b3e07014346a699. * remove price bands logic * add zero ix for mm oracle for reset * add new drift client ix grouping * v1 safety improvements * isolate funding from MM oracle * add cargo tests for amm availability * change oracle validity log bool to enum * address comment * make validate fill direction agnostic * fix liquidate borrow for perp pnl test * fix tests and address comments * commit constituent map to barrel file * add lp fields to perp market account * rearrange perp market struct for lp fields * bug fix for notional position tracking * view function * fee view functions * max aum + whitelist check and removing get_mint_redeem_fee for now * add wsol support for add liquidity * fix sdk and typing bugs * update lp pool params ix * admin override cache and disable settle functions * devnet swap working * dlp taker discovered bug fixes and sdk changes * refactor last settle ts to last settle slot * Nour/settle pnl fix (#1817) * settle perp to lp pool bug fixes * update bankrun test to not use admin fee pool deposit * fix tests using update spot market balances too * add log msgs for withdraw and fix casting bug * check in for z (#1823) * feat: option for custom oracle ws subscriber * fix: pass custom oracle ws sub option in dc constructor * sdk: add spot-market-index-57 to constants (#1815) * sdk: release v2.134.0-beta.2 * lazer oracle migration (#1813) * lazer oracle migration * spot markets too * sdk: release v2.134.0-beta.3 * sdk: release v2.134.0-beta.4 * program: settle pnl invariants (#1812) * program: settle pnl invariants * add test * fix lint * lints * add msg * CHANGELOG * cargo fmt -- * program: add_update_perp_pnl_pool (#1810) * program: add_update_perp_pnl_pool * test * CHANGELOG * sdk: release v2.134.0-beta.5 * program: update-mark-twap-integer-bias (#1783) * program: update-mark-twap-integer-bias * changelog update * program: update-fee-tier-determine-fix5 (#1800) * program: update-fee-tier-determine-fix5 * update changelog * program: update-mark-twap-crank-use-5min-basis (#1769) * program: update-mark-twap-crank-use-5min-basis * changelog * program: update-min-margin-const-limit (#1802) * program: update-min-margin-const-limit * add CHANGELOG.md * sdk: release v2.134.0-beta.6 * program: rm-burn-lp-shares-invariant (#1816) * program: rm-burn-lp-shares-invariant * update changelog * fix test and cargo fmt * fix anchor tests * yarn prettify:fix * reenable settle_pnl mode test * v2.134.0 * sdk: release v2.135.0-beta.0 * Merge pull request #1820 from drift-labs/chester/fix-zod * sdk: release v2.135.0-beta.1 * mm oracle sdk change (#1806) * mm oracle sdk change * better conditional typing * DLOB bug fix * updated idl * rm getAmmBidAskPrice * sdk: release v2.135.0-beta.2 * sdk: fix isHighLeverageMode * sdk: release v2.135.0-beta.3 * refactor(sdk): add update delegate ix method, ovrride authority for settle multiple pnl (#1822) * check in for z * more logging changes * mm oracle sdk additions (#1824) * strict typing for more MM oracle contact points * add comments to auction.ts * prettify * sdk: release v2.135.0-beta.4 * init constituent bug fix and type change * add in invariant to be within 1 bp of balance before after * add strict typing for getPrice and new auction trigger function (#1826) * add strict typing for getPrice and new auction trigger function * refactor getTriggerAuctionStartAndExecutionPrice * sdk: release v2.135.0-beta.5 * update tests and enforce atomic settles for withdraw * add failing withdraw test * withdraw fix * bring diff in validate back to 1 * make lp pool test fail * better failed test * only check after < before, do to spot precision limits * add balance check to be < 1 cent --------- Co-authored-by: Lukas deConantsesznak <[email protected]> Co-authored-by: bigz_Pubkey <[email protected]> Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: LukasDeco <[email protected]> Co-authored-by: lil perp <[email protected]> Co-authored-by: wphan <[email protected]> Co-authored-by: Chester Sim <[email protected]> * add price for lp validates (#1833) * add missing token account reloads and syncs * add disabled lp pool swaps by default * more extensive aum logging * Wphan/merge-builder-codes (#1842) * add RevenueShare and RevenueShareEscrow accounts an init ixs * fix multiple array zc account, and handling different message types in place_signed_msg_taker_order * decoding error * recording orders in RevenueShareEscrow workin * cancel and fill orders * idl * fix sdk build * fix math * update RevenueShareOrder bitflags, store builder_idx instead of pubkey * merge RevenueShareOrders on add * remove builder accounts from cancel ixs, wip settle impl * dont fail settlpnl if no builder users provided * finish settle, rename RevenueShare->Builder, RevenueShareEscrow->BuilderEscrow * feat: option for custom oracle ws subscriber * fix: pass custom oracle ws sub option in dc constructor * sdk: add spot-market-index-57 to constants (#1815) * sdk: release v2.134.0-beta.2 * lazer oracle migration (#1813) * lazer oracle migration * spot markets too * sdk: release v2.134.0-beta.3 * sdk: release v2.134.0-beta.4 * program: settle pnl invariants (#1812) * program: settle pnl invariants * add test * fix lint * lints * add msg * CHANGELOG * cargo fmt -- * program: add_update_perp_pnl_pool (#1810) * program: add_update_perp_pnl_pool * test * CHANGELOG * sdk: release v2.134.0-beta.5 * program: update-mark-twap-integer-bias (#1783) * program: update-mark-twap-integer-bias * changelog update * program: update-fee-tier-determine-fix5 (#1800) * program: update-fee-tier-determine-fix5 * update changelog * program: update-mark-twap-crank-use-5min-basis (#1769) * program: update-mark-twap-crank-use-5min-basis * changelog * program: update-min-margin-const-limit (#1802) * program: update-min-margin-const-limit * add CHANGELOG.md * sdk: release v2.134.0-beta.6 * program: rm-burn-lp-shares-invariant (#1816) * program: rm-burn-lp-shares-invariant * update changelog * fix test and cargo fmt * fix anchor tests * yarn prettify:fix * reenable settle_pnl mode test * v2.134.0 * sdk: release v2.135.0-beta.0 * add more bankrun tests, clean up * clean up, fix tests * why test fail * add subaccountid to BuilderOrder * reduce diff * add referrals * add test can fill settle user with no builderescrow * add referral builder feature flag and referral migration method * fix cargo tests, try fix bankrun test timing issue * Merge pull request #1820 from drift-labs/chester/fix-zod * sdk: release v2.135.0-beta.1 * mm oracle sdk change (#1806) * mm oracle sdk change * better conditional typing * DLOB bug fix * updated idl * rm getAmmBidAskPrice * sdk: release v2.135.0-beta.2 * sdk: fix isHighLeverageMode * sdk: release v2.135.0-beta.3 * refactor(sdk): add update delegate ix method, ovrride authority for settle multiple pnl (#1822) * mm oracle sdk additions (#1824) * strict typing for more MM oracle contact points * add comments to auction.ts * prettify * sdk: release v2.135.0-beta.4 * add strict typing for getPrice and new auction trigger function (#1826) * add strict typing for getPrice and new auction trigger function * refactor getTriggerAuctionStartAndExecutionPrice * sdk: release v2.135.0-beta.5 * sdk: handle unfillable reduce only orders (#1790) * sdk: handle unfillable reduce only orders * fix dlob tests build errors * fix some test build errors * sdk: release v2.135.0-beta.6 * ref price offset amm math fix (#1828) * ref price offset amm math fix * add latest slot optional var to callers of update amm spread * sdk: release v2.135.0-beta.7 * latest slot as argument to getL2 (#1829) * latest slot as argument to getL2 * add comment * update BN import * sdk: release v2.135.0-beta.8 * add SignedMsgOrderParamsMessageV2 * program: trigger price use 5min mark price (#1830) * program: trigger price use 5min mark price * cargo fmt -- --------- Co-authored-by: 0xbigz <[email protected]> * v2.135.0 * sdk: release v2.136.0-beta.0 * zero pad swift messages to make backwards compatible * PR feedback * update tests/placeAndMakeSignedMsgBankrun.ts to handle client side errors * lukas/websocket improvements (#1807) * feat: initial implementation for users and markets WS improvements * lukas/gill websocket sub (#1781) * websockets gill temp * feat: feature parity between gill version ws acct sub and reg one + optional passing into driftClient * fix: post rebase bugs and cleanup * chore: websocket account subscriber export * feat: logging string update on ws acct v2 * rm: useless logging * chore: cleanup ws subscriber v2 docs * chore: specific name on custom ws acct sub param * fix: post rebase again cleanup * fix: prettier fixed * feat: initial implementation for users and markets WS improvements * feat: polling check on websocket acct subscriber v2 + naming * fix: lint * fix: non-hanging WS subscription async loop handling * fix: bugs with program ws subs hanging on asynciter * fix: goofy self imports * feat: initial batch fetching temp * temp: sub second WS subscribe time * fix: ws program account subscriber v2 bugs and optimizations * feat: chunk stuff account requests * feat: more subscribe optimizations ws driftclient sub v2 * chore: cleanup ws sub v2 logs * feat: conditional check on using ws account subscriber + unused * fix: bad import * chore: add export of WebSocketProgramAccountSubscriberV2 * fix: unneeded drift idl export messing up common build * fix: consolidate rpc ws subscriptions for oracles * feat: docs for ws v2 and cleanup * chore: more docs on ws acct susbcriber v2 * feat: PR feedback round 2 * fix: default timeout for ws v2 susbcribers * feat: PR feedback on resubOpts and simplify logic * fix: prettier * sdk: release v2.136.0-beta.1 * refactor(sdk): add decimal override for bignum prettyPrint * sdk: release v2.136.0-beta.2 * sdk: while valid tx sender memory leak fix * sdk: release v2.136.0-beta.3 * refactor account logic for borrows * remove double fee count, update tests to check filled position and quote amounts fda * rename Builder -> RevenueShare * add test check accumulated builder/ref fees * fix settle multiple pnl accounts, test ref rewards in multiple markets * [ FIX ] `posaune0423/fix tx fee payer` (#1837) * sdk: release v2.136.0-beta.4 * sdk: add constant for spot market index 58 (#1840) * sdk: add spot market constant 58 * revert .sh * sdk: release v2.136.0-beta.5 * Revert "[ FIX ] `posaune0423/fix tx fee payer` (#1837)" (#1841) This reverts commit 8cc07e0e179d4335fbb47f8aef5ae022b7143550. * sdk: release v2.136.0-beta.6 * express builder fees in tenth of bps * update referral migration params * PR feedback * add builder code feature gate * fix tests * add referral fields * run all tests * kickoff build * disable extra instructions, fix builder code feature flag selection --------- Co-authored-by: Lukas deConantsesznak <[email protected]> Co-authored-by: bigz_Pubkey <[email protected]> Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: moosecat <[email protected]> Co-authored-by: LukasDeco <[email protected]> Co-authored-by: lil perp <[email protected]> Co-authored-by: Chester Sim <[email protected]> Co-authored-by: asuma <[email protected]> * calc aum bug fix for borrows * idl changes and drift client working * Wphan/dlp revert builder codes (#1854) * Revert "Wphan/merge-builder-codes (#1842)" This reverts commit c999f83e000436e34ce4cde17700521d24057208. * fix conflicts * fix incorrect merges * address some perp comments * respond to more comments * pda efficiency changes * Revert "pda efficiency changes" This reverts commit 578b957fe9dc6caa6dd1221e357cfc9ddfee0170. * Revert "respond to more comments" This reverts commit 27600a179f57287aeed860a6ae6c6451eb9a62ba. * better wsol handling * subtract exchange fees from amount settled (#1849) * subtract exchange fees from amount settled * add exchange fee scalar to settling * use percents isntead of scalars * re-introduce breaking bchanges * pda efficiency changes * more pda changes * fix tests * merge in crisp token authority changes * address more comments * amm cache rework (#1863) * Crispheaney/lp whitelist mint (#1866) * lp whitelist mint * test * prettify * Crispheaney/zero copy oracle validity (#1865) * amm cache zero copy validity * remove unnecessary fields from amm cache * update pda --------- Co-authored-by: Nour Alharithi <[email protected]> * address renaming comments * Nour/cu profiling (#1870) * add CU profiling test * reduce CUs for target base * cache robustness and limit testing CUs * pass through trade ratio in fee calcs * Crispheaney/withdraw in rm liquidity (#1871) * init * fail transfer_from_program_vault if withdraw too big * test * Nour/expand lp status (#1867) * constituent status and paused operations * add admin functions and tests * add lp status checks * testing expanded to lp pool paushed operations on perp markets * make new wallet for lp taker swaps rather than hot wallet * idl changes and bug fixes * improve CUs for target base * more CU opts * more CU reduction in target crank * lp/init lp-settle-records (#1872) * init lp-settle-records * update pr to emit event * add in last settle ts --------- Co-authored-by: Nour Alharithi <[email protected]> * remove more unused lp pool params * update idl * update constituent target params vals * update idl * Crispheaney/rm mint (#1875) * rm unnecessary mints * sdk updates --------- Co-authored-by: Nour Alharithi <[email protected]> * add constituent map memcmp and lp status on cache * update tests and amm cache iteration method * change target base ix ordering * update admin client whitelistdlp token ix and other things --------- Co-authored-by: 0xbigz <[email protected]> Co-authored-by: wphan <[email protected]> Co-authored-by: Chris Heaney <[email protected]> Co-authored-by: Lukas deConantsesznak <[email protected]> Co-authored-by: Chester Sim <[email protected]> Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: lowkeynicc <[email protected]> Co-authored-by: jordy25519 <[email protected]> Co-authored-by: Luke Steyn <[email protected]> Co-authored-by: LukasDeco <[email protected]> Co-authored-by: Nick Caradonna <[email protected]> Co-authored-by: Jesse Cha <[email protected]> Co-authored-by: asuma <[email protected]> * add vamm cache percent scalar (default is 100) * aum cant go below zero (#1890) * aum cant go below zero * keep it signed * reassing dlp taker bot wallet * add event subscriber changes for dlp events * give permission for dlp taker bot to deposit withdraw from program vault to dlp * fix max withdrawals bug * get max transfer bug fix * Wphan/merge-master (#1915) * fix comments (#1844) * chore: update laser 0.1.8 * chore: remove logging * program: tweak ResizeSignedMsgUserOrders (#1898) * fix linter and cargo test * fix cargo build errors * v2.138.0 * sdk: release v2.139.0-beta.0 * program: init-delegated-if-stake (#1859) * program: init-delegated-if-stake * add sdk * CHANGELOG --------- Co-authored-by: Chris Heaney <[email protected]> * program: auction-order-params-on-slow-fast-twap-divergence (#1882) * program: auction-order-params-on-slow-fast-twap-divergence * change tests * rm dlog * CHANGELOG * cargo fmt -- --------- Co-authored-by: Chris Heaney <[email protected]> * program: add invariant for max in amount for if swap (#1825) * sdk: release v2.139.0-beta.1 * chore: add grpc client to order subscriber * sdk: release v2.139.0-beta.2 * sdk: add market index 76 to constant (#1901) * sdk: release v2.139.0-beta.3 * fix ui build (#1902) * sdk: release v2.139.0-beta.4 * sdk: update aster config (#1903) * update aster config * add pythLazerId * sdk: release v2.139.0-beta.5 * Revert "Revert "Crispeaney/revert swift max margin ratio" (#1877)" (#1907) This reverts commit 0a8e15349f45e135df3eb2341f163d70ef09fe64. * sdk: release v2.139.0-beta.6 * Revert "Revert "Revert "Crispeaney/revert swift max margin ratio" (#1877)" (#…" (#1910) * sdk: release v2.139.0-beta.7 * more robust isDelegateSigner for swift orders * sdk: release v2.139.0-beta.8 * program: allow resolve perp pnl deficit if pnl pool isnt 0 but at deficit (#1909) * program: update-resolve-perp-pnl-pool-validate * CHANGELOG --------- Co-authored-by: Chris Heaney <[email protected]> * program: add immutable owner support for token 22 vaults (#1904) * program: add immutable owner support for token 22 vaults * cargo fmt -- * CHANGELOG * sdk: tweak math for filling triggers (#1880) * sdk: tweak math for filling triggers * add back line * sdk: release v2.139.0-beta.9 * program: allow delegate to update user position max margin ratio (#1913) * Revert "more robust isDelegateSigner for swift orders" This reverts commit 2d4e30b5bfac835c2251b8640b898408714a7c13. * sdk: release v2.139.0-beta.10 * update SwiftOrderMessage type for missing fields (#1908) * sdk: release v2.139.0-beta.11 * sdk: add getUpdateFeatureBitFlagsMedianTriggerPriceIx * sdk: release v2.139.0-beta.12 * update devnet market constants (#1914) * sdk: release v2.139.0-beta.13 * program: deposit into if stake from admin (#1899) * program: deposit into if stake from admin * add test * change action * cargo fmt -- * move depositIntoInsuranceFundStake to adminClient --------- Co-authored-by: wphan <[email protected]> * sdk: release v2.139.0-beta.14 * program: comment out unused ix (#1911) * program: raise MAX_BASE_ASSET_AMOUNT_WITH_AMM numerical invariant * v2.139.0 * sdk: release v2.140.0-beta.0 --------- Co-authored-by: jordy25519 <[email protected]> Co-authored-by: Jack Waller <[email protected]> Co-authored-by: lil perp <[email protected]> Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bigz_Pubkey <[email protected]> Co-authored-by: lowkeynicc <[email protected]> Co-authored-by: Nour Alharithi <[email protected]> * add new bulk instruction packaging * logging changes * Wphan/master-dlp (#1918) * fix comments (#1844) * chore: update laser 0.1.8 * chore: remove logging * program: tweak ResizeSignedMsgUserOrders (#1898) * fix linter and cargo test * fix cargo build errors * v2.138.0 * sdk: release v2.139.0-beta.0 * program: init-delegated-if-stake (#1859) * program: init-delegated-if-stake * add sdk * CHANGELOG --------- Co-authored-by: Chris Heaney <[email protected]> * program: auction-order-params-on-slow-fast-twap-divergence (#1882) * program: auction-order-params-on-slow-fast-twap-divergence * change tests * rm dlog * CHANGELOG * cargo fmt -- --------- Co-authored-by: Chris Heaney <[email protected]> * program: add invariant for max in amount for if swap (#1825) * sdk: release v2.139.0-beta.1 * chore: add grpc client to order subscriber * sdk: release v2.139.0-beta.2 * sdk: add market index 76 to constant (#1901) * sdk: release v2.139.0-beta.3 * fix ui build (#1902) * sdk: release v2.139.0-beta.4 * sdk: update aster config (#1903) * update aster config * add pythLazerId * sdk: release v2.139.0-beta.5 * Revert "Revert "Crispeaney/revert swift max margin ratio" (#1877)" (#1907) This reverts commit 0a8e15349f45e135df3eb2341f163d70ef09fe64. * sdk: release v2.139.0-beta.6 * Revert "Revert "Revert "Crispeaney/revert swift max margin ratio" (#1877)" (#…" (#1910) * sdk: release v2.139.0-beta.7 * more robust isDelegateSigner for swift orders * sdk: release v2.139.0-beta.8 * program: allow resolve perp pnl deficit if pnl pool isnt 0 but at deficit (#1909) * program: update-resolve-perp-pnl-pool-validate * CHANGELOG --------- Co-authored-by: Chris Heaney <[email protected]> * program: add immutable owner support for token 22 vaults (#1904) * program: add immutable owner support for token 22 vaults * cargo fmt -- * CHANGELOG * sdk: tweak math for filling triggers (#1880) * sdk: tweak math for filling triggers * add back line * sdk: release v2.139.0-beta.9 * program: allow delegate to update user position max margin ratio (#1913) * Revert "more robust isDelegateSigner for swift orders" This reverts commit 2d4e30b5bfac835c2251b8640b898408714a7c13. * sdk: release v2.139.0-beta.10 * update SwiftOrderMessage type for missing fields (#1908) * sdk: release v2.139.0-beta.11 * sdk: add getUpdateFeatureBitFlagsMedianTriggerPriceIx * sdk: release v2.139.0-beta.12 * update devnet market constants (#1914) * sdk: release v2.139.0-beta.13 * program: deposit into if stake from admin (#1899) * program: deposit into if stake from admin * add test * change action * cargo fmt -- * move depositIntoInsuranceFundStake to adminClient --------- Co-authored-by: wphan <[email protected]> * sdk: release v2.139.0-beta.14 * program: comment out unused ix (#1911) * program: raise MAX_BASE_ASSET_AMOUNT_WITH_AMM numerical invariant * v2.139.0 * sdk: release v2.140.0-beta.0 * sdk: update constants market index 77 (#1916) * sdk: release v2.140.0-beta.1 * Wphan/builder codes (#1805) * program: init lp pool * cargo fmt -- * add total fee fields * add update_target_weights math * program: use sparse matrix for constituent map and update tests * zero copy accounts, init ix (#1578) * update accounts (#1580) * zero copy + permissionless crank ixs (#1581) * program: support negative target weights for borrow-lend * fix tests to work with zero copy * few comment changes * remove discriminator from impl macro * add get_swap_amount, get_swap_fees, get_weight (#1579) * add get_swap_amount, get_swap_fees, get_weight * update accounts * add back ts * rebase * add constituent swap fees * fix swap fee calc (#1582) * add init amm mapping to lp context (#1583) * init constituent * add initializeLpPool test (#1585) * add initializeLpPool test * add check for constituent target weights * add add datum ix * add init tests and invariant checks * rename data to more useful names * dlp use spl token program (#1588) * add crank ix * update total_weight for validation_flags check * push test so far * overriding perp position works * remove message * fix dup total_weight add * constituent map remaining accounts * compiles * bankrun tests pass * compiles but casting failure in overflow protection test * address comment and change token arguments from u64 to u128 * bankrun tests pass * init constituent token account (#1596) * update aum calc * add update /remove mapping ixs * fix test - init constituent spot market * add crank improvements * passes tests * precision fix crank aum * precision fixes and constituent map check for account owner * add passthrough account logic (#1602) * add passthrough account logic * cant read yet * fix all zc alignment issues * make oracle source a u8 on zc struct * Wphan/dlp-swap-ixs (#1592) * add lp_swap ix * rebase * test helpers * swap works * fix swaps, add more cargo tests for fees n swap amt * remove console.logs * address PR comments * merge upstream * post-merge fixes * store bumps on accounts (#1604) * store bumps on accounts * do pda check in constituent map * address comments * Wphan/add liquidity (#1607) * add add remove liquidity fees calc * add liquidity ix * fix init mint and lppool token account, refactor test fees * add removeLiquidity bankrun test * merge upstream * add LPPool.next_mint_redeem_id * program: lp-pool-to-use-target-base-vector (#1615) * init lp pool target-base matrix * working target-base logic * add todos for add/remove liquidity aum * add renames + fix test * add beta and cost to trade in bps to target datum * add more tests * add fields to LP events, fix tests (#1620) * add fields to LP events, fix tests * revert target weight calc * add constituent.next_swap_id, fix cost_to_trade math * dlp jup swap (#1636) * dlp jup swap * add admin client ixs * almost fixed * test working? * update begin and end swap * tweaks * fix math on how much was swapped * remove unnecessary lp pool args * extra account validation * added token account pda checks in other ixs * stablecoin targets (#1638) * is stablecoin * address comments --------- Co-authored-by: Chris Heaney <[email protected]> * cleanup * transfer oracle data ix to constituent (#1643) * transfer oracle data ix to constituent * add lib entrypoint * simplify more * add spot market constraint * big cargo test (#1644) * derivative constituents + better testing + bug fixes (#1657) * all tests technically pass * update tests + prettify * bug fixes and tests pass * fix many bugs and finalize logic * deposit/borrow working and changing positions (#1652) * sdk: allow custom coder * program: dlp add upnl for settles to amm cache (#1659) * program: dlp add-upnl-for-settles-to-amm-cache * finish up lp pool transfer from perp market * add amount_to_transfer using diff * merge * add pnl and fee pool accounting + transfer from dlp to perp market --------- Co-authored-by: Nour Alharithi <[email protected]> * remove unused accounts coder * move customCoder into sdk, lint * testing: ix: settle perp to dlp, insufficient balance edge case and improvements (#1688) * finish edge case test * aum check also passes * prettify * added more settle test coverage and squash bugs (#1689) * dlp: add constituentMap (#1699) * Nour/gauntlet fee impl (#1698) * added correlation matrix infra * refactor builds * mint redeem handled for usdc * remove liquidity also should work * all tests pass * bankrun tests pass too * update aum considers amm cache (#1701) * prettify (#1702) * Wphan/merge master dlp (#1703) * feat: init swift user orders on user account creation if needed * fix: wrong pushing of swift user orders ixs * fix: broken swift tests * fix: swift -> signed msg * refactor(sdk): update jupiter's api url * fix(sdk): remove error thrown * indicative qutoes server changes * sdk: release v2.121.0-beta.7 * sdK: update market index 33 oracle rr (#1606) * sdk: add to spot constants market index 34 * revert adminClient.ts change * sdk: update spot market constants oracle index 33 * sdk: release v2.121.0-beta.8 * sdk: high leverage mode updates (#1605) * sdk: high leverage mode updates * add optional param for fee calc * update changelog * sdk: release v2.121.0-beta.9 * getPlaceSignedMsgTakerPerpOrderIxs infer HLM mode from bitflags (#1608) * sdk: release v2.121.0-beta.10 * fix: dehexify in getPlaceSignedMsgTakerPerpOrderIxs (#1610) * fix: dehexify in getPlaceSignedMsgTakerPerpOrderIxs * bankrun test * sdk: release v2.121.0-beta.11 * sdk: round tick/step size for getVammL2Generateor (#1612) * sdk: round tick/step size for etVammL2Generateor * use standard functions, include in all fcns * fix const declare, rm whitespace * fix posdir sign * sdk: release v2.121.0-beta.12 * sdk: release v2.121.0-beta.13 * sdk: constants market-index-45-46 (#1618) * sdk: release v2.121.0-beta.14 * robustness check for indicative quotes sender (#1621) * robustness check for indicative quotes sender * delete quote from market index of bad quote * sdk: release v2.121.0-beta.15 * Added launchTs for ZEUS, zBTC * sdk: release v2.121.0-beta.16 * sdk: bigz/fix-vamm-l2-generator-baseSwapped var assign (#1622) * sdk: release v2.121.0-beta.17 * sdk: fix vamm l2 generator base swapped (#1623) * sdk: bigz/fix-vamm-l2-generator-baseSwapped var assign * fix ask book else baseSwapped calc * sdk: release v2.121.0-beta.18 * sdk: revert vamm l2 gen (#1624) * Revert "sdk: fix vamm l2 generator base swapped (#1623)" This reverts commit 56bc78d70e82cb35a90f12f73162bffb640cb655. * Revert "sdk: bigz/fix-vamm-l2-generator-baseSwapped var assign (#1622)" This reverts commit e49cfd554cc44cd8d7770184f02f6ddb0bfc92f1. * Revert "sdk: round tick/step size for getVammL2Generateor (#1612)" This reverts commit f932a4ea2afcae314e406b7c7ee35e55b36043ad. * sdk: release v2.121.0-beta.19 * sdk: show protected-asset have zero-borrow-limit (#1603) * sdk: show protected-asset have zero-borrow-limit * rm unused AssetTier import * sdk: release v2.121.0-beta.20 * sdk: market-constants-index-74 (#1629) * sdk: release v2.121.0-beta.21 * program: use saturating_sub for number_of_users (#1616) * program: use saturating_sub for number_of_users * update CHANGELOG.md * program: allow fixing hlm num users (#1630) * sdk: release v2.121.0-beta.22 * sdk: fix switchboard on demand client to use landed at * sdk: release v2.121.0-beta.23 * sdk: spot-market-poolid-4 constants (#1631) * sdk: release v2.121.0-beta.24 * fix high lev mode liq price (#1632) * sdk: release v2.121.0-beta.25 * replace deprecated solana install scripts (#1634) * sdk: release v2.121.0-beta.26 * refactor(sdk): use ReturnType for Timeout types (#1637) * sdk: release v2.121.0-beta.27 * auction price sdk fix * sdk: release v2.121.0-beta.28 * program: multi piecewise interest rate curve (#1560) * program: multi-piecewise-interest-rate-curve * update tests * widen out borrow limits/healthy util check * add break, use array of array for borrow slope segments * program: fix cargo test * sdk: add segmented IR curve to interest rate calc * clean up unusded var, make interest rate segment logic a const * incorp efficiency feedback points * test: add sol realistic market example * cargo fmt -- * CHANGELOG --------- Co-authored-by: Chris Heaney <[email protected]> * sdk: release v2.121.0-beta.29 * program: allow hot admin to update market fuel params (#1640) * v2.121.0 * sdk: release v2.122.0-beta.0 * sdk: fix nullish coalescing * sdk: release v2.122.0-beta.1 * program: add logging for wrong perp market mutability * sdk: check free collateral change in maxTradeSizeUsdcForPerp (#1645) * sdk: check free collateral change in maxTradeSizeUsdcForPerp * update changelog * sdk: release v2.122.0-beta.2 * refactor(sdk): emit newSlot event on initial subscribe call (#1646) * sdk: release v2.122.0-beta.3 * sdk: spot-market-constants-pool-id-2 (#1647) * sdk: release v2.122.0-beta.4 * sdk: add-spot-market-index-52-constants (#1649) * sdk: release v2.122.0-beta.5 * program: add existing position fields to order records (#1614) * program: add quote entry amount to order records * fix cargo fmt and test * more reusable code * more reusable code * add another comment * fix math * account for pos flip * fix typo * missed commit * more fixes * align naming * fix typo * CHANGELOG * program: check limit price after applying buffer in trigger limit ord… (#1648) * program: check limit price after applying buffer in trigger limit order auction * program: reduce duplicate code * fix tests * CHANGELOG --------- Co-authored-by: 0xbigz <[email protected]> * program: fix cargo tests * program: check limit price when setting auction for limit order (#1650) * program: check limit price after applying buffer in trigger limit order auction * program: reduce duplicate code * program: check limit price when setting limit auction params * cargo fmt -- * fix CHANGELOG * tests: updates switchboardTxCus.ts * program: try to fix iteration for max order size (#1651) * Revert "program: try to fix iteration for max order size (#1651)" This reverts commit 3f0eab39ed23fa4a9c41cbab9af793c60b50a239. * disable debug logging in bankrun tests * v2.122.0 * sdk: release v2.123.0-beta.0 * sdk: constants-spot-market-index-53 (#1655) * sdk: release v2.123.0-beta.1 * sdk: idl for new existing position order action records * fix: protocol test prettier fix * make ci lut checks not shit * sdk: release v2.123.0-beta.2 * sdk: fix vamm l2 generator base swapped and add new top of book (#1626) * sdk: bigz/fix-vamm-l2-generator-baseSwapped var assign * fix ask book else baseSwapped calc * use proper quoteAmount with baseSwap for top of book orders * clean up console.log * sdk: getVammL2Generator reduce loc (#1628) * sdk: getVammL2Generator-reduce-loc * add MAJORS_TOP_OF_BOOK_QUOTE_AMOUNTS * add marketindex check topOfBookAmounts * yarn lint/prettier * sdk: release v2.123.0-beta.3 * program: allow all limit orders to go through swift (#1661) * program: allow all limit orders to go through swift * add anchor test * CHANGELOG * sdk: add optional initSwiftAccount on existing account deposits (#1660) * sdk: release v2.123.0-beta.4 * program: add taker_speed_bump_override and amm_spread_adjustment * Revert "program: add taker_speed_bump_override and amm_spread_adjustment" This reverts commit 1e19b7e7a6c5cecebdbfb3a9e224a0d4471ba6d2. * program: tests-fee-adjustment-neg-100 (#1656) * program: tests-fee-adjustment-neg-100 * add HLM field to test * cargo fmt -- --------- Co-authored-by: Chris Heaney <[email protected]> * program: simplify user can skip duration (#1668) * program: simplify user can skip duration * update context * CHANGELOG * fix test * fix pmm tests --------- Co-authored-by: Chris Heaney <[email protected]> * program: add taker_speed_bump_override and amm_spread_adjustment (#1665) * program: add taker_speed_bump_override and amm_spread_adjustment * add admin client * cargo test * add impl for amm_spread_adjustment * ensure no overflows * CHANGELOG * cargo fmt -- * sdk types * prettify --------- Co-authored-by: 0xbigz <[email protected]> * program: update-amm-spread-and-availability-constraints (#1663) * program: update-amm-spread-and-availability-constraints * fix cargo tests * program: use saturating mul for amm spread adj * nour/indic-quotes-sender-v2 (#1667) * nour/indic-quotes-sender-v2 * prettify * pass margin category into calculateEntriesEffectOnFreeCollateral (#1669) * fix cargo test * tests: fix oracle guardrail test * sdk: update idl * yarn prettify:fix * tests: fix a few more place and make tests * prettify fix * whitespace readme change * sdk: release v2.123.0-beta.5 * v2.123.0 * sdk: release v2.124.0-beta.0 * v2.123.0-1 * sdk: calculateVolSpreadBN-sync (#1671) * sdk: release v2.124.0-beta.1 * sdk: calculate-spread-bn-add-amm-spread-adjustment (#1672) * sdk: calculate-spread-bn-add-amm-spread-adjustment * corect sign * add math max 1 * prettify * sdk: release v2.124.0-beta.2 * sdk: correct calculateVolSpreadBN reversion * sdk: release v2.124.0-beta.3 * sdk: add getTriggerAuctionStartPrice (#1654) * sdk: add getTriggerAuctionStartPrice * updates * precisions * remove startBuffer param --------- Co-authored-by: Chris Heaney <[email protected]> * sdk: release v2.124.0-beta.4 * feat: customized cadence account loader (#1666) * feat: customized cadence account loader bby * feat: method to read account cadence on custom cadence account loader * feat: PR feedback on customized loader cleaup code and better naming * fix: lint and prettify * feat: more efficient rpc polling on custom polling intervals * feat: custom cadence acct loader override load * chore: prettify * sdk: release v2.124.0-beta.5 * sdk: sync-user-trade-tier-calcs (#1673) * sdk: sync-user-trade-tier-calcs * prettify --------- Co-authored-by: Nick Caradonna <[email protected]> * sdk: release v2.124.0-beta.6 * sdk: add new admin client fn * Revert "sdk: add new admin client fn" This reverts commit c7a4f0b174858048bd379f2f2bb0e63595949921. * sdk: release v2.124.0-beta.7 * refactor(ui): add callback logic, fix polling frequency update * sdk: release v2.124.0-beta.8 * program: less order param sanitization for long tail perps (#1680) * program: allow-auction-start-buffer-on-tail-mkt * fix test * cargo fmt -- * CHANGELOG --------- Co-authored-by: 0xbigz <[email protected]> * Wphan/custom coder (#1682) * sdk: allow custom coder * remove unused accounts coder * linter * move customCoder into sdk, lint * update test helpers * update testhelpers.ts * sdk: release v2.124.0-beta.9 * update sdk exports * sdk: release v2.124.0-beta.10 * sdk: safer-calculate-spread-reserve-math (#1681) * sdk: release v2.124.0-beta.11 * update getMaxLeverageForPerp to use usdc logic (#1678) * sdk: release v2.124.0-beta.12 * program: override for oracle delay (#1679) * programy: override for oracle delay * update impl * switch to i8 * CHANGELOG * program: programmatic rebalance between protocol owned if holdings (#1653) * program: if swap * program: add initial config * add update * more * moar * moar * moar * program: update how swap epoch works * add test * add an invariant * cargo fmt -- * add transfer to rev pool * add mint validation * cargo fmt -- * track in amount between tranfsers * add to ci tests * separate key * program: always transfer max amount to rev pool * CHANGELOG * sdk: release v2.124.0-beta.13 * sdk: improve-aclient-accounts-logic (#1684) * sdk: release v2.124.0-beta.14 * program: improve-amm-spread-validates (#1685) * program: let hot wallet update amm jit intensity * sdk: hot wallet can update amm jit intensity * program: hot wallet can update curve intensity * program: fix build * sdk: update idl * sdk: release v2.124.0-beta.15 * v2.124.0 * sdk: release v2.125.0-beta.0 * program: three-point-std-estimator (#1686) * program: three-point-std-estimator * update tests and add sdk * update changelog * sdk: add-updatePerpMarketOracleSlotDelayOverride (#1691) * sdk: release v2.125.0-beta.1 * program: add-amm-inventory-spread-adjustment-param (#1690) * program: add-amm-inventory-spread-adjustment-param * cargo fmt -- * update sdk * prettier * fix syntax { --------- Co-authored-by: Chris Heaney <[email protected]> * program: max-apr-rev-settle-by-spot-market (#1692) * program: max-apr-rev-settle-by-spot-market * update max * default to u128 to avoid casts * changelog * sdk: release v2.125.0-beta.2 * program: better account for imf in calculate_max_perp_order_size (#1693) * program: better account for imf in calculate_max_perp_order_size * CHANGELOG * v2.125.0 * sdk: release v2.126.0-beta.0 * sdk: only count taker fee in calculateEntriesEffectOnFreeCollateral for maintenance (#1694) * sdk: release v2.126.0-beta.1 * Separate getAddInsuranceFundStakeIxs (#1695) * sdk: release v2.126.0-beta.2 * idl: amm-inv-adj-latest-idl (#1697) * sdk: release v2.126.0-beta.3 * sdk: spot-market-index-54 constants (#1696) * sdk: release v2.126.0-beta.4 * sdk: update spot market index 54 pythlazer id * sdk: release v2.126.0-beta.5 * Update spotMarkets.ts * sdk: release v2.126.0-beta.6 * prettify --------- Co-authored-by: Lukas deConantsesznak <[email protected]> Co-authored-by: Chester Sim <[email protected]> Co-authored-by: Nour Alharithi <[email protected]> Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bigz_Pubkey <[email protected]> Co-authored-by: lowkeynicc <[email protected]> Co-authored-by: jordy25519 <[email protected]> Co-authored-by: Luke Steyn <[email protected]> Co-authored-by: lil perp <[email protected]> Co-authored-by: LukasDeco <[email protected]> Co-authored-by: Nick Caradonna <[email protected]> Co-authored-by: Jesse Cha <[email protected]> * slot staleness checks (#1705) * slot staleness checks * update aum ix to use constituent oracles * Nour/derivative constituent testing (#1708) * slot staleness checks * update aum ix to use constituent oracles * constituent test works when adjusting derivative index * constituent depeg kill switch works * works with multiple derivatives on the same parent * remove incorrect usage of nav * fix adminClient and tests * Nour/fee grid search testing (#1714) * grid search * grid search swap test * Nour/address comments (#1715) * low hanging fruit comments * remove pda checks and store lp pool on zero copy accounts * parameterize depeg threshold * make description in lp pool event * update idl for event change * add swap fee unit tests (#1713) * add swap fee unit tests * remove linear inventory fee component * Nour/settle accounting (#1723) * fixing the main settle test and settle function * all current tests pass * update msg occurrences * dont update lp quote owed unless collateralized * Nour/settle testing (#1725) * refactor settle pnl to modularize and add tests * more cargo tests * prettify * Nour/address more comments (#1726) * use oracle staleness threshold for staleness * add spot market vault invariant * refactor update_aum, add unit tests (#1727) * refactor update_aum, add unit tests * add constituent target base tests * update doc * Nour/parameterize dlp (#1731) * add validates and test for withdraw limit * settlement max * update idl * merge conflicts * fixes * update idl * bug fixes * mostly sdk fixes * bug fixes * bug fix and deploy script * program: new amm oracle (#1738) * zero unused amm fields * cargo fmt * bare bones ix * minimal anchor mm oracle impl * update test file * only do admin validate when not anchor test * updates * generalize native entry * fix weird function name chop off * make it compile for --feature cpi (#1748) Co-authored-by: jordy25519 <[email protected]> * more efficeint clock and state bit flags check * vamm uses mm oracle (#1747) * add offset * working tests * refactor to use MM oracle as its own type * remove weird preface * sdk updates * bankrun tests all pass * fix test * changes and fixes * widen confidence if mm oracle too diff * sdk side for confidence adjust * changelog * fix lint * fix cargo tests * address comments * add conf check * remove anchor ix and cache oracle confidence * only state admin can reenable mm oracle kill switch * cargo fmt --------- Co-authored-by: jordy25519 <[email protected]> * fix tests (#1764) * Nour/move ixs around (#1766) * move around ixs * remove message * add devnet oracle crank wallet * refactored mm oracle * sdk changes + cargo fmt * fix tests * validate price bands with fill fix * normalize fill within price bands * add sdk warning * updated type * undefined guard so anchor tests pass * accept vec for update amm and view amm * adjust test to work with new price bands * Revert "adjust test to work with new price bands" This reverts commit ee40ac8799fa2f6222ea7d0e9b3e07014346a699. * remove price bands logic * add zero ix for mm oracle for reset * add new drift client ix grouping * v1 safety improvements * isolate funding from MM oracle * add cargo tests for amm availability * change oracle validity log bool to enum * address comment * make validate fill direction agnostic * fix liquidate borrow for perp pnl test * fix tests and address comments * add RevenueShare and RevenueShareEscrow accounts an init ixs * fix multiple array zc account, and handling different message types in place_signed_msg_taker_order * decoding error * commit constituent map to barrel file * add lp fields to perp market account * recording orders in RevenueShareEscrow workin * rearrange perp market struct for lp fields * cancel and fill orders * idl * fix sdk build * fix math * bug fix for notional position tracking * u…
1 parent 35586ec commit 1fb6e52

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+23652
-1690
lines changed

.devcontainer/Dockerfile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ ENV HOME="/root"
1313
ENV PATH="/usr/local/cargo/bin:${PATH}"
1414
ENV PATH="/root/.local/share/solana/install/active_release/bin:${PATH}"
1515

16-
RUN mkdir -p /workdir /tmp && \
17-
apt-get update -qq && apt-get upgrade -qq && apt-get install -y --no-install-recommends \
18-
build-essential git curl wget jq pkg-config python3-pip xz-utils ca-certificates \
19-
libssl-dev libudev-dev bash && \
20-
rm -rf /var/lib/apt/lists/*
16+
RUN mkdir -p /workdir /tmp \
17+
&& apt-get update -qq \
18+
&& apt-get upgrade -qq \
19+
&& apt-get install -y --no-install-recommends \
20+
build-essential git curl wget jq pkg-config python3-pip xz-utils ca-certificates \
21+
libssl-dev libudev-dev bash software-properties-common \
22+
&& add-apt-repository 'deb http://deb.debian.org/debian bookworm main' \
23+
&& apt-get update -qq \
24+
&& apt-get install -y libc6 libc6-dev \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
RUN rustup component add rustfmt
2128

2229
RUN rustup install 1.78.0 \
2330
&& rustup component add rustfmt clippy --toolchain 1.78.0

CHANGELOG.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
119119

120120
### Breaking
121121

122-
## [2.135.0] - 2025-08-22
123-
124-
### Features
125-
126-
### Fixes
127-
128-
- program: trigger price use 5min mark price ([#1830](https://github.com/drift-labs/protocol-v2/pull/1830))
129-
130-
### Breaking
131-
132122
## [2.134.0] - 2025-08-13
133123

134124
### Features

programs/drift/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ drift-rs=[]
2020
[dependencies]
2121
anchor-lang = "0.29.0"
2222
solana-program = "1.16"
23-
anchor-spl = "0.29.0"
23+
anchor-spl = { version = "0.29.0", features = [] }
2424
pyth-client = "0.2.2"
2525
pyth-lazer-solana-contract = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb", features = ["no-entrypoint"]}
2626
pythnet-sdk = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "3e8a24ecd0bcf22b787313e2020f4186bb22c729"}

programs/drift/src/controller/insurance.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use crate::error::ErrorCode;
1414
use crate::math::amm::calculate_net_user_pnl;
1515
use crate::math::casting::Cast;
1616
use crate::math::constants::{
17-
MAX_APR_PER_REVENUE_SETTLE_TO_INSURANCE_FUND_VAULT,
17+
FUEL_START_TS, GOV_SPOT_MARKET_INDEX, MAX_APR_PER_REVENUE_SETTLE_TO_INSURANCE_FUND_VAULT,
1818
MAX_APR_PER_REVENUE_SETTLE_TO_INSURANCE_FUND_VAULT_GOV, ONE_YEAR, PERCENTAGE_PRECISION,
19-
SHARE_OF_REVENUE_ALLOCATED_TO_INSURANCE_FUND_VAULT_DENOMINATOR,
19+
QUOTE_SPOT_MARKET_INDEX, SHARE_OF_REVENUE_ALLOCATED_TO_INSURANCE_FUND_VAULT_DENOMINATOR,
2020
SHARE_OF_REVENUE_ALLOCATED_TO_INSURANCE_FUND_VAULT_NUMERATOR,
2121
};
2222
use crate::math::fuel::calculate_insurance_fuel_bonus;
@@ -40,7 +40,7 @@ use crate::state::perp_market::PerpMarket;
4040
use crate::state::spot_market::{SpotBalanceType, SpotMarket};
4141
use crate::state::state::State;
4242
use crate::state::user::UserStats;
43-
use crate::{emit, validate, FUEL_START_TS, GOV_SPOT_MARKET_INDEX, QUOTE_SPOT_MARKET_INDEX};
43+
use crate::{emit, validate};
4444

4545
#[cfg(test)]
4646
mod tests;

programs/drift/src/controller/liquidation.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ use crate::error::{DriftResult, ErrorCode};
2121
use crate::math::bankruptcy::is_user_bankrupt;
2222
use crate::math::casting::Cast;
2323
use crate::math::constants::{
24-
LIQUIDATION_FEE_PRECISION_U128, LIQUIDATION_PCT_PRECISION, QUOTE_PRECISION,
25-
QUOTE_PRECISION_I128, QUOTE_PRECISION_U64, QUOTE_SPOT_MARKET_INDEX, SPOT_WEIGHT_PRECISION,
24+
LIQUIDATION_FEE_PRECISION, LIQUIDATION_FEE_PRECISION_U128, LIQUIDATION_PCT_PRECISION,
25+
QUOTE_PRECISION, QUOTE_PRECISION_I128, QUOTE_PRECISION_U64, QUOTE_SPOT_MARKET_INDEX,
26+
SPOT_WEIGHT_PRECISION,
2627
};
2728
use crate::math::liquidation::{
2829
calculate_asset_transfer_for_liability_transfer,
@@ -48,6 +49,7 @@ use crate::math::orders::{
4849
use crate::math::position::calculate_base_asset_value_with_oracle_price;
4950
use crate::math::safe_math::SafeMath;
5051

52+
use crate::math::constants::LST_POOL_ID;
5153
use crate::math::spot_balance::get_token_value;
5254
use crate::state::events::{
5355
LiquidateBorrowForPerpPnlRecord, LiquidatePerpPnlForDepositRecord, LiquidatePerpRecord,
@@ -66,8 +68,8 @@ use crate::state::spot_market_map::SpotMarketMap;
6668
use crate::state::state::State;
6769
use crate::state::user::{MarketType, Order, OrderStatus, OrderType, User, UserStats};
6870
use crate::state::user_map::{UserMap, UserStatsMap};
69-
use crate::{get_then_update_id, load_mut, LST_POOL_ID};
70-
use crate::{validate, LIQUIDATION_FEE_PRECISION};
71+
use crate::validate;
72+
use crate::{get_then_update_id, load_mut};
7173

7274
#[cfg(test)]
7375
mod tests;

programs/drift/src/controller/orders.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::state::revenue_share::{
1010
};
1111
use anchor_lang::prelude::*;
1212

13+
use crate::controller;
1314
use crate::controller::funding::settle_funding_payment;
1415
use crate::controller::position;
1516
use crate::controller::position::{
@@ -32,7 +33,9 @@ use crate::math::amm::calculate_amm_available_liquidity;
3233
use crate::math::amm_jit::calculate_amm_jit_liquidity;
3334
use crate::math::auction::{calculate_auction_params_for_trigger_order, calculate_auction_prices};
3435
use crate::math::casting::Cast;
35-
use crate::math::constants::{BASE_PRECISION_U64, PERP_DECIMALS, QUOTE_SPOT_MARKET_INDEX};
36+
use crate::math::constants::{
37+
BASE_PRECISION_U64, MARGIN_PRECISION, PERP_DECIMALS, QUOTE_SPOT_MARKET_INDEX,
38+
};
3639
use crate::math::fees::{determine_user_fee_tier, ExternalFillFees, FillFees};
3740
use crate::math::fulfillment::{
3841
determine_perp_fulfillment_methods, determine_spot_fulfillment_methods,
@@ -81,7 +84,6 @@ use crate::validation;
8184
use crate::validation::order::{
8285
validate_order, validate_order_for_force_reduce_only, validate_spot_order,
8386
};
84-
use crate::{controller, MARGIN_PRECISION};
8587

8688
#[cfg(test)]
8789
mod tests;

programs/drift/src/controller/position/tests.rs

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,7 @@ fn amm_pool_balance_liq_fees_example() {
5353
let perp_market_loader: AccountLoader<PerpMarket> =
5454
AccountLoader::try_from(&perp_market_account_info).unwrap();
5555

56-
let perp_market_map = PerpMarketMap::load_one(&perp_market_account_info, true).unwrap();
57-
5856
let now = 1725948560;
59-
let clock_slot = 326319440;
60-
let clock = Clock {
61-
unix_timestamp: now,
62-
slot: clock_slot,
63-
..Clock::default()
64-
};
65-
66-
let mut state = State::default();
6757

6858
let mut prelaunch_oracle_price = PrelaunchOracle {
6959
price: PRICE_PRECISION_I64,
@@ -77,9 +67,8 @@ fn amm_pool_balance_liq_fees_example() {
7767
prelaunch_oracle_price,
7868
&prelaunch_oracle_price_key,
7969
PrelaunchOracle,
80-
oracle_account_info
70+
_oracle_account_info
8171
);
82-
let mut oracle_map = OracleMap::load_one(&oracle_account_info, clock_slot, None).unwrap();
8372

8473
let mut spot_market = SpotMarket {
8574
cumulative_deposit_interest: 11425141382,
@@ -609,11 +598,11 @@ fn amm_ref_price_decay_tail_test() {
609598

610599
let signed_liquidity_ratio = liquidity_ratio
611600
.checked_mul(
612-
(perp_market
601+
perp_market
613602
.amm
614603
.get_protocol_owned_position()
615604
.unwrap()
616-
.signum() as i128),
605+
.signum() as i128,
617606
)
618607
.unwrap();
619608

@@ -654,7 +643,7 @@ fn amm_ref_price_decay_tail_test() {
654643
&state.oracle_guard_rails.validity,
655644
)
656645
.unwrap();
657-
let cost = _update_amm(
646+
_update_amm(
658647
&mut perp_market,
659648
&mm_oracle_price_data,
660649
&state,
@@ -687,7 +676,7 @@ fn amm_ref_price_decay_tail_test() {
687676
)
688677
.unwrap();
689678

690-
let cost = _update_amm(
679+
_update_amm(
691680
&mut perp_market,
692681
&mm_oracle_price_data,
693682
&state,
@@ -786,11 +775,11 @@ fn amm_ref_price_offset_decay_logic() {
786775

787776
let signed_liquidity_ratio = liquidity_ratio
788777
.checked_mul(
789-
(perp_market
778+
perp_market
790779
.amm
791780
.get_protocol_owned_position()
792781
.unwrap()
793-
.signum() as i128),
782+
.signum() as i128,
794783
)
795784
.unwrap();
796785

@@ -831,7 +820,7 @@ fn amm_ref_price_offset_decay_logic() {
831820
&state.oracle_guard_rails.validity,
832821
)
833822
.unwrap();
834-
let cost = _update_amm(
823+
_update_amm(
835824
&mut perp_market,
836825
&mm_oracle_price_data,
837826
&state,
@@ -871,7 +860,7 @@ fn amm_ref_price_offset_decay_logic() {
871860
)
872861
.unwrap();
873862

874-
let cost = _update_amm(
863+
_update_amm(
875864
&mut perp_market,
876865
&mm_oracle_price_data,
877866
&state,
@@ -961,11 +950,11 @@ fn amm_negative_ref_price_offset_decay_logic() {
961950

962951
let signed_liquidity_ratio = liquidity_ratio
963952
.checked_mul(
964-
(perp_market
953+
perp_market
965954
.amm
966955
.get_protocol_owned_position()
967956
.unwrap()
968-
.signum() as i128),
957+
.signum() as i128,
969958
)
970959
.unwrap();
971960

@@ -1006,7 +995,7 @@ fn amm_negative_ref_price_offset_decay_logic() {
1006995
&state.oracle_guard_rails.validity,
1007996
)
1008997
.unwrap();
1009-
let cost = _update_amm(
998+
_update_amm(
1010999
&mut perp_market,
10111000
&mm_oracle_price_data,
10121001
&state,
@@ -1047,7 +1036,7 @@ fn amm_negative_ref_price_offset_decay_logic() {
10471036
)
10481037
.unwrap();
10491038

1050-
let cost = _update_amm(
1039+
_update_amm(
10511040
&mut perp_market,
10521041
&mm_oracle_price_data,
10531042
&state,
@@ -1147,11 +1136,11 @@ fn amm_perp_ref_offset() {
11471136

11481137
let signed_liquidity_ratio = liquidity_ratio
11491138
.checked_mul(
1150-
(perp_market
1139+
perp_market
11511140
.amm
11521141
.get_protocol_owned_position()
11531142
.unwrap()
1154-
.signum() as i128),
1143+
.signum() as i128,
11551144
)
11561145
.unwrap();
11571146

@@ -1173,7 +1162,7 @@ fn amm_perp_ref_offset() {
11731162
max_ref_offset,
11741163
)
11751164
.unwrap();
1176-
assert_eq!(res, (perp_market.amm.max_spread / 2) as i32);
1165+
assert_eq!(res, 45000);
11771166
assert_eq!(perp_market.amm.reference_price_offset, 18000); // not updated vs market account
11781167

11791168
let now = 1741207620 + 1;
@@ -1193,7 +1182,7 @@ fn amm_perp_ref_offset() {
11931182
&state.oracle_guard_rails.validity,
11941183
)
11951184
.unwrap();
1196-
let cost = _update_amm(
1185+
_update_amm(
11971186
&mut perp_market,
11981187
&mm_oracle_price_data,
11991188
&state,
@@ -1252,21 +1241,15 @@ fn amm_perp_ref_offset() {
12521241
// Uses the original oracle if the slot is old, ignoring MM oracle
12531242
perp_market.amm.mm_oracle_price = mm_oracle_price_data.get_price() * 995 / 1000;
12541243
perp_market.amm.mm_oracle_slot = clock_slot - 100;
1255-
let mut mm_oracle_price = perp_market
1244+
let mm_oracle_price = perp_market
12561245
.get_mm_oracle_price_data(
12571246
oracle_price_data,
12581247
clock_slot,
12591248
&state.oracle_guard_rails.validity,
12601249
)
12611250
.unwrap();
12621251

1263-
let _ = _update_amm(
1264-
&mut perp_market,
1265-
&mut mm_oracle_price,
1266-
&state,
1267-
now,
1268-
clock_slot,
1269-
);
1252+
let _ = _update_amm(&mut perp_market, &mm_oracle_price, &state, now, clock_slot);
12701253
let reserve_price_mm_offset_3 = perp_market.amm.reserve_price().unwrap();
12711254
let (b3, a3) = perp_market
12721255
.amm

programs/drift/src/controller/repeg/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pub fn update_amm_test_bad_oracle() {
260260
#[test]
261261
pub fn update_amm_larg_conf_test() {
262262
let now = 1662800000 + 60;
263-
let mut slot = 81680085;
263+
let slot = 81680085;
264264

265265
let mut market = PerpMarket::default_btc_test();
266266
assert_eq!(market.amm.base_asset_amount_with_amm, -1000000000);
@@ -409,7 +409,7 @@ pub fn update_amm_larg_conf_test() {
409409
#[test]
410410
pub fn update_amm_larg_conf_w_neg_tfmd_test() {
411411
let now = 1662800000 + 60;
412-
let mut slot = 81680085;
412+
let slot = 81680085;
413413

414414
let mut market = PerpMarket::default_btc_test();
415415
market.amm.concentration_coef = 1414213;

programs/drift/src/controller/spot_balance/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ fn check_fee_collection_larger_nums() {
13851385

13861386
#[test]
13871387
fn test_multi_stage_borrow_rate_curve() {
1388-
let mut spot_market = SpotMarket {
1388+
let spot_market = SpotMarket {
13891389
market_index: 0,
13901390
oracle_source: OracleSource::QuoteAsset,
13911391
cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION,
@@ -1455,7 +1455,7 @@ fn test_multi_stage_borrow_rate_curve_sol() {
14551455

14561456
let spot_market_loader: AccountLoader<SpotMarket> =
14571457
AccountLoader::try_from(&sol_market_account_info).unwrap();
1458-
let mut spot_market = spot_market_loader.load_mut().unwrap();
1458+
let spot_market = spot_market_loader.load_mut().unwrap();
14591459

14601460
// Store all rates to verify monotonicity and smoothness later
14611461
let mut last_rate = 0_u128;

0 commit comments

Comments
 (0)