@velocity-exchange/sdk 0.7.0 → 0.9.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 (75) hide show
  1. package/lib/browser/adminClient.d.ts +35 -12
  2. package/lib/browser/adminClient.js +75 -22
  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/decode/user.js +3 -1
  8. package/lib/browser/equityFloorManager.d.ts +150 -0
  9. package/lib/browser/equityFloorManager.js +279 -0
  10. package/lib/browser/idl/velocity.d.ts +307 -43
  11. package/lib/browser/idl/velocity.json +308 -44
  12. package/lib/browser/index.d.ts +2 -0
  13. package/lib/browser/index.js +2 -0
  14. package/lib/browser/jupiter/jupiterClient.js +24 -3
  15. package/lib/browser/math/liquidation.d.ts +37 -2
  16. package/lib/browser/math/liquidation.js +44 -3
  17. package/lib/browser/math/margin.d.ts +26 -0
  18. package/lib/browser/math/margin.js +41 -1
  19. package/lib/browser/math/spotBalance.d.ts +13 -0
  20. package/lib/browser/math/spotBalance.js +43 -2
  21. package/lib/browser/swap/UnifiedSwapClient.js +17 -3
  22. package/lib/browser/titan/titanClient.d.ts +6 -0
  23. package/lib/browser/titan/titanClient.js +44 -13
  24. package/lib/browser/types.d.ts +15 -2
  25. package/lib/browser/types.js +2 -0
  26. package/lib/browser/user.d.ts +38 -11
  27. package/lib/browser/user.js +84 -33
  28. package/lib/browser/velocityClient.d.ts +37 -24
  29. package/lib/browser/velocityClient.js +56 -35
  30. package/lib/node/adminClient.d.ts +35 -12
  31. package/lib/node/adminClient.d.ts.map +1 -1
  32. package/lib/node/adminClient.js +75 -22
  33. package/lib/node/core/VelocityCore.d.ts +2 -0
  34. package/lib/node/core/VelocityCore.d.ts.map +1 -1
  35. package/lib/node/core/VelocityCore.js +1 -0
  36. package/lib/node/core/instructions/trigger.d.ts +4 -0
  37. package/lib/node/core/instructions/trigger.d.ts.map +1 -1
  38. package/lib/node/core/instructions/trigger.js +4 -0
  39. package/lib/node/decode/user.d.ts.map +1 -1
  40. package/lib/node/decode/user.js +3 -1
  41. package/lib/node/equityFloorManager.d.ts +151 -0
  42. package/lib/node/equityFloorManager.d.ts.map +1 -0
  43. package/lib/node/equityFloorManager.js +279 -0
  44. package/lib/node/idl/velocity.d.ts +307 -43
  45. package/lib/node/idl/velocity.d.ts.map +1 -1
  46. package/lib/node/idl/velocity.json +308 -44
  47. package/lib/node/index.d.ts +2 -0
  48. package/lib/node/index.d.ts.map +1 -1
  49. package/lib/node/index.js +2 -0
  50. package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
  51. package/lib/node/jupiter/jupiterClient.js +24 -3
  52. package/lib/node/math/liquidation.d.ts +37 -2
  53. package/lib/node/math/liquidation.d.ts.map +1 -1
  54. package/lib/node/math/liquidation.js +44 -3
  55. package/lib/node/math/margin.d.ts +26 -0
  56. package/lib/node/math/margin.d.ts.map +1 -1
  57. package/lib/node/math/margin.js +41 -1
  58. package/lib/node/math/spotBalance.d.ts +13 -0
  59. package/lib/node/math/spotBalance.d.ts.map +1 -1
  60. package/lib/node/math/spotBalance.js +43 -2
  61. package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
  62. package/lib/node/swap/UnifiedSwapClient.js +17 -3
  63. package/lib/node/titan/titanClient.d.ts +6 -0
  64. package/lib/node/titan/titanClient.d.ts.map +1 -1
  65. package/lib/node/titan/titanClient.js +44 -13
  66. package/lib/node/types.d.ts +15 -2
  67. package/lib/node/types.d.ts.map +1 -1
  68. package/lib/node/types.js +2 -0
  69. package/lib/node/user.d.ts +38 -11
  70. package/lib/node/user.d.ts.map +1 -1
  71. package/lib/node/user.js +84 -33
  72. package/lib/node/velocityClient.d.ts +37 -24
  73. package/lib/node/velocityClient.d.ts.map +1 -1
  74. package/lib/node/velocityClient.js +56 -35
  75. package/package.json +1 -1
@@ -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": [
@@ -12355,6 +12466,10 @@ export type Velocity = {
12355
12466
  {
12356
12467
  "name": "equityFloor";
12357
12468
  "type": "u64";
12469
+ },
12470
+ {
12471
+ "name": "equityFloorBuffer";
12472
+ "type": "u64";
12358
12473
  }
12359
12474
  ];
12360
12475
  },
@@ -12776,6 +12891,63 @@ export type Velocity = {
12776
12891
  ];
12777
12892
  "args": [];
12778
12893
  },
12894
+ {
12895
+ "name": "updateUserVaultOwned";
12896
+ "docs": [
12897
+ "Mark a User as vault-owned (its authority is a vault PDA and its equity",
12898
+ "prices vault depositor shares). Set-only and authority-gated: only the",
12899
+ "User's authority may call it, and it is CPI'd by the vaults program at",
12900
+ "vault init. A vault-owned User is skipped by the revenue-share sweep so a",
12901
+ "builder/referral reward can never enter vault NAV (OtterSec #91/#92/#93)."
12902
+ ];
12903
+ "discriminator": [
12904
+ 50,
12905
+ 156,
12906
+ 218,
12907
+ 143,
12908
+ 216,
12909
+ 94,
12910
+ 68,
12911
+ 93
12912
+ ];
12913
+ "accounts": [
12914
+ {
12915
+ "name": "user";
12916
+ "writable": true;
12917
+ "pda": {
12918
+ "seeds": [
12919
+ {
12920
+ "kind": "const";
12921
+ "value": [
12922
+ 117,
12923
+ 115,
12924
+ 101,
12925
+ 114
12926
+ ];
12927
+ },
12928
+ {
12929
+ "kind": "account";
12930
+ "path": "authority";
12931
+ },
12932
+ {
12933
+ "kind": "arg";
12934
+ "path": "subAccountId";
12935
+ }
12936
+ ];
12937
+ };
12938
+ },
12939
+ {
12940
+ "name": "authority";
12941
+ "signer": true;
12942
+ }
12943
+ ];
12944
+ "args": [
12945
+ {
12946
+ "name": "subAccountId";
12947
+ "type": "u16";
12948
+ }
12949
+ ];
12950
+ },
12779
12951
  {
12780
12952
  "name": "updateWarmAdmin";
12781
12953
  "discriminator": [
@@ -16163,6 +16335,41 @@ export type Velocity = {
16163
16335
  "code": 6359;
16164
16336
  "name": "invalidEquityFloorTransfer";
16165
16337
  "msg": "Invalid equity floor transfer between subaccounts";
16338
+ },
16339
+ {
16340
+ "code": 6360;
16341
+ "name": "ifDepositMintsZeroShares";
16342
+ "msg": "Insurance fund deposit would mint zero shares";
16343
+ },
16344
+ {
16345
+ "code": 6361;
16346
+ "name": "liquidationWorsensAccountHealth";
16347
+ "msg": "Liquidation would worsen the account's margin shortage";
16348
+ },
16349
+ {
16350
+ "code": 6362;
16351
+ "name": "perpBankruptcyMustPrecedeSpot";
16352
+ "msg": "Perp bankruptcies must be resolved before spot bankruptcies";
16353
+ },
16354
+ {
16355
+ "code": 6363;
16356
+ "name": "invalidRevenueShareRecipient";
16357
+ "msg": "Revenue share recipient user must be sub_account_id 0";
16358
+ },
16359
+ {
16360
+ "code": 6364;
16361
+ "name": "dailyDepositLimit";
16362
+ "msg": "Spot market daily deposit limit hit";
16363
+ },
16364
+ {
16365
+ "code": 6365;
16366
+ "name": "reservedSpotMarketName";
16367
+ "msg": "The name 'USDT' is reserved for the quote spot market (index 0)";
16368
+ },
16369
+ {
16370
+ "code": 6366;
16371
+ "name": "cannotModifyBuilderOrder";
16372
+ "msg": "Cannot modify a builder-coded order; cancel and re-place instead";
16166
16373
  }
16167
16374
  ];
16168
16375
  "types": [
@@ -21210,19 +21417,24 @@ export type Velocity = {
21210
21417
  };
21211
21418
  },
21212
21419
  {
21213
- "name": "paddingAlignAmm";
21420
+ "name": "pendingRevenueShare";
21214
21421
  "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)`."
21422
+ "Aggregate accrued builder/referrer revenue-share owed out of this",
21423
+ "market's `pnl_pool` but not yet paid: incremented as builder and",
21424
+ "referrer fees accrue on fills (mirrors the per-order",
21425
+ "`RevenueShareOrder.fees_accrued` writes) and decremented as",
21426
+ "`sweep_completed_revenue_share_for_market` pays them. The",
21427
+ "permissionless fee sweep reserves it (like `max(net_user_pnl, 0)` and",
21428
+ "the floored IF tranche) so a protocol-fee drain can't move the tokens",
21429
+ "backing already-owed revenue share out of the pnl pool and leave those",
21430
+ "claims temporarily unpayable. precision: QUOTE_PRECISION.",
21431
+ "",
21432
+ "Occupies the 8 bytes Rust naturally inserts to 16-align AMM's leading",
21433
+ "u128 (formerly explicit `_padding_align_amm`): a u64 at the same",
21434
+ "8-aligned offset keeps every downstream byte offset and the total size",
21435
+ "unchanged, so legacy accounts read 0 (nothing owed) until fees accrue."
21219
21436
  ];
21220
- "type": {
21221
- "array": [
21222
- "u8",
21223
- 8
21224
- ];
21225
- };
21437
+ "type": "u64";
21226
21438
  },
21227
21439
  {
21228
21440
  "name": "amm";
@@ -23004,15 +23216,44 @@ export type Velocity = {
23004
23216
  {
23005
23217
  "name": "paddingAlignPfp";
23006
23218
  "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."
23219
+ "Explicit filler carved from the alignment gap before `protocol_fee_pool`",
23220
+ "(which must stay at struct offset 752 so host/SBF layouts agree and the",
23221
+ "borsh/IDL packed offset matches). The gap is 13 bytes; the three",
23222
+ "configurable-limit fields below plus this 1-byte filler fill it exactly,",
23223
+ "so `protocol_fee_pool` and every field after it keep their offsets and the",
23224
+ "account size is unchanged. Reads 0 on markets created before these fields",
23225
+ "existed. Every byte is explicit so no implicit `#[repr(C)]` pad desyncs",
23226
+ "off-chain borsh decoders. Do not reorder or resize."
23009
23227
  ];
23010
- "type": {
23011
- "array": [
23012
- "u8",
23013
- 8
23014
- ];
23015
- };
23228
+ "type": "u8";
23229
+ },
23230
+ {
23231
+ "name": "withdrawCircuitBreakerBps";
23232
+ "docs": [
23233
+ "Daily withdraw circuit-breaker size: the max fraction of the 24h deposit",
23234
+ "TWAP that may be withdrawn per 24h window. `0` is treated as the default",
23235
+ "(2500 bps = 25%) so markets created before this field existed keep prior",
23236
+ "behavior. precision: basis points (10_000 = 100%)"
23237
+ ];
23238
+ "type": "u16";
23239
+ },
23240
+ {
23241
+ "name": "maxDepositBpsPerDay";
23242
+ "docs": [
23243
+ "Daily deposit rate limit: the max fraction above the 24h deposit TWAP that",
23244
+ "resulting deposits may reach per 24h window. Disabled when `0`.",
23245
+ "precision: basis points (10_000 = 100%)"
23246
+ ];
23247
+ "type": "u16";
23248
+ },
23249
+ {
23250
+ "name": "depositGuardThreshold";
23251
+ "docs": [
23252
+ "No deposit rate limit when resulting deposits are below this threshold.",
23253
+ "Mirrors `withdraw_guard_threshold` on the deposit side.",
23254
+ "precision: token mint precision"
23255
+ ];
23256
+ "type": "u64";
23016
23257
  },
23017
23258
  {
23018
23259
  "name": "protocolFeePool";
@@ -23048,13 +23289,33 @@ export type Velocity = {
23048
23289
  "type": "u32";
23049
23290
  },
23050
23291
  {
23051
- "name": "padding";
23052
- "type": {
23053
- "array": [
23054
- "u8",
23055
- 8
23056
- ];
23057
- };
23292
+ "name": "ifLastSettleVaultAmount";
23293
+ "docs": [
23294
+ "Donation-proof accounted balance of the insurance-fund vault. It is moved",
23295
+ "by the same signed delta as the real SPL vault on *every* instruction that",
23296
+ "moves the vault, so it stays a faithful shadow of the vault minus raw",
23297
+ "donations. Inflows grow it: staker deposits (`add_insurance_fund_stake`)",
23298
+ "and settled revenue (`settle_revenue_to_insurance_fund`). Outflows/draws",
23299
+ "shrink it (saturating at 0): staker withdrawals",
23300
+ "(`remove_insurance_fund_stake`) and every IF draw that covers a loss —",
23301
+ "`resolve_perp_pnl_deficit`, `resolve_perp_bankruptcy`,",
23302
+ "`resolve_spot_bankruptcy`. The one movement deliberately *excluded* is a",
23303
+ "raw SPL transfer straight into the vault: it runs no instruction, so it",
23304
+ "never enters this balance — that is exactly the donation the shadow must",
23305
+ "not see. Consumed by the per-period revenue-settle APR cap in",
23306
+ "`settle_revenue_to_insurance_fund`, sized off `min(live_if_vault, this)`,",
23307
+ "so a donation spiked into the live vault right before a settle cannot",
23308
+ "inflate the cap while legitimate stakes and real settled revenue (which",
23309
+ "this balance tracks) still do. (The unstake-cancel share forfeiture is",
23310
+ "donation-proofed differently — by withdraw-and-restake at the active share",
23311
+ "price — and does *not* read this field.) Repurposed from trailing padding —",
23312
+ "layout/size unchanged; `0` means \"uninitialized\" (existing account",
23313
+ "pre-upgrade, or an accounted balance legitimately drained to empty — an",
23314
+ "empty IF vault has no user shares, so this is safe), and is seeded from the",
23315
+ "live balance on the next add/settle and treated as \"fall back to live\" by",
23316
+ "the consumers."
23317
+ ];
23318
+ "type": "u64";
23058
23319
  }
23059
23320
  ];
23060
23321
  };
@@ -23875,21 +24136,24 @@ export type Velocity = {
23875
24136
  {
23876
24137
  "name": "equityFloor";
23877
24138
  "docs": [
23878
- "Minimum account equity (cross-margin total collateral) required for",
23879
- "risk-increasing orders, fills, withdrawals and deposit transfers.",
23880
- "Settable only by the warm/cold admin; 0 disables the check.",
24139
+ "Minimum account equity (cross-margin total collateral). Below this the",
24140
+ "permissionless breaker can trip. Risk-increasing orders, fills,",
24141
+ "withdrawals and deposit transfers must clear `equity_floor +",
24142
+ "equity_floor_buffer`. Settable only by the warm/cold admin; 0 disables",
24143
+ "both checks.",
23881
24144
  "precision: QUOTE_PRECISION"
23882
24145
  ];
23883
24146
  "type": "u64";
23884
24147
  },
23885
24148
  {
23886
- "name": "padding2";
23887
- "type": {
23888
- "array": [
23889
- "u8",
23890
- 8
23891
- ];
23892
- };
24149
+ "name": "equityFloorBuffer";
24150
+ "docs": [
24151
+ "Extra headroom above `equity_floor` required by risk-increasing",
24152
+ "actions, so an account cannot legally end an action at the trip",
24153
+ "threshold. No effect while `equity_floor` is 0.",
24154
+ "precision: QUOTE_PRECISION"
24155
+ ];
24156
+ "type": "u64";
23893
24157
  }
23894
24158
  ];
23895
24159
  };