@haven-fi/solauto-sdk 1.0.74 → 1.0.76

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,7 @@ interface AssetProps {
19
19
  amountUsed?: number;
20
20
  }
21
21
  export declare function createFakePositionState(supply: AssetProps, debt: AssetProps, maxLtvBps: number, liqThresholdBps: number): PositionState;
22
+ export declare function createSolautoSettings(settings: SolautoSettingsParametersInpArgs): SolautoSettingsParameters;
22
23
  type PositionAdjustment = {
23
24
  type: "supply";
24
25
  value: bigint;
@@ -1 +1 @@
1
- {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAA+B,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAElB,aAAa,EAEb,yBAAyB,EACzB,gCAAgC,EAIjC,MAAM,iBAAiB,CAAC;AAezB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAgB9E,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,kBAAkB,GAC7B,MAAM,CAKR;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,kBAAkB,EAC9B,eAAe,EAAE,MAAM,GACtB,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,kBAAkB,EAC9B,oBAAoB,EAAE,MAAM,UAY7B;AAED,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,yBAAyB,EACnC,eAAe,EAAE,MAAM,GACtB,yBAAyB,CAgB3B;AAED,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,yBAAyB,EAC3C,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,eAAe,EAAE,MAAM,GACtB,eAAe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,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,gCAAgC,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE/C,qBAAa,mBAAmB;IACvB,gBAAgB,EAAE,MAAM,CAAa;IACrC,cAAc,EAAE,MAAM,CAAa;IACnC,uBAAuB,EAAE,MAAM,CAAa;IAC5C,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAa;IAC5D,SAAS,EAAE,WAAW,GAAG,SAAS,CAAa;IAEtD,GAAG,CAAC,MAAM,EAAE,kBAAkB;IA0B9B,KAAK;IAQL,UAAU,IAAI,OAAO;CAQtB"}
@@ -13,6 +13,7 @@ exports.getReferralsByUser = getReferralsByUser;
13
13
  exports.getAllPositionsByAuthority = getAllPositionsByAuthority;
14
14
  exports.positionStateWithLatestPrices = positionStateWithLatestPrices;
15
15
  exports.createFakePositionState = createFakePositionState;
16
+ exports.createSolautoSettings = createSolautoSettings;
16
17
  const web3_js_1 = require("@solana/web3.js");
17
18
  const umi_1 = require("@metaplex-foundation/umi");
18
19
  const generated_1 = require("../../generated");
@@ -291,6 +292,36 @@ function createFakePositionState(supply, debt, maxLtvBps, liqThresholdBps) {
291
292
  padding: [],
292
293
  };
293
294
  }
295
+ function createSolautoSettings(settings) {
296
+ return {
297
+ automation: (0, umi_1.isOption)(settings.automation) && (0, umi_1.isSome)(settings.automation)
298
+ ? {
299
+ ...settings.automation.value,
300
+ intervalSeconds: BigInt(settings.automation.value.intervalSeconds),
301
+ unixStartDate: BigInt(settings.automation.value.unixStartDate),
302
+ padding: new Uint8Array([]),
303
+ padding1: [],
304
+ }
305
+ : {
306
+ targetPeriods: 0,
307
+ periodsPassed: 0,
308
+ intervalSeconds: BigInt(0),
309
+ unixStartDate: BigInt(0),
310
+ padding: new Uint8Array([]),
311
+ padding1: [],
312
+ },
313
+ targetBoostToBps: (0, umi_1.isOption)(settings.targetBoostToBps) &&
314
+ (0, umi_1.isSome)(settings.targetBoostToBps)
315
+ ? settings.targetBoostToBps.value
316
+ : 0,
317
+ boostGap: settings.boostGap,
318
+ boostToBps: settings.boostToBps,
319
+ repayGap: settings.repayGap,
320
+ repayToBps: settings.repayToBps,
321
+ padding: new Uint8Array([]),
322
+ padding1: [],
323
+ };
324
+ }
294
325
  class LivePositionUpdates {
295
326
  constructor() {
296
327
  this.supplyAdjustment = BigInt(0);
@@ -311,34 +342,7 @@ class LivePositionUpdates {
311
342
  }
312
343
  else if (update.type === "settings") {
313
344
  const settings = update.value;
314
- this.settings = {
315
- automation: (0, umi_1.isOption)(settings.automation) && (0, umi_1.isSome)(settings.automation)
316
- ? {
317
- ...settings.automation.value,
318
- intervalSeconds: BigInt(settings.automation.value.intervalSeconds),
319
- unixStartDate: BigInt(settings.automation.value.unixStartDate),
320
- padding: new Uint8Array([]),
321
- padding1: [],
322
- }
323
- : {
324
- targetPeriods: 0,
325
- periodsPassed: 0,
326
- intervalSeconds: BigInt(0),
327
- unixStartDate: BigInt(0),
328
- padding: new Uint8Array([]),
329
- padding1: [],
330
- },
331
- targetBoostToBps: (0, umi_1.isOption)(settings.targetBoostToBps) &&
332
- (0, umi_1.isSome)(settings.targetBoostToBps)
333
- ? settings.targetBoostToBps.value
334
- : 0,
335
- boostGap: settings.boostGap,
336
- boostToBps: settings.boostToBps,
337
- repayGap: settings.repayGap,
338
- repayToBps: settings.repayToBps,
339
- padding: new Uint8Array([]),
340
- padding1: [],
341
- };
345
+ this.settings = createSolautoSettings(settings);
342
346
  }
343
347
  else if (update.type === "dca") {
344
348
  const dca = update.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.74",
3
+ "version": "1.0.76",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -429,6 +429,41 @@ export function createFakePositionState(
429
429
  };
430
430
  }
431
431
 
432
+ export function createSolautoSettings(settings: SolautoSettingsParametersInpArgs): SolautoSettingsParameters {
433
+ return {
434
+ automation:
435
+ isOption(settings.automation) && isSome(settings.automation)
436
+ ? {
437
+ ...settings.automation.value,
438
+ intervalSeconds: BigInt(
439
+ settings.automation.value.intervalSeconds
440
+ ),
441
+ unixStartDate: BigInt(settings.automation.value.unixStartDate),
442
+ padding: new Uint8Array([]),
443
+ padding1: [],
444
+ }
445
+ : {
446
+ targetPeriods: 0,
447
+ periodsPassed: 0,
448
+ intervalSeconds: BigInt(0),
449
+ unixStartDate: BigInt(0),
450
+ padding: new Uint8Array([]),
451
+ padding1: [],
452
+ },
453
+ targetBoostToBps:
454
+ isOption(settings.targetBoostToBps) &&
455
+ isSome(settings.targetBoostToBps)
456
+ ? settings.targetBoostToBps.value
457
+ : 0,
458
+ boostGap: settings.boostGap,
459
+ boostToBps: settings.boostToBps,
460
+ repayGap: settings.repayGap,
461
+ repayToBps: settings.repayToBps,
462
+ padding: new Uint8Array([]),
463
+ padding1: [],
464
+ };
465
+ }
466
+
432
467
  type PositionAdjustment =
433
468
  | { type: "supply"; value: bigint }
434
469
  | { type: "debt"; value: bigint }
@@ -452,38 +487,7 @@ export class LivePositionUpdates {
452
487
  this.debtTaBalanceAdjustment += update.value;
453
488
  } else if (update.type === "settings") {
454
489
  const settings = update.value;
455
- this.settings = {
456
- automation:
457
- isOption(settings.automation) && isSome(settings.automation)
458
- ? {
459
- ...settings.automation.value,
460
- intervalSeconds: BigInt(
461
- settings.automation.value.intervalSeconds
462
- ),
463
- unixStartDate: BigInt(settings.automation.value.unixStartDate),
464
- padding: new Uint8Array([]),
465
- padding1: [],
466
- }
467
- : {
468
- targetPeriods: 0,
469
- periodsPassed: 0,
470
- intervalSeconds: BigInt(0),
471
- unixStartDate: BigInt(0),
472
- padding: new Uint8Array([]),
473
- padding1: [],
474
- },
475
- targetBoostToBps:
476
- isOption(settings.targetBoostToBps) &&
477
- isSome(settings.targetBoostToBps)
478
- ? settings.targetBoostToBps.value
479
- : 0,
480
- boostGap: settings.boostGap,
481
- boostToBps: settings.boostToBps,
482
- repayGap: settings.repayGap,
483
- repayToBps: settings.repayToBps,
484
- padding: new Uint8Array([]),
485
- padding1: [],
486
- };
490
+ this.settings = createSolautoSettings(settings);
487
491
  } else if (update.type === "dca") {
488
492
  const dca = update.value;
489
493
  this.activeDca = {