Skip to content

Commit 30fe08f

Browse files
wphanLukasDecoChesterSimNourAlharithigithub-actions[bot]
authored
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 56bc78d. * Revert "sdk: bigz/fix-vamm-l2-generator-baseSwapped var assign (#1622)" This reverts commit e49cfd5. * Revert "sdk: round tick/step size for getVammL2Generateor (#1612)" This reverts commit f932a4e. * 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 <chrisheaney30@gmail.com> * 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 <83473873+0xbigz@users.noreply.github.com> * 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 3f0eab3. * 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 1e19b7e. * 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 <chrisheaney30@gmail.com> * 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 <chrisheaney30@gmail.com> * 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 <83473873+0xbigz@users.noreply.github.com> * 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 <chrisheaney30@gmail.com> * 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 <lowkeynicc@gmail.com> * sdk: release v2.124.0-beta.6 * sdk: add new admin client fn * Revert "sdk: add new admin client fn" This reverts commit c7a4f0b. * 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 <83473873+0xbigz@users.noreply.github.com> * 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 <chrisheaney30@gmail.com> * 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 <lukas@lunoho.company> Co-authored-by: Chester Sim <chestersimdy@gmail.com> Co-authored-by: Nour Alharithi <nour.alharithi@gmail.com> Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bigz_Pubkey <83473873+0xbigz@users.noreply.github.com> Co-authored-by: lowkeynicc <85139158+lowkeynicc@users.noreply.github.com> Co-authored-by: jordy25519 <beauchjord@gmail.com> Co-authored-by: Luke Steyn <lukecaan@gmail.com> Co-authored-by: lil perp <chrisheaney30@gmail.com> Co-authored-by: LukasDeco <ldeconantsesznak@gmail.com> Co-authored-by: Nick Caradonna <lowkeynicc@gmail.com> Co-authored-by: Jesse Cha <42378241+Jesscha@users.noreply.github.com>
1 parent f5d5a4f commit 30fe08f

File tree

110 files changed

+6446
-1239
lines changed

Some content is hidden

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

110 files changed

+6446
-1239
lines changed

