@velocity-exchange/sdk 0.8.0 → 0.10.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 +13 -10
- package/lib/browser/adminClient.js +16 -21
- package/lib/browser/decode/user.js +3 -1
- package/lib/browser/equityFloorManager.d.ts +154 -0
- package/lib/browser/equityFloorManager.js +283 -0
- package/lib/browser/idl/velocity.d.ts +85 -10
- package/lib/browser/idl/velocity.json +85 -10
- package/lib/browser/index.d.ts +4 -0
- package/lib/browser/index.js +5 -0
- package/lib/browser/jupiter/jupiterClient.d.ts +31 -27
- package/lib/browser/jupiter/jupiterClient.js +84 -37
- package/lib/browser/math/margin.d.ts +28 -0
- package/lib/browser/math/margin.js +43 -1
- package/lib/browser/math/superStake.d.ts +9 -9
- package/lib/browser/math/superStake.js +8 -8
- package/lib/browser/swap/UnifiedSwapClient.d.ts +38 -76
- package/lib/browser/swap/UnifiedSwapClient.js +53 -110
- package/lib/browser/swap/routeInstructions.d.ts +19 -0
- package/lib/browser/swap/routeInstructions.js +43 -0
- package/lib/browser/swap/types.d.ts +196 -0
- package/lib/browser/swap/types.js +88 -0
- package/lib/browser/titan/titanClient.d.ts +37 -67
- package/lib/browser/titan/titanClient.js +160 -103
- package/lib/browser/types.d.ts +6 -2
- package/lib/browser/types.js +2 -0
- package/lib/browser/user.d.ts +43 -18
- package/lib/browser/user.js +94 -45
- package/lib/browser/velocityClient.d.ts +86 -103
- package/lib/browser/velocityClient.js +157 -298
- package/lib/node/adminClient.d.ts +13 -10
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +16 -21
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +3 -1
- package/lib/node/equityFloorManager.d.ts +155 -0
- package/lib/node/equityFloorManager.d.ts.map +1 -0
- package/lib/node/equityFloorManager.js +283 -0
- package/lib/node/idl/velocity.d.ts +85 -10
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +85 -10
- package/lib/node/index.d.ts +4 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +5 -0
- package/lib/node/jupiter/jupiterClient.d.ts +31 -27
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.js +84 -37
- package/lib/node/math/margin.d.ts +28 -0
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +43 -1
- package/lib/node/math/superStake.d.ts +9 -9
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +8 -8
- package/lib/node/swap/UnifiedSwapClient.d.ts +38 -76
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- package/lib/node/swap/UnifiedSwapClient.js +53 -110
- package/lib/node/swap/routeInstructions.d.ts +20 -0
- package/lib/node/swap/routeInstructions.d.ts.map +1 -0
- package/lib/node/swap/routeInstructions.js +43 -0
- package/lib/node/swap/types.d.ts +197 -0
- package/lib/node/swap/types.d.ts.map +1 -0
- package/lib/node/swap/types.js +88 -0
- package/lib/node/titan/titanClient.d.ts +37 -67
- package/lib/node/titan/titanClient.d.ts.map +1 -1
- package/lib/node/titan/titanClient.js +160 -103
- package/lib/node/types.d.ts +6 -2
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +2 -0
- package/lib/node/user.d.ts +43 -18
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +94 -45
- package/lib/node/velocityClient.d.ts +86 -103
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +157 -298
- package/package.json +1 -1
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EquityFloorManager = exports.planFloorMoves = exports.allocateEquityFloors = void 0;
|
|
4
|
+
const anchor_1 = require("./isomorphic/anchor");
|
|
5
|
+
const numericConstants_1 = require("./constants/numericConstants");
|
|
6
|
+
const numericConstants_2 = require("./constants/numericConstants");
|
|
7
|
+
const margin_1 = require("./math/margin");
|
|
8
|
+
/**
|
|
9
|
+
* Splits `totalFloor` across subaccounts proportionally to their equity,
|
|
10
|
+
* clamped so every allocation is backed (`floor_i <= max(0, equity_i -
|
|
11
|
+
* buffer_i)`), with the clamped remainder water-filled into subaccounts that
|
|
12
|
+
* still have capacity. Entries in `pinned` keep their current floor and
|
|
13
|
+
* receive none of the remainder (used for breached subaccounts, which cannot
|
|
14
|
+
* shed floor on-chain). Returns `null` when no backed allocation exists, i.e.
|
|
15
|
+
* the pool's equity cannot cover `totalFloor` plus buffers.
|
|
16
|
+
*/
|
|
17
|
+
function allocateEquityFloors(totalFloor, subaccounts, pinned = []) {
|
|
18
|
+
const n = subaccounts.length;
|
|
19
|
+
const targets = new Array(n).fill(numericConstants_1.ZERO);
|
|
20
|
+
let remaining = totalFloor;
|
|
21
|
+
for (let i = 0; i < n; i++) {
|
|
22
|
+
if (pinned[i]) {
|
|
23
|
+
targets[i] = subaccounts[i].currentFloor;
|
|
24
|
+
remaining = remaining.sub(subaccounts[i].currentFloor);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (remaining.isNeg()) {
|
|
28
|
+
// pinned floors alone exceed the total: nothing to allocate elsewhere
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const free = [...Array(n).keys()].filter((i) => !pinned[i]);
|
|
32
|
+
const caps = subaccounts.map((s, i) => pinned[i] ? numericConstants_1.ZERO : anchor_1.BN.max(s.equity.sub(s.buffer), numericConstants_1.ZERO));
|
|
33
|
+
const totalCap = free.reduce((sum, i) => sum.add(caps[i]), numericConstants_1.ZERO);
|
|
34
|
+
if (totalCap.lt(remaining)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const totalFreeEquity = free.reduce((sum, i) => sum.add(anchor_1.BN.max(subaccounts[i].equity, numericConstants_1.ZERO)), numericConstants_1.ZERO);
|
|
38
|
+
// proportional-to-equity first pass (floor division), clamped to capacity
|
|
39
|
+
let assigned = numericConstants_1.ZERO;
|
|
40
|
+
for (const i of free) {
|
|
41
|
+
const share = totalFreeEquity.gt(numericConstants_1.ZERO)
|
|
42
|
+
? remaining.mul(anchor_1.BN.max(subaccounts[i].equity, numericConstants_1.ZERO)).div(totalFreeEquity)
|
|
43
|
+
: numericConstants_1.ZERO;
|
|
44
|
+
targets[i] = anchor_1.BN.min(share, caps[i]);
|
|
45
|
+
assigned = assigned.add(targets[i]);
|
|
46
|
+
}
|
|
47
|
+
// water-fill the rounding/clamping remainder into leftover capacity
|
|
48
|
+
let leftover = remaining.sub(assigned);
|
|
49
|
+
for (const i of free) {
|
|
50
|
+
if (leftover.lte(numericConstants_1.ZERO)) {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
const slack = caps[i].sub(targets[i]);
|
|
54
|
+
const add = anchor_1.BN.min(slack, leftover);
|
|
55
|
+
targets[i] = targets[i].add(add);
|
|
56
|
+
leftover = leftover.sub(add);
|
|
57
|
+
}
|
|
58
|
+
if (leftover.gt(numericConstants_1.ZERO)) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return targets;
|
|
62
|
+
}
|
|
63
|
+
exports.allocateEquityFloors = allocateEquityFloors;
|
|
64
|
+
/**
|
|
65
|
+
* Turns a current → target floor split into concrete moves, greedily matching
|
|
66
|
+
* surpluses against deficits. The moves conserve the floor sum by
|
|
67
|
+
* construction and each one only ever sheds floor from a subaccount whose
|
|
68
|
+
* floor is above its target.
|
|
69
|
+
*/
|
|
70
|
+
function planFloorMoves(subAccountIds, current, target) {
|
|
71
|
+
const surpluses = [];
|
|
72
|
+
const deficits = [];
|
|
73
|
+
for (let i = 0; i < current.length; i++) {
|
|
74
|
+
const diff = current[i].sub(target[i]);
|
|
75
|
+
if (diff.gt(numericConstants_1.ZERO)) {
|
|
76
|
+
surpluses.push({ index: i, amount: diff });
|
|
77
|
+
}
|
|
78
|
+
else if (diff.lt(numericConstants_1.ZERO)) {
|
|
79
|
+
deficits.push({ index: i, amount: diff.neg() });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const moves = [];
|
|
83
|
+
let s = 0;
|
|
84
|
+
let d = 0;
|
|
85
|
+
while (s < surpluses.length && d < deficits.length) {
|
|
86
|
+
const delta = anchor_1.BN.min(surpluses[s].amount, deficits[d].amount);
|
|
87
|
+
moves.push({
|
|
88
|
+
fromSubAccountId: subAccountIds[surpluses[s].index],
|
|
89
|
+
toSubAccountId: subAccountIds[deficits[d].index],
|
|
90
|
+
equityFloorDelta: delta,
|
|
91
|
+
});
|
|
92
|
+
surpluses[s].amount = surpluses[s].amount.sub(delta);
|
|
93
|
+
deficits[d].amount = deficits[d].amount.sub(delta);
|
|
94
|
+
if (surpluses[s].amount.isZero()) {
|
|
95
|
+
s++;
|
|
96
|
+
}
|
|
97
|
+
if (deficits[d].amount.isZero()) {
|
|
98
|
+
d++;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return moves;
|
|
102
|
+
}
|
|
103
|
+
exports.planFloorMoves = planFloorMoves;
|
|
104
|
+
const LEVEL_SEVERITY = {
|
|
105
|
+
breached: 4,
|
|
106
|
+
critical: 3,
|
|
107
|
+
warning: 2,
|
|
108
|
+
healthy: 1,
|
|
109
|
+
disabled: 0,
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* See the module doc. All reads use the subaccounts already subscribed on the
|
|
113
|
+
* wrapped `VelocityClient` (the delegate's client, whose `authority` is the
|
|
114
|
+
* subaccounts' owner); all writes go through `transferDepositByDelegate`.
|
|
115
|
+
*/
|
|
116
|
+
class EquityFloorManager {
|
|
117
|
+
constructor(velocityClient, config = {}) {
|
|
118
|
+
var _a;
|
|
119
|
+
this.velocityClient = velocityClient;
|
|
120
|
+
this.subAccountIds = config.subAccountIds;
|
|
121
|
+
this.collateralHaircut = (_a = config.collateralHaircut) !== null && _a !== void 0 ? _a : numericConstants_1.QUOTE_PRECISION;
|
|
122
|
+
}
|
|
123
|
+
getManagedUsers() {
|
|
124
|
+
const authority = this.velocityClient.authority;
|
|
125
|
+
let users = this.velocityClient
|
|
126
|
+
.getUsers()
|
|
127
|
+
.filter((user) => user.getUserAccountOrThrow().authority.equals(authority));
|
|
128
|
+
if (this.subAccountIds !== undefined) {
|
|
129
|
+
const wanted = new Set(this.subAccountIds);
|
|
130
|
+
users = users.filter((user) => wanted.has(user.getUserAccountOrThrow().subAccountId));
|
|
131
|
+
}
|
|
132
|
+
return users.sort((a, b) => a.getUserAccountOrThrow().subAccountId -
|
|
133
|
+
b.getUserAccountOrThrow().subAccountId);
|
|
134
|
+
}
|
|
135
|
+
getSubaccountStatus(user) {
|
|
136
|
+
const userAccount = user.getUserAccountOrThrow();
|
|
137
|
+
const equity = user.getNetUsdValue();
|
|
138
|
+
const bufferedFloor = userAccount.equityFloor.add(userAccount.equityFloorBuffer);
|
|
139
|
+
return {
|
|
140
|
+
subAccountId: userAccount.subAccountId,
|
|
141
|
+
equity,
|
|
142
|
+
equityFloor: userAccount.equityFloor,
|
|
143
|
+
equityFloorBuffer: userAccount.equityFloorBuffer,
|
|
144
|
+
bufferedFloor,
|
|
145
|
+
headroom: equity.sub(userAccount.equityFloor),
|
|
146
|
+
bufferedHeadroom: equity.sub(bufferedFloor),
|
|
147
|
+
level: (0, margin_1.getEquityFloorLevel)(equity, userAccount.equityFloor, userAccount.equityFloorBuffer),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Full authority-wide standing: aggregates, worst level, per-subaccount detail. */
|
|
151
|
+
getStatus() {
|
|
152
|
+
var _a, _b, _c;
|
|
153
|
+
const subaccounts = this.getManagedUsers().map((user) => this.getSubaccountStatus(user));
|
|
154
|
+
const totalEquity = subaccounts.reduce((s, u) => s.add(u.equity), numericConstants_1.ZERO);
|
|
155
|
+
const totalFloor = subaccounts.reduce((s, u) => s.add(u.equityFloor), numericConstants_1.ZERO);
|
|
156
|
+
const totalBuffer = subaccounts.reduce((s, u) => s.add(u.equityFloorBuffer), numericConstants_1.ZERO);
|
|
157
|
+
const level = subaccounts.reduce((worst, u) => LEVEL_SEVERITY[u.level] > LEVEL_SEVERITY[worst] ? u.level : worst, 'disabled');
|
|
158
|
+
return {
|
|
159
|
+
authority: this.velocityClient.authority,
|
|
160
|
+
breakerTripped: ((_c = (_b = (_a = this.velocityClient.getUserStats()) === null || _a === void 0 ? void 0 : _a.getAccount()) === null || _b === void 0 ? void 0 : _b.equityBreakerTripped) !== null && _c !== void 0 ? _c : 0) !== 0,
|
|
161
|
+
totalEquity,
|
|
162
|
+
totalFloor,
|
|
163
|
+
totalBuffer,
|
|
164
|
+
totalBufferedHeadroom: totalEquity.sub(totalFloor).sub(totalBuffer),
|
|
165
|
+
level,
|
|
166
|
+
subaccounts,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The most quote that can leave `subAccountId` to the outside (a
|
|
171
|
+
* withdrawal, which cannot move floor): equity above the buffered floor,
|
|
172
|
+
* less the haircut. Floor constraint only — the withdrawal itself is still
|
|
173
|
+
* subject to margin and borrow limits.
|
|
174
|
+
*/
|
|
175
|
+
getMaxWithdrawable(subAccountId) {
|
|
176
|
+
const status = this.getSubaccountStatus(this.velocityClient.getUser(subAccountId, this.velocityClient.authority));
|
|
177
|
+
if (status.equityFloor.lte(numericConstants_1.ZERO)) {
|
|
178
|
+
return status.equity;
|
|
179
|
+
}
|
|
180
|
+
return anchor_1.BN.max(status.bufferedHeadroom.sub(this.collateralHaircut), numericConstants_1.ZERO);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The most quote that can move from one subaccount to another when the
|
|
184
|
+
* transfer carries floor with it. Because floor travels with the funds
|
|
185
|
+
* (capped at the floor the debited side holds, after which its check
|
|
186
|
+
* disables entirely), this is normally the debited side's whole equity —
|
|
187
|
+
* bounded by what the credited side's equity can back. Floor constraint
|
|
188
|
+
* only; margin and borrow limits still apply on top.
|
|
189
|
+
*/
|
|
190
|
+
getMaxQuoteTransferable(fromSubAccountId, toSubAccountId) {
|
|
191
|
+
const from = this.getSubaccountStatus(this.velocityClient.getUser(fromSubAccountId, this.velocityClient.authority));
|
|
192
|
+
const to = this.getSubaccountStatus(this.velocityClient.getUser(toSubAccountId, this.velocityClient.authority));
|
|
193
|
+
const haircut = this.collateralHaircut;
|
|
194
|
+
// how much floor the credited side can absorb beyond what the incoming
|
|
195
|
+
// funds themselves back: its own buffered headroom (delta <= amount
|
|
196
|
+
// keeps it backed; beyond that it eats into existing headroom)
|
|
197
|
+
const toSlack = anchor_1.BN.max(to.bufferedHeadroom.sub(haircut), numericConstants_1.ZERO);
|
|
198
|
+
if (from.equityFloor.lte(numericConstants_1.ZERO)) {
|
|
199
|
+
return anchor_1.BN.max(from.equity.sub(haircut), numericConstants_1.ZERO);
|
|
200
|
+
}
|
|
201
|
+
// shedding the entire floor disables the debited side's check; possible
|
|
202
|
+
// only if the credited side can absorb floor faster than the funds back
|
|
203
|
+
// it, i.e. it has slack of its own
|
|
204
|
+
const fullShedViable = from.equity
|
|
205
|
+
.sub(from.bufferedFloor)
|
|
206
|
+
.add(from.equityFloor)
|
|
207
|
+
.add(toSlack);
|
|
208
|
+
// without full shed: amount <= excess + floor (auto delta caps at floor)
|
|
209
|
+
const partialShedMax = anchor_1.BN.max(from.bufferedHeadroom, numericConstants_1.ZERO).add(from.equityFloor);
|
|
210
|
+
const floorwiseMax = anchor_1.BN.min(anchor_1.BN.max(fullShedViable, partialShedMax), from.equity);
|
|
211
|
+
return anchor_1.BN.max(floorwiseMax.sub(haircut), numericConstants_1.ZERO);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Resolves a quote transfer into the exact instruction parameters,
|
|
215
|
+
* padding the auto floor delta by the haircut so onchain pricing dust
|
|
216
|
+
* cannot fail it. The padded delta never exceeds the amount or the
|
|
217
|
+
* debited side's floor, so the credited side stays backed whenever it was
|
|
218
|
+
* before.
|
|
219
|
+
*/
|
|
220
|
+
planQuoteTransfer(amount, fromSubAccountId, toSubAccountId) {
|
|
221
|
+
const fromUser = this.velocityClient.getUser(fromSubAccountId, this.velocityClient.authority);
|
|
222
|
+
const fromAccount = fromUser.getUserAccountOrThrow();
|
|
223
|
+
const equityFloorDelta = (0, margin_1.calculateEquityFloorAutoDelta)(amount, fromUser.getNetUsdValue().sub(this.collateralHaircut), fromAccount.equityFloor, fromAccount.equityFloorBuffer);
|
|
224
|
+
return {
|
|
225
|
+
amount,
|
|
226
|
+
marketIndex: numericConstants_2.QUOTE_SPOT_MARKET_INDEX,
|
|
227
|
+
fromSubAccountId,
|
|
228
|
+
toSubAccountId,
|
|
229
|
+
equityFloorDelta: anchor_1.BN.min(equityFloorDelta, amount),
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/** Plans and submits a quote transfer between two subaccounts in one call. */
|
|
233
|
+
async transferQuote(amount, fromSubAccountId, toSubAccountId, txParams) {
|
|
234
|
+
const plan = this.planQuoteTransfer(amount, fromSubAccountId, toSubAccountId);
|
|
235
|
+
return this.velocityClient.transferDepositByDelegate(plan.amount, plan.marketIndex, plan.fromSubAccountId, plan.toSubAccountId, plan.equityFloorDelta, txParams);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Plans the floor-only moves (zero-amount transfers) that re-split the
|
|
239
|
+
* total floor proportionally to where the equity currently sits, so every
|
|
240
|
+
* subaccount ends with the same relative headroom. Breached subaccounts
|
|
241
|
+
* (below their raw floor) cannot shed floor on-chain, so their floor is
|
|
242
|
+
* pinned in place and the rest is allocated around them. Throws when the
|
|
243
|
+
* pool's equity cannot back the total floor plus buffers — at that point
|
|
244
|
+
* no split works and equity must be deposited (or the admin must lower
|
|
245
|
+
* the floor). Each onchain move also carries a proportional share of the
|
|
246
|
+
* debited side's buffer, so buffers drift toward the same split as the
|
|
247
|
+
* floors; the plan sizes against current buffers and the haircut absorbs
|
|
248
|
+
* the drift dust, but a move can still revert if a credited side cannot
|
|
249
|
+
* back the buffer share it receives.
|
|
250
|
+
*/
|
|
251
|
+
planFloorRebalance() {
|
|
252
|
+
const subaccounts = this.getManagedUsers().map((user) => this.getSubaccountStatus(user));
|
|
253
|
+
if (subaccounts.length < 2) {
|
|
254
|
+
return [];
|
|
255
|
+
}
|
|
256
|
+
const totalFloor = subaccounts.reduce((sum, u) => sum.add(u.equityFloor), numericConstants_1.ZERO);
|
|
257
|
+
if (totalFloor.lte(numericConstants_1.ZERO)) {
|
|
258
|
+
return [];
|
|
259
|
+
}
|
|
260
|
+
const pinned = subaccounts.map((u) => u.level === 'breached');
|
|
261
|
+
const targets = allocateEquityFloors(totalFloor, subaccounts.map((u) => ({
|
|
262
|
+
equity: anchor_1.BN.max(u.equity.sub(this.collateralHaircut), numericConstants_1.ZERO),
|
|
263
|
+
buffer: u.equityFloorBuffer,
|
|
264
|
+
currentFloor: u.equityFloor,
|
|
265
|
+
})), pinned);
|
|
266
|
+
if (targets === null) {
|
|
267
|
+
throw new Error('no backed floor split exists: total equity cannot cover the total floor plus buffers; deposit equity or have the admin lower the floor');
|
|
268
|
+
}
|
|
269
|
+
return planFloorMoves(subaccounts.map((u) => u.subAccountId), subaccounts.map((u) => u.equityFloor), targets);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Executes `planFloorRebalance` serially. Safe to run at any time; a
|
|
273
|
+
* no-op when the split already matches the equity distribution.
|
|
274
|
+
*/
|
|
275
|
+
async rebalanceFloors(txParams) {
|
|
276
|
+
const sigs = [];
|
|
277
|
+
for (const move of this.planFloorRebalance()) {
|
|
278
|
+
sigs.push(await this.velocityClient.transferDepositByDelegate(numericConstants_1.ZERO, numericConstants_2.QUOTE_SPOT_MARKET_INDEX, move.fromSubAccountId, move.toSubAccountId, move.equityFloorDelta, txParams));
|
|
279
|
+
}
|
|
280
|
+
return sigs;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
exports.EquityFloorManager = EquityFloorManager;
|
|
@@ -12466,6 +12466,10 @@ export type Velocity = {
|
|
|
12466
12466
|
{
|
|
12467
12467
|
"name": "equityFloor";
|
|
12468
12468
|
"type": "u64";
|
|
12469
|
+
},
|
|
12470
|
+
{
|
|
12471
|
+
"name": "equityFloorBuffer";
|
|
12472
|
+
"type": "u64";
|
|
12469
12473
|
}
|
|
12470
12474
|
];
|
|
12471
12475
|
},
|
|
@@ -12887,6 +12891,63 @@ export type Velocity = {
|
|
|
12887
12891
|
];
|
|
12888
12892
|
"args": [];
|
|
12889
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
|
+
},
|
|
12890
12951
|
{
|
|
12891
12952
|
"name": "updateWarmAdmin";
|
|
12892
12953
|
"discriminator": [
|
|
@@ -16299,6 +16360,16 @@ export type Velocity = {
|
|
|
16299
16360
|
"code": 6364;
|
|
16300
16361
|
"name": "dailyDepositLimit";
|
|
16301
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";
|
|
16302
16373
|
}
|
|
16303
16374
|
];
|
|
16304
16375
|
"types": [
|
|
@@ -24065,21 +24136,25 @@ export type Velocity = {
|
|
|
24065
24136
|
{
|
|
24066
24137
|
"name": "equityFloor";
|
|
24067
24138
|
"docs": [
|
|
24068
|
-
"Minimum account equity (
|
|
24069
|
-
"
|
|
24070
|
-
"
|
|
24139
|
+
"Minimum account net equity (unweighted assets plus perp pnl minus",
|
|
24140
|
+
"spot liabilities, see `calculate_user_equity`). Below this the",
|
|
24141
|
+
"permissionless breaker can trip. Risk-increasing orders, fills,",
|
|
24142
|
+
"withdrawals and deposit transfers must clear `equity_floor +",
|
|
24143
|
+
"equity_floor_buffer`. Settable only by the warm/cold admin; 0 disables",
|
|
24144
|
+
"both checks.",
|
|
24071
24145
|
"precision: QUOTE_PRECISION"
|
|
24072
24146
|
];
|
|
24073
24147
|
"type": "u64";
|
|
24074
24148
|
},
|
|
24075
24149
|
{
|
|
24076
|
-
"name": "
|
|
24077
|
-
"
|
|
24078
|
-
"
|
|
24079
|
-
|
|
24080
|
-
|
|
24081
|
-
|
|
24082
|
-
|
|
24150
|
+
"name": "equityFloorBuffer";
|
|
24151
|
+
"docs": [
|
|
24152
|
+
"Extra headroom above `equity_floor` required by risk-increasing",
|
|
24153
|
+
"actions, so an account cannot legally end an action at the trip",
|
|
24154
|
+
"threshold. No effect while `equity_floor` is 0.",
|
|
24155
|
+
"precision: QUOTE_PRECISION"
|
|
24156
|
+
];
|
|
24157
|
+
"type": "u64";
|
|
24083
24158
|
}
|
|
24084
24159
|
];
|
|
24085
24160
|
};
|