@haven-fi/solauto-sdk 1.0.75 → 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,S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E,MAAM,EACjB,eAAe,EAAE,MAAM,GACtB,aAAa,CA8Df;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,gCAAgC,GAAG,yBAAyB,CAiC3G;AAED,KAAK,kBAAkB,GACnB;IAAE,IAAI,EAAE,QAAQ,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");
|
@@ -198,15 +199,7 @@ async function getAllPositionsByAuthority(umi, user) {
|
|
198
199
|
debtMint: x.debtMint,
|
199
200
|
})));
|
200
201
|
// TODO support other platforms
|
201
|
-
return allPositions
|
202
|
-
if (a.positionId === 0 && b.positionId !== 0) {
|
203
|
-
return 1;
|
204
|
-
}
|
205
|
-
if (b.positionId === 0 && a.positionId !== 0) {
|
206
|
-
return -1;
|
207
|
-
}
|
208
|
-
return a.positionId - b.positionId;
|
209
|
-
});
|
202
|
+
return allPositions;
|
210
203
|
}
|
211
204
|
async function positionStateWithLatestPrices(state, supplyPrice, debtPrice) {
|
212
205
|
if (!supplyPrice || !debtPrice) {
|
@@ -299,6 +292,36 @@ function createFakePositionState(supply, debt, maxLtvBps, liqThresholdBps) {
|
|
299
292
|
padding: [],
|
300
293
|
};
|
301
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
|
+
}
|
302
325
|
class LivePositionUpdates {
|
303
326
|
constructor() {
|
304
327
|
this.supplyAdjustment = BigInt(0);
|
@@ -319,34 +342,7 @@ class LivePositionUpdates {
|
|
319
342
|
}
|
320
343
|
else if (update.type === "settings") {
|
321
344
|
const settings = update.value;
|
322
|
-
this.settings =
|
323
|
-
automation: (0, umi_1.isOption)(settings.automation) && (0, umi_1.isSome)(settings.automation)
|
324
|
-
? {
|
325
|
-
...settings.automation.value,
|
326
|
-
intervalSeconds: BigInt(settings.automation.value.intervalSeconds),
|
327
|
-
unixStartDate: BigInt(settings.automation.value.unixStartDate),
|
328
|
-
padding: new Uint8Array([]),
|
329
|
-
padding1: [],
|
330
|
-
}
|
331
|
-
: {
|
332
|
-
targetPeriods: 0,
|
333
|
-
periodsPassed: 0,
|
334
|
-
intervalSeconds: BigInt(0),
|
335
|
-
unixStartDate: BigInt(0),
|
336
|
-
padding: new Uint8Array([]),
|
337
|
-
padding1: [],
|
338
|
-
},
|
339
|
-
targetBoostToBps: (0, umi_1.isOption)(settings.targetBoostToBps) &&
|
340
|
-
(0, umi_1.isSome)(settings.targetBoostToBps)
|
341
|
-
? settings.targetBoostToBps.value
|
342
|
-
: 0,
|
343
|
-
boostGap: settings.boostGap,
|
344
|
-
boostToBps: settings.boostToBps,
|
345
|
-
repayGap: settings.repayGap,
|
346
|
-
repayToBps: settings.repayToBps,
|
347
|
-
padding: new Uint8Array([]),
|
348
|
-
padding1: [],
|
349
|
-
};
|
345
|
+
this.settings = createSolautoSettings(settings);
|
350
346
|
}
|
351
347
|
else if (update.type === "dca") {
|
352
348
|
const dca = update.value;
|
package/package.json
CHANGED
@@ -302,15 +302,7 @@ export async function getAllPositionsByAuthority(
|
|
302
302
|
|
303
303
|
// TODO support other platforms
|
304
304
|
|
305
|
-
return allPositions
|
306
|
-
if (a.positionId === 0 && b.positionId !== 0) {
|
307
|
-
return 1;
|
308
|
-
}
|
309
|
-
if (b.positionId === 0 && a.positionId !== 0) {
|
310
|
-
return -1;
|
311
|
-
}
|
312
|
-
return a.positionId - b.positionId;
|
313
|
-
});
|
305
|
+
return allPositions;
|
314
306
|
}
|
315
307
|
|
316
308
|
export async function positionStateWithLatestPrices(
|
@@ -437,6 +429,41 @@ export function createFakePositionState(
|
|
437
429
|
};
|
438
430
|
}
|
439
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
|
+
|
440
467
|
type PositionAdjustment =
|
441
468
|
| { type: "supply"; value: bigint }
|
442
469
|
| { type: "debt"; value: bigint }
|
@@ -460,38 +487,7 @@ export class LivePositionUpdates {
|
|
460
487
|
this.debtTaBalanceAdjustment += update.value;
|
461
488
|
} else if (update.type === "settings") {
|
462
489
|
const settings = update.value;
|
463
|
-
this.settings =
|
464
|
-
automation:
|
465
|
-
isOption(settings.automation) && isSome(settings.automation)
|
466
|
-
? {
|
467
|
-
...settings.automation.value,
|
468
|
-
intervalSeconds: BigInt(
|
469
|
-
settings.automation.value.intervalSeconds
|
470
|
-
),
|
471
|
-
unixStartDate: BigInt(settings.automation.value.unixStartDate),
|
472
|
-
padding: new Uint8Array([]),
|
473
|
-
padding1: [],
|
474
|
-
}
|
475
|
-
: {
|
476
|
-
targetPeriods: 0,
|
477
|
-
periodsPassed: 0,
|
478
|
-
intervalSeconds: BigInt(0),
|
479
|
-
unixStartDate: BigInt(0),
|
480
|
-
padding: new Uint8Array([]),
|
481
|
-
padding1: [],
|
482
|
-
},
|
483
|
-
targetBoostToBps:
|
484
|
-
isOption(settings.targetBoostToBps) &&
|
485
|
-
isSome(settings.targetBoostToBps)
|
486
|
-
? settings.targetBoostToBps.value
|
487
|
-
: 0,
|
488
|
-
boostGap: settings.boostGap,
|
489
|
-
boostToBps: settings.boostToBps,
|
490
|
-
repayGap: settings.repayGap,
|
491
|
-
repayToBps: settings.repayToBps,
|
492
|
-
padding: new Uint8Array([]),
|
493
|
-
padding1: [],
|
494
|
-
};
|
490
|
+
this.settings = createSolautoSettings(settings);
|
495
491
|
} else if (update.type === "dca") {
|
496
492
|
const dca = update.value;
|
497
493
|
this.activeDca = {
|