@velocity-exchange/sdk 0.6.1 → 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.
- package/lib/browser/adminClient.d.ts +24 -4
- package/lib/browser/adminClient.js +62 -12
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +19 -15
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +31 -22
- package/lib/browser/constants/numericConstants.d.ts +2 -0
- package/lib/browser/constants/numericConstants.js +3 -1
- package/lib/browser/core/VelocityCore.d.ts +2 -0
- package/lib/browser/core/VelocityCore.js +1 -0
- package/lib/browser/core/instructions/trigger.d.ts +4 -0
- package/lib/browser/core/instructions/trigger.js +4 -0
- package/lib/browser/idl/velocity.d.ts +223 -33
- package/lib/browser/idl/velocity.json +224 -34
- package/lib/browser/math/amm.d.ts +8 -8
- package/lib/browser/math/funding.d.ts +2 -2
- package/lib/browser/math/liquidation.d.ts +37 -2
- package/lib/browser/math/liquidation.js +44 -3
- package/lib/browser/math/market.d.ts +5 -4
- package/lib/browser/math/market.js +21 -14
- package/lib/browser/math/oracles.d.ts +3 -3
- package/lib/browser/math/orders.d.ts +1 -1
- package/lib/browser/math/spotBalance.d.ts +13 -0
- package/lib/browser/math/spotBalance.js +43 -2
- package/lib/browser/testClient.js +12 -1
- package/lib/browser/tx/txHandler.d.ts +7 -1
- package/lib/browser/tx/txHandler.js +7 -3
- package/lib/browser/types.d.ts +9 -0
- package/lib/browser/user.d.ts +2 -2
- package/lib/browser/userMap/userMap.d.ts +1 -0
- package/lib/browser/userMap/userMap.js +3 -7
- package/lib/browser/velocityClient.d.ts +32 -20
- package/lib/browser/velocityClient.js +48 -23
- package/lib/node/adminClient.d.ts +24 -4
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +62 -12
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +19 -15
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +31 -22
- package/lib/node/constants/numericConstants.d.ts +2 -0
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +3 -1
- package/lib/node/core/VelocityCore.d.ts +2 -0
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.js +1 -0
- package/lib/node/core/instructions/trigger.d.ts +4 -0
- package/lib/node/core/instructions/trigger.d.ts.map +1 -1
- package/lib/node/core/instructions/trigger.js +4 -0
- package/lib/node/idl/velocity.d.ts +223 -33
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +224 -34
- package/lib/node/math/amm.d.ts +8 -8
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/funding.d.ts +2 -2
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/liquidation.d.ts +37 -2
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/liquidation.js +44 -3
- package/lib/node/math/market.d.ts +5 -4
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +21 -14
- package/lib/node/math/oracles.d.ts +3 -3
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/orders.d.ts +1 -1
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/spotBalance.d.ts +13 -0
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotBalance.js +43 -2
- package/lib/node/testClient.d.ts.map +1 -1
- package/lib/node/testClient.js +12 -1
- package/lib/node/tx/txHandler.d.ts +7 -1
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +7 -3
- package/lib/node/types.d.ts +9 -0
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/user.d.ts +2 -2
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/userMap/userMap.d.ts +1 -0
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +3 -7
- package/lib/node/velocityClient.d.ts +32 -20
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +48 -23
- 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.
|
|
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": "
|
|
21349
|
+
"name": "pendingRevenueShare";
|
|
21214
21350
|
"docs": [
|
|
21215
|
-
"
|
|
21216
|
-
"
|
|
21217
|
-
"
|
|
21218
|
-
"
|
|
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
|
-
"
|
|
23008
|
-
"
|
|
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
|
-
|
|
23012
|
-
|
|
23013
|
-
|
|
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": "
|
|
23052
|
-
"
|
|
23053
|
-
"
|
|
23054
|
-
|
|
23055
|
-
|
|
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
|
};
|