@haven-fi/solauto-sdk 1.0.225 → 1.0.227

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,CAmGpB"}
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
- rent: { index: 4, isWritable: false, value: input.rent ?? null },
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: 5,
53
+ index: 6,
49
54
  isWritable: false,
50
55
  value: input.referralState ?? null,
51
56
  },
52
57
  referralFeesDestTa: {
53
- index: 6,
58
+ index: 7,
54
59
  isWritable: true,
55
60
  value: input.referralFeesDestTa ?? null,
56
61
  },
57
62
  referralFeesDestMint: {
58
- index: 7,
63
+ index: 8,
59
64
  isWritable: false,
60
65
  value: input.referralFeesDestMint ?? null,
61
66
  },
62
67
  referralAuthority: {
63
- index: 8,
68
+ index: 9,
64
69
  isWritable: true,
65
70
  value: input.referralAuthority ?? null,
66
71
  },
67
72
  feesDestinationTa: {
68
- index: 9,
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 @@
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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,8 +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 &&
77
+ targetLiqUtilizationRateBps === 0) {
78
+ return {
79
+ solauto: 0,
80
+ referrer: 0,
81
+ total: 0,
82
+ };
83
+ }
76
84
  let feeBps = 0;
77
- if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === generated_1.RebalanceDirection.Repay) {
85
+ if (targetLiqUtilizationRateBps !== undefined ||
86
+ rebalanceDirection === generated_1.RebalanceDirection.Repay) {
78
87
  feeBps = 25;
79
88
  }
80
89
  else if (positionNetWorthUsd <= minSize) {
@@ -99,7 +108,8 @@ function getSolautoFeesBps(isReferred, targetLiqUtilizationRateBps, positionNetW
99
108
  };
100
109
  }
101
110
  function getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, offsetFromMaxLtv) {
102
- return toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) - 1; // -1 to account for any rounding issues
111
+ return (toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) -
112
+ 1); // -1 to account for any rounding issues
103
113
  }
104
114
  function maxRepayFromBps(maxLtvBps, liqThresholdBps) {
105
115
  return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.01));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.225",
3
+ "version": "1.0.227",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -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
- rent: { index: 4, isWritable: false as boolean, value: input.rent ?? null },
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: 5,
109
+ index: 6,
104
110
  isWritable: false as boolean,
105
111
  value: input.referralState ?? null,
106
112
  },
107
113
  referralFeesDestTa: {
108
- index: 6,
114
+ index: 7,
109
115
  isWritable: true as boolean,
110
116
  value: input.referralFeesDestTa ?? null,
111
117
  },
112
118
  referralFeesDestMint: {
113
- index: 7,
119
+ index: 8,
114
120
  isWritable: false as boolean,
115
121
  value: input.referralFeesDestMint ?? null,
116
122
  },
117
123
  referralAuthority: {
118
- index: 8,
124
+ index: 9,
119
125
  isWritable: true as boolean,
120
126
  value: input.referralAuthority ?? null,
121
127
  },
122
128
  feesDestinationTa: {
123
- index: 9,
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'
@@ -103,9 +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 (
107
+ targetLiqUtilizationRateBps !== undefined &&
108
+ targetLiqUtilizationRateBps === 0
109
+ ) {
110
+ return {
111
+ solauto: 0,
112
+ referrer: 0,
113
+ total: 0,
114
+ };
115
+ }
116
+
106
117
  let feeBps: number = 0;
107
118
 
108
- if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === RebalanceDirection.Repay) {
119
+ if (
120
+ targetLiqUtilizationRateBps !== undefined ||
121
+ rebalanceDirection === RebalanceDirection.Repay
122
+ ) {
109
123
  feeBps = 25;
110
124
  } else if (positionNetWorthUsd <= minSize) {
111
125
  feeBps = maxFeeBps;
@@ -115,7 +129,9 @@ export function getSolautoFeesBps(
115
129
  const t =
116
130
  (Math.log(positionNetWorthUsd) - Math.log(minSize)) /
117
131
  (Math.log(maxSize) - Math.log(minSize));
118
- feeBps = Math.round(minFeeBps + (maxFeeBps - minFeeBps) * (1 - Math.pow(t, k)));
132
+ feeBps = Math.round(
133
+ minFeeBps + (maxFeeBps - minFeeBps) * (1 - Math.pow(t, k))
134
+ );
119
135
  }
120
136
 
121
137
  let referrer = 0;
@@ -135,7 +151,10 @@ export function getMaxLiqUtilizationRateBps(
135
151
  liqThresholdBps: number,
136
152
  offsetFromMaxLtv: number
137
153
  ): number {
138
- return toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) - 1; // -1 to account for any rounding issues
154
+ return (
155
+ toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) -
156
+ 1
157
+ ); // -1 to account for any rounding issues
139
158
  }
140
159
 
141
160
  export function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number) {
@@ -157,4 +176,4 @@ export function maxBoostToBps(maxLtvBps: number, liqThresholdBps: number) {
157
176
  maxRepayToBps(maxLtvBps, liqThresholdBps),
158
177
  getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01)
159
178
  );
160
- }
179
+ }