.github/actions/setup-solana/action.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ runs:
1414
- name: Download Solana
1515
run: |
1616
echo Downloading Solana v${{ env.SOLANA_VERSION }}... 🧬
17-
sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_VERSION }}/install)"
17+
export SOLANA_RELEASE=v${{ env.SOLANA_VERSION }}
18+
export SOLANA_INSTALL_INIT_ARGS=v${{ env.SOLANA_VERSION }}
19+
${{ github.workspace }}/.github/actions/setup-solana/scripts/solana-install-init.sh
1820
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
1921
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
2022
echo "[41,242,37,42,13,160,221,13,242,224,230,17,141,228,35,40,57,231,71,8,239,32,226,165,181,216,231,245,170,229,117,123,39,103,128,179,245,168,230,228,127,219,58,249,69,6,251,148,173,190,191,217,50,67,123,105,121,215,242,41,242,85,71,109]" > $HOME/.config/solana/id.json
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#!/bin/sh
2+
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
# This is just a little script that can be downloaded from the internet to
13+
# install solana-install. It just does platform detection, downloads the installer
14+
# and runs it.
15+
16+
{ # this ensures the entire script is downloaded #
17+
18+
if [ -z "$SOLANA_DOWNLOAD_ROOT" ]; then
19+
SOLANA_DOWNLOAD_ROOT="https://github.com/solana-labs/solana/releases/download/"
20+
fi
21+
GH_LATEST_RELEASE="https://api.github.com/repos/solana-labs/solana/releases/latest"
22+
23+
set -e
24+
25+
usage() {
26+
cat 1>&2 <<EOF
27+
solana-install-init
28+
initializes a new installation
29+
30+
USAGE:
31+
solana-install-init [FLAGS] [OPTIONS] --data_dir <PATH> --pubkey <PUBKEY>
32+
33+
FLAGS:
34+
-h, --help Prints help information
35+
--no-modify-path Don't configure the PATH environment variable
36+
37+
OPTIONS:
38+
-d, --data-dir <PATH> Directory to store install data
39+
-u, --url <URL> JSON RPC URL for the solana cluster
40+
-p, --pubkey <PUBKEY> Public key of the update manifest
41+
EOF
42+
}
43+
44+
main() {
45+
downloader --check
46+
need_cmd uname
47+
need_cmd mktemp
48+
need_cmd chmod
49+
need_cmd mkdir
50+
need_cmd rm
51+
need_cmd sed
52+
need_cmd grep
53+
54+
for arg in "$@"; do
55+
case "$arg" in
56+
-h|--help)
57+
usage
58+
exit 0
59+
;;
60+
*)
61+
;;
62+
esac
63+
done
64+
65+
_ostype="$(uname -s)"
66+
_cputype="$(uname -m)"
67+
68+
case "$_ostype" in
69+
Linux)
70+
_ostype=unknown-linux-gnu
71+
;;
72+
Darwin)
73+
if [[ $_cputype = arm64 ]]; then
74+
_cputype=aarch64
75+
fi
76+
_ostype=apple-darwin
77+
;;
78+
*)
79+
err "machine architecture is currently unsupported"
80+
;;
81+
esac
82+
TARGET="${_cputype}-${_ostype}"
83+
84+
temp_dir="$(mktemp -d 2>/dev/null || ensure mktemp -d -t solana-install-init)"
85+
ensure mkdir -p "$temp_dir"
86+
87+
# Check for SOLANA_RELEASE environment variable override. Otherwise fetch
88+
# the latest release tag from github
89+
if [ -n "$SOLANA_RELEASE" ]; then
90+
release="$SOLANA_RELEASE"
91+
else
92+
release_file="$temp_dir/release"
93+
printf 'looking for latest release\n' 1>&2
94+
ensure downloader "$GH_LATEST_RELEASE" "$release_file"
95+
release=$(\
96+
grep -m 1 \"tag_name\": "$release_file" \
97+
| sed -ne 's/^ *"tag_name": "\([^"]*\)",$/\1/p' \
98+
)
99+
if [ -z "$release" ]; then
100+
err 'Unable to figure latest release'
101+
fi
102+
fi
103+
104+
download_url="$SOLANA_DOWNLOAD_ROOT/$release/solana-install-init-$TARGET"
105+
solana_install_init="$temp_dir/solana-install-init"
106+
107+
printf 'downloading %s installer\n' "$release" 1>&2
108+
109+
ensure mkdir -p "$temp_dir"
110+
ensure downloader "$download_url" "$solana_install_init"
111+
ensure chmod u+x "$solana_install_init"
112+
if [ ! -x "$solana_install_init" ]; then
113+
printf '%s\n' "Cannot execute $solana_install_init (likely because of mounting /tmp as noexec)." 1>&2
114+
printf '%s\n' "Please copy the file to a location where you can execute binaries and run ./solana-install-init." 1>&2
115+
exit 1
116+
fi
117+
118+
if [ -z "$1" ]; then
119+
#shellcheck disable=SC2086
120+
ignore "$solana_install_init" $SOLANA_INSTALL_INIT_ARGS
121+
else
122+
ignore "$solana_install_init" "$@"
123+
fi
124+
retval=$?
125+
126+
ignore rm "$solana_install_init"
127+
ignore rm -rf "$temp_dir"
128+
129+
return "$retval"
130+
}
131+
132+
err() {
133+
printf 'solana-install-init: %s\n' "$1" >&2
134+
exit 1
135+
}
136+
137+
need_cmd() {
138+
if ! check_cmd "$1"; then
139+
err "need '$1' (command not found)"
140+
fi
141+
}
142+
143+
check_cmd() {
144+
command -v "$1" > /dev/null 2>&1
145+
}
146+
147+
# Run a command that should never fail. If the command fails execution
148+
# will immediately terminate with an error showing the failing
149+
# command.
150+
ensure() {
151+
if ! "$@"; then
152+
err "command failed: $*"
153+
fi
154+
}
155+
156+
# This is just for indicating that commands' results are being
157+
# intentionally ignored. Usually, because it's being executed
158+
# as part of error handling.
159+
ignore() {
160+
"$@"
161+
}
162+
163+
# This wraps curl or wget. Try curl first, if not installed,
164+
# use wget instead.
165+
downloader() {
166+
if check_cmd curl; then
167+
program=curl
168+
elif check_cmd wget; then
169+
program=wget
170+
else
171+
program='curl or wget' # to be used in error message of need_cmd
172+
fi
173+
174+
if [ "$1" = --check ]; then
175+
need_cmd "$program"
176+
elif [ "$program" = curl ]; then
177+
curl -sSfL "$1" -o "$2"
178+
elif [ "$program" = wget ]; then
179+
wget "$1" -O "$2"
180+
else
181+
err "Unknown downloader" # should not reach here
182+
fi
183+
}
184+
185+
main "$@"
186+
187+
} # this ensures the entire script is downloaded #

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ jobs:
149149
run: cd sdk/ && yarn && yarn build && cd ..
150150

151151
- name: run anchor tests
152+
env:
153+
RUST_LOG: solana_runtime::message_processor::stable_log=info
152154
run: bash test-scripts/run-anchor-tests.sh
153155
verify-sdk-configs:
154156
name: Verify SDK Configs

CHANGELOG.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,78 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## Unreleased
9+
10+
### Features
11+
12+
### Fixes
13+
14+
### Breaking
15+
16+
## [2.125.0] - 2025-06-24
17+
18+
### Features
19+
20+
- program: use three points for std estimator ([#1686](https://github.com/drift-labs/protocol-v2/pull/1686))
21+
- program: add inventory component amm_spread_adjustment ([#1690](https://github.com/drift-labs/protocol-v2/pull/1690))
22+
- program: spot market specific rev pool to insurance cap ([#1692](https://github.com/drift-labs/protocol-v2/pull/1692))
23+
- program: better account for imf in calculate_max_perp_order_size ([#1693](https://github.com/drift-labs/protocol-v2/pull/1693))
24+
25+
### Fixes
26+
27+
### Breaking
28+
29+
## [2.124.0] - 2025-06-18
930

1031
### Features
1132

33+
- program: perp market amm oracle delay override ([#1679](https://github.com/drift-labs/protocol-v2/pull/1679))
34+
- program: sanitize long tail perp market orders less frequently ([#1641](https://github.com/drift-labs/protocol-v2/pull/1641))
35+
- program: programmatic rebalance between protocol owned if holdings ([#1653](https://github.com/drift-labs/protocol-v2/pull/1653))
36+
1237
### Fixes
1338

1439
### Breaking
1540

41+
## [2.123.0] - 2025-06-13
42+
43+
### Features
44+
45+
- program: simplify user can skip duration ([#1668](https://github.com/drift-labs/protocol-v2/pull/1668))
46+
- program: allow limit orders without auctions in swift ([#1661](https://github.com/drift-labs/protocol-v2/pull/1661))
47+
- program: add taker_speed_bump_override and amm_spread_adjustment ([#1665](https://github.com/drift-labs/protocol-v2/pull/1665))
48+
49+
### Fixes
50+
51+
### Breaking
52+
53+
## [2.122.0] - 2025-06-05
54+
55+
### Features
56+
57+
- program: add existing position fields to order records ([#1614](https://github.com/drift-labs/protocol-v2/pull/1614))
58+
59+
### Fixes
60+
61+
- sdk: fix to getMaxTradeSizeUSDCForPerp which was previously overshooting max allowed size due to IMF factor
62+
- program: check limit price after applying buffer in trigger limit order ([#1648](https://github.com/drift-labs/protocol-v2/pull/1648))
63+
- program: check limit price when setting auction for limit order ([#1650](https://github.com/drift-labs/protocol-v2/pull/1650))
64+
65+
### Breaking
66+
67+
## [2.121.0] - 2025-05-29
68+
69+
### Features
70+
71+
- program: multi piecewise interest rate curve ([#1560](https://github.com/drift-labs/protocol-v2/pull/1560))
72+
- sdk: fees and max perp trade size calculation functions allow an optional parameter for a user using bitFlags to enter high leverage mode
73+
74+
### Fixes
75+
76+
- program: safely use saturating sub number_of_users fields per market ([#1616](https://github.com/drift-labs/protocol-v2/pull/1616))
77+
78+
### Breaking
79+
1680
## [2.120.0] - 2025-04-29
1781

1882
### Features

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

programs/drift/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "drift"
3-
version = "2.120.0"
3+
version = "2.125.0"
44
description = "Created with Anchor"
55
edition = "2018"
66

programs/drift/src/controller/amm.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use crate::math::amm::calculate_quote_asset_amount_swapped;
1515
use crate::math::amm_spread::{calculate_spread_reserves, get_spread_reserves};
1616
use crate::math::casting::Cast;
1717
use crate::math::constants::{
18-
CONCENTRATION_PRECISION, FEE_POOL_TO_REVENUE_POOL_THRESHOLD, K_BPS_UPDATE_SCALE,
19-
MAX_CONCENTRATION_COEFFICIENT, MAX_K_BPS_INCREASE, MAX_SQRT_K,
18+
CONCENTRATION_PRECISION, FEE_ADJUSTMENT_MAX, FEE_POOL_TO_REVENUE_POOL_THRESHOLD,
19+
K_BPS_UPDATE_SCALE, MAX_CONCENTRATION_COEFFICIENT, MAX_K_BPS_INCREASE, MAX_SQRT_K,
2020
};
2121
use crate::math::cp_curve::get_update_k_result;
2222
use crate::math::repeg::get_total_fee_lower_bound;
@@ -209,7 +209,7 @@ pub fn update_spreads(market: &mut PerpMarket, reserve_price: u64) -> DriftResul
209209
0
210210
};
211211

212-
let (long_spread, short_spread) = if market.amm.curve_update_intensity > 0 {
212+
let (mut long_spread, mut short_spread) = if market.amm.curve_update_intensity > 0 {
213213
amm_spread::calculate_spread(
214214
market.amm.base_spread,
215215
market.amm.last_oracle_reserve_price_spread_pct,
@@ -230,12 +230,31 @@ pub fn update_spreads(market: &mut PerpMarket, reserve_price: u64) -> DriftResul
230230
market.amm.long_intensity_volume,
231231
market.amm.short_intensity_volume,
232232
market.amm.volume_24h,
233+
market.amm.amm_inventory_spread_adjustment,
233234
)?
234235
} else {
235236
let half_base_spread = market.amm.base_spread.safe_div(2)?;
236237
(half_base_spread, half_base_spread)
237238
};
238239

240+
if market.amm.amm_spread_adjustment < 0 {
241+
let adjustment = market.amm.amm_spread_adjustment.unsigned_abs().cast()?;
242+
long_spread = long_spread
243+
.saturating_sub(long_spread.saturating_mul(adjustment).safe_div(100)?)
244+
.max(1);
245+
short_spread = short_spread
246+
.saturating_sub(short_spread.saturating_mul(adjustment).safe_div(100)?)
247+
.max(1);
248+
} else if market.amm.amm_spread_adjustment > 0 {
249+
let adjustment = market.amm.amm_spread_adjustment.cast()?;
250+
long_spread = long_spread
251+
.saturating_add(long_spread.saturating_mul(adjustment).safe_div_ceil(100)?)
252+
.max(1);
253+
short_spread = short_spread
254+
.saturating_add(short_spread.saturating_mul(adjustment).safe_div_ceil(100)?)
255+
.max(1);
256+
}
257+
239258
market.amm.long_spread = long_spread;
240259
market.amm.short_spread = short_spread;
241260
market.amm.reference_price_offset = reference_price_offset;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ fn update_pool_balances_test() {
513513
market.pnl_pool.balance_type(),
514514
)
515515
.unwrap();
516-
assert_eq!(pnl_pool_token_amount, 1_650_000_000 + 3);
517-
assert_eq!(amm_fee_pool_token_amount, 16_666_666);
516+
assert_eq!(pnl_pool_token_amount, 3_300_000_000 + 3);
517+
assert_eq!(amm_fee_pool_token_amount, 33333333);
518518

519519
// negative fee pool
520520
market.amm.total_fee_minus_distributions = -8_008_123_456;
@@ -539,7 +539,7 @@ fn update_pool_balances_test() {
539539
market.pnl_pool.balance_type(),
540540
)
541541
.unwrap();
542-
assert_eq!(pnl_pool_token_amount, 665678880);
542+
assert_eq!(pnl_pool_token_amount, 2332345547);
543543
assert_eq!(amm_fee_pool_token_amount, 0);
544544
}
545545

0 commit comments

Comments
 (0)