@haven-fi/solauto-sdk 1.0.68 → 1.0.69
Sign up to get free protection for your applications and to get access to all the features.
- 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/types/index.d.ts +0 -1
- package/dist/generated/types/index.d.ts.map +1 -1
- package/dist/generated/types/index.js +0 -1
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +2 -2
- package/dist/utils/numberUtils.d.ts +7 -1
- package/dist/utils/numberUtils.d.ts.map +1 -1
- package/dist/utils/numberUtils.js +45 -9
- package/dist/utils/solauto/generalUtils.d.ts +2 -7
- package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
- package/dist/utils/solauto/generalUtils.js +4 -17
- package/dist/utils/solauto/rebalanceUtils.d.ts +2 -2
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +6 -6
- package/package.json +1 -1
- package/src/generated/accounts/solautoPosition.ts +2 -15
- package/src/generated/types/index.ts +0 -1
- package/src/transactions/transactionUtils.ts +2 -4
- package/src/utils/numberUtils.ts +70 -16
- package/src/utils/solauto/generalUtils.ts +4 -27
- package/src/utils/solauto/rebalanceUtils.ts +11 -8
- package/tests/unit/rebalanceCalculations.ts +27 -27
- package/dist/generated/types/feeType.d.ts +0 -15
- package/dist/generated/types/feeType.d.ts.map +0 -1
- package/dist/generated/types/feeType.js +0 -20
- package/src/generated/types/feeType.ts +0 -23
@@ -7,7 +7,7 @@
|
|
7
7
|
*/
|
8
8
|
import { Account, Context, Pda, PublicKey, RpcAccount, RpcGetAccountOptions, RpcGetAccountsOptions } from '@metaplex-foundation/umi';
|
9
9
|
import { Serializer } from '@metaplex-foundation/umi/serializers';
|
10
|
-
import {
|
10
|
+
import { PodBool, PodBoolArgs, PositionData, PositionDataArgs, PositionState, PositionStateArgs, RebalanceData, RebalanceDataArgs } from '../types';
|
11
11
|
export type SolautoPosition = Account<SolautoPositionAccountData>;
|
12
12
|
export type SolautoPositionAccountData = {
|
13
13
|
bump: Array<number>;
|
@@ -18,8 +18,6 @@ export type SolautoPositionAccountData = {
|
|
18
18
|
position: PositionData;
|
19
19
|
state: PositionState;
|
20
20
|
rebalance: RebalanceData;
|
21
|
-
feeType: FeeType;
|
22
|
-
padding2: Array<number>;
|
23
21
|
padding: Array<number>;
|
24
22
|
};
|
25
23
|
export type SolautoPositionAccountDataArgs = {
|
@@ -31,8 +29,6 @@ export type SolautoPositionAccountDataArgs = {
|
|
31
29
|
position: PositionDataArgs;
|
32
30
|
state: PositionStateArgs;
|
33
31
|
rebalance: RebalanceDataArgs;
|
34
|
-
feeType: FeeTypeArgs;
|
35
|
-
padding2: Array<number>;
|
36
32
|
padding: Array<number>;
|
37
33
|
};
|
38
34
|
export declare function getSolautoPositionAccountDataSerializer(): Serializer<SolautoPositionAccountDataArgs, SolautoPositionAccountData>;
|
@@ -50,8 +46,6 @@ export declare function getSolautoPositionGpaBuilder(context: Pick<Context, 'rpc
|
|
50
46
|
position: PositionDataArgs;
|
51
47
|
state: PositionStateArgs;
|
52
48
|
rebalance: RebalanceDataArgs;
|
53
|
-
feeType: FeeTypeArgs;
|
54
|
-
padding2: Array<number>;
|
55
49
|
padding: Array<number>;
|
56
50
|
}>;
|
57
51
|
export declare function getSolautoPositionSize(): number;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoPosition.d.ts","sourceRoot":"","sources":["../../../src/generated/accounts/solautoPosition.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,OAAO,EACP,GAAG,EACH,SAAS,EACT,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EAKtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EAMX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,OAAO,EACP,WAAW,EACX,
|
1
|
+
{"version":3,"file":"solaut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CAAC;GAe3B;AAED,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C"}
|
@@ -28,9 +28,7 @@ function getSolautoPositionAccountDataSerializer() {
|
|
28
28
|
['position', (0, types_1.getPositionDataSerializer)()],
|
29
29
|
['state', (0, types_1.getPositionStateSerializer)()],
|
30
30
|
['rebalance', (0, types_1.getRebalanceDataSerializer)()],
|
31
|
-
['
|
32
|
-
['padding2', (0, serializers_1.array)((0, serializers_1.u8)(), { size: 7 })],
|
33
|
-
['padding', (0, serializers_1.array)((0, serializers_1.u32)(), { size: 30 })],
|
31
|
+
['padding', (0, serializers_1.array)((0, serializers_1.u32)(), { size: 32 })],
|
34
32
|
], { description: 'SolautoPositionAccountData' });
|
35
33
|
}
|
36
34
|
function deserializeSolautoPosition(rawAccount) {
|
@@ -70,9 +68,7 @@ function getSolautoPositionGpaBuilder(context) {
|
|
70
68
|
position: [40, (0, types_1.getPositionDataSerializer)()],
|
71
69
|
state: [360, (0, types_1.getPositionStateSerializer)()],
|
72
70
|
rebalance: [648, (0, types_1.getRebalanceDataSerializer)()],
|
73
|
-
|
74
|
-
padding2: [705, (0, serializers_1.array)((0, serializers_1.u8)(), { size: 7 })],
|
75
|
-
padding: [712, (0, serializers_1.array)((0, serializers_1.u32)(), { size: 30 })],
|
71
|
+
padding: [704, (0, serializers_1.array)((0, serializers_1.u32)(), { size: 32 })],
|
76
72
|
})
|
77
73
|
.deserializeUsing((account) => deserializeSolautoPosition(account));
|
78
74
|
}
|
@@ -9,7 +9,6 @@ export * from './automationSettings';
|
|
9
9
|
export * from './automationSettingsInp';
|
10
10
|
export * from './dCASettings';
|
11
11
|
export * from './dCASettingsInp';
|
12
|
-
export * from './feeType';
|
13
12
|
export * from './lendingPlatform';
|
14
13
|
export * from './podBool';
|
15
14
|
export * from './positionData';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generated/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generated/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC"}
|
@@ -25,7 +25,6 @@ __exportStar(require("./automationSettings"), exports);
|
|
25
25
|
__exportStar(require("./automationSettingsInp"), exports);
|
26
26
|
__exportStar(require("./dCASettings"), exports);
|
27
27
|
__exportStar(require("./dCASettingsInp"), exports);
|
28
|
-
__exportStar(require("./feeType"), exports);
|
29
28
|
__exportStar(require("./lendingPlatform"), exports);
|
30
29
|
__exportStar(require("./podBool"), exports);
|
31
30
|
__exportStar(require("./positionData"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAuMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CA0HA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CA8BzC"}
|
@@ -329,7 +329,7 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
329
329
|
client.log("Not eligible for a rebalance");
|
330
330
|
return undefined;
|
331
331
|
}
|
332
|
-
const values = (0, rebalanceUtils_1.getRebalanceValues)(client.solautoPositionState, client.solautoPositionSettings(), client.solautoPositionActiveDca(),
|
332
|
+
const values = (0, rebalanceUtils_1.getRebalanceValues)(client.solautoPositionState, client.solautoPositionSettings(), client.solautoPositionActiveDca(), (0, generalUtils_1.currentUnixSeconds)(), constants_1.PRICES[client.supplyMint.toString()].price, constants_1.PRICES[client.debtMint.toString()].price, targetLiqUtilizationRateBps);
|
333
333
|
client.log("Rebalance values: ", values);
|
334
334
|
const swapDetails = (0, rebalanceUtils_1.getJupSwapRebalanceDetails)(client, values, targetLiqUtilizationRateBps, attemptNum);
|
335
335
|
const { jupQuote, lookupTableAddresses, setupInstructions, tokenLedgerIx, swapIx, } = await (0, jupiterUtils_1.getJupSwapTransaction)(client.signer, swapDetails, attemptNum);
|
@@ -366,7 +366,7 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
366
366
|
]);
|
367
367
|
}
|
368
368
|
if (client.solautoPositionState.liqUtilizationRateBps >
|
369
|
-
(0, numberUtils_1.getMaxLiqUtilizationRateBps)(client.solautoPositionState.maxLtvBps, client.solautoPositionState.liqThresholdBps)) {
|
369
|
+
(0, numberUtils_1.getMaxLiqUtilizationRateBps)(client.solautoPositionState.maxLtvBps, client.solautoPositionState.liqThresholdBps, 0.01)) {
|
370
370
|
tx = tx.prepend(client.refresh());
|
371
371
|
}
|
372
372
|
return {
|
@@ -6,7 +6,13 @@ export declare function toBps(value: number): number;
|
|
6
6
|
export declare function bytesToI80F48(bytes: number[]): number;
|
7
7
|
export declare function uint8ArrayToBigInt(uint8Array: Uint8Array): bigint;
|
8
8
|
export declare function getDebtAdjustmentUsd(liqThresholdBps: number, supplyUsd: number, debtUsd: number, targetLiqUtilizationRateBps: number, adjustmentFeeBps?: number): number;
|
9
|
-
export declare function
|
9
|
+
export declare function getSolautoFeesBps(isReferred: boolean, selfManaged: boolean, positionNetWorthUsd: number): {
|
10
|
+
solauto: number;
|
11
|
+
referrer: number;
|
12
|
+
total: number;
|
13
|
+
};
|
14
|
+
export declare function getMaxLiqUtilizationRateBps(maxLtvBps: number, liqThresholdBps: number, offsetFromMaxLtv: number): number;
|
15
|
+
export declare function maxBoostToBps(maxLtvBps: number, liqThresholdBps: number): number;
|
10
16
|
export declare function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number): number;
|
11
17
|
export declare function maxRepayToBps(maxLtvBps: number, liqThresholdBps: number): number;
|
12
18
|
//# sourceMappingURL=numberUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,
|
1
|
+
{"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,GACtB,MAAM,CAMR;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBrD;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAejE;AAED,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,2BAA2B,EAAE,MAAM,EACnC,gBAAgB,CAAC,EAAE,MAAM,UAW1B;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,OAAO,EACnB,WAAW,EAAE,OAAO,EACpB,mBAAmB,EAAE,MAAM,GAC1B;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CA8BA;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAER;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAEvE;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKzE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE"}
|
@@ -8,7 +8,9 @@ exports.toBps = toBps;
|
|
8
8
|
exports.bytesToI80F48 = bytesToI80F48;
|
9
9
|
exports.uint8ArrayToBigInt = uint8ArrayToBigInt;
|
10
10
|
exports.getDebtAdjustmentUsd = getDebtAdjustmentUsd;
|
11
|
+
exports.getSolautoFeesBps = getSolautoFeesBps;
|
11
12
|
exports.getMaxLiqUtilizationRateBps = getMaxLiqUtilizationRateBps;
|
13
|
+
exports.maxBoostToBps = maxBoostToBps;
|
12
14
|
exports.maxRepayFromBps = maxRepayFromBps;
|
13
15
|
exports.maxRepayToBps = maxRepayToBps;
|
14
16
|
const constants_1 = require("../constants");
|
@@ -32,7 +34,7 @@ function toBps(value) {
|
|
32
34
|
}
|
33
35
|
function bytesToI80F48(bytes) {
|
34
36
|
if (bytes.length !== 16) {
|
35
|
-
throw new Error(
|
37
|
+
throw new Error("Byte array must be exactly 16 bytes.");
|
36
38
|
}
|
37
39
|
const reversedBytes = bytes.slice().reverse();
|
38
40
|
let integerPart = BigInt(0);
|
@@ -44,31 +46,65 @@ function bytesToI80F48(bytes) {
|
|
44
46
|
fractionalPart = (fractionalPart << 8n) | BigInt(reversedBytes[i]);
|
45
47
|
}
|
46
48
|
const fullValue = integerPart * BigInt(2 ** 48) + fractionalPart;
|
47
|
-
return Number(fullValue) /
|
49
|
+
return Number(fullValue) / 2 ** 48;
|
48
50
|
}
|
49
51
|
function uint8ArrayToBigInt(uint8Array) {
|
50
52
|
if (uint8Array.length !== 8) {
|
51
|
-
throw new Error(
|
53
|
+
throw new Error("Uint8Array must be exactly 8 bytes long to convert to u64.");
|
52
54
|
}
|
53
55
|
const buffer = uint8Array.buffer;
|
54
56
|
const dataView = new DataView(buffer);
|
55
57
|
const low = dataView.getUint32(0, true);
|
56
58
|
const high = dataView.getUint32(4, true);
|
57
|
-
return BigInt(high) << 32n | BigInt(low);
|
59
|
+
return (BigInt(high) << 32n) | BigInt(low);
|
58
60
|
}
|
59
61
|
function getDebtAdjustmentUsd(liqThresholdBps, supplyUsd, debtUsd, targetLiqUtilizationRateBps, adjustmentFeeBps) {
|
60
62
|
const adjustmentFee = adjustmentFeeBps && adjustmentFeeBps > 0 ? fromBps(adjustmentFeeBps) : 0;
|
61
63
|
const liqThreshold = fromBps(liqThresholdBps);
|
62
64
|
const targetLiqUtilizationRate = fromBps(targetLiqUtilizationRateBps);
|
63
|
-
const debtAdjustmentUsd = (targetLiqUtilizationRate * supplyUsd * liqThreshold - debtUsd) /
|
65
|
+
const debtAdjustmentUsd = (targetLiqUtilizationRate * supplyUsd * liqThreshold - debtUsd) /
|
66
|
+
(1 - targetLiqUtilizationRate * (1 - adjustmentFee) * liqThreshold);
|
64
67
|
return debtAdjustmentUsd;
|
65
68
|
}
|
66
|
-
function
|
67
|
-
|
69
|
+
function getSolautoFeesBps(isReferred, selfManaged, positionNetWorthUsd) {
|
70
|
+
const minSize = 10000; // Minimum position size
|
71
|
+
const maxSize = 1000000; // Maximum position size
|
72
|
+
const maxFeeBps = 500; // Fee in basis points for minSize (5%)
|
73
|
+
const minFeeBps = 100; // Fee in basis points for maxSize (1%)
|
74
|
+
let feeBps = 0;
|
75
|
+
if (selfManaged) {
|
76
|
+
feeBps = 100;
|
77
|
+
}
|
78
|
+
else if (positionNetWorthUsd <= minSize) {
|
79
|
+
feeBps = maxFeeBps;
|
80
|
+
}
|
81
|
+
else if (positionNetWorthUsd >= maxSize) {
|
82
|
+
feeBps = minFeeBps;
|
83
|
+
}
|
84
|
+
else {
|
85
|
+
const t = (Math.log(positionNetWorthUsd) - Math.log(minSize)) /
|
86
|
+
(Math.log(maxSize) - Math.log(minSize));
|
87
|
+
feeBps = Math.round(minFeeBps + (maxFeeBps - minFeeBps) * (1 - t));
|
88
|
+
}
|
89
|
+
let referrer = 0;
|
90
|
+
if (isReferred) {
|
91
|
+
referrer = Math.floor(feeBps / 4);
|
92
|
+
}
|
93
|
+
return {
|
94
|
+
solauto: feeBps - referrer,
|
95
|
+
referrer,
|
96
|
+
total: feeBps,
|
97
|
+
};
|
98
|
+
}
|
99
|
+
function getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, offsetFromMaxLtv) {
|
100
|
+
return toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) - 1; // -1 to account for any rounding issues
|
101
|
+
}
|
102
|
+
function maxBoostToBps(maxLtvBps, liqThresholdBps) {
|
103
|
+
return getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.015);
|
68
104
|
}
|
69
105
|
function maxRepayFromBps(maxLtvBps, liqThresholdBps) {
|
70
|
-
return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000));
|
106
|
+
return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.005));
|
71
107
|
}
|
72
108
|
function maxRepayToBps(maxLtvBps, liqThresholdBps) {
|
73
|
-
return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MAX_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps));
|
109
|
+
return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MAX_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.005));
|
74
110
|
}
|
@@ -1,17 +1,12 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
2
|
import { Umi } from "@metaplex-foundation/umi";
|
3
|
-
import { AutomationSettings, DCASettings, DCASettingsInpArgs,
|
3
|
+
import { AutomationSettings, DCASettings, DCASettingsInpArgs, PositionState, SolautoSettingsParameters, SolautoSettingsParametersInpArgs } from "../../generated";
|
4
4
|
import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
|
5
5
|
export declare function nextAutomationPeriodTimestamp(automation: AutomationSettings): number;
|
6
6
|
export declare function eligibleForNextAutomationPeriod(automation: AutomationSettings, currentUnixTime: number): boolean;
|
7
7
|
export declare function getUpdatedValueFromAutomation(currValue: number, targetValue: number, automation: AutomationSettings, currentUnixTimestamp: number): number;
|
8
8
|
export declare function getAdjustedSettingsFromAutomation(settings: SolautoSettingsParameters, currentUnixTime: number): SolautoSettingsParameters;
|
9
|
-
export declare function
|
10
|
-
solauto: number;
|
11
|
-
referrer: number;
|
12
|
-
total: number;
|
13
|
-
};
|
14
|
-
export declare function eligibleForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters, positionDca: DCASettings | undefined, currentUnixSecs: number): RebalanceAction | undefined;
|
9
|
+
export declare function eligibleForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters, positionDca: DCASettings | undefined, currentUnixTime: number): RebalanceAction | undefined;
|
15
10
|
export declare function eligibleForRefresh(positionState: PositionState, positionSettings: SolautoSettingsParameters, currentUnixTime: number): boolean;
|
16
11
|
export declare function getSolautoManagedPositions(umi: Umi, authority?: PublicKey): Promise<SolautoPositionDetails[]>;
|
17
12
|
export declare function getAllReferralStates(umi: Umi): Promise<PublicKey[]>;
|
@@ -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,
|
1
|
+
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/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M,EAAE,kBAAkB;IAyD9B,KAAK;IAQL,UAAU,IAAI,OAAO;CAQtB"}
|
@@ -5,7 +5,6 @@ exports.nextAutomationPeriodTimestamp = nextAutomationPeriodTimestamp;
|
|
5
5
|
exports.eligibleForNextAutomationPeriod = eligibleForNextAutomationPeriod;
|
6
6
|
exports.getUpdatedValueFromAutomation = getUpdatedValueFromAutomation;
|
7
7
|
exports.getAdjustedSettingsFromAutomation = getAdjustedSettingsFromAutomation;
|
8
|
-
exports.getSolautoFeesBps = getSolautoFeesBps;
|
9
8
|
exports.eligibleForRebalance = eligibleForRebalance;
|
10
9
|
exports.eligibleForRefresh = eligibleForRefresh;
|
11
10
|
exports.getSolautoManagedPositions = getSolautoManagedPositions;
|
@@ -55,30 +54,18 @@ function getAdjustedSettingsFromAutomation(settings, currentUnixTime) {
|
|
55
54
|
boostToBps,
|
56
55
|
};
|
57
56
|
}
|
58
|
-
function
|
59
|
-
const fees = feeType === generated_1.FeeType.Small ? 100 : 500;
|
60
|
-
let referrer = 0;
|
61
|
-
if (isReferred) {
|
62
|
-
referrer = fees / 4;
|
63
|
-
}
|
64
|
-
return {
|
65
|
-
solauto: fees - referrer,
|
66
|
-
referrer,
|
67
|
-
total: fees,
|
68
|
-
};
|
69
|
-
}
|
70
|
-
function eligibleForRebalance(positionState, positionSettings, positionDca, currentUnixSecs) {
|
57
|
+
function eligibleForRebalance(positionState, positionSettings, positionDca, currentUnixTime) {
|
71
58
|
if (positionDca &&
|
72
59
|
positionDca.automation.targetPeriods > 0 &&
|
73
|
-
eligibleForNextAutomationPeriod(positionDca.automation,
|
60
|
+
eligibleForNextAutomationPeriod(positionDca.automation, currentUnixTime)) {
|
74
61
|
return "dca";
|
75
62
|
}
|
76
63
|
if (positionState.supply.amountUsed.baseUnit === BigInt(0)) {
|
77
64
|
return undefined;
|
78
65
|
}
|
79
|
-
const boostToBps = eligibleForRefresh(positionState, positionSettings,
|
66
|
+
const boostToBps = eligibleForRefresh(positionState, positionSettings, currentUnixTime) &&
|
80
67
|
positionSettings.automation.targetPeriods > 0
|
81
|
-
? getUpdatedValueFromAutomation(positionSettings.boostToBps, positionSettings.targetBoostToBps, positionSettings.automation,
|
68
|
+
? getUpdatedValueFromAutomation(positionSettings.boostToBps, positionSettings.targetBoostToBps, positionSettings.automation, currentUnixTime)
|
82
69
|
: positionSettings.boostToBps;
|
83
70
|
const repayFrom = positionSettings.repayToBps + positionSettings.repayGap;
|
84
71
|
const boostFrom = boostToBps - positionSettings.boostGap;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
2
|
import { SolautoClient } from "../../clients/solautoClient";
|
3
|
-
import { DCASettings,
|
3
|
+
import { DCASettings, PositionState, SolautoSettingsParameters } from "../../generated";
|
4
4
|
import { QuoteResponse } from "@jup-ag/api";
|
5
5
|
import { JupSwapDetails } from "../jupiterUtils";
|
6
6
|
export interface RebalanceValues {
|
@@ -9,7 +9,7 @@ export interface RebalanceValues {
|
|
9
9
|
amountToDcaIn: number;
|
10
10
|
amountUsdToDcaIn: number;
|
11
11
|
}
|
12
|
-
export declare function getRebalanceValues(state: PositionState, settings: SolautoSettingsParameters | undefined, dca: DCASettings | undefined,
|
12
|
+
export declare function getRebalanceValues(state: PositionState, settings: SolautoSettingsParameters | undefined, dca: DCASettings | undefined, currentUnixTime: number, supplyPrice: number, debtPrice: number, targetLiqUtilizationRateBps?: number, limitGapBps?: number): RebalanceValues;
|
13
13
|
export interface FlashLoanDetails {
|
14
14
|
baseUnitAmount: bigint;
|
15
15
|
mint: PublicKey;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/rebalanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,
|
1
|
+
{"version":3,"file":"rebalanceUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/rebalanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,aAAa,EAEb,yBAAyB,EAC1B,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAkJjD,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,yBAAyB,GAAG,SAAS,EAC/C,GAAG,EAAE,WAAW,GAAG,SAAS,EAC5B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,CA0EjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CAmE9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAkChB"}
|
@@ -19,8 +19,8 @@ function getAdditionalAmountToDcaIn(dca) {
|
|
19
19
|
}
|
20
20
|
function getStandardTargetLiqUtilizationRateBps(state, settings) {
|
21
21
|
const adjustedSettings = (0, generalUtils_1.getAdjustedSettingsFromAutomation)(settings, (0, generalUtils_2.currentUnixSeconds)());
|
22
|
-
const repayFrom =
|
23
|
-
const boostFrom = adjustedSettings.boostToBps -
|
22
|
+
const repayFrom = settings.repayToBps + settings.repayGap;
|
23
|
+
const boostFrom = adjustedSettings.boostToBps - settings.boostGap;
|
24
24
|
if (state.liqUtilizationRateBps < boostFrom) {
|
25
25
|
return adjustedSettings.boostToBps;
|
26
26
|
}
|
@@ -63,7 +63,7 @@ function getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, target
|
|
63
63
|
};
|
64
64
|
}
|
65
65
|
if (settings === undefined) {
|
66
|
-
throw new Error("If rebalancing a self-managed position, settings
|
66
|
+
throw new Error("If rebalancing a self-managed position, settings and DCA should be provided");
|
67
67
|
}
|
68
68
|
if (isDcaRebalance(state, settings, dca, currentUnixTime)) {
|
69
69
|
const amountToDcaIn = getAdditionalAmountToDcaIn(dca);
|
@@ -79,7 +79,7 @@ function getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, target
|
|
79
79
|
};
|
80
80
|
}
|
81
81
|
}
|
82
|
-
function getRebalanceValues(state, settings, dca,
|
82
|
+
function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice, debtPrice, targetLiqUtilizationRateBps, limitGapBps) {
|
83
83
|
if (state === undefined ||
|
84
84
|
state.lastUpdated <
|
85
85
|
BigInt(Math.round((0, generalUtils_2.currentUnixSeconds)() - solautoConstants_1.MIN_POSITION_STATE_FRESHNESS_SECS))) {
|
@@ -91,7 +91,7 @@ function getRebalanceValues(state, settings, dca, feeType, currentUnixTime, supp
|
|
91
91
|
const increasingLeverage = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps;
|
92
92
|
let adjustmentFeeBps = 0;
|
93
93
|
if (increasingLeverage) {
|
94
|
-
adjustmentFeeBps = (0,
|
94
|
+
adjustmentFeeBps = (0, numberUtils_1.getSolautoFeesBps)(false, settings === undefined, (0, numberUtils_1.fromBaseUnit)(state.netWorth.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS)).total;
|
95
95
|
}
|
96
96
|
const supplyUsd = (0, numberUtils_1.fromBaseUnit)(state.supply.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS) +
|
97
97
|
amountUsdToDcaIn;
|
@@ -133,7 +133,7 @@ function getFlashLoanDetails(client, values, jupQuote) {
|
|
133
133
|
const tempLiqUtilizationRateBps = (0, numberUtils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, client.solautoPositionState.liqThresholdBps);
|
134
134
|
const requiresFlashLoan = supplyUsd <= 0 ||
|
135
135
|
tempLiqUtilizationRateBps >
|
136
|
-
(0, numberUtils_1.getMaxLiqUtilizationRateBps)(client.solautoPositionState.maxLtvBps, client.solautoPositionState.liqThresholdBps);
|
136
|
+
(0, numberUtils_1.getMaxLiqUtilizationRateBps)(client.solautoPositionState.maxLtvBps, client.solautoPositionState.liqThresholdBps, 0.01);
|
137
137
|
let flashLoanToken = undefined;
|
138
138
|
let flashLoanTokenPrice = 0;
|
139
139
|
if (values.increasingLeverage) {
|
package/package.json
CHANGED
@@ -28,8 +28,6 @@ import {
|
|
28
28
|
u8,
|
29
29
|
} from '@metaplex-foundation/umi/serializers';
|
30
30
|
import {
|
31
|
-
FeeType,
|
32
|
-
FeeTypeArgs,
|
33
31
|
PodBool,
|
34
32
|
PodBoolArgs,
|
35
33
|
PositionData,
|
@@ -38,7 +36,6 @@ import {
|
|
38
36
|
PositionStateArgs,
|
39
37
|
RebalanceData,
|
40
38
|
RebalanceDataArgs,
|
41
|
-
getFeeTypeSerializer,
|
42
39
|
getPodBoolSerializer,
|
43
40
|
getPositionDataSerializer,
|
44
41
|
getPositionStateSerializer,
|
@@ -56,8 +53,6 @@ export type SolautoPositionAccountData = {
|
|
56
53
|
position: PositionData;
|
57
54
|
state: PositionState;
|
58
55
|
rebalance: RebalanceData;
|
59
|
-
feeType: FeeType;
|
60
|
-
padding2: Array<number>;
|
61
56
|
padding: Array<number>;
|
62
57
|
};
|
63
58
|
|
@@ -70,8 +65,6 @@ export type SolautoPositionAccountDataArgs = {
|
|
70
65
|
position: PositionDataArgs;
|
71
66
|
state: PositionStateArgs;
|
72
67
|
rebalance: RebalanceDataArgs;
|
73
|
-
feeType: FeeTypeArgs;
|
74
|
-
padding2: Array<number>;
|
75
68
|
padding: Array<number>;
|
76
69
|
};
|
77
70
|
|
@@ -89,9 +82,7 @@ export function getSolautoPositionAccountDataSerializer(): Serializer<
|
|
89
82
|
['position', getPositionDataSerializer()],
|
90
83
|
['state', getPositionStateSerializer()],
|
91
84
|
['rebalance', getRebalanceDataSerializer()],
|
92
|
-
['
|
93
|
-
['padding2', array(u8(), { size: 7 })],
|
94
|
-
['padding', array(u32(), { size: 30 })],
|
85
|
+
['padding', array(u32(), { size: 32 })],
|
95
86
|
],
|
96
87
|
{ description: 'SolautoPositionAccountData' }
|
97
88
|
) as Serializer<SolautoPositionAccountDataArgs, SolautoPositionAccountData>;
|
@@ -179,8 +170,6 @@ export function getSolautoPositionGpaBuilder(
|
|
179
170
|
position: PositionDataArgs;
|
180
171
|
state: PositionStateArgs;
|
181
172
|
rebalance: RebalanceDataArgs;
|
182
|
-
feeType: FeeTypeArgs;
|
183
|
-
padding2: Array<number>;
|
184
173
|
padding: Array<number>;
|
185
174
|
}>({
|
186
175
|
bump: [0, array(u8(), { size: 1 })],
|
@@ -191,9 +180,7 @@ export function getSolautoPositionGpaBuilder(
|
|
191
180
|
position: [40, getPositionDataSerializer()],
|
192
181
|
state: [360, getPositionStateSerializer()],
|
193
182
|
rebalance: [648, getRebalanceDataSerializer()],
|
194
|
-
|
195
|
-
padding2: [705, array(u8(), { size: 7 })],
|
196
|
-
padding: [712, array(u32(), { size: 30 })],
|
183
|
+
padding: [704, array(u32(), { size: 32 })],
|
197
184
|
})
|
198
185
|
.deserializeUsing<SolautoPosition>((account) =>
|
199
186
|
deserializeSolautoPosition(account)
|
@@ -10,7 +10,6 @@ export * from './automationSettings';
|
|
10
10
|
export * from './automationSettingsInp';
|
11
11
|
export * from './dCASettings';
|
12
12
|
export * from './dCASettingsInp';
|
13
|
-
export * from './feeType';
|
14
13
|
export * from './lendingPlatform';
|
15
14
|
export * from './podBool';
|
16
15
|
export * from './positionData';
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import {
|
2
2
|
Instruction,
|
3
|
-
Signer,
|
4
3
|
TransactionBuilder,
|
5
4
|
Umi,
|
6
5
|
publicKey,
|
@@ -14,7 +13,6 @@ import {
|
|
14
13
|
Account as SplTokenAccount,
|
15
14
|
} from "@solana/spl-token";
|
16
15
|
import {
|
17
|
-
FeeType,
|
18
16
|
LendingPlatform,
|
19
17
|
ReferralState,
|
20
18
|
SOLAUTO_PROGRAM_ID,
|
@@ -582,7 +580,6 @@ export async function buildSolautoRebalanceTransaction(
|
|
582
580
|
client.solautoPositionState!,
|
583
581
|
client.solautoPositionSettings(),
|
584
582
|
client.solautoPositionActiveDca(),
|
585
|
-
client.solautoPositionData?.feeType ?? FeeType.Small,
|
586
583
|
currentUnixSeconds(),
|
587
584
|
PRICES[client.supplyMint.toString()].price,
|
588
585
|
PRICES[client.debtMint.toString()].price,
|
@@ -672,7 +669,8 @@ export async function buildSolautoRebalanceTransaction(
|
|
672
669
|
client.solautoPositionState!.liqUtilizationRateBps >
|
673
670
|
getMaxLiqUtilizationRateBps(
|
674
671
|
client.solautoPositionState!.maxLtvBps,
|
675
|
-
client.solautoPositionState!.liqThresholdBps
|
672
|
+
client.solautoPositionState!.liqThresholdBps,
|
673
|
+
0.01
|
676
674
|
)
|
677
675
|
) {
|
678
676
|
tx = tx.prepend(client.refresh());
|
package/src/utils/numberUtils.ts
CHANGED
@@ -1,17 +1,21 @@
|
|
1
1
|
import { MAX_REPAY_GAP_BPS } from "../constants";
|
2
2
|
|
3
|
-
export function getLiqUtilzationRateBps(
|
3
|
+
export function getLiqUtilzationRateBps(
|
4
|
+
supplyUsd: number,
|
5
|
+
debtUsd: number,
|
6
|
+
liqThresholdBps: number
|
7
|
+
): number {
|
4
8
|
if (supplyUsd === 0) {
|
5
9
|
return 0;
|
6
10
|
}
|
7
|
-
|
11
|
+
|
8
12
|
return toBps(debtUsd / (supplyUsd * fromBps(liqThresholdBps)));
|
9
13
|
}
|
10
14
|
|
11
15
|
export function toBaseUnit(value: number, decimals: number): bigint {
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
return BigInt(Math.round(value * Math.pow(10, decimals)));
|
17
|
+
}
|
18
|
+
|
15
19
|
export function fromBaseUnit(value: bigint, decimals: number): number {
|
16
20
|
return Number(value) / Math.pow(10, decimals);
|
17
21
|
}
|
@@ -26,7 +30,7 @@ export function toBps(value: number): number {
|
|
26
30
|
|
27
31
|
export function bytesToI80F48(bytes: number[]): number {
|
28
32
|
if (bytes.length !== 16) {
|
29
|
-
throw new Error(
|
33
|
+
throw new Error("Byte array must be exactly 16 bytes.");
|
30
34
|
}
|
31
35
|
|
32
36
|
const reversedBytes = bytes.slice().reverse();
|
@@ -44,12 +48,14 @@ export function bytesToI80F48(bytes: number[]): number {
|
|
44
48
|
|
45
49
|
const fullValue = integerPart * BigInt(2 ** 48) + fractionalPart;
|
46
50
|
|
47
|
-
return Number(fullValue) /
|
51
|
+
return Number(fullValue) / 2 ** 48;
|
48
52
|
}
|
49
53
|
|
50
54
|
export function uint8ArrayToBigInt(uint8Array: Uint8Array): bigint {
|
51
55
|
if (uint8Array.length !== 8) {
|
52
|
-
throw new Error(
|
56
|
+
throw new Error(
|
57
|
+
"Uint8Array must be exactly 8 bytes long to convert to u64."
|
58
|
+
);
|
53
59
|
}
|
54
60
|
|
55
61
|
const buffer = uint8Array.buffer;
|
@@ -59,7 +65,7 @@ export function uint8ArrayToBigInt(uint8Array: Uint8Array): bigint {
|
|
59
65
|
const low = dataView.getUint32(0, true);
|
60
66
|
const high = dataView.getUint32(4, true);
|
61
67
|
|
62
|
-
return BigInt(high) << 32n | BigInt(low);
|
68
|
+
return (BigInt(high) << 32n) | BigInt(low);
|
63
69
|
}
|
64
70
|
|
65
71
|
export function getDebtAdjustmentUsd(
|
@@ -69,31 +75,79 @@ export function getDebtAdjustmentUsd(
|
|
69
75
|
targetLiqUtilizationRateBps: number,
|
70
76
|
adjustmentFeeBps?: number
|
71
77
|
) {
|
72
|
-
const adjustmentFee =
|
78
|
+
const adjustmentFee =
|
79
|
+
adjustmentFeeBps && adjustmentFeeBps > 0 ? fromBps(adjustmentFeeBps) : 0;
|
73
80
|
const liqThreshold = fromBps(liqThresholdBps);
|
74
81
|
const targetLiqUtilizationRate = fromBps(targetLiqUtilizationRateBps);
|
75
82
|
|
76
|
-
const debtAdjustmentUsd =
|
83
|
+
const debtAdjustmentUsd =
|
84
|
+
(targetLiqUtilizationRate * supplyUsd * liqThreshold - debtUsd) /
|
85
|
+
(1 - targetLiqUtilizationRate * (1 - adjustmentFee) * liqThreshold);
|
77
86
|
return debtAdjustmentUsd;
|
78
87
|
}
|
79
88
|
|
89
|
+
export function getSolautoFeesBps(
|
90
|
+
isReferred: boolean,
|
91
|
+
selfManaged: boolean,
|
92
|
+
positionNetWorthUsd: number
|
93
|
+
): {
|
94
|
+
solauto: number;
|
95
|
+
referrer: number;
|
96
|
+
total: number;
|
97
|
+
} {
|
98
|
+
const minSize = 10000; // Minimum position size
|
99
|
+
const maxSize = 1000000; // Maximum position size
|
100
|
+
const maxFeeBps = 500; // Fee in basis points for minSize (5%)
|
101
|
+
const minFeeBps = 100; // Fee in basis points for maxSize (1%)
|
102
|
+
|
103
|
+
let feeBps: number = 0;
|
104
|
+
if (selfManaged) {
|
105
|
+
feeBps = 100;
|
106
|
+
} else if (positionNetWorthUsd <= minSize) {
|
107
|
+
feeBps = maxFeeBps;
|
108
|
+
} else if (positionNetWorthUsd >= maxSize) {
|
109
|
+
feeBps = minFeeBps;
|
110
|
+
} else {
|
111
|
+
const t =
|
112
|
+
(Math.log(positionNetWorthUsd) - Math.log(minSize)) /
|
113
|
+
(Math.log(maxSize) - Math.log(minSize));
|
114
|
+
feeBps = Math.round(minFeeBps + (maxFeeBps - minFeeBps) * (1 - t));
|
115
|
+
}
|
116
|
+
|
117
|
+
let referrer = 0;
|
118
|
+
if (isReferred) {
|
119
|
+
referrer = Math.floor(feeBps / 4);
|
120
|
+
}
|
121
|
+
|
122
|
+
return {
|
123
|
+
solauto: feeBps - referrer,
|
124
|
+
referrer,
|
125
|
+
total: feeBps,
|
126
|
+
};
|
127
|
+
}
|
128
|
+
|
80
129
|
export function getMaxLiqUtilizationRateBps(
|
81
130
|
maxLtvBps: number,
|
82
|
-
liqThresholdBps: number
|
131
|
+
liqThresholdBps: number,
|
132
|
+
offsetFromMaxLtv: number
|
83
133
|
): number {
|
84
|
-
return toBps((fromBps(maxLtvBps) -
|
134
|
+
return toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) - 1; // -1 to account for any rounding issues
|
135
|
+
}
|
136
|
+
|
137
|
+
export function maxBoostToBps(maxLtvBps: number, liqThresholdBps: number) {
|
138
|
+
return getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.015);
|
85
139
|
}
|
86
140
|
|
87
141
|
export function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number) {
|
88
142
|
return Math.min(
|
89
143
|
9000,
|
90
|
-
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000)
|
144
|
+
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.005)
|
91
145
|
);
|
92
146
|
}
|
93
147
|
|
94
148
|
export function maxRepayToBps(maxLtvBps: number, liqThresholdBps: number) {
|
95
149
|
return Math.min(
|
96
150
|
maxRepayFromBps(maxLtvBps, liqThresholdBps) - MAX_REPAY_GAP_BPS,
|
97
|
-
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps)
|
151
|
+
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.005)
|
98
152
|
);
|
99
|
-
}
|
153
|
+
}
|
@@ -4,7 +4,6 @@ import {
|
|
4
4
|
AutomationSettings,
|
5
5
|
DCASettings,
|
6
6
|
DCASettingsInpArgs,
|
7
|
-
FeeType,
|
8
7
|
LendingPlatform,
|
9
8
|
PositionState,
|
10
9
|
SOLAUTO_PROGRAM_ID,
|
@@ -29,7 +28,6 @@ import {
|
|
29
28
|
} from "../../constants";
|
30
29
|
import {
|
31
30
|
getAllMarginfiAccountsByAuthority,
|
32
|
-
getMarginfiAccountPositionState,
|
33
31
|
} from "../marginfiUtils";
|
34
32
|
import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
|
35
33
|
|
@@ -102,37 +100,16 @@ export function getAdjustedSettingsFromAutomation(
|
|
102
100
|
};
|
103
101
|
}
|
104
102
|
|
105
|
-
export function getSolautoFeesBps(
|
106
|
-
isReferred: boolean,
|
107
|
-
feeType: FeeType
|
108
|
-
): {
|
109
|
-
solauto: number;
|
110
|
-
referrer: number;
|
111
|
-
total: number;
|
112
|
-
} {
|
113
|
-
const fees = feeType === FeeType.Small ? 100 : 500;
|
114
|
-
let referrer = 0;
|
115
|
-
if (isReferred) {
|
116
|
-
referrer = fees / 4;
|
117
|
-
}
|
118
|
-
|
119
|
-
return {
|
120
|
-
solauto: fees - referrer,
|
121
|
-
referrer,
|
122
|
-
total: fees,
|
123
|
-
};
|
124
|
-
}
|
125
|
-
|
126
103
|
export function eligibleForRebalance(
|
127
104
|
positionState: PositionState,
|
128
105
|
positionSettings: SolautoSettingsParameters,
|
129
106
|
positionDca: DCASettings | undefined,
|
130
|
-
|
107
|
+
currentUnixTime: number
|
131
108
|
): RebalanceAction | undefined {
|
132
109
|
if (
|
133
110
|
positionDca &&
|
134
111
|
positionDca.automation.targetPeriods > 0 &&
|
135
|
-
eligibleForNextAutomationPeriod(positionDca.automation,
|
112
|
+
eligibleForNextAutomationPeriod(positionDca.automation, currentUnixTime)
|
136
113
|
) {
|
137
114
|
return "dca";
|
138
115
|
}
|
@@ -142,13 +119,13 @@ export function eligibleForRebalance(
|
|
142
119
|
}
|
143
120
|
|
144
121
|
const boostToBps =
|
145
|
-
eligibleForRefresh(positionState, positionSettings,
|
122
|
+
eligibleForRefresh(positionState, positionSettings, currentUnixTime) &&
|
146
123
|
positionSettings.automation.targetPeriods > 0
|
147
124
|
? getUpdatedValueFromAutomation(
|
148
125
|
positionSettings.boostToBps,
|
149
126
|
positionSettings.targetBoostToBps,
|
150
127
|
positionSettings.automation,
|
151
|
-
|
128
|
+
currentUnixTime
|
152
129
|
)
|
153
130
|
: positionSettings.boostToBps;
|
154
131
|
const repayFrom = positionSettings.repayToBps + positionSettings.repayGap;
|
@@ -2,7 +2,6 @@ import { PublicKey } from "@solana/web3.js";
|
|
2
2
|
import { SolautoClient } from "../../clients/solautoClient";
|
3
3
|
import {
|
4
4
|
DCASettings,
|
5
|
-
FeeType,
|
6
5
|
PositionState,
|
7
6
|
PositionTokenUsage,
|
8
7
|
SolautoSettingsParameters,
|
@@ -10,7 +9,6 @@ import {
|
|
10
9
|
import {
|
11
10
|
eligibleForNextAutomationPeriod,
|
12
11
|
getAdjustedSettingsFromAutomation,
|
13
|
-
getSolautoFeesBps,
|
14
12
|
getUpdatedValueFromAutomation,
|
15
13
|
} from "./generalUtils";
|
16
14
|
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
@@ -23,6 +21,7 @@ import {
|
|
23
21
|
getDebtAdjustmentUsd,
|
24
22
|
getLiqUtilzationRateBps,
|
25
23
|
getMaxLiqUtilizationRateBps,
|
24
|
+
getSolautoFeesBps,
|
26
25
|
toBaseUnit,
|
27
26
|
} from "../numberUtils";
|
28
27
|
import { USD_DECIMALS } from "../../constants/generalAccounts";
|
@@ -57,8 +56,8 @@ function getStandardTargetLiqUtilizationRateBps(
|
|
57
56
|
currentUnixSeconds()
|
58
57
|
);
|
59
58
|
|
60
|
-
const repayFrom =
|
61
|
-
const boostFrom = adjustedSettings.boostToBps -
|
59
|
+
const repayFrom = settings.repayToBps + settings.repayGap;
|
60
|
+
const boostFrom = adjustedSettings.boostToBps - settings.boostGap;
|
62
61
|
|
63
62
|
if (state.liqUtilizationRateBps < boostFrom) {
|
64
63
|
return adjustedSettings.boostToBps;
|
@@ -136,7 +135,7 @@ function getTargetRateAndDcaAmount(
|
|
136
135
|
|
137
136
|
if (settings === undefined) {
|
138
137
|
throw new Error(
|
139
|
-
"If rebalancing a self-managed position, settings
|
138
|
+
"If rebalancing a self-managed position, settings and DCA should be provided"
|
140
139
|
);
|
141
140
|
}
|
142
141
|
|
@@ -171,7 +170,6 @@ export function getRebalanceValues(
|
|
171
170
|
state: PositionState,
|
172
171
|
settings: SolautoSettingsParameters | undefined,
|
173
172
|
dca: DCASettings | undefined,
|
174
|
-
feeType: FeeType,
|
175
173
|
currentUnixTime: number,
|
176
174
|
supplyPrice: number,
|
177
175
|
debtPrice: number,
|
@@ -204,7 +202,11 @@ export function getRebalanceValues(
|
|
204
202
|
amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps;
|
205
203
|
let adjustmentFeeBps = 0;
|
206
204
|
if (increasingLeverage) {
|
207
|
-
adjustmentFeeBps = getSolautoFeesBps(
|
205
|
+
adjustmentFeeBps = getSolautoFeesBps(
|
206
|
+
false,
|
207
|
+
settings === undefined,
|
208
|
+
fromBaseUnit(state.netWorth.baseAmountUsdValue, USD_DECIMALS)
|
209
|
+
).total;
|
208
210
|
}
|
209
211
|
|
210
212
|
const supplyUsd =
|
@@ -290,7 +292,8 @@ export function getFlashLoanDetails(
|
|
290
292
|
tempLiqUtilizationRateBps >
|
291
293
|
getMaxLiqUtilizationRateBps(
|
292
294
|
client.solautoPositionState!.maxLtvBps,
|
293
|
-
client.solautoPositionState!.liqThresholdBps
|
295
|
+
client.solautoPositionState!.liqThresholdBps,
|
296
|
+
0.01
|
294
297
|
);
|
295
298
|
|
296
299
|
let flashLoanToken: PositionTokenUsage | undefined = undefined;
|
@@ -9,7 +9,6 @@ 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,
|
@@ -18,6 +17,7 @@ import {
|
|
18
17
|
fromBaseUnit,
|
19
18
|
fromBps,
|
20
19
|
getLiqUtilzationRateBps,
|
20
|
+
getSolautoFeesBps,
|
21
21
|
toBaseUnit,
|
22
22
|
} from "../../src/utils/numberUtils";
|
23
23
|
import { USD_DECIMALS } from "../../src/constants/generalAccounts";
|
@@ -25,7 +25,6 @@ import {
|
|
25
25
|
createFakePositionState,
|
26
26
|
eligibleForNextAutomationPeriod,
|
27
27
|
getAdjustedSettingsFromAutomation,
|
28
|
-
getSolautoFeesBps,
|
29
28
|
getUpdatedValueFromAutomation,
|
30
29
|
positionStateWithLatestPrices,
|
31
30
|
} from "../../src/utils/solauto/generalUtils";
|
@@ -49,7 +48,6 @@ function assertAccurateRebalance(
|
|
49
48
|
client.solautoPositionState!,
|
50
49
|
client.solautoPositionSettings(),
|
51
50
|
client.solautoPositionActiveDca(),
|
52
|
-
client.solautoPositionData?.feeType ?? FeeType.Small,
|
53
51
|
currentUnixSeconds(),
|
54
52
|
PRICES[client.supplyMint.toString()].price,
|
55
53
|
PRICES[client.debtMint.toString()].price,
|
@@ -60,7 +58,11 @@ function assertAccurateRebalance(
|
|
60
58
|
if (increasingLeverage) {
|
61
59
|
adjustmentFeeBps = getSolautoFeesBps(
|
62
60
|
client.referredByState !== undefined,
|
63
|
-
client.
|
61
|
+
client.selfManaged,
|
62
|
+
fromBaseUnit(
|
63
|
+
client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0),
|
64
|
+
USD_DECIMALS
|
65
|
+
)
|
64
66
|
).total;
|
65
67
|
}
|
66
68
|
|
@@ -176,9 +178,7 @@ async function getFakePosition(
|
|
176
178
|
padding2: [],
|
177
179
|
padding: new Uint8Array([]),
|
178
180
|
},
|
179
|
-
feeType: FeeType.Default,
|
180
181
|
padding1: [],
|
181
|
-
padding2: [],
|
182
182
|
padding: [],
|
183
183
|
publicKey: publicKey(PublicKey.default),
|
184
184
|
header: {
|
@@ -285,28 +285,28 @@ describe("Rebalance tests", async () => {
|
|
285
285
|
]);
|
286
286
|
});
|
287
287
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
288
|
+
it("Standard rebalance with target rate", async () => {
|
289
|
+
const client = await getFakePosition(supplyPrice, debtPrice, 3450, {
|
290
|
+
boostToBps: 500,
|
291
|
+
boostGap: 100,
|
292
|
+
repayToBps: 7000,
|
293
|
+
repayGap: 250,
|
294
|
+
automation: {
|
295
|
+
targetPeriods: 0,
|
296
|
+
periodsPassed: 0,
|
297
|
+
unixStartDate: BigInt(0),
|
298
|
+
intervalSeconds: BigInt(0),
|
299
|
+
padding1: [],
|
300
|
+
padding: new Uint8Array([]),
|
301
|
+
},
|
302
|
+
targetBoostToBps: 0,
|
303
|
+
padding1: [],
|
304
|
+
padding: new Uint8Array([]),
|
305
|
+
});
|
306
306
|
|
307
|
-
|
308
|
-
|
309
|
-
|
307
|
+
assertAccurateRebalance(client, 5000, 5000);
|
308
|
+
assertAccurateRebalance(client, 1000, 1000);
|
309
|
+
});
|
310
310
|
|
311
311
|
it("Standard boost or repay", async () => {
|
312
312
|
const settings: SolautoSettingsParameters = {
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* This code was AUTOGENERATED using the kinobi library.
|
3
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
4
|
-
* to add features, then rerun kinobi to update it.
|
5
|
-
*
|
6
|
-
* @see https://github.com/metaplex-foundation/kinobi
|
7
|
-
*/
|
8
|
-
import { Serializer } from '@metaplex-foundation/umi/serializers';
|
9
|
-
export declare enum FeeType {
|
10
|
-
Small = 0,
|
11
|
-
Default = 1
|
12
|
-
}
|
13
|
-
export type FeeTypeArgs = FeeType;
|
14
|
-
export declare function getFeeTypeSerializer(): Serializer<FeeTypeArgs, FeeType>;
|
15
|
-
//# sourceMappingURL=feeType.d.ts.map
|
@@ -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
|
-
}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* This code was AUTOGENERATED using the kinobi library.
|
3
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
4
|
-
* to add features, then rerun kinobi to update it.
|
5
|
-
*
|
6
|
-
* @see https://github.com/metaplex-foundation/kinobi
|
7
|
-
*/
|
8
|
-
|
9
|
-
import { Serializer, scalarEnum } from '@metaplex-foundation/umi/serializers';
|
10
|
-
|
11
|
-
export enum FeeType {
|
12
|
-
Small,
|
13
|
-
Default,
|
14
|
-
}
|
15
|
-
|
16
|
-
export type FeeTypeArgs = FeeType;
|
17
|
-
|
18
|
-
export function getFeeTypeSerializer(): Serializer<FeeTypeArgs, FeeType> {
|
19
|
-
return scalarEnum<FeeType>(FeeType, { description: 'FeeType' }) as Serializer<
|
20
|
-
FeeTypeArgs,
|
21
|
-
FeeType
|
22
|
-
>;
|
23
|
-
}
|