@velocity-exchange/sdk 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/lib/browser/adminClient.d.ts +24 -4
  2. package/lib/browser/adminClient.js +62 -12
  3. package/lib/browser/core/VelocityCore.d.ts +2 -0
  4. package/lib/browser/core/VelocityCore.js +1 -0
  5. package/lib/browser/core/instructions/trigger.d.ts +4 -0
  6. package/lib/browser/core/instructions/trigger.js +4 -0
  7. package/lib/browser/idl/velocity.d.ts +223 -33
  8. package/lib/browser/idl/velocity.json +224 -34
  9. package/lib/browser/math/liquidation.d.ts +37 -2
  10. package/lib/browser/math/liquidation.js +44 -3
  11. package/lib/browser/math/spotBalance.d.ts +13 -0
  12. package/lib/browser/math/spotBalance.js +43 -2
  13. package/lib/browser/types.d.ts +9 -0
  14. package/lib/browser/velocityClient.d.ts +32 -20
  15. package/lib/browser/velocityClient.js +48 -23
  16. package/lib/node/adminClient.d.ts +24 -4
  17. package/lib/node/adminClient.d.ts.map +1 -1
  18. package/lib/node/adminClient.js +62 -12
  19. package/lib/node/core/VelocityCore.d.ts +2 -0
  20. package/lib/node/core/VelocityCore.d.ts.map +1 -1
  21. package/lib/node/core/VelocityCore.js +1 -0
  22. package/lib/node/core/instructions/trigger.d.ts +4 -0
  23. package/lib/node/core/instructions/trigger.d.ts.map +1 -1
  24. package/lib/node/core/instructions/trigger.js +4 -0
  25. package/lib/node/idl/velocity.d.ts +223 -33
  26. package/lib/node/idl/velocity.d.ts.map +1 -1
  27. package/lib/node/idl/velocity.json +224 -34
  28. package/lib/node/math/liquidation.d.ts +37 -2
  29. package/lib/node/math/liquidation.d.ts.map +1 -1
  30. package/lib/node/math/liquidation.js +44 -3
  31. package/lib/node/math/spotBalance.d.ts +13 -0
  32. package/lib/node/math/spotBalance.d.ts.map +1 -1
  33. package/lib/node/math/spotBalance.js +43 -2
  34. package/lib/node/types.d.ts +9 -0
  35. package/lib/node/types.d.ts.map +1 -1
  36. package/lib/node/velocityClient.d.ts +32 -20
  37. package/lib/node/velocityClient.d.ts.map +1 -1
  38. package/lib/node/velocityClient.js +48 -23
  39. package/package.json +1 -1
@@ -894,9 +894,13 @@ export declare class AdminClient extends VelocityClient {
894
894
  * `updateWithdrawGuardThreshold` — in particular, the `oracle` param must equal
895
895
  * `spotMarket.oracle` (enforced by the `has_one` constraint) and is auto-resolved when
896
896
  * omitted. Throws if the spot market account can't be found when not subscribed.
897
+ * @param admin - Overrides the `admin` signer account. The instruction is warm-gated
898
+ * on-chain, so pass the key that will actually sign at execution — e.g. a Squads warm-admin
899
+ * vault PDA when the ix is wrapped in a multisig proposal. Defaults to `state.coldAdmin`
900
+ * (or the wallet if not subscribed).
897
901
  * @returns The unsigned `updateWithdrawGuardThreshold` instruction.
898
902
  */
899
- getUpdateWithdrawGuardThresholdIx(spotMarketIndex: number, withdrawGuardThreshold: BN, oracle?: PublicKey): Promise<TransactionInstruction>;
903
+ getUpdateWithdrawGuardThresholdIx(spotMarketIndex: number, withdrawGuardThreshold: BN, oracle?: PublicKey, admin?: PublicKey): Promise<TransactionInstruction>;
900
904
  /**
901
905
  * Sets a spot market's lending-gain carveouts: the share of deposit interest routed to the
902
906
  * insurance fund (`ifFeeFactor`) and to the withdrawable protocol fee pool
@@ -913,9 +917,13 @@ export declare class AdminClient extends VelocityClient {
913
917
  /**
914
918
  * Builds the `updateSpotMarketIfFactor` instruction without sending it. See
915
919
  * `updateSpotMarketIfFactor` for units and validation.
920
+ * @param admin - Overrides the `admin` signer account. The instruction is warm-gated
921
+ * on-chain, so pass the key that will actually sign at execution — e.g. a Squads warm-admin
922
+ * vault PDA when the ix is wrapped in a multisig proposal. Defaults to `state.coldAdmin`
923
+ * (or the wallet if not subscribed).
916
924
  * @returns The unsigned `updateSpotMarketIfFactor` instruction.
917
925
  */
918
- getUpdateSpotMarketIfFactorIx(spotMarketIndex: number, ifFeeFactor: number, protocolFeeFactor: number): Promise<TransactionInstruction>;
926
+ getUpdateSpotMarketIfFactorIx(spotMarketIndex: number, ifFeeFactor: number, protocolFeeFactor: number, admin?: PublicKey): Promise<TransactionInstruction>;
919
927
  /**
920
928
  * Sets how often a spot market's revenue pool may be settled to the insurance fund.
921
929
  * Requires warm admin (`check_warm`).
@@ -943,6 +951,10 @@ export declare class AdminClient extends VelocityClient {
943
951
  * @returns The unsigned `updateSpotMarketMaxTokenDeposits` instruction.
944
952
  */
945
953
  getUpdateSpotMarketMaxTokenDepositsIx(spotMarketIndex: number, maxTokenDeposits: BN): Promise<TransactionInstruction>;
954
+ updateSpotMarketWithdrawCircuitBreaker(spotMarketIndex: number, withdrawCircuitBreakerBps: number): Promise<TransactionSignature>;
955
+ getUpdateSpotMarketWithdrawCircuitBreakerIx(spotMarketIndex: number, withdrawCircuitBreakerBps: number): Promise<TransactionInstruction>;
956
+ updateSpotMarketDepositCap(spotMarketIndex: number, depositGuardThreshold: BN, maxDepositBpsPerDay: number): Promise<TransactionSignature>;
957
+ getUpdateSpotMarketDepositCapIx(spotMarketIndex: number, depositGuardThreshold: BN, maxDepositBpsPerDay: number): Promise<TransactionInstruction>;
946
958
  /**
947
959
  * Caps a spot market's total borrows as a fraction of its `maxTokenDeposits`, rather than
948
960
  * an absolute token amount. Requires warm admin (`check_warm`). On-chain, the effective cap
@@ -971,9 +983,13 @@ export declare class AdminClient extends VelocityClient {
971
983
  /**
972
984
  * Builds the `updateSpotMarketScaleInitialAssetWeightStart` instruction without sending it.
973
985
  * See `updateSpotMarketScaleInitialAssetWeightStart`.
986
+ * @param admin - Overrides the `admin` signer account. The instruction is warm-gated
987
+ * on-chain, so pass the key that will actually sign at execution — e.g. a Squads warm-admin
988
+ * vault PDA when the ix is wrapped in a multisig proposal. Defaults to `state.coldAdmin`
989
+ * (or the wallet if not subscribed).
974
990
  * @returns The unsigned `updateSpotMarketScaleInitialAssetWeightStart` instruction.
975
991
  */
976
- getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex: number, scaleInitialAssetWeightStart: BN): Promise<TransactionInstruction>;
992
+ getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex: number, scaleInitialAssetWeightStart: BN, admin?: PublicKey): Promise<TransactionInstruction>;
977
993
  /**
978
994
  * Sets how long an insurance-fund staker's unstake request must sit in escrow before it can
979
995
  * be completed for a given spot market. Requires warm admin (`check_warm`).
@@ -1258,9 +1274,13 @@ export declare class AdminClient extends VelocityClient {
1258
1274
  /**
1259
1275
  * Builds the `updateSpotMarketStatus` instruction without sending it. See
1260
1276
  * `updateSpotMarketStatus`.
1277
+ * @param admin - Overrides the `admin` signer account. The instruction is warm-gated
1278
+ * on-chain, so pass the key that will actually sign at execution — e.g. a Squads warm-admin
1279
+ * vault PDA when the ix is wrapped in a multisig proposal. Defaults to `state.coldAdmin`
1280
+ * (or the wallet if not subscribed).
1261
1281
  * @returns The unsigned `updateSpotMarketStatus` instruction.
1262
1282
  */
1263
- getUpdateSpotMarketStatusIx(spotMarketIndex: number, marketStatus: MarketStatus): Promise<TransactionInstruction>;
1283
+ getUpdateSpotMarketStatusIx(spotMarketIndex: number, marketStatus: MarketStatus, admin?: PublicKey): Promise<TransactionInstruction>;
1264
1284
  /**
1265
1285
  * Sets a spot market's operation pause bitmask (`SpotOperation`: `UpdateCumulativeInterest`
1266
1286
  * 0b00001, `Fill` 0b00010, `Deposit` 0b00100, `Withdraw` 0b01000, `Liquidation` 0b10000).
@@ -1767,9 +1767,13 @@ class AdminClient extends velocityClient_1.VelocityClient {
1767
1767
  * `updateWithdrawGuardThreshold` — in particular, the `oracle` param must equal
1768
1768
  * `spotMarket.oracle` (enforced by the `has_one` constraint) and is auto-resolved when
1769
1769
  * omitted. Throws if the spot market account can't be found when not subscribed.
1770
+ * @param admin - Overrides the `admin` signer account. The instruction is warm-gated
1771
+ * on-chain, so pass the key that will actually sign at execution — e.g. a Squads warm-admin
1772
+ * vault PDA when the ix is wrapped in a multisig proposal. Defaults to `state.coldAdmin`
1773
+ * (or the wallet if not subscribed).
1770
1774
  * @returns The unsigned `updateWithdrawGuardThreshold` instruction.
1771
1775
  */
1772
- async getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold, oracle) {
1776
+ async getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold, oracle, admin) {
1773
1777
  const spotMarketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
1774
1778
  if (!oracle) {
1775
1779
  const cachedSpotMarket = this.isSubscribed
@@ -1789,9 +1793,9 @@ class AdminClient extends velocityClient_1.VelocityClient {
1789
1793
  }
1790
1794
  return await this.program.instruction.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
1791
1795
  accounts: {
1792
- admin: this.isSubscribed
1796
+ admin: admin !== null && admin !== void 0 ? admin : (this.isSubscribed
1793
1797
  ? this.getStateAccount().coldAdmin
1794
- : this.wallet.publicKey,
1798
+ : this.wallet.publicKey),
1795
1799
  state: await this.getStatePublicKey(),
1796
1800
  spotMarket: spotMarketPublicKey,
1797
1801
  oracle,
@@ -1819,14 +1823,18 @@ class AdminClient extends velocityClient_1.VelocityClient {
1819
1823
  /**
1820
1824
  * Builds the `updateSpotMarketIfFactor` instruction without sending it. See
1821
1825
  * `updateSpotMarketIfFactor` for units and validation.
1826
+ * @param admin - Overrides the `admin` signer account. The instruction is warm-gated
1827
+ * on-chain, so pass the key that will actually sign at execution — e.g. a Squads warm-admin
1828
+ * vault PDA when the ix is wrapped in a multisig proposal. Defaults to `state.coldAdmin`
1829
+ * (or the wallet if not subscribed).
1822
1830
  * @returns The unsigned `updateSpotMarketIfFactor` instruction.
1823
1831
  */
1824
- async getUpdateSpotMarketIfFactorIx(spotMarketIndex, ifFeeFactor, protocolFeeFactor) {
1832
+ async getUpdateSpotMarketIfFactorIx(spotMarketIndex, ifFeeFactor, protocolFeeFactor, admin) {
1825
1833
  return await this.program.instruction.updateSpotMarketIfFactor(spotMarketIndex, ifFeeFactor, protocolFeeFactor, {
1826
1834
  accounts: {
1827
- admin: this.isSubscribed
1835
+ admin: admin !== null && admin !== void 0 ? admin : (this.isSubscribed
1828
1836
  ? this.getStateAccount().coldAdmin
1829
- : this.wallet.publicKey,
1837
+ : this.wallet.publicKey),
1830
1838
  state: await this.getStatePublicKey(),
1831
1839
  spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
1832
1840
  },
@@ -1889,6 +1897,40 @@ class AdminClient extends velocityClient_1.VelocityClient {
1889
1897
  },
1890
1898
  });
1891
1899
  }
1900
+ async updateSpotMarketWithdrawCircuitBreaker(spotMarketIndex, withdrawCircuitBreakerBps) {
1901
+ const ix = await this.getUpdateSpotMarketWithdrawCircuitBreakerIx(spotMarketIndex, withdrawCircuitBreakerBps);
1902
+ const tx = await this.buildTransaction(ix);
1903
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
1904
+ return txSig;
1905
+ }
1906
+ async getUpdateSpotMarketWithdrawCircuitBreakerIx(spotMarketIndex, withdrawCircuitBreakerBps) {
1907
+ return this.program.instruction.updateSpotMarketWithdrawCircuitBreaker(withdrawCircuitBreakerBps, {
1908
+ accounts: {
1909
+ admin: this.isSubscribed
1910
+ ? this.getStateAccount().coldAdmin
1911
+ : this.wallet.publicKey,
1912
+ state: await this.getStatePublicKey(),
1913
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
1914
+ },
1915
+ });
1916
+ }
1917
+ async updateSpotMarketDepositCap(spotMarketIndex, depositGuardThreshold, maxDepositBpsPerDay) {
1918
+ const ix = await this.getUpdateSpotMarketDepositCapIx(spotMarketIndex, depositGuardThreshold, maxDepositBpsPerDay);
1919
+ const tx = await this.buildTransaction(ix);
1920
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
1921
+ return txSig;
1922
+ }
1923
+ async getUpdateSpotMarketDepositCapIx(spotMarketIndex, depositGuardThreshold, maxDepositBpsPerDay) {
1924
+ return this.program.instruction.updateSpotMarketDepositCap(depositGuardThreshold, maxDepositBpsPerDay, {
1925
+ accounts: {
1926
+ admin: this.isSubscribed
1927
+ ? this.getStateAccount().coldAdmin
1928
+ : this.wallet.publicKey,
1929
+ state: await this.getStatePublicKey(),
1930
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
1931
+ },
1932
+ });
1933
+ }
1892
1934
  /**
1893
1935
  * Caps a spot market's total borrows as a fraction of its `maxTokenDeposits`, rather than
1894
1936
  * an absolute token amount. Requires warm admin (`check_warm`). On-chain, the effective cap
@@ -1937,14 +1979,18 @@ class AdminClient extends velocityClient_1.VelocityClient {
1937
1979
  /**
1938
1980
  * Builds the `updateSpotMarketScaleInitialAssetWeightStart` instruction without sending it.
1939
1981
  * See `updateSpotMarketScaleInitialAssetWeightStart`.
1982
+ * @param admin - Overrides the `admin` signer account. The instruction is warm-gated
1983
+ * on-chain, so pass the key that will actually sign at execution — e.g. a Squads warm-admin
1984
+ * vault PDA when the ix is wrapped in a multisig proposal. Defaults to `state.coldAdmin`
1985
+ * (or the wallet if not subscribed).
1940
1986
  * @returns The unsigned `updateSpotMarketScaleInitialAssetWeightStart` instruction.
1941
1987
  */
1942
- async getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex, scaleInitialAssetWeightStart) {
1988
+ async getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex, scaleInitialAssetWeightStart, admin) {
1943
1989
  return this.program.instruction.updateSpotMarketScaleInitialAssetWeightStart(scaleInitialAssetWeightStart, {
1944
1990
  accounts: {
1945
- admin: this.isSubscribed
1991
+ admin: admin !== null && admin !== void 0 ? admin : (this.isSubscribed
1946
1992
  ? this.getStateAccount().coldAdmin
1947
- : this.wallet.publicKey,
1993
+ : this.wallet.publicKey),
1948
1994
  state: await this.getStatePublicKey(),
1949
1995
  spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
1950
1996
  },
@@ -2492,14 +2538,18 @@ class AdminClient extends velocityClient_1.VelocityClient {
2492
2538
  /**
2493
2539
  * Builds the `updateSpotMarketStatus` instruction without sending it. See
2494
2540
  * `updateSpotMarketStatus`.
2541
+ * @param admin - Overrides the `admin` signer account. The instruction is warm-gated
2542
+ * on-chain, so pass the key that will actually sign at execution — e.g. a Squads warm-admin
2543
+ * vault PDA when the ix is wrapped in a multisig proposal. Defaults to `state.coldAdmin`
2544
+ * (or the wallet if not subscribed).
2495
2545
  * @returns The unsigned `updateSpotMarketStatus` instruction.
2496
2546
  */
2497
- async getUpdateSpotMarketStatusIx(spotMarketIndex, marketStatus) {
2547
+ async getUpdateSpotMarketStatusIx(spotMarketIndex, marketStatus, admin) {
2498
2548
  return await this.program.instruction.updateSpotMarketStatus(marketStatus, {
2499
2549
  accounts: {
2500
- admin: this.isSubscribed
2550
+ admin: admin !== null && admin !== void 0 ? admin : (this.isSubscribed
2501
2551
  ? this.getStateAccount().coldAdmin
2502
- : this.wallet.publicKey,
2552
+ : this.wallet.publicKey),
2503
2553
  state: await this.getStatePublicKey(),
2504
2554
  spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
2505
2555
  },
@@ -224,6 +224,7 @@ export declare class VelocityCore {
224
224
  * @param args.state - the global `State` PDA.
225
225
  * @param args.filler - the keeper's `User` account submitting the trigger.
226
226
  * @param args.user - the order owner's `User` account.
227
+ * @param args.userStats - the order owner's `UserStats` account (authority-wide equity breaker).
227
228
  * @param args.authority - signer that must own or be a registered delegate of `filler`.
228
229
  * @param args.remainingAccounts - oracle/market `AccountMeta[]` for the order's market.
229
230
  * @returns the unsigned `triggerOrder` `TransactionInstruction`.
@@ -234,6 +235,7 @@ export declare class VelocityCore {
234
235
  state: PublicKey;
235
236
  filler: PublicKey;
236
237
  user: PublicKey;
238
+ userStats: PublicKey;
237
239
  authority: PublicKey;
238
240
  remainingAccounts: AccountMeta[];
239
241
  }): Promise<TransactionInstruction>;
@@ -202,6 +202,7 @@ class VelocityCore {
202
202
  * @param args.state - the global `State` PDA.
203
203
  * @param args.filler - the keeper's `User` account submitting the trigger.
204
204
  * @param args.user - the order owner's `User` account.
205
+ * @param args.userStats - the order owner's `UserStats` account (authority-wide equity breaker).
205
206
  * @param args.authority - signer that must own or be a registered delegate of `filler`.
206
207
  * @param args.remainingAccounts - oracle/market `AccountMeta[]` for the order's market.
207
208
  * @returns the unsigned `triggerOrder` `TransactionInstruction`.
@@ -11,6 +11,9 @@ import type { VelocityProgram } from '../../config';
11
11
  * @param args.state - the global `State` PDA.
12
12
  * @param args.filler - the keeper's `User` account submitting the trigger.
13
13
  * @param args.user - the order owner's `User` account.
14
+ * @param args.userStats - the order owner's `UserStats` account (checked for the
15
+ * authority-wide equity breaker; a risk-increasing trigger order is cancelled
16
+ * rather than activated while the breaker is tripped).
14
17
  * @param args.authority - signer that must own or be a registered delegate of `filler`.
15
18
  * @param args.remainingAccounts - oracle/market `AccountMeta[]` for the order's market.
16
19
  * @returns the unsigned `triggerOrder` `TransactionInstruction`.
@@ -21,6 +24,7 @@ export declare function buildTriggerOrderInstruction(args: {
21
24
  state: PublicKey;
22
25
  filler: PublicKey;
23
26
  user: PublicKey;
27
+ userStats: PublicKey;
24
28
  authority: PublicKey;
25
29
  remainingAccounts: AccountMeta[];
26
30
  }): Promise<TransactionInstruction>;
@@ -12,6 +12,9 @@ exports.buildTriggerOrderInstruction = void 0;
12
12
  * @param args.state - the global `State` PDA.
13
13
  * @param args.filler - the keeper's `User` account submitting the trigger.
14
14
  * @param args.user - the order owner's `User` account.
15
+ * @param args.userStats - the order owner's `UserStats` account (checked for the
16
+ * authority-wide equity breaker; a risk-increasing trigger order is cancelled
17
+ * rather than activated while the breaker is tripped).
15
18
  * @param args.authority - signer that must own or be a registered delegate of `filler`.
16
19
  * @param args.remainingAccounts - oracle/market `AccountMeta[]` for the order's market.
17
20
  * @returns the unsigned `triggerOrder` `TransactionInstruction`.
@@ -22,6 +25,7 @@ async function buildTriggerOrderInstruction(args) {
22
25
  state: args.state,
23
26
  filler: args.filler,
24
27
  user: args.user,
28
+ userStats: args.userStats,
25
29
  authority: args.authority,
26
30
  },
27
31
  remainingAccounts: args.remainingAccounts,
@@ -8,7 +8,7 @@ export type Velocity = {
8
8
  "address": "vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P";
9
9
  "metadata": {
10
10
  "name": "velocity";
11
- "version": "2.163.1";
11
+ "version": "2.164.0";
12
12
  "spec": "0.1.0";
13
13
  "description": "Created with Anchor";
14
14
  };
@@ -4426,6 +4426,9 @@ export type Velocity = {
4426
4426
  "name": "liquidator";
4427
4427
  "writable": true;
4428
4428
  },
4429
+ {
4430
+ "name": "liquidatorStats";
4431
+ },
4429
4432
  {
4430
4433
  "name": "user";
4431
4434
  "writable": true;
@@ -6289,6 +6292,9 @@ export type Velocity = {
6289
6292
  52
6290
6293
  ];
6291
6294
  "accounts": [
6295
+ {
6296
+ "name": "state";
6297
+ },
6292
6298
  {
6293
6299
  "name": "spotMarket";
6294
6300
  "writable": true;
@@ -6333,6 +6339,40 @@ export type Velocity = {
6333
6339
  "userStats"
6334
6340
  ];
6335
6341
  },
6342
+ {
6343
+ "name": "spotMarketVault";
6344
+ "writable": true;
6345
+ "pda": {
6346
+ "seeds": [
6347
+ {
6348
+ "kind": "const";
6349
+ "value": [
6350
+ 115,
6351
+ 112,
6352
+ 111,
6353
+ 116,
6354
+ 95,
6355
+ 109,
6356
+ 97,
6357
+ 114,
6358
+ 107,
6359
+ 101,
6360
+ 116,
6361
+ 95,
6362
+ 118,
6363
+ 97,
6364
+ 117,
6365
+ 108,
6366
+ 116
6367
+ ];
6368
+ },
6369
+ {
6370
+ "kind": "arg";
6371
+ "path": "marketIndex";
6372
+ }
6373
+ ];
6374
+ };
6375
+ },
6336
6376
  {
6337
6377
  "name": "insuranceFundVault";
6338
6378
  "writable": true;
@@ -6369,6 +6409,12 @@ export type Velocity = {
6369
6409
  }
6370
6410
  ];
6371
6411
  };
6412
+ },
6413
+ {
6414
+ "name": "velocitySigner";
6415
+ },
6416
+ {
6417
+ "name": "tokenProgram";
6372
6418
  }
6373
6419
  ];
6374
6420
  "args": [
@@ -6544,12 +6590,6 @@ export type Velocity = {
6544
6590
  },
6545
6591
  {
6546
6592
  "name": "authority";
6547
- "relations": [
6548
- "user"
6549
- ];
6550
- },
6551
- {
6552
- "name": "user";
6553
6593
  },
6554
6594
  {
6555
6595
  "name": "payer";
@@ -8244,6 +8284,9 @@ export type Velocity = {
8244
8284
  {
8245
8285
  "name": "user";
8246
8286
  "writable": true;
8287
+ },
8288
+ {
8289
+ "name": "userStats";
8247
8290
  }
8248
8291
  ];
8249
8292
  "args": [
@@ -11437,6 +11480,42 @@ export type Velocity = {
11437
11480
  ];
11438
11481
  "args": [];
11439
11482
  },
11483
+ {
11484
+ "name": "updateSpotMarketDepositCap";
11485
+ "discriminator": [
11486
+ 76,
11487
+ 21,
11488
+ 179,
11489
+ 154,
11490
+ 28,
11491
+ 161,
11492
+ 174,
11493
+ 107
11494
+ ];
11495
+ "accounts": [
11496
+ {
11497
+ "name": "admin";
11498
+ "signer": true;
11499
+ },
11500
+ {
11501
+ "name": "state";
11502
+ },
11503
+ {
11504
+ "name": "spotMarket";
11505
+ "writable": true;
11506
+ }
11507
+ ];
11508
+ "args": [
11509
+ {
11510
+ "name": "depositGuardThreshold";
11511
+ "type": "u64";
11512
+ },
11513
+ {
11514
+ "name": "maxDepositBpsPerDay";
11515
+ "type": "u16";
11516
+ }
11517
+ ];
11518
+ },
11440
11519
  {
11441
11520
  "name": "updateSpotMarketExpiry";
11442
11521
  "discriminator": [
@@ -12076,6 +12155,38 @@ export type Velocity = {
12076
12155
  }
12077
12156
  ];
12078
12157
  },
12158
+ {
12159
+ "name": "updateSpotMarketWithdrawCircuitBreaker";
12160
+ "discriminator": [
12161
+ 2,
12162
+ 97,
12163
+ 135,
12164
+ 97,
12165
+ 117,
12166
+ 169,
12167
+ 65,
12168
+ 223
12169
+ ];
12170
+ "accounts": [
12171
+ {
12172
+ "name": "admin";
12173
+ "signer": true;
12174
+ },
12175
+ {
12176
+ "name": "state";
12177
+ },
12178
+ {
12179
+ "name": "spotMarket";
12180
+ "writable": true;
12181
+ }
12182
+ ];
12183
+ "args": [
12184
+ {
12185
+ "name": "withdrawCircuitBreakerBps";
12186
+ "type": "u16";
12187
+ }
12188
+ ];
12189
+ },
12079
12190
  {
12080
12191
  "name": "updateStateMaxInitializeUserFee";
12081
12192
  "discriminator": [
@@ -16163,6 +16274,31 @@ export type Velocity = {
16163
16274
  "code": 6359;
16164
16275
  "name": "invalidEquityFloorTransfer";
16165
16276
  "msg": "Invalid equity floor transfer between subaccounts";
16277
+ },
16278
+ {
16279
+ "code": 6360;
16280
+ "name": "ifDepositMintsZeroShares";
16281
+ "msg": "Insurance fund deposit would mint zero shares";
16282
+ },
16283
+ {
16284
+ "code": 6361;
16285
+ "name": "liquidationWorsensAccountHealth";
16286
+ "msg": "Liquidation would worsen the account's margin shortage";
16287
+ },
16288
+ {
16289
+ "code": 6362;
16290
+ "name": "perpBankruptcyMustPrecedeSpot";
16291
+ "msg": "Perp bankruptcies must be resolved before spot bankruptcies";
16292
+ },
16293
+ {
16294
+ "code": 6363;
16295
+ "name": "invalidRevenueShareRecipient";
16296
+ "msg": "Revenue share recipient user must be sub_account_id 0";
16297
+ },
16298
+ {
16299
+ "code": 6364;
16300
+ "name": "dailyDepositLimit";
16301
+ "msg": "Spot market daily deposit limit hit";
16166
16302
  }
16167
16303
  ];
16168
16304
  "types": [
@@ -21210,19 +21346,24 @@ export type Velocity = {
21210
21346
  };
21211
21347
  },
21212
21348
  {
21213
- "name": "paddingAlignAmm";
21349
+ "name": "pendingRevenueShare";
21214
21350
  "docs": [
21215
- "8 bytes of explicit padding so MarketStats (216 bytes) plus this",
21216
- "padding equals 224 bytes the offset Rust naturally inserts to",
21217
- "16-align AMM's leading u128. Making it explicit keeps the IDL byte",
21218
- "layout aligned with `repr(C)`."
21351
+ "Aggregate accrued builder/referrer revenue-share owed out of this",
21352
+ "market's `pnl_pool` but not yet paid: incremented as builder and",
21353
+ "referrer fees accrue on fills (mirrors the per-order",
21354
+ "`RevenueShareOrder.fees_accrued` writes) and decremented as",
21355
+ "`sweep_completed_revenue_share_for_market` pays them. The",
21356
+ "permissionless fee sweep reserves it (like `max(net_user_pnl, 0)` and",
21357
+ "the floored IF tranche) so a protocol-fee drain can't move the tokens",
21358
+ "backing already-owed revenue share out of the pnl pool and leave those",
21359
+ "claims temporarily unpayable. precision: QUOTE_PRECISION.",
21360
+ "",
21361
+ "Occupies the 8 bytes Rust naturally inserts to 16-align AMM's leading",
21362
+ "u128 (formerly explicit `_padding_align_amm`): a u64 at the same",
21363
+ "8-aligned offset keeps every downstream byte offset and the total size",
21364
+ "unchanged, so legacy accounts read 0 (nothing owed) until fees accrue."
21219
21365
  ];
21220
- "type": {
21221
- "array": [
21222
- "u8",
21223
- 8
21224
- ];
21225
- };
21366
+ "type": "u64";
21226
21367
  },
21227
21368
  {
21228
21369
  "name": "amm";
@@ -23004,15 +23145,44 @@ export type Velocity = {
23004
23145
  {
23005
23146
  "name": "paddingAlignPfp";
23006
23147
  "docs": [
23007
- "Aligns `protocol_fee_pool`'s leading u128 to a 16-byte struct offset so",
23008
- "host (x86_64, align 16) and SBF (align 8) layouts agree. Do not reorder."
23148
+ "Explicit filler carved from the alignment gap before `protocol_fee_pool`",
23149
+ "(which must stay at struct offset 752 so host/SBF layouts agree and the",
23150
+ "borsh/IDL packed offset matches). The gap is 13 bytes; the three",
23151
+ "configurable-limit fields below plus this 1-byte filler fill it exactly,",
23152
+ "so `protocol_fee_pool` and every field after it keep their offsets and the",
23153
+ "account size is unchanged. Reads 0 on markets created before these fields",
23154
+ "existed. Every byte is explicit so no implicit `#[repr(C)]` pad desyncs",
23155
+ "off-chain borsh decoders. Do not reorder or resize."
23009
23156
  ];
23010
- "type": {
23011
- "array": [
23012
- "u8",
23013
- 8
23014
- ];
23015
- };
23157
+ "type": "u8";
23158
+ },
23159
+ {
23160
+ "name": "withdrawCircuitBreakerBps";
23161
+ "docs": [
23162
+ "Daily withdraw circuit-breaker size: the max fraction of the 24h deposit",
23163
+ "TWAP that may be withdrawn per 24h window. `0` is treated as the default",
23164
+ "(2500 bps = 25%) so markets created before this field existed keep prior",
23165
+ "behavior. precision: basis points (10_000 = 100%)"
23166
+ ];
23167
+ "type": "u16";
23168
+ },
23169
+ {
23170
+ "name": "maxDepositBpsPerDay";
23171
+ "docs": [
23172
+ "Daily deposit rate limit: the max fraction above the 24h deposit TWAP that",
23173
+ "resulting deposits may reach per 24h window. Disabled when `0`.",
23174
+ "precision: basis points (10_000 = 100%)"
23175
+ ];
23176
+ "type": "u16";
23177
+ },
23178
+ {
23179
+ "name": "depositGuardThreshold";
23180
+ "docs": [
23181
+ "No deposit rate limit when resulting deposits are below this threshold.",
23182
+ "Mirrors `withdraw_guard_threshold` on the deposit side.",
23183
+ "precision: token mint precision"
23184
+ ];
23185
+ "type": "u64";
23016
23186
  },
23017
23187
  {
23018
23188
  "name": "protocolFeePool";
@@ -23048,13 +23218,33 @@ export type Velocity = {
23048
23218
  "type": "u32";
23049
23219
  },
23050
23220
  {
23051
- "name": "padding";
23052
- "type": {
23053
- "array": [
23054
- "u8",
23055
- 8
23056
- ];
23057
- };
23221
+ "name": "ifLastSettleVaultAmount";
23222
+ "docs": [
23223
+ "Donation-proof accounted balance of the insurance-fund vault. It is moved",
23224
+ "by the same signed delta as the real SPL vault on *every* instruction that",
23225
+ "moves the vault, so it stays a faithful shadow of the vault minus raw",
23226
+ "donations. Inflows grow it: staker deposits (`add_insurance_fund_stake`)",
23227
+ "and settled revenue (`settle_revenue_to_insurance_fund`). Outflows/draws",
23228
+ "shrink it (saturating at 0): staker withdrawals",
23229
+ "(`remove_insurance_fund_stake`) and every IF draw that covers a loss —",
23230
+ "`resolve_perp_pnl_deficit`, `resolve_perp_bankruptcy`,",
23231
+ "`resolve_spot_bankruptcy`. The one movement deliberately *excluded* is a",
23232
+ "raw SPL transfer straight into the vault: it runs no instruction, so it",
23233
+ "never enters this balance — that is exactly the donation the shadow must",
23234
+ "not see. Consumed by the per-period revenue-settle APR cap in",
23235
+ "`settle_revenue_to_insurance_fund`, sized off `min(live_if_vault, this)`,",
23236
+ "so a donation spiked into the live vault right before a settle cannot",
23237
+ "inflate the cap while legitimate stakes and real settled revenue (which",
23238
+ "this balance tracks) still do. (The unstake-cancel share forfeiture is",
23239
+ "donation-proofed differently — by withdraw-and-restake at the active share",
23240
+ "price — and does *not* read this field.) Repurposed from trailing padding —",
23241
+ "layout/size unchanged; `0` means \"uninitialized\" (existing account",
23242
+ "pre-upgrade, or an accounted balance legitimately drained to empty — an",
23243
+ "empty IF vault has no user shares, so this is safe), and is seeded from the",
23244
+ "live balance on the next add/settle and treated as \"fall back to live\" by",
23245
+ "the consumers."
23246
+ ];
23247
+ "type": "u64";
23058
23248
  }
23059
23249
  ];
23060
23250
  };