@haven-fi/solauto-sdk 1.0.226 → 1.0.227
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/generated/instructions/claimReferralFees.d.ts +1 -0
- package/dist/generated/instructions/claimReferralFees.d.ts.map +1 -1
- package/dist/generated/instructions/claimReferralFees.js +15 -6
- package/dist/utils/numberUtils.d.ts.map +1 -1
- package/dist/utils/numberUtils.js +7 -4
- package/package.json +1 -1
- package/src/generated/instructions/claimReferralFees.ts +19 -6
- package/src/utils/numberUtils.ts +18 -7
@@ -12,6 +12,7 @@ export type ClaimReferralFeesInstructionAccounts = {
|
|
12
12
|
signerWsolTa?: PublicKey | Pda;
|
13
13
|
systemProgram?: PublicKey | Pda;
|
14
14
|
tokenProgram?: PublicKey | Pda;
|
15
|
+
ataProgram?: PublicKey | Pda;
|
15
16
|
rent?: PublicKey | Pda;
|
16
17
|
referralState: PublicKey | Pda;
|
17
18
|
referralFeesDestTa: PublicKey | Pda;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"claimReferralFees.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/claimReferralFees.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,GAAG,EACH,SAAS,EACT,MAAM,EACN,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EAIX,MAAM,sCAAsC,CAAC;AAQ9C,MAAM,MAAM,oCAAoC,GAAG;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAC/B,aAAa,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAChC,YAAY,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAC/B,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACvB,aAAa,EAAE,SAAS,GAAG,GAAG,CAAC;IAC/B,kBAAkB,EAAE,SAAS,GAAG,GAAG,CAAC;IACpC,oBAAoB,EAAE,SAAS,GAAG,GAAG,CAAC;IACtC,iBAAiB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACpC,iBAAiB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;CACrC,CAAC;AAGF,MAAM,MAAM,gCAAgC,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,MAAM,MAAM,oCAAoC,GAAG,EAAE,CAAC;AAEtD,wBAAgB,6CAA6C,IAAI,UAAU,CACzE,oCAAoC,EACpC,gCAAgC,CACjC,CAcA;AAGD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAClC,KAAK,EAAE,oCAAoC,GAC1C,kBAAkB,
|
1
|
+
{"version":3,"file":"claimReferralFees.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/claimReferralFees.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,GAAG,EACH,SAAS,EACT,MAAM,EACN,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EAIX,MAAM,sCAAsC,CAAC;AAQ9C,MAAM,MAAM,oCAAoC,GAAG;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAC/B,aAAa,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAChC,YAAY,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAC/B,UAAU,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAC7B,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACvB,aAAa,EAAE,SAAS,GAAG,GAAG,CAAC;IAC/B,kBAAkB,EAAE,SAAS,GAAG,GAAG,CAAC;IACpC,oBAAoB,EAAE,SAAS,GAAG,GAAG,CAAC;IACtC,iBAAiB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACpC,iBAAiB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;CACrC,CAAC;AAGF,MAAM,MAAM,gCAAgC,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,MAAM,MAAM,oCAAoC,GAAG,EAAE,CAAC;AAEtD,wBAAgB,6CAA6C,IAAI,UAAU,CACzE,oCAAoC,EACpC,gCAAgC,CACjC,CAcA;AAGD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAClC,KAAK,EAAE,oCAAoC,GAC1C,kBAAkB,CA+GpB"}
|
@@ -43,29 +43,34 @@ function claimReferralFees(context, input) {
|
|
43
43
|
isWritable: false,
|
44
44
|
value: input.tokenProgram ?? null,
|
45
45
|
},
|
46
|
-
|
46
|
+
ataProgram: {
|
47
|
+
index: 4,
|
48
|
+
isWritable: false,
|
49
|
+
value: input.ataProgram ?? null,
|
50
|
+
},
|
51
|
+
rent: { index: 5, isWritable: false, value: input.rent ?? null },
|
47
52
|
referralState: {
|
48
|
-
index:
|
53
|
+
index: 6,
|
49
54
|
isWritable: false,
|
50
55
|
value: input.referralState ?? null,
|
51
56
|
},
|
52
57
|
referralFeesDestTa: {
|
53
|
-
index:
|
58
|
+
index: 7,
|
54
59
|
isWritable: true,
|
55
60
|
value: input.referralFeesDestTa ?? null,
|
56
61
|
},
|
57
62
|
referralFeesDestMint: {
|
58
|
-
index:
|
63
|
+
index: 8,
|
59
64
|
isWritable: false,
|
60
65
|
value: input.referralFeesDestMint ?? null,
|
61
66
|
},
|
62
67
|
referralAuthority: {
|
63
|
-
index:
|
68
|
+
index: 9,
|
64
69
|
isWritable: true,
|
65
70
|
value: input.referralAuthority ?? null,
|
66
71
|
},
|
67
72
|
feesDestinationTa: {
|
68
|
-
index:
|
73
|
+
index: 10,
|
69
74
|
isWritable: true,
|
70
75
|
value: input.feesDestinationTa ?? null,
|
71
76
|
},
|
@@ -79,6 +84,10 @@ function claimReferralFees(context, input) {
|
|
79
84
|
resolvedAccounts.tokenProgram.value = context.programs.getPublicKey('splToken', 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');
|
80
85
|
resolvedAccounts.tokenProgram.isWritable = false;
|
81
86
|
}
|
87
|
+
if (!resolvedAccounts.ataProgram.value) {
|
88
|
+
resolvedAccounts.ataProgram.value = context.programs.getPublicKey('splAssociatedToken', 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL');
|
89
|
+
resolvedAccounts.ataProgram.isWritable = false;
|
90
|
+
}
|
82
91
|
if (!resolvedAccounts.rent.value) {
|
83
92
|
resolvedAccounts.rent.value = (0, umi_1.publicKey)('SysvarRent111111111111111111111111111111111');
|
84
93
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,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,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/C,mBAAmB,EAAE,MAAM,EAC3B,kBAAkB,EAAE,kBAAkB,GACrC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAgDA;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAKR;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKzE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE"}
|
@@ -73,15 +73,17 @@ function getSolautoFeesBps(isReferred, targetLiqUtilizationRateBps, positionNetW
|
|
73
73
|
const maxFeeBps = 200; // Fee in basis points for minSize (2%)
|
74
74
|
const minFeeBps = 50; // Fee in basis points for maxSize (0.5%)
|
75
75
|
const k = 1.5;
|
76
|
-
if (targetLiqUtilizationRateBps !== undefined &&
|
76
|
+
if (targetLiqUtilizationRateBps !== undefined &&
|
77
|
+
targetLiqUtilizationRateBps === 0) {
|
77
78
|
return {
|
78
79
|
solauto: 0,
|
79
80
|
referrer: 0,
|
80
|
-
total: 0
|
81
|
+
total: 0,
|
81
82
|
};
|
82
83
|
}
|
83
84
|
let feeBps = 0;
|
84
|
-
if (targetLiqUtilizationRateBps !== undefined ||
|
85
|
+
if (targetLiqUtilizationRateBps !== undefined ||
|
86
|
+
rebalanceDirection === generated_1.RebalanceDirection.Repay) {
|
85
87
|
feeBps = 25;
|
86
88
|
}
|
87
89
|
else if (positionNetWorthUsd <= minSize) {
|
@@ -106,7 +108,8 @@ function getSolautoFeesBps(isReferred, targetLiqUtilizationRateBps, positionNetW
|
|
106
108
|
};
|
107
109
|
}
|
108
110
|
function getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, offsetFromMaxLtv) {
|
109
|
-
return toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) -
|
111
|
+
return (toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) -
|
112
|
+
1); // -1 to account for any rounding issues
|
110
113
|
}
|
111
114
|
function maxRepayFromBps(maxLtvBps, liqThresholdBps) {
|
112
115
|
return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.01));
|
package/package.json
CHANGED
@@ -33,6 +33,7 @@ export type ClaimReferralFeesInstructionAccounts = {
|
|
33
33
|
signerWsolTa?: PublicKey | Pda;
|
34
34
|
systemProgram?: PublicKey | Pda;
|
35
35
|
tokenProgram?: PublicKey | Pda;
|
36
|
+
ataProgram?: PublicKey | Pda;
|
36
37
|
rent?: PublicKey | Pda;
|
37
38
|
referralState: PublicKey | Pda;
|
38
39
|
referralFeesDestTa: PublicKey | Pda;
|
@@ -98,29 +99,34 @@ export function claimReferralFees(
|
|
98
99
|
isWritable: false as boolean,
|
99
100
|
value: input.tokenProgram ?? null,
|
100
101
|
},
|
101
|
-
|
102
|
+
ataProgram: {
|
103
|
+
index: 4,
|
104
|
+
isWritable: false as boolean,
|
105
|
+
value: input.ataProgram ?? null,
|
106
|
+
},
|
107
|
+
rent: { index: 5, isWritable: false as boolean, value: input.rent ?? null },
|
102
108
|
referralState: {
|
103
|
-
index:
|
109
|
+
index: 6,
|
104
110
|
isWritable: false as boolean,
|
105
111
|
value: input.referralState ?? null,
|
106
112
|
},
|
107
113
|
referralFeesDestTa: {
|
108
|
-
index:
|
114
|
+
index: 7,
|
109
115
|
isWritable: true as boolean,
|
110
116
|
value: input.referralFeesDestTa ?? null,
|
111
117
|
},
|
112
118
|
referralFeesDestMint: {
|
113
|
-
index:
|
119
|
+
index: 8,
|
114
120
|
isWritable: false as boolean,
|
115
121
|
value: input.referralFeesDestMint ?? null,
|
116
122
|
},
|
117
123
|
referralAuthority: {
|
118
|
-
index:
|
124
|
+
index: 9,
|
119
125
|
isWritable: true as boolean,
|
120
126
|
value: input.referralAuthority ?? null,
|
121
127
|
},
|
122
128
|
feesDestinationTa: {
|
123
|
-
index:
|
129
|
+
index: 10,
|
124
130
|
isWritable: true as boolean,
|
125
131
|
value: input.feesDestinationTa ?? null,
|
126
132
|
},
|
@@ -141,6 +147,13 @@ export function claimReferralFees(
|
|
141
147
|
);
|
142
148
|
resolvedAccounts.tokenProgram.isWritable = false;
|
143
149
|
}
|
150
|
+
if (!resolvedAccounts.ataProgram.value) {
|
151
|
+
resolvedAccounts.ataProgram.value = context.programs.getPublicKey(
|
152
|
+
'splAssociatedToken',
|
153
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'
|
154
|
+
);
|
155
|
+
resolvedAccounts.ataProgram.isWritable = false;
|
156
|
+
}
|
144
157
|
if (!resolvedAccounts.rent.value) {
|
145
158
|
resolvedAccounts.rent.value = publicKey(
|
146
159
|
'SysvarRent111111111111111111111111111111111'
|
package/src/utils/numberUtils.ts
CHANGED
@@ -103,17 +103,23 @@ export function getSolautoFeesBps(
|
|
103
103
|
const minFeeBps = 50; // Fee in basis points for maxSize (0.5%)
|
104
104
|
const k = 1.5;
|
105
105
|
|
106
|
-
if (
|
106
|
+
if (
|
107
|
+
targetLiqUtilizationRateBps !== undefined &&
|
108
|
+
targetLiqUtilizationRateBps === 0
|
109
|
+
) {
|
107
110
|
return {
|
108
111
|
solauto: 0,
|
109
112
|
referrer: 0,
|
110
|
-
total: 0
|
111
|
-
}
|
113
|
+
total: 0,
|
114
|
+
};
|
112
115
|
}
|
113
116
|
|
114
117
|
let feeBps: number = 0;
|
115
118
|
|
116
|
-
if (
|
119
|
+
if (
|
120
|
+
targetLiqUtilizationRateBps !== undefined ||
|
121
|
+
rebalanceDirection === RebalanceDirection.Repay
|
122
|
+
) {
|
117
123
|
feeBps = 25;
|
118
124
|
} else if (positionNetWorthUsd <= minSize) {
|
119
125
|
feeBps = maxFeeBps;
|
@@ -123,7 +129,9 @@ export function getSolautoFeesBps(
|
|
123
129
|
const t =
|
124
130
|
(Math.log(positionNetWorthUsd) - Math.log(minSize)) /
|
125
131
|
(Math.log(maxSize) - Math.log(minSize));
|
126
|
-
feeBps = Math.round(
|
132
|
+
feeBps = Math.round(
|
133
|
+
minFeeBps + (maxFeeBps - minFeeBps) * (1 - Math.pow(t, k))
|
134
|
+
);
|
127
135
|
}
|
128
136
|
|
129
137
|
let referrer = 0;
|
@@ -143,7 +151,10 @@ export function getMaxLiqUtilizationRateBps(
|
|
143
151
|
liqThresholdBps: number,
|
144
152
|
offsetFromMaxLtv: number
|
145
153
|
): number {
|
146
|
-
return
|
154
|
+
return (
|
155
|
+
toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) -
|
156
|
+
1
|
157
|
+
); // -1 to account for any rounding issues
|
147
158
|
}
|
148
159
|
|
149
160
|
export function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number) {
|
@@ -165,4 +176,4 @@ export function maxBoostToBps(maxLtvBps: number, liqThresholdBps: number) {
|
|
165
176
|
maxRepayToBps(maxLtvBps, liqThresholdBps),
|
166
177
|
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01)
|
167
178
|
);
|
168
|
-
}
|
179
|
+
}
|