@haven-fi/solauto-sdk 1.0.133 → 1.0.135

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/dist/clients/solautoClient.d.ts.map +1 -1
  2. package/dist/clients/solautoClient.js +49 -39
  3. package/dist/generated/accounts/solautoPosition.d.ts +1 -7
  4. package/dist/generated/accounts/solautoPosition.d.ts.map +1 -1
  5. package/dist/generated/accounts/solautoPosition.js +2 -6
  6. package/dist/generated/instructions/cancelDCA.d.ts +3 -3
  7. package/dist/generated/instructions/cancelDCA.d.ts.map +1 -1
  8. package/dist/generated/instructions/cancelDCA.js +6 -6
  9. package/dist/generated/instructions/closePosition.d.ts +1 -2
  10. package/dist/generated/instructions/closePosition.d.ts.map +1 -1
  11. package/dist/generated/instructions/closePosition.js +6 -11
  12. package/dist/generated/instructions/updatePosition.d.ts +3 -3
  13. package/dist/generated/instructions/updatePosition.d.ts.map +1 -1
  14. package/dist/generated/instructions/updatePosition.js +6 -6
  15. package/dist/generated/types/dCASettings.d.ts +7 -5
  16. package/dist/generated/types/dCASettings.d.ts.map +1 -1
  17. package/dist/generated/types/dCASettings.js +3 -2
  18. package/dist/generated/types/dCASettingsInp.d.ts +5 -3
  19. package/dist/generated/types/dCASettingsInp.d.ts.map +1 -1
  20. package/dist/generated/types/dCASettingsInp.js +2 -1
  21. package/dist/generated/types/index.d.ts +1 -1
  22. package/dist/generated/types/index.d.ts.map +1 -1
  23. package/dist/generated/types/index.js +1 -1
  24. package/dist/generated/types/{feeType.d.ts → tokenType.d.ts} +6 -6
  25. package/dist/generated/types/tokenType.d.ts.map +1 -0
  26. package/dist/generated/types/tokenType.js +22 -0
  27. package/dist/transactions/transactionUtils.d.ts.map +1 -1
  28. package/dist/transactions/transactionUtils.js +15 -15
  29. package/dist/utils/marginfiUtils.d.ts.map +1 -1
  30. package/dist/utils/solauto/generalUtils.d.ts +15 -5
  31. package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
  32. package/dist/utils/solauto/generalUtils.js +54 -37
  33. package/dist/utils/solauto/rebalanceUtils.d.ts +2 -1
  34. package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
  35. package/dist/utils/solauto/rebalanceUtils.js +7 -5
  36. package/package.json +1 -1
  37. package/src/clients/solautoClient.ts +50 -45
  38. package/src/generated/accounts/solautoPosition.ts +2 -15
  39. package/src/generated/instructions/cancelDCA.ts +9 -9
  40. package/src/generated/instructions/closePosition.ts +7 -13
  41. package/src/generated/instructions/updatePosition.ts +9 -9
  42. package/src/generated/types/dCASettings.ts +14 -7
  43. package/src/generated/types/dCASettingsInp.ts +9 -3
  44. package/src/generated/types/index.ts +1 -1
  45. package/src/generated/types/{feeType.ts → tokenType.ts} +8 -9
  46. package/src/transactions/transactionUtils.ts +35 -25
  47. package/src/utils/marginfiUtils.ts +2 -2
  48. package/src/utils/solauto/generalUtils.ts +75 -59
  49. package/src/utils/solauto/rebalanceUtils.ts +9 -8
  50. package/tests/unit/rebalanceCalculations.ts +14 -14
  51. package/dist/generated/types/feeType.d.ts.map +0 -1
  52. package/dist/generated/types/feeType.js +0 -20
@@ -9,10 +9,10 @@ import { publicKey } from "@metaplex-foundation/umi";
9
9
  import { SolautoClient } from "../../src/clients/solautoClient";
10
10
  import {
11
11
  DCASettings,
12
- FeeType,
13
12
  LendingPlatform,
14
13
  SolautoRebalanceType,
15
14
  SolautoSettingsParameters,
15
+ TokenType,
16
16
  } from "../../src/generated";
17
17
  import {
18
18
  fromBaseUnit,
@@ -35,7 +35,6 @@ import {
35
35
  safeGetPrice,
36
36
  } from "../../src/utils/generalUtils";
37
37
  import { USDC_MINT } from "../../src/constants/tokenConstants";
38
- import { PRICES } from "../../src/constants";
39
38
 
40
39
  const signer = setupTest(undefined, true);
41
40
 
@@ -159,8 +158,9 @@ async function getFakePosition(
159
158
  padding1: [],
160
159
  padding: new Uint8Array([]),
161
160
  },
162
- debtToAddBaseUnit: BigInt(0),
163
- padding: new Uint8Array([]),
161
+ dcaInBaseUnit: BigInt(0),
162
+ tokenType: TokenType.Debt,
163
+ padding: [],
164
164
  },
165
165
  lendingPlatform: LendingPlatform.Marginfi,
166
166
  supplyMint: publicKey(client.supplyMint),
@@ -180,9 +180,7 @@ async function getFakePosition(
180
180
  padding2: [],
181
181
  padding: new Uint8Array([]),
182
182
  },
183
- feeType: FeeType.Default,
184
183
  padding1: [],
185
- padding2: [],
186
184
  padding: [],
187
185
  publicKey: publicKey(PublicKey.default),
188
186
  header: {
@@ -246,18 +244,18 @@ async function dcaRebalanceFromFakePosition(
246
244
  currentUnixSeconds()
247
245
  );
248
246
  const expectedLiqUtilizationRateBps =
249
- dca.debtToAddBaseUnit > BigInt(0)
247
+ dca.dcaInBaseUnit > BigInt(0)
250
248
  ? Math.max(fakeLiqUtilizationRateBps, adjustedSettings.boostToBps)
251
249
  : adjustedSettings.boostToBps;
252
250
 
253
251
  const expectedDcaInAmount =
254
- dca.debtToAddBaseUnit > 0 &&
252
+ dca.dcaInBaseUnit > BigInt(0) &&
255
253
  eligibleForNextAutomationPeriod(dca.automation, currentUnixSeconds())
256
- ? dca.debtToAddBaseUnit -
254
+ ? dca.dcaInBaseUnit -
257
255
  BigInt(
258
256
  Math.round(
259
257
  getUpdatedValueFromAutomation(
260
- Number(dca.debtToAddBaseUnit),
258
+ Number(dca.dcaInBaseUnit),
261
259
  0,
262
260
  dca.automation,
263
261
  currentUnixSeconds()
@@ -390,8 +388,9 @@ describe("Rebalance tests", async () => {
390
388
  padding1: [],
391
389
  padding: new Uint8Array([]),
392
390
  },
393
- debtToAddBaseUnit: BigInt(0),
394
- padding: new Uint8Array([]),
391
+ dcaInBaseUnit: BigInt(0),
392
+ tokenType: TokenType.Debt,
393
+ padding: [],
395
394
  };
396
395
  await dcaRebalanceFromFakePosition(
397
396
  supplyPrice,
@@ -442,8 +441,9 @@ describe("Rebalance tests", async () => {
442
441
  padding1: [],
443
442
  padding: new Uint8Array([]),
444
443
  },
445
- debtToAddBaseUnit: toBaseUnit(debtPrice * 300, 6),
446
- padding: new Uint8Array([]),
444
+ dcaInBaseUnit: toBaseUnit(debtPrice * 300, 6),
445
+ tokenType: TokenType.Debt,
446
+ padding: [],
447
447
  };
448
448
  await dcaRebalanceFromFakePosition(
449
449
  supplyPrice,
@@ -1 +0,0 @@
1
- {"version":3,"file":"feeType.d.ts","sourceRoot":"","sources":["../../../src/generated/types/feeType.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,sCAAsC,CAAC;AAE9E,oBAAY,OAAO;IACjB,KAAK,IAAA;IACL,OAAO,IAAA;CACR;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;AAElC,wBAAgB,oBAAoB,IAAI,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC,CAKvE"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- /**
3
- * This code was AUTOGENERATED using the kinobi library.
4
- * Please DO NOT EDIT THIS FILE, instead use visitors
5
- * to add features, then rerun kinobi to update it.
6
- *
7
- * @see https://github.com/metaplex-foundation/kinobi
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.FeeType = void 0;
11
- exports.getFeeTypeSerializer = getFeeTypeSerializer;
12
- const serializers_1 = require("@metaplex-foundation/umi/serializers");
13
- var FeeType;
14
- (function (FeeType) {
15
- FeeType[FeeType["Small"] = 0] = "Small";
16
- FeeType[FeeType["Default"] = 1] = "Default";
17
- })(FeeType || (exports.FeeType = FeeType = {}));
18
- function getFeeTypeSerializer() {
19
- return (0, serializers_1.scalarEnum)(FeeType, { description: 'FeeType' });
20
- }