@lavarage/sdk 7.5.21 → 8.0.1
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/constants.ts +6 -0
- package/crossbar.ts +53 -0
- package/dist/index.d.mts +5559 -1791
- package/dist/index.d.ts +5559 -1791
- package/dist/index.js +3502 -4975
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3301 -4772
- package/dist/index.mjs.map +1 -1
- package/docs/functions/borrowV1.html +1 -1
- package/docs/functions/borrowV2.html +1 -1
- package/docs/functions/closePositionEvm.html +2 -2
- package/docs/functions/closeTradeV1.html +2 -2
- package/docs/functions/closeTradeV2.html +2 -2
- package/docs/functions/createTpDelegate.html +2 -2
- package/docs/functions/getActiveLoanCountEvm.html +2 -2
- package/docs/functions/getActiveLoansBatchEvm.html +2 -2
- package/docs/functions/getAllPositions.html +2 -2
- package/docs/functions/getAvailableExposureEvm.html +2 -2
- package/docs/functions/getClosedPositions.html +2 -2
- package/docs/functions/getClosedPositionsEvm.html +2 -2
- package/docs/functions/getCollateralExposureEvm.html +2 -2
- package/docs/functions/getCollateralInfoEvm.html +2 -2
- package/docs/functions/getDelegateAccounts.html +2 -2
- package/docs/functions/getLiquidatedPositions.html +2 -2
- package/docs/functions/getLiquidatedPositionsEvm.html +2 -2
- package/docs/functions/getLoanEvm.html +2 -2
- package/docs/functions/getLoansByBorrowerEvm.html +2 -2
- package/docs/functions/getOffers.html +2 -2
- package/docs/functions/getOffersEvm.html +2 -2
- package/docs/functions/getOpenPositions.html +2 -2
- package/docs/functions/getOpeningFeeEvm.html +2 -2
- package/docs/functions/getPda.html +2 -2
- package/docs/functions/getPositionAccountPDA.html +2 -2
- package/docs/functions/getPositionsEvm.html +2 -2
- package/docs/functions/getProfitFeeEvm.html +2 -2
- package/docs/functions/getTokenBalanceEvm.html +2 -2
- package/docs/functions/getUserLoansEvm.html +2 -2
- package/docs/functions/lending.addToWithdrawalAccessList.html +1 -1
- package/docs/functions/lending.createOffer.html +2 -2
- package/docs/functions/lending.depositFunds.html +2 -2
- package/docs/functions/lending.getNodeWalletPDA.html +2 -2
- package/docs/functions/lending.getTradingPoolPDA.html +2 -2
- package/docs/functions/lending.getWithdrawalAccessList.html +1 -1
- package/docs/functions/lending.getWithdrawalAccessListPDA.html +1 -1
- package/docs/functions/lending.removeFromWithdrawalAccessList.html +1 -1
- package/docs/functions/lending.updateInterestRate.html +2 -2
- package/docs/functions/lending.updateMaxBorrow.html +2 -2
- package/docs/functions/lending.updateMaxExposure.html +2 -2
- package/docs/functions/lending.updateOffer.html +2 -2
- package/docs/functions/lending.withdrawFunds.html +2 -2
- package/docs/functions/lending.withdrawFundsV1.html +2 -2
- package/docs/functions/lending.withdrawFundsV2.html +2 -2
- package/docs/functions/liquidatePositionEvm.html +2 -2
- package/docs/functions/mergePositionV2.html +2 -2
- package/docs/functions/modifyTpDelegate.html +2 -2
- package/docs/functions/openPositionEvm.html +2 -2
- package/docs/functions/openTradeV1.html +2 -2
- package/docs/functions/openTradeV2.html +2 -2
- package/docs/functions/partialRepayV1.html +2 -2
- package/docs/functions/partialRepayV2.html +2 -2
- package/docs/functions/removeTpDelegate.html +2 -2
- package/docs/functions/splitPositionV2.html +2 -2
- package/docs/functions/updateMaxLendPerTokenBatchEvm.html +2 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +2 -2
- package/docs/modules/IDLV2.html +2 -2
- package/docs/modules/lending.html +1 -1
- package/docs/modules.html +2 -2
- package/docs/types/IDLV2.Lavarage.html +2 -2
- package/docs/types/Lavarage.html +2 -2
- package/docs/variables/IDL.html +1 -1
- package/docs/variables/IDLV2.IDL.html +1 -1
- package/idl/lavarageSOL.json +1852 -0
- package/idl/lavarageSOL.ts +1858 -0
- package/idl/lavarageUSDC.json +5377 -0
- package/idl/lavarageUSDC.ts +5383 -0
- package/idl/userVault.json +244 -0
- package/idl/userVault.ts +250 -0
- package/index.ts +81 -42
- package/lending.ts +225 -86
- package/package.json +6 -4
- package/switchboard.ts +23 -0
- package/tsconfig.json +2 -1
- package/utils.ts +54 -0
- package/idl/lavarage.ts +0 -3465
- package/idl/lavaragev2.ts +0 -3791
- package/idl/referralVault.ts +0 -276
package/constants.ts
ADDED
package/crossbar.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { NATIVE_MINT } from "@solana/spl-token";
|
|
2
|
+
import { USDC_MINT } from "./constants";
|
|
3
|
+
import { Program } from "@coral-xyz/anchor";
|
|
4
|
+
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
5
|
+
import { getQueue } from "@switchboard-xyz/on-demand";
|
|
6
|
+
import { CrossbarClient } from "@switchboard-xyz/common";
|
|
7
|
+
import { retryWithBackoff } from "./utils";
|
|
8
|
+
import { Lavarage as LavarageSOL } from "./idl/lavarageSOL";
|
|
9
|
+
import { Lavarage as LavarageUSDC } from "./idl/lavarageUSDC";
|
|
10
|
+
|
|
11
|
+
export type ApiKeys = {
|
|
12
|
+
birdeyeApiKey: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const SURGE_FEEDS = [
|
|
16
|
+
{
|
|
17
|
+
address: NATIVE_MINT.toBase58(),
|
|
18
|
+
feedId: '822512ee9add93518eca1c105a38422841a76c590db079eebb283deb2c14caa9',
|
|
19
|
+
label: 'SOL-USD',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
address: USDC_MINT.toBase58(),
|
|
23
|
+
feedId: '883ea8295f70ae506e894679d124196bb07064ea530cefd835b58c33a5ab6549',
|
|
24
|
+
label: 'USDC-USD',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// TODO: should not be hardcoded, use class-based approach
|
|
29
|
+
const crossbarClient = new CrossbarClient("https://crossbar.switchboard.xyz");
|
|
30
|
+
|
|
31
|
+
function getVariableOverrides(apiKeys: ApiKeys) {
|
|
32
|
+
return {
|
|
33
|
+
BIRDEYE_API_KEY: apiKeys.birdeyeApiKey,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function getUpdateOracleIxs(program: Program<LavarageSOL | LavarageUSDC>, feedId: string, payer: PublicKey, apiKeys: ApiKeys): Promise<TransactionInstruction[]> {
|
|
38
|
+
const queue = await getQueue({
|
|
39
|
+
// @ts-expect-error @coral-xyz/anchor versions mismatch
|
|
40
|
+
program,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return await retryWithBackoff(async () => await queue.fetchManagedUpdateIxs(
|
|
44
|
+
crossbarClient,
|
|
45
|
+
[feedId],
|
|
46
|
+
{
|
|
47
|
+
numSignatures: 1,
|
|
48
|
+
variableOverrides: getVariableOverrides(apiKeys),
|
|
49
|
+
instructionIdx: 0,
|
|
50
|
+
payer,
|
|
51
|
+
}
|
|
52
|
+
));
|
|
53
|
+
}
|