@symmetry-hq/sdk 1.0.19 → 1.0.20
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/dist/instructions/management/edit.js +15 -4
- package/package.json +1 -1
- package/src/instructions/management/edit.ts +15 -4
- package/test.ts +25 -12
|
@@ -356,14 +356,25 @@ function createEditVaultIntentIx(params) {
|
|
|
356
356
|
break;
|
|
357
357
|
case intent_1.TaskType.UpdateWeights: { // 15 - 202
|
|
358
358
|
const updateWeightsData = editData;
|
|
359
|
-
const weights = updateWeightsData.token_weights
|
|
360
|
-
while (weights.length < constants_1.MAX_SUPPORTED_TOKENS_PER_VAULT)
|
|
361
|
-
weights.push({ mint: '', weight_bps: 0 });
|
|
359
|
+
const weights = updateWeightsData.token_weights;
|
|
362
360
|
let tokenMintsHash = (_e = updateWeightsData.token_mints_hash) !== null && _e !== void 0 ? _e : (0, basket_1.computeTokenMintsHash)(vault.composition.slice(0, vault.numTokens)
|
|
363
361
|
.filter((asset) => asset.active === 1)
|
|
364
362
|
.map((asset) => asset.mint.toBase58()));
|
|
363
|
+
let tokenWeights = [];
|
|
364
|
+
for (let i = 0; i < constants_1.MAX_SUPPORTED_TOKENS_PER_VAULT; i++) {
|
|
365
|
+
if (i >= vault.numTokens || vault.composition[i].active === 0) {
|
|
366
|
+
tokenWeights.push(0);
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
let mint = vault.composition[i].mint.toBase58();
|
|
370
|
+
let weight = 0;
|
|
371
|
+
for (let j = 0; j < weights.length; j++)
|
|
372
|
+
if (weights[j].mint === mint)
|
|
373
|
+
weight = weights[j].weight_bps;
|
|
374
|
+
tokenWeights.push(weight);
|
|
375
|
+
}
|
|
365
376
|
let updateWeights = {
|
|
366
|
-
tokenWeights:
|
|
377
|
+
tokenWeights: tokenWeights,
|
|
367
378
|
tokenMintsHash: tokenMintsHash,
|
|
368
379
|
};
|
|
369
380
|
config_1.UpdateWeightsLayout.encode(updateWeights, editDataBuf);
|
package/package.json
CHANGED
|
@@ -442,16 +442,27 @@ export function createEditVaultIntentIx(params: {
|
|
|
442
442
|
|
|
443
443
|
case TaskType.UpdateWeights: { // 15 - 202
|
|
444
444
|
const updateWeightsData = (editData as UpdateWeightsInput);
|
|
445
|
-
const weights = updateWeightsData.token_weights
|
|
446
|
-
while (weights.length < MAX_SUPPORTED_TOKENS_PER_VAULT) weights.push({ mint: '', weight_bps: 0 });
|
|
447
|
-
|
|
445
|
+
const weights = updateWeightsData.token_weights;
|
|
448
446
|
let tokenMintsHash = updateWeightsData.token_mints_hash ?? computeTokenMintsHash(
|
|
449
447
|
vault.composition.slice(0, vault.numTokens)
|
|
450
448
|
.filter((asset) => asset.active === 1)
|
|
451
449
|
.map((asset) => asset.mint.toBase58())
|
|
452
450
|
);
|
|
451
|
+
let tokenWeights = [];
|
|
452
|
+
for (let i = 0; i < MAX_SUPPORTED_TOKENS_PER_VAULT; i++) {
|
|
453
|
+
if (i >= vault.numTokens || vault.composition[i].active === 0) {
|
|
454
|
+
tokenWeights.push(0);
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
let mint = vault.composition[i].mint.toBase58();
|
|
458
|
+
let weight = 0;
|
|
459
|
+
for (let j = 0; j < weights.length; j++)
|
|
460
|
+
if (weights[j].mint === mint)
|
|
461
|
+
weight = weights[j].weight_bps;
|
|
462
|
+
tokenWeights.push(weight);
|
|
463
|
+
}
|
|
453
464
|
let updateWeights: UpdateWeights = {
|
|
454
|
-
tokenWeights:
|
|
465
|
+
tokenWeights: tokenWeights,
|
|
455
466
|
tokenMintsHash: tokenMintsHash,
|
|
456
467
|
}
|
|
457
468
|
UpdateWeightsLayout.encode(updateWeights, editDataBuf);
|
package/test.ts
CHANGED
|
@@ -322,7 +322,7 @@ async function testStates() {
|
|
|
322
322
|
|
|
323
323
|
if (tests.addOrEditToken) {
|
|
324
324
|
let add_token: AddOrEditTokenInput = {
|
|
325
|
-
token_mint: "
|
|
325
|
+
token_mint: "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn",
|
|
326
326
|
active: true,
|
|
327
327
|
min_oracles_thresh: 1,
|
|
328
328
|
min_conf_bps: 50,
|
|
@@ -330,14 +330,14 @@ async function testStates() {
|
|
|
330
330
|
conf_multiplier: 1,
|
|
331
331
|
oracles: [
|
|
332
332
|
{
|
|
333
|
-
oracle_type: "
|
|
333
|
+
oracle_type: "lst",
|
|
334
334
|
account_lut_id: 0,
|
|
335
335
|
account_lut_index: 0,
|
|
336
|
-
account: "
|
|
336
|
+
account: "Jito4APyf642JPZPx3hGc6WWJ8zPKtRbRs4P815Awbb",
|
|
337
337
|
weight_bps: 5000,
|
|
338
338
|
is_required: false,
|
|
339
|
-
conf_thresh_bps:
|
|
340
|
-
volatility_thresh_bps:
|
|
339
|
+
conf_thresh_bps: 100,
|
|
340
|
+
volatility_thresh_bps: 100,
|
|
341
341
|
max_slippage_bps: 100,
|
|
342
342
|
min_liquidity: 0,
|
|
343
343
|
staleness_thresh: 120,
|
|
@@ -348,10 +348,10 @@ async function testStates() {
|
|
|
348
348
|
quote_token: "wsol",
|
|
349
349
|
},
|
|
350
350
|
{
|
|
351
|
-
oracle_type: "
|
|
351
|
+
oracle_type: "pyth",
|
|
352
352
|
account_lut_id: 0,
|
|
353
353
|
account_lut_index: 0,
|
|
354
|
-
account: "
|
|
354
|
+
account: "AxaxyeDT8JnWERSaTKvFXvPKkEdxnamKSqpWbsSjYg1g",
|
|
355
355
|
weight_bps: 5000,
|
|
356
356
|
is_required: false,
|
|
357
357
|
conf_thresh_bps: 200,
|
|
@@ -363,7 +363,7 @@ async function testStates() {
|
|
|
363
363
|
token_decimals: 9,
|
|
364
364
|
twap_seconds_ago: 50,
|
|
365
365
|
twap_secondary_seconds_ago: 100,
|
|
366
|
-
quote_token: "
|
|
366
|
+
quote_token: "usd",
|
|
367
367
|
},
|
|
368
368
|
],
|
|
369
369
|
};
|
|
@@ -377,11 +377,24 @@ async function testStates() {
|
|
|
377
377
|
token_weights: [
|
|
378
378
|
{
|
|
379
379
|
mint: "So11111111111111111111111111111111111111112",
|
|
380
|
-
weight_bps:
|
|
380
|
+
weight_bps: 2000,
|
|
381
381
|
},
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
382
|
+
{
|
|
383
|
+
mint: "cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij",
|
|
384
|
+
weight_bps: 2500,
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
mint: "XsoCS1TfEyfFhfvj8EtZ528L3CaKBDBRqRapnBbDF2W",
|
|
388
|
+
weight_bps: 2500,
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
392
|
+
weight_bps: 1000,
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
mint: "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn",
|
|
396
|
+
weight_bps: 2000,
|
|
397
|
+
}
|
|
385
398
|
],
|
|
386
399
|
};
|
|
387
400
|
let tx = await sdk.updateWeightsTx(task_context, update_weights);
|