@haven-fi/solauto-sdk 1.0.133 → 1.0.135
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/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +49 -39
- package/dist/generated/accounts/solautoPosition.d.ts +1 -7
- package/dist/generated/accounts/solautoPosition.d.ts.map +1 -1
- package/dist/generated/accounts/solautoPosition.js +2 -6
- package/dist/generated/instructions/cancelDCA.d.ts +3 -3
- package/dist/generated/instructions/cancelDCA.d.ts.map +1 -1
- package/dist/generated/instructions/cancelDCA.js +6 -6
- package/dist/generated/instructions/closePosition.d.ts +1 -2
- package/dist/generated/instructions/closePosition.d.ts.map +1 -1
- package/dist/generated/instructions/closePosition.js +6 -11
- package/dist/generated/instructions/updatePosition.d.ts +3 -3
- package/dist/generated/instructions/updatePosition.d.ts.map +1 -1
- package/dist/generated/instructions/updatePosition.js +6 -6
- package/dist/generated/types/dCASettings.d.ts +7 -5
- package/dist/generated/types/dCASettings.d.ts.map +1 -1
- package/dist/generated/types/dCASettings.js +3 -2
- package/dist/generated/types/dCASettingsInp.d.ts +5 -3
- package/dist/generated/types/dCASettingsInp.d.ts.map +1 -1
- package/dist/generated/types/dCASettingsInp.js +2 -1
- package/dist/generated/types/index.d.ts +1 -1
- package/dist/generated/types/index.d.ts.map +1 -1
- package/dist/generated/types/index.js +1 -1
- package/dist/generated/types/{feeType.d.ts → tokenType.d.ts} +6 -6
- package/dist/generated/types/tokenType.d.ts.map +1 -0
- package/dist/generated/types/tokenType.js +22 -0
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +15 -15
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/solauto/generalUtils.d.ts +15 -5
- package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
- package/dist/utils/solauto/generalUtils.js +54 -37
- package/dist/utils/solauto/rebalanceUtils.d.ts +2 -1
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +7 -5
- package/package.json +1 -1
- package/src/clients/solautoClient.ts +50 -45
- package/src/generated/accounts/solautoPosition.ts +2 -15
- package/src/generated/instructions/cancelDCA.ts +9 -9
- package/src/generated/instructions/closePosition.ts +7 -13
- package/src/generated/instructions/updatePosition.ts +9 -9
- package/src/generated/types/dCASettings.ts +14 -7
- package/src/generated/types/dCASettingsInp.ts +9 -3
- package/src/generated/types/index.ts +1 -1
- package/src/generated/types/{feeType.ts → tokenType.ts} +8 -9
- package/src/transactions/transactionUtils.ts +35 -25
- package/src/utils/marginfiUtils.ts +2 -2
- package/src/utils/solauto/generalUtils.ts +75 -59
- package/src/utils/solauto/rebalanceUtils.ts +9 -8
- package/tests/unit/rebalanceCalculations.ts +14 -14
- package/dist/generated/types/feeType.d.ts.map +0 -1
- 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
|
-
|
|
163
|
-
|
|
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.
|
|
247
|
+
dca.dcaInBaseUnit > BigInt(0)
|
|
250
248
|
? Math.max(fakeLiqUtilizationRateBps, adjustedSettings.boostToBps)
|
|
251
249
|
: adjustedSettings.boostToBps;
|
|
252
250
|
|
|
253
251
|
const expectedDcaInAmount =
|
|
254
|
-
dca.
|
|
252
|
+
dca.dcaInBaseUnit > BigInt(0) &&
|
|
255
253
|
eligibleForNextAutomationPeriod(dca.automation, currentUnixSeconds())
|
|
256
|
-
? dca.
|
|
254
|
+
? dca.dcaInBaseUnit -
|
|
257
255
|
BigInt(
|
|
258
256
|
Math.round(
|
|
259
257
|
getUpdatedValueFromAutomation(
|
|
260
|
-
Number(dca.
|
|
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
|
-
|
|
394
|
-
|
|
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
|
-
|
|
446
|
-
|
|
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
|
-
}
|