@haven-fi/solauto-sdk 1.0.56 → 1.0.58

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,4 +4,5 @@ export declare const TOKEN_DECIMALS: {
4
4
  [x: string]: number;
5
5
  EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: number;
6
6
  };
7
+ export declare const STABLECOINS: string[];
7
8
  //# sourceMappingURL=tokenConstants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,iDAAiD,CAAC;AAGxE,eAAO,MAAM,oBAAoB,UAGhC,CAAC;AAEF,eAAO,MAAM,cAAc;;;CAG1B,CAAC"}
1
+ {"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,iDAAiD,CAAC;AAGxE,eAAO,MAAM,oBAAoB,UAGhC,CAAC;AAEF,eAAO,MAAM,cAAc;;;CAG1B,CAAC;AAEF,eAAO,MAAM,WAAW,UAEvB,CAAC"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TOKEN_DECIMALS = exports.ALL_SUPPORTED_TOKENS = exports.USDC_MINT = void 0;
3
+ exports.STABLECOINS = exports.TOKEN_DECIMALS = exports.ALL_SUPPORTED_TOKENS = exports.USDC_MINT = void 0;
4
4
  const spl_token_1 = require("@solana/spl-token");
5
+ // When adding token ensure a price feed is provided in pythConstants.ts & the token is added to the necessary lists below
5
6
  exports.USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
6
- // When adding token ensure a price feed is provided in pythConstants.ts
7
7
  exports.ALL_SUPPORTED_TOKENS = [
8
8
  spl_token_1.NATIVE_MINT.toString(),
9
9
  exports.USDC_MINT,
@@ -12,3 +12,6 @@ exports.TOKEN_DECIMALS = {
12
12
  [spl_token_1.NATIVE_MINT.toString()]: 9,
13
13
  [exports.USDC_MINT]: 6
14
14
  };
15
+ exports.STABLECOINS = [
16
+ exports.USDC_MINT
17
+ ];
@@ -12,6 +12,6 @@ export declare function closeTokenAccountUmiIx(signer: Signer, tokenAccount: Pub
12
12
  export declare function splTokenTransferUmiIx(signer: Signer, fromTa: PublicKey, toTa: PublicKey, authority: PublicKey, amount: bigint): WrappedInstruction;
13
13
  export declare function getAdressLookupInputs(umi: Umi, lookupTableAddresses: string[]): Promise<AddressLookupTableInput[]>;
14
14
  export declare function assembleFinalTransaction(signer: Signer, tx: TransactionBuilder, computeUnitPrice: number, computeUnitLimit?: number): TransactionBuilder;
15
- export declare function getComputeUnitPriceEstimate(umi: Umi, tx: TransactionBuilder, prioritySetting: PriorityFeeSetting, attemptNum?: number): Promise<number>;
15
+ export declare function getComputeUnitPriceEstimate(umi: Umi, tx: TransactionBuilder, prioritySetting: PriorityFeeSetting): Promise<number>;
16
16
  export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder, simulateOnly?: boolean, attemptNum?: number, prioritySetting?: PriorityFeeSetting): Promise<Uint8Array | undefined>;
17
17
  //# sourceMappingURL=solanaUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,GAAG,EACH,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAGL,UAAU,EACV,SAAS,EAIT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAO9E;AAED,wBAAsB,wBAAwB,CAAC,GAAG,EA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f,kBAAkB,CASpB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,SAAS,EACvB,SAAS,EAAE,SAAS,GACnB,kBAAkB,CAKpB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,GACb,kBAAkB,CAKpB;AAED,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,GAAG,EACR,oBAAoB,EAAE,MAAM,EAAE,GAC7B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkBpC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,kBAAkB,EACtB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,CAAC,EAAE,MAAM,sBA4D1B;AAmBD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,GAClC,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,YAAY,CAAC,EAAE,OAAO,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,eAAe,GAAE,kBAA+C,GAC/D,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAmDjC"}
@@ -140,7 +140,7 @@ async function simulateTransaction(connection, transaction) {
140
140
  }
141
141
  return simulationResult;
142
142
  }
143
- async function getComputeUnitPriceEstimate(umi, tx, prioritySetting, attemptNum) {
143
+ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting) {
144
144
  const web3Transaction = (0, umi_web3js_adapters_1.toWeb3JsTransaction)((await tx.setLatestBlockhash(umi, { commitment: "finalized" })).build(umi));
145
145
  const serializedTransaction = bs58_1.default.encode(web3Transaction.serialize());
146
146
  const resp = await umi.rpc.call("getPriorityFeeEstimate", [
@@ -158,7 +158,7 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, simulateOnly,
158
158
  console.log("Sending single optimized transaction...");
159
159
  console.log("Instructions: ", tx.getInstructions().length);
160
160
  console.log("Serialized transaction size: ", tx.getTransactionSize(umi));
161
- const feeEstimate = await getComputeUnitPriceEstimate(umi, tx, prioritySetting, attemptNum);
161
+ const feeEstimate = await getComputeUnitPriceEstimate(umi, tx, prioritySetting);
162
162
  console.log("Compute unit price: ", feeEstimate);
163
163
  const simulationResult = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await simulateTransaction(connection, (0, umi_web3js_adapters_1.toWeb3JsTransaction)(await (await assembleFinalTransaction(umi.identity, tx, feeEstimate, 1400000).setLatestBlockhash(umi)).build(umi))));
164
164
  const computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.1);
@@ -17,7 +17,7 @@ export declare function getSolautoManagedPositions(umi: Umi, authority?: PublicK
17
17
  export declare function getAllReferralStates(umi: Umi): Promise<PublicKey[]>;
18
18
  export declare function getReferralsByUser(umi: Umi, user: PublicKey): Promise<PublicKey[]>;
19
19
  export declare function getAllPositionsByAuthority(umi: Umi, user: PublicKey): Promise<SolautoPositionDetails[]>;
20
- export declare function positionStateWithLatestPrices(umi: Umi, state: PositionState, protocolAccount: PublicKey, lendingPlatform: LendingPlatform): Promise<PositionState | undefined>;
20
+ export declare function positionStateWithPrices(umi: Umi, state: PositionState, protocolAccount: PublicKey, lendingPlatform: LendingPlatform, supplyPrice?: number, debtPrice?: number): Promise<PositionState | undefined>;
21
21
  type PositionAdjustment = {
22
22
  type: "supply";
23
23
  value: bigint;
@@ -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,EAAoB,GAAG,EAAE,MA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AkB,CACtC,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,SAAS,EAAE,CAAC,CA2BtB;AAED,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAuCnC;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,aAAa,EACpB,eAAe,EAAE,SAAS,EAC1B,eAAe,EAAE,eAAe,EAChC,WAAW,CAAC,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAqDpC;AAED,KAAK,kBAAkB,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,gCAAgC,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE/C,qBAAa,mBAAmB;IACvB,gBAAgB,EAAE,MAAM,CAAa;IACrC,cAAc,EAAE,MAAM,CAAa;IACnC,uBAAuB,EAAE,MAAM,CAAa;IAC5C,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAa;IAC5D,SAAS,EAAE,WAAW,GAAG,SAAS,CAAa;IAEtD,GAAG,CAAC,MAAM,EAAE,kBAAkB;IAyD9B,KAAK;IAQL,UAAU,IAAI,OAAO;CAQtB"}
@@ -12,7 +12,7 @@ exports.getSolautoManagedPositions = getSolautoManagedPositions;
12
12
  exports.getAllReferralStates = getAllReferralStates;
13
13
  exports.getReferralsByUser = getReferralsByUser;
14
14
  exports.getAllPositionsByAuthority = getAllPositionsByAuthority;
15
- exports.positionStateWithLatestPrices = positionStateWithLatestPrices;
15
+ exports.positionStateWithPrices = positionStateWithPrices;
16
16
  const web3_js_1 = require("@solana/web3.js");
17
17
  const umi_1 = require("@metaplex-foundation/umi");
18
18
  const generated_1 = require("../../generated");
@@ -211,7 +211,7 @@ async function getAllPositionsByAuthority(umi, user) {
211
211
  // TODO support other platforms
212
212
  return allPositions;
213
213
  }
214
- async function positionStateWithLatestPrices(umi, state, protocolAccount, lendingPlatform) {
214
+ async function positionStateWithPrices(umi, state, protocolAccount, lendingPlatform, supplyPrice, debtPrice) {
215
215
  if ((0, generalUtils_1.currentUnixSeconds)() - Number(state.lastUpdated) > 60 * 60 * 24 * 7) {
216
216
  if (lendingPlatform === generated_1.LendingPlatform.Marginfi) {
217
217
  return await (0, marginfiUtils_1.getMarginfiAccountPositionState)(umi, protocolAccount, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.supply.mint), (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.debt.mint));
@@ -220,10 +220,12 @@ async function positionStateWithLatestPrices(umi, state, protocolAccount, lendin
220
220
  throw new Error("Lending platorm not yet supported");
221
221
  }
222
222
  }
223
- const [supplyPrice, debtPrice] = await (0, generalUtils_1.getTokenPrices)([
224
- (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.supply.mint),
225
- (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.debt.mint),
226
- ]);
223
+ if (!supplyPrice || !debtPrice) {
224
+ [supplyPrice, debtPrice] = await (0, generalUtils_1.getTokenPrices)([
225
+ (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.supply.mint),
226
+ (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.debt.mint),
227
+ ]);
228
+ }
227
229
  const supplyUsd = (0, numberUtils_1.fromBaseUnit)(state.supply.amountUsed.baseUnit, state.supply.decimals) *
228
230
  supplyPrice;
229
231
  const debtUsd = (0, numberUtils_1.fromBaseUnit)(state.debt.amountUsed.baseUnit, state.debt.decimals) *
@@ -186,7 +186,7 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
186
186
  inputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint),
187
187
  outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint),
188
188
  destinationWallet: client.solautoPosition,
189
- slippageBpsIncFactor: (attemptNum ?? 0) * 0.2,
189
+ slippageBpsIncFactor: 0.25 + ((attemptNum ?? 0) * 0.2),
190
190
  amount: rebalancingToZero
191
191
  ? client.solautoPositionState.debt.amountUsed.baseUnit +
192
192
  BigInt(Math.round(Number(client.solautoPositionState.debt.amountUsed.baseUnit) *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.56",
3
+ "version": "1.0.58",
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",
@@ -1,8 +1,9 @@
1
1
  import { NATIVE_MINT } from "@solana/spl-token";
2
2
 
3
+ // When adding token ensure a price feed is provided in pythConstants.ts & the token is added to the necessary lists below
3
4
  export const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
4
5
 
5
- // When adding token ensure a price feed is provided in pythConstants.ts
6
+
6
7
  export const ALL_SUPPORTED_TOKENS = [
7
8
  NATIVE_MINT.toString(),
8
9
  USDC_MINT,
@@ -11,4 +12,8 @@ export const ALL_SUPPORTED_TOKENS = [
11
12
  export const TOKEN_DECIMALS = {
12
13
  [NATIVE_MINT.toString()]: 9,
13
14
  [USDC_MINT]: 6
14
- };
15
+ };
16
+
17
+ export const STABLECOINS = [
18
+ USDC_MINT
19
+ ];
@@ -257,7 +257,6 @@ export async function getComputeUnitPriceEstimate(
257
257
  umi: Umi,
258
258
  tx: TransactionBuilder,
259
259
  prioritySetting: PriorityFeeSetting,
260
- attemptNum?: number,
261
260
  ): Promise<number> {
262
261
  const web3Transaction = toWeb3JsTransaction(
263
262
  (await tx.setLatestBlockhash(umi, { commitment: "finalized" })).build(umi)
@@ -288,7 +287,7 @@ export async function sendSingleOptimizedTransaction(
288
287
  console.log("Instructions: ", tx.getInstructions().length);
289
288
  console.log("Serialized transaction size: ", tx.getTransactionSize(umi));
290
289
 
291
- const feeEstimate = await getComputeUnitPriceEstimate(umi, tx, prioritySetting, attemptNum);
290
+ const feeEstimate = await getComputeUnitPriceEstimate(umi, tx, prioritySetting);
292
291
  console.log("Compute unit price: ", feeEstimate);
293
292
 
294
293
  const simulationResult = await retryWithExponentialBackoff(
@@ -319,11 +319,13 @@ export async function getAllPositionsByAuthority(
319
319
  return allPositions;
320
320
  }
321
321
 
322
- export async function positionStateWithLatestPrices(
322
+ export async function positionStateWithPrices(
323
323
  umi: Umi,
324
324
  state: PositionState,
325
325
  protocolAccount: PublicKey,
326
- lendingPlatform: LendingPlatform
326
+ lendingPlatform: LendingPlatform,
327
+ supplyPrice?: number,
328
+ debtPrice?: number
327
329
  ): Promise<PositionState | undefined> {
328
330
  if (currentUnixSeconds() - Number(state.lastUpdated) > 60 * 60 * 24 * 7) {
329
331
  if (lendingPlatform === LendingPlatform.Marginfi) {
@@ -338,10 +340,12 @@ export async function positionStateWithLatestPrices(
338
340
  }
339
341
  }
340
342
 
341
- const [supplyPrice, debtPrice] = await getTokenPrices([
342
- toWeb3JsPublicKey(state.supply.mint),
343
- toWeb3JsPublicKey(state.debt.mint),
344
- ]);
343
+ if (!supplyPrice || !debtPrice) {
344
+ [supplyPrice, debtPrice] = await getTokenPrices([
345
+ toWeb3JsPublicKey(state.supply.mint),
346
+ toWeb3JsPublicKey(state.debt.mint),
347
+ ]);
348
+ }
345
349
 
346
350
  const supplyUsd =
347
351
  fromBaseUnit(state.supply.amountUsed.baseUnit, state.supply.decimals) *
@@ -342,7 +342,7 @@ export function getJupSwapRebalanceDetails(
342
342
  inputMint: toWeb3JsPublicKey(input.mint),
343
343
  outputMint: toWeb3JsPublicKey(output.mint),
344
344
  destinationWallet: client.solautoPosition,
345
- slippageBpsIncFactor: (attemptNum ?? 0) * 0.2,
345
+ slippageBpsIncFactor: 0.25 + ((attemptNum ?? 0) * 0.2),
346
346
  amount: rebalancingToZero
347
347
  ? client.solautoPositionState!.debt.amountUsed.baseUnit +
348
348
  BigInt(