@kamino-finance/klend-sdk 5.2.14 → 5.4.0
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/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +1 -2
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +2 -4
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +29 -20
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +1 -2
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +7 -20
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/reserve.js +14 -14
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +2 -2
- package/dist/classes/shared.d.ts.map +1 -1
- package/dist/classes/vault.d.ts +2 -4
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +7 -15
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.js +7 -3
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +310 -48
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +48 -3
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +35 -8
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.d.ts +30 -0
- package/dist/idl_codegen/accounts/Obligation.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.js +23 -2
- package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
- package/dist/idl_codegen/accounts/Reserve.js +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +33 -1
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +57 -1
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +7 -3
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +7 -3
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts +2 -5
- package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/initReferrerTokenState.js +3 -32
- package/dist/idl_codegen/instructions/initReferrerTokenState.js.map +1 -1
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.d.ts +12 -0
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.js +47 -0
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.js.map +1 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts +38 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js +159 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/types/ReserveConfig.d.ts +78 -20
- package/dist/idl_codegen/types/ReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen/types/ReserveConfig.js +45 -14
- package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
- package/dist/idl_codegen/types/ReserveLiquidity.d.ts +16 -16
- package/dist/idl_codegen/types/ReserveLiquidity.d.ts.map +1 -1
- package/dist/idl_codegen/types/ReserveLiquidity.js +16 -16
- package/dist/idl_codegen/types/ReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts +40 -14
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.js +71 -23
- package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +37 -11
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +64 -16
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +4 -4
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen/types/index.js.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +4 -0
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.js +10 -0
- package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
- package/dist/pyth/accounts/PriceUpdateV2.d.ts +30 -0
- package/dist/pyth/accounts/PriceUpdateV2.d.ts.map +1 -0
- package/dist/pyth/accounts/PriceUpdateV2.js +104 -0
- package/dist/pyth/accounts/PriceUpdateV2.js.map +1 -0
- package/dist/pyth/accounts/index.d.ts +3 -0
- package/dist/pyth/accounts/index.d.ts.map +1 -0
- package/dist/pyth/accounts/index.js +6 -0
- package/dist/pyth/accounts/index.js.map +1 -0
- package/dist/pyth/types/PriceFeedMessage.d.ts +58 -0
- package/dist/pyth/types/PriceFeedMessage.d.ts.map +1 -0
- package/dist/pyth/types/PriceFeedMessage.js +118 -0
- package/dist/pyth/types/PriceFeedMessage.js.map +1 -0
- package/dist/pyth/types/VerificationLevel.d.ts +45 -0
- package/dist/pyth/types/VerificationLevel.d.ts.map +1 -0
- package/dist/pyth/types/VerificationLevel.js +105 -0
- package/dist/pyth/types/VerificationLevel.js.map +1 -0
- package/dist/pyth/types/index.d.ts +7 -0
- package/dist/pyth/types/index.d.ts.map +1 -0
- package/dist/pyth/types/index.js +31 -0
- package/dist/pyth/types/index.js.map +1 -0
- package/dist/referrals/instructions.d.ts.map +1 -1
- package/dist/referrals/instructions.js +1 -2
- package/dist/referrals/instructions.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +5 -4
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/oracle.d.ts.map +1 -1
- package/dist/utils/oracle.js +9 -14
- package/dist/utils/oracle.js.map +1 -1
- package/dist/utils/rpc.d.ts +2 -1
- package/dist/utils/rpc.d.ts.map +1 -1
- package/dist/utils/rpc.js +8 -6
- package/dist/utils/rpc.js.map +1 -1
- package/package.json +5 -6
- package/src/classes/action.ts +1 -3
- package/src/classes/manager.ts +39 -19
- package/src/classes/market.ts +8 -21
- package/src/classes/reserve.ts +16 -16
- package/src/classes/shared.ts +2 -2
- package/src/classes/vault.ts +10 -14
- package/src/client_kamino_manager.ts +7 -3
- package/src/idl_codegen/accounts/LendingMarket.ts +76 -13
- package/src/idl_codegen/accounts/Obligation.ts +47 -2
- package/src/idl_codegen/accounts/Reserve.ts +1 -1
- package/src/idl_codegen/errors/custom.ts +56 -0
- package/src/idl_codegen/instructions/index.ts +13 -6
- package/src/idl_codegen/instructions/initReferrerTokenState.ts +3 -15
- package/src/idl_codegen/instructions/markObligationForDeleveraging.ts +40 -0
- package/src/idl_codegen/instructions/repayAndWithdrawAndRedeem.ts +177 -0
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +1 -1
- package/src/idl_codegen/programId.ts +1 -1
- package/src/idl_codegen/types/ReserveConfig.ts +100 -28
- package/src/idl_codegen/types/ReserveLiquidity.ts +25 -24
- package/src/idl_codegen/types/UpdateConfigMode.ts +86 -26
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +77 -17
- package/src/idl_codegen/types/index.ts +14 -6
- package/src/idl_codegen/zero_padding/ObligationZP.ts +10 -0
- package/src/pyth/accounts/PriceUpdateV2.ts +110 -0
- package/src/pyth/accounts/index.ts +2 -0
- package/src/pyth/types/PriceFeedMessage.ts +120 -0
- package/src/pyth/types/VerificationLevel.ts +98 -0
- package/src/pyth/types/index.ts +9 -0
- package/src/referrals/instructions.ts +1 -3
- package/src/utils/managerTypes.ts +5 -5
- package/src/utils/oracle.ts +9 -15
- package/src/utils/rpc.ts +8 -5
package/src/utils/oracle.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { parsePriceData } from '@pythnetwork/client';
|
|
2
1
|
import { AccountInfo, Connection, PublicKey } from '@solana/web3.js';
|
|
3
2
|
import Decimal from 'decimal.js';
|
|
4
3
|
import { OraclePrices, Scope } from '@kamino-finance/scope-sdk';
|
|
@@ -8,6 +7,7 @@ import SwitchboardProgram from '@switchboard-xyz/sbv2-lite';
|
|
|
8
7
|
import { Reserve } from '../lib';
|
|
9
8
|
import { batchFetch } from '@kamino-finance/kliquidity-sdk';
|
|
10
9
|
import BN from 'bn.js';
|
|
10
|
+
import { PriceUpdateV2 } from '../pyth/accounts';
|
|
11
11
|
|
|
12
12
|
const SWITCHBOARD_V2_PROGRAM_ID = new PublicKey('SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f');
|
|
13
13
|
|
|
@@ -166,27 +166,21 @@ export function cacheOrGetPythPrices(
|
|
|
166
166
|
const result = oracleAccounts.get(oracle);
|
|
167
167
|
if (result) {
|
|
168
168
|
try {
|
|
169
|
-
const {
|
|
170
|
-
|
|
171
|
-
);
|
|
169
|
+
const { priceMessage } = PriceUpdateV2.decode(result.data);
|
|
170
|
+
const { price, exponent, conf: confidence, publishTime: timestamp, emaPrice } = priceMessage;
|
|
172
171
|
if (price) {
|
|
173
|
-
const px = new Decimal(price);
|
|
172
|
+
const px = new Decimal(price.toString()).div(10 ** Math.abs(exponent));
|
|
174
173
|
prices.spot = {
|
|
175
174
|
price: px,
|
|
176
|
-
timestamp,
|
|
177
|
-
valid: validatePythPx(px, confidence),
|
|
178
|
-
};
|
|
179
|
-
} else {
|
|
180
|
-
prices.spot = {
|
|
181
|
-
price: new Decimal(previousPrice),
|
|
182
|
-
timestamp: previousTimestamp,
|
|
183
|
-
valid: false,
|
|
175
|
+
timestamp: BigInt(timestamp.toString()),
|
|
176
|
+
valid: validatePythPx(px, confidence.toNumber()),
|
|
184
177
|
};
|
|
185
178
|
}
|
|
186
179
|
if (emaPrice !== undefined && emaPrice !== null) {
|
|
180
|
+
const emaPx = new Decimal(emaPrice.toString()).div(10 ** Math.abs(exponent));
|
|
187
181
|
prices.twap = {
|
|
188
|
-
price:
|
|
189
|
-
timestamp,
|
|
182
|
+
price: emaPx,
|
|
183
|
+
timestamp: BigInt(timestamp.toString()),
|
|
190
184
|
valid: true,
|
|
191
185
|
};
|
|
192
186
|
}
|
package/src/utils/rpc.ts
CHANGED
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
} from '@solana/web3.js';
|
|
10
10
|
import { Buffer } from 'buffer';
|
|
11
11
|
import axios from 'axios';
|
|
12
|
-
import { init, decompress } from '@bokuweb/zstd-wasm';
|
|
13
12
|
import { v4 as uuidv4 } from 'uuid';
|
|
13
|
+
import { ZSTDDecoder } from 'zstddec';
|
|
14
14
|
|
|
15
|
+
const decoder = new ZSTDDecoder();
|
|
15
16
|
(async () => {
|
|
16
|
-
await init();
|
|
17
|
+
await decoder.init();
|
|
17
18
|
})();
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -21,11 +22,13 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
21
22
|
* Uses axios instead of node-fetch to work around a bug in node-fetch that causes subsequent requests with different encoding to fail
|
|
22
23
|
* @param connection
|
|
23
24
|
* @param programId
|
|
25
|
+
* @param structSize - the size of the decompressed account data struct
|
|
24
26
|
* @param configOrCommitment
|
|
25
27
|
*/
|
|
26
28
|
export async function getProgramAccounts(
|
|
27
29
|
connection: Connection,
|
|
28
30
|
programId: PublicKey,
|
|
31
|
+
structSize: number,
|
|
29
32
|
configOrCommitment?: GetProgramAccountsConfig | Commitment
|
|
30
33
|
): Promise<GetProgramAccountsResponse> {
|
|
31
34
|
const programIdStr = programId.toBase58();
|
|
@@ -65,7 +68,7 @@ export async function getProgramAccounts(
|
|
|
65
68
|
|
|
66
69
|
const res = unsafeRes as RpcResult;
|
|
67
70
|
const deser = res.result.map(async (account) => ({
|
|
68
|
-
account: await deserializeAccountInfo(account.account),
|
|
71
|
+
account: await deserializeAccountInfo(account.account, structSize),
|
|
69
72
|
pubkey: new PublicKey(account.pubkey),
|
|
70
73
|
}));
|
|
71
74
|
const x = await Promise.all(deser);
|
|
@@ -80,8 +83,8 @@ export async function getAccountOwner(connection: Connection, address: PublicKey
|
|
|
80
83
|
return acc.owner;
|
|
81
84
|
}
|
|
82
85
|
|
|
83
|
-
async function deserializeAccountInfo(accountInfo: AccountInfo<string[]
|
|
84
|
-
const data =
|
|
86
|
+
async function deserializeAccountInfo(accountInfo: AccountInfo<string[]>, size: number): Promise<AccountInfo<Buffer>> {
|
|
87
|
+
const data = decoder.decode(Buffer.from(accountInfo.data[0], 'base64'), size);
|
|
85
88
|
return {
|
|
86
89
|
owner: accountInfo.owner,
|
|
87
90
|
lamports: accountInfo.lamports,
|