@exponent-labs/klend-idl 0.9.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/build/accounts/LendingMarket.d.ts +88 -0
- package/build/accounts/LendingMarket.js +225 -0
- package/build/accounts/LendingMarket.js.map +1 -0
- package/build/accounts/Obligation.d.ts +85 -0
- package/build/accounts/Obligation.js +217 -0
- package/build/accounts/Obligation.js.map +1 -0
- package/build/accounts/ReferrerState.d.ts +23 -0
- package/build/accounts/ReferrerState.js +85 -0
- package/build/accounts/ReferrerState.js.map +1 -0
- package/build/accounts/ReferrerTokenState.d.ts +36 -0
- package/build/accounts/ReferrerTokenState.js +116 -0
- package/build/accounts/ReferrerTokenState.js.map +1 -0
- package/build/accounts/Reserve.d.ts +61 -0
- package/build/accounts/Reserve.js +169 -0
- package/build/accounts/Reserve.js.map +1 -0
- package/build/accounts/ShortUrl.d.ts +23 -0
- package/build/accounts/ShortUrl.js +85 -0
- package/build/accounts/ShortUrl.js.map +1 -0
- package/build/accounts/UserMetadata.d.ts +36 -0
- package/build/accounts/UserMetadata.js +116 -0
- package/build/accounts/UserMetadata.js.map +1 -0
- package/build/accounts/UserState.d.ts +69 -0
- package/build/accounts/UserState.js +182 -0
- package/build/accounts/UserState.js.map +1 -0
- package/build/accounts/index.d.ts +16 -0
- package/build/accounts/index.js +20 -0
- package/build/accounts/index.js.map +1 -0
- package/build/errors/anchor.d.ts +434 -0
- package/build/errors/anchor.js +767 -0
- package/build/errors/anchor.js.map +1 -0
- package/build/errors/custom.d.ts +898 -0
- package/build/errors/custom.js +1580 -0
- package/build/errors/custom.js.map +1 -0
- package/build/errors/index.d.ts +5 -0
- package/build/errors/index.js +71 -0
- package/build/errors/index.js.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +34 -0
- package/build/index.js.map +1 -0
- package/build/instructions/borrowObligationLiquidity.d.ts +21 -0
- package/build/instructions/borrowObligationLiquidity.js +80 -0
- package/build/instructions/borrowObligationLiquidity.js.map +1 -0
- package/build/instructions/borrowObligationLiquidityV2.d.ts +28 -0
- package/build/instructions/borrowObligationLiquidityV2.js +90 -0
- package/build/instructions/borrowObligationLiquidityV2.js.map +1 -0
- package/build/instructions/deleteReferrerStateAndShortUrl.d.ts +9 -0
- package/build/instructions/deleteReferrerStateAndShortUrl.js +20 -0
- package/build/instructions/deleteReferrerStateAndShortUrl.js.map +1 -0
- package/build/instructions/depositObligationCollateral.d.ts +17 -0
- package/build/instructions/depositObligationCollateral.js +64 -0
- package/build/instructions/depositObligationCollateral.js.map +1 -0
- package/build/instructions/depositReserveLiquidity.d.ts +21 -0
- package/build/instructions/depositReserveLiquidity.js +88 -0
- package/build/instructions/depositReserveLiquidity.js.map +1 -0
- package/build/instructions/depositReserveLiquidityAndObligationCollateral.d.ts +23 -0
- package/build/instructions/depositReserveLiquidityAndObligationCollateral.js +94 -0
- package/build/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -0
- package/build/instructions/depositReserveLiquidityAndObligationCollateralV2.d.ts +30 -0
- package/build/instructions/depositReserveLiquidityAndObligationCollateralV2.js +100 -0
- package/build/instructions/depositReserveLiquidityAndObligationCollateralV2.js.map +1 -0
- package/build/instructions/flashBorrowReserveLiquidity.d.ts +21 -0
- package/build/instructions/flashBorrowReserveLiquidity.js +80 -0
- package/build/instructions/flashBorrowReserveLiquidity.js.map +1 -0
- package/build/instructions/flashRepayReserveLiquidity.d.ts +22 -0
- package/build/instructions/flashRepayReserveLiquidity.js +77 -0
- package/build/instructions/flashRepayReserveLiquidity.js.map +1 -0
- package/build/instructions/idlMissingTypes.d.ts +18 -0
- package/build/instructions/idlMissingTypes.js +62 -0
- package/build/instructions/idlMissingTypes.js.map +1 -0
- package/build/instructions/index.d.ts +74 -0
- package/build/instructions/index.js +78 -0
- package/build/instructions/index.js.map +1 -0
- package/build/instructions/initFarmsForReserve.d.ts +18 -0
- package/build/instructions/initFarmsForReserve.js +62 -0
- package/build/instructions/initFarmsForReserve.js.map +1 -0
- package/build/instructions/initLendingMarket.d.ts +13 -0
- package/build/instructions/initLendingMarket.js +53 -0
- package/build/instructions/initLendingMarket.js.map +1 -0
- package/build/instructions/initObligation.d.ts +18 -0
- package/build/instructions/initObligation.js +54 -0
- package/build/instructions/initObligation.js.map +1 -0
- package/build/instructions/initObligationFarmsForReserve.d.ts +19 -0
- package/build/instructions/initObligationFarmsForReserve.js +59 -0
- package/build/instructions/initObligationFarmsForReserve.js.map +1 -0
- package/build/instructions/initReferrerStateAndShortUrl.d.ts +14 -0
- package/build/instructions/initReferrerStateAndShortUrl.js +54 -0
- package/build/instructions/initReferrerStateAndShortUrl.js.map +1 -0
- package/build/instructions/initReferrerTokenState.d.ts +14 -0
- package/build/instructions/initReferrerTokenState.js +50 -0
- package/build/instructions/initReferrerTokenState.js.map +1 -0
- package/build/instructions/initReserve.d.ts +17 -0
- package/build/instructions/initReserve.js +56 -0
- package/build/instructions/initReserve.js.map +1 -0
- package/build/instructions/initUserMetadata.d.ts +14 -0
- package/build/instructions/initUserMetadata.js +54 -0
- package/build/instructions/initUserMetadata.js.map +1 -0
- package/build/instructions/liquidateObligationAndRedeemReserveCollateral.d.ts +31 -0
- package/build/instructions/liquidateObligationAndRedeemReserveCollateral.js +126 -0
- package/build/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -0
- package/build/instructions/redeemFees.d.ts +11 -0
- package/build/instructions/redeemFees.js +38 -0
- package/build/instructions/redeemFees.js.map +1 -0
- package/build/instructions/redeemReserveCollateral.d.ts +21 -0
- package/build/instructions/redeemReserveCollateral.js +92 -0
- package/build/instructions/redeemReserveCollateral.js.map +1 -0
- package/build/instructions/refreshObligation.d.ts +6 -0
- package/build/instructions/refreshObligation.js +17 -0
- package/build/instructions/refreshObligation.js.map +1 -0
- package/build/instructions/refreshObligationFarmsForReserve.d.ts +18 -0
- package/build/instructions/refreshObligationFarmsForReserve.js +62 -0
- package/build/instructions/refreshObligationFarmsForReserve.js.map +1 -0
- package/build/instructions/refreshReserve.d.ts +10 -0
- package/build/instructions/refreshReserve.js +29 -0
- package/build/instructions/refreshReserve.js.map +1 -0
- package/build/instructions/refreshReservesBatch.d.ts +6 -0
- package/build/instructions/refreshReservesBatch.js +43 -0
- package/build/instructions/refreshReservesBatch.js.map +1 -0
- package/build/instructions/repayObligationLiquidity.d.ts +18 -0
- package/build/instructions/repayObligationLiquidity.js +65 -0
- package/build/instructions/repayObligationLiquidity.js.map +1 -0
- package/build/instructions/repayObligationLiquidityV2.d.ts +26 -0
- package/build/instructions/repayObligationLiquidityV2.js +76 -0
- package/build/instructions/repayObligationLiquidityV2.js.map +1 -0
- package/build/instructions/requestElevationGroup.d.ts +11 -0
- package/build/instructions/requestElevationGroup.js +47 -0
- package/build/instructions/requestElevationGroup.js.map +1 -0
- package/build/instructions/socializeLoss.d.ts +14 -0
- package/build/instructions/socializeLoss.js +53 -0
- package/build/instructions/socializeLoss.js.map +1 -0
- package/build/instructions/updateLendingMarket.d.ts +12 -0
- package/build/instructions/updateLendingMarket.js +47 -0
- package/build/instructions/updateLendingMarket.js.map +1 -0
- package/build/instructions/updateLendingMarketOwner.d.ts +6 -0
- package/build/instructions/updateLendingMarketOwner.js +21 -0
- package/build/instructions/updateLendingMarketOwner.js.map +1 -0
- package/build/instructions/updateReserveConfig.d.ts +14 -0
- package/build/instructions/updateReserveConfig.js +49 -0
- package/build/instructions/updateReserveConfig.js.map +1 -0
- package/build/instructions/withdrawObligationCollateral.d.ts +18 -0
- package/build/instructions/withdrawObligationCollateral.js +69 -0
- package/build/instructions/withdrawObligationCollateral.js.map +1 -0
- package/build/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.d.ts +23 -0
- package/build/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +98 -0
- package/build/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -0
- package/build/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.d.ts +30 -0
- package/build/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js +104 -0
- package/build/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js.map +1 -0
- package/build/instructions/withdrawProtocolFee.d.ts +17 -0
- package/build/instructions/withdrawProtocolFee.js +64 -0
- package/build/instructions/withdrawProtocolFee.js.map +1 -0
- package/build/instructions/withdrawReferrerFees.d.ts +13 -0
- package/build/instructions/withdrawReferrerFees.js +40 -0
- package/build/instructions/withdrawReferrerFees.js.map +1 -0
- package/build/kamino_lending.d.ts +3937 -0
- package/build/kamino_lending.js +3940 -0
- package/build/kamino_lending.js.map +1 -0
- package/build/kamino_lending.json +6352 -0
- package/build/programId.d.ts +3 -0
- package/build/programId.js +9 -0
- package/build/programId.js.map +1 -0
- package/build/types/AssetTier.d.ts +44 -0
- package/build/types/AssetTier.js +122 -0
- package/build/types/AssetTier.js.map +1 -0
- package/build/types/BigFractionBytes.d.ts +26 -0
- package/build/types/BigFractionBytes.js +72 -0
- package/build/types/BigFractionBytes.js.map +1 -0
- package/build/types/BorrowRateCurve.d.ts +27 -0
- package/build/types/BorrowRateCurve.js +63 -0
- package/build/types/BorrowRateCurve.js.map +1 -0
- package/build/types/CurvePoint.d.ts +25 -0
- package/build/types/CurvePoint.js +68 -0
- package/build/types/CurvePoint.js.map +1 -0
- package/build/types/ElevationGroup.d.ts +62 -0
- package/build/types/ElevationGroup.js +125 -0
- package/build/types/ElevationGroup.js.map +1 -0
- package/build/types/FeeCalculation.d.ts +31 -0
- package/build/types/FeeCalculation.js +95 -0
- package/build/types/FeeCalculation.js.map +1 -0
- package/build/types/InitObligationArgs.d.ts +25 -0
- package/build/types/InitObligationArgs.js +68 -0
- package/build/types/InitObligationArgs.js.map +1 -0
- package/build/types/LastUpdate.d.ts +36 -0
- package/build/types/LastUpdate.js +84 -0
- package/build/types/LastUpdate.js.map +1 -0
- package/build/types/ObligationCollateral.d.ts +43 -0
- package/build/types/ObligationCollateral.js +98 -0
- package/build/types/ObligationCollateral.js.map +1 -0
- package/build/types/ObligationLiquidity.d.ts +64 -0
- package/build/types/ObligationLiquidity.js +123 -0
- package/build/types/ObligationLiquidity.js.map +1 -0
- package/build/types/PriceHeuristic.d.ts +32 -0
- package/build/types/PriceHeuristic.js +78 -0
- package/build/types/PriceHeuristic.js.map +1 -0
- package/build/types/PythConfiguration.d.ts +22 -0
- package/build/types/PythConfiguration.js +63 -0
- package/build/types/PythConfiguration.js.map +1 -0
- package/build/types/ReserveCollateral.d.ts +43 -0
- package/build/types/ReserveCollateral.js +97 -0
- package/build/types/ReserveCollateral.js.map +1 -0
- package/build/types/ReserveConfig.d.ts +246 -0
- package/build/types/ReserveConfig.js +269 -0
- package/build/types/ReserveConfig.js.map +1 -0
- package/build/types/ReserveFarmKind.d.ts +31 -0
- package/build/types/ReserveFarmKind.js +98 -0
- package/build/types/ReserveFarmKind.js.map +1 -0
- package/build/types/ReserveFees.d.ts +32 -0
- package/build/types/ReserveFees.js +82 -0
- package/build/types/ReserveFees.js.map +1 -0
- package/build/types/ReserveLiquidity.d.ts +114 -0
- package/build/types/ReserveLiquidity.js +191 -0
- package/build/types/ReserveLiquidity.js.map +1 -0
- package/build/types/ReserveStatus.d.ts +44 -0
- package/build/types/ReserveStatus.js +122 -0
- package/build/types/ReserveStatus.js.map +1 -0
- package/build/types/ScopeConfiguration.d.ts +32 -0
- package/build/types/ScopeConfiguration.js +79 -0
- package/build/types/ScopeConfiguration.js.map +1 -0
- package/build/types/SwitchboardConfiguration.d.ts +27 -0
- package/build/types/SwitchboardConfiguration.js +69 -0
- package/build/types/SwitchboardConfiguration.js.map +1 -0
- package/build/types/TokenInfo.d.ts +99 -0
- package/build/types/TokenInfo.js +145 -0
- package/build/types/TokenInfo.js.map +1 -0
- package/build/types/UpdateConfigMode.d.ts +616 -0
- package/build/types/UpdateConfigMode.js +1178 -0
- package/build/types/UpdateConfigMode.js.map +1 -0
- package/build/types/UpdateLendingMarketConfigValue.d.ts +177 -0
- package/build/types/UpdateLendingMarketConfigValue.js +312 -0
- package/build/types/UpdateLendingMarketConfigValue.js.map +1 -0
- package/build/types/UpdateLendingMarketMode.d.ts +239 -0
- package/build/types/UpdateLendingMarketMode.js +482 -0
- package/build/types/UpdateLendingMarketMode.js.map +1 -0
- package/build/types/WithdrawalCaps.d.ts +37 -0
- package/build/types/WithdrawalCaps.js +89 -0
- package/build/types/WithdrawalCaps.js.map +1 -0
- package/build/types/index.d.ts +64 -0
- package/build/types/index.js +77 -0
- package/build/types/index.js.map +1 -0
- package/package.json +44 -0
- package/src/accounts/LendingMarket.ts +292 -0
- package/src/accounts/Obligation.ts +282 -0
- package/src/accounts/ReferrerState.ts +90 -0
- package/src/accounts/ReferrerTokenState.ts +126 -0
- package/src/accounts/Reserve.ts +218 -0
- package/src/accounts/ShortUrl.ts +86 -0
- package/src/accounts/UserMetadata.ts +126 -0
- package/src/accounts/UserState.ts +210 -0
- package/src/accounts/index.ts +19 -0
- package/src/errors/anchor.ts +773 -0
- package/src/errors/custom.ts +1633 -0
- package/src/errors/index.ts +62 -0
- package/src/index.ts +5 -0
- package/src/instructions/borrowObligationLiquidity.ts +81 -0
- package/src/instructions/borrowObligationLiquidityV2.ts +103 -0
- package/src/instructions/deleteReferrerStateAndShortUrl.ts +27 -0
- package/src/instructions/depositObligationCollateral.ts +61 -0
- package/src/instructions/depositReserveLiquidity.ts +89 -0
- package/src/instructions/depositReserveLiquidityAndObligationCollateral.ts +97 -0
- package/src/instructions/depositReserveLiquidityAndObligationCollateralV2.ts +119 -0
- package/src/instructions/flashBorrowReserveLiquidity.ts +81 -0
- package/src/instructions/flashRepayReserveLiquidity.ts +79 -0
- package/src/instructions/idlMissingTypes.ts +59 -0
- package/src/instructions/index.ts +158 -0
- package/src/instructions/initFarmsForReserve.ts +60 -0
- package/src/instructions/initLendingMarket.ts +46 -0
- package/src/instructions/initObligation.ts +51 -0
- package/src/instructions/initObligationFarmsForReserve.ts +58 -0
- package/src/instructions/initReferrerStateAndShortUrl.ts +48 -0
- package/src/instructions/initReferrerTokenState.ts +44 -0
- package/src/instructions/initReserve.ts +68 -0
- package/src/instructions/initUserMetadata.ts +48 -0
- package/src/instructions/liquidateObligationAndRedeemReserveCollateral.ts +137 -0
- package/src/instructions/redeemFees.ts +44 -0
- package/src/instructions/redeemReserveCollateral.ts +93 -0
- package/src/instructions/refreshObligation.ts +18 -0
- package/src/instructions/refreshObligationFarmsForReserve.ts +60 -0
- package/src/instructions/refreshReserve.ts +34 -0
- package/src/instructions/refreshReservesBatch.ts +24 -0
- package/src/instructions/repayObligationLiquidity.ts +63 -0
- package/src/instructions/repayObligationLiquidityV2.ts +87 -0
- package/src/instructions/requestElevationGroup.ts +38 -0
- package/src/instructions/socializeLoss.ts +47 -0
- package/src/instructions/updateLendingMarket.ts +39 -0
- package/src/instructions/updateLendingMarketOwner.ts +25 -0
- package/src/instructions/updateReserveConfig.ts +43 -0
- package/src/instructions/withdrawObligationCollateral.ts +67 -0
- package/src/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +101 -0
- package/src/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts +123 -0
- package/src/instructions/withdrawProtocolFee.ts +61 -0
- package/src/instructions/withdrawReferrerFees.ts +48 -0
- package/src/kamino_lending.json +6352 -0
- package/src/kamino_lending.ts +7873 -0
- package/src/programId.ts +9 -0
- package/src/types/AssetTier.ts +116 -0
- package/src/types/BigFractionBytes.ts +59 -0
- package/src/types/BorrowRateCurve.ts +53 -0
- package/src/types/CurvePoint.ts +58 -0
- package/src/types/ElevationGroup.ts +129 -0
- package/src/types/FeeCalculation.ts +83 -0
- package/src/types/InitObligationArgs.ts +58 -0
- package/src/types/LastUpdate.ts +78 -0
- package/src/types/ObligationCollateral.ts +100 -0
- package/src/types/ObligationLiquidity.ts +140 -0
- package/src/types/PriceHeuristic.ts +72 -0
- package/src/types/PythConfiguration.ts +53 -0
- package/src/types/ReserveCollateral.ts +94 -0
- package/src/types/ReserveConfig.ts +349 -0
- package/src/types/ReserveFarmKind.ts +90 -0
- package/src/types/ReserveFees.ts +76 -0
- package/src/types/ReserveLiquidity.ts +219 -0
- package/src/types/ReserveStatus.ts +120 -0
- package/src/types/ScopeConfiguration.ts +76 -0
- package/src/types/SwitchboardConfiguration.ts +64 -0
- package/src/types/TokenInfo.ts +172 -0
- package/src/types/UpdateConfigMode.ts +1440 -0
- package/src/types/UpdateLendingMarketConfigValue.ts +376 -0
- package/src/types/UpdateLendingMarketMode.ts +570 -0
- package/src/types/WithdrawalCaps.ts +85 -0
- package/src/types/index.ts +275 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { PublicKey, Connection } from "@solana/web3.js"
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
|
6
|
+
|
|
7
|
+
export interface ObligationFields {
|
|
8
|
+
tag: BN
|
|
9
|
+
lastUpdate: types.LastUpdateFields
|
|
10
|
+
lendingMarket: PublicKey
|
|
11
|
+
owner: PublicKey
|
|
12
|
+
deposits: Array<types.ObligationCollateralFields>
|
|
13
|
+
lowestReserveDepositLiquidationLtv: BN
|
|
14
|
+
depositedValueSf: BN
|
|
15
|
+
borrows: Array<types.ObligationLiquidityFields>
|
|
16
|
+
borrowFactorAdjustedDebtValueSf: BN
|
|
17
|
+
borrowedAssetsMarketValueSf: BN
|
|
18
|
+
allowedBorrowValueSf: BN
|
|
19
|
+
unhealthyBorrowValueSf: BN
|
|
20
|
+
depositsAssetTiers: Array<number>
|
|
21
|
+
borrowsAssetTiers: Array<number>
|
|
22
|
+
elevationGroup: number
|
|
23
|
+
numOfObsoleteReserves: number
|
|
24
|
+
hasDebt: number
|
|
25
|
+
referrer: PublicKey
|
|
26
|
+
borrowingDisabled: number
|
|
27
|
+
reserved: Array<number>
|
|
28
|
+
highestBorrowFactorPct: BN
|
|
29
|
+
padding3: Array<BN>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ObligationJSON {
|
|
33
|
+
tag: string
|
|
34
|
+
lastUpdate: types.LastUpdateJSON
|
|
35
|
+
lendingMarket: string
|
|
36
|
+
owner: string
|
|
37
|
+
deposits: Array<types.ObligationCollateralJSON>
|
|
38
|
+
lowestReserveDepositLiquidationLtv: string
|
|
39
|
+
depositedValueSf: string
|
|
40
|
+
borrows: Array<types.ObligationLiquidityJSON>
|
|
41
|
+
borrowFactorAdjustedDebtValueSf: string
|
|
42
|
+
borrowedAssetsMarketValueSf: string
|
|
43
|
+
allowedBorrowValueSf: string
|
|
44
|
+
unhealthyBorrowValueSf: string
|
|
45
|
+
depositsAssetTiers: Array<number>
|
|
46
|
+
borrowsAssetTiers: Array<number>
|
|
47
|
+
elevationGroup: number
|
|
48
|
+
numOfObsoleteReserves: number
|
|
49
|
+
hasDebt: number
|
|
50
|
+
referrer: string
|
|
51
|
+
borrowingDisabled: number
|
|
52
|
+
reserved: Array<number>
|
|
53
|
+
highestBorrowFactorPct: string
|
|
54
|
+
padding3: Array<string>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export class Obligation {
|
|
58
|
+
readonly tag: BN
|
|
59
|
+
readonly lastUpdate: types.LastUpdate
|
|
60
|
+
readonly lendingMarket: PublicKey
|
|
61
|
+
readonly owner: PublicKey
|
|
62
|
+
readonly deposits: Array<types.ObligationCollateral>
|
|
63
|
+
readonly lowestReserveDepositLiquidationLtv: BN
|
|
64
|
+
readonly depositedValueSf: BN
|
|
65
|
+
readonly borrows: Array<types.ObligationLiquidity>
|
|
66
|
+
readonly borrowFactorAdjustedDebtValueSf: BN
|
|
67
|
+
readonly borrowedAssetsMarketValueSf: BN
|
|
68
|
+
readonly allowedBorrowValueSf: BN
|
|
69
|
+
readonly unhealthyBorrowValueSf: BN
|
|
70
|
+
readonly depositsAssetTiers: Array<number>
|
|
71
|
+
readonly borrowsAssetTiers: Array<number>
|
|
72
|
+
readonly elevationGroup: number
|
|
73
|
+
readonly numOfObsoleteReserves: number
|
|
74
|
+
readonly hasDebt: number
|
|
75
|
+
readonly referrer: PublicKey
|
|
76
|
+
readonly borrowingDisabled: number
|
|
77
|
+
readonly reserved: Array<number>
|
|
78
|
+
readonly highestBorrowFactorPct: BN
|
|
79
|
+
readonly padding3: Array<BN>
|
|
80
|
+
|
|
81
|
+
static readonly discriminator = Buffer.from([
|
|
82
|
+
168, 206, 141, 106, 88, 76, 172, 167,
|
|
83
|
+
])
|
|
84
|
+
|
|
85
|
+
static readonly layout = borsh.struct([
|
|
86
|
+
borsh.u64("tag"),
|
|
87
|
+
types.LastUpdate.layout("lastUpdate"),
|
|
88
|
+
borsh.publicKey("lendingMarket"),
|
|
89
|
+
borsh.publicKey("owner"),
|
|
90
|
+
borsh.array(types.ObligationCollateral.layout(), 8, "deposits"),
|
|
91
|
+
borsh.u64("lowestReserveDepositLiquidationLtv"),
|
|
92
|
+
borsh.u128("depositedValueSf"),
|
|
93
|
+
borsh.array(types.ObligationLiquidity.layout(), 5, "borrows"),
|
|
94
|
+
borsh.u128("borrowFactorAdjustedDebtValueSf"),
|
|
95
|
+
borsh.u128("borrowedAssetsMarketValueSf"),
|
|
96
|
+
borsh.u128("allowedBorrowValueSf"),
|
|
97
|
+
borsh.u128("unhealthyBorrowValueSf"),
|
|
98
|
+
borsh.array(borsh.u8(), 8, "depositsAssetTiers"),
|
|
99
|
+
borsh.array(borsh.u8(), 5, "borrowsAssetTiers"),
|
|
100
|
+
borsh.u8("elevationGroup"),
|
|
101
|
+
borsh.u8("numOfObsoleteReserves"),
|
|
102
|
+
borsh.u8("hasDebt"),
|
|
103
|
+
borsh.publicKey("referrer"),
|
|
104
|
+
borsh.u8("borrowingDisabled"),
|
|
105
|
+
borsh.array(borsh.u8(), 7, "reserved"),
|
|
106
|
+
borsh.u64("highestBorrowFactorPct"),
|
|
107
|
+
borsh.array(borsh.u64(), 126, "padding3"),
|
|
108
|
+
])
|
|
109
|
+
|
|
110
|
+
constructor(fields: ObligationFields) {
|
|
111
|
+
this.tag = fields.tag
|
|
112
|
+
this.lastUpdate = new types.LastUpdate({ ...fields.lastUpdate })
|
|
113
|
+
this.lendingMarket = fields.lendingMarket
|
|
114
|
+
this.owner = fields.owner
|
|
115
|
+
this.deposits = fields.deposits.map(
|
|
116
|
+
(item) => new types.ObligationCollateral({ ...item })
|
|
117
|
+
)
|
|
118
|
+
this.lowestReserveDepositLiquidationLtv =
|
|
119
|
+
fields.lowestReserveDepositLiquidationLtv
|
|
120
|
+
this.depositedValueSf = fields.depositedValueSf
|
|
121
|
+
this.borrows = fields.borrows.map(
|
|
122
|
+
(item) => new types.ObligationLiquidity({ ...item })
|
|
123
|
+
)
|
|
124
|
+
this.borrowFactorAdjustedDebtValueSf =
|
|
125
|
+
fields.borrowFactorAdjustedDebtValueSf
|
|
126
|
+
this.borrowedAssetsMarketValueSf = fields.borrowedAssetsMarketValueSf
|
|
127
|
+
this.allowedBorrowValueSf = fields.allowedBorrowValueSf
|
|
128
|
+
this.unhealthyBorrowValueSf = fields.unhealthyBorrowValueSf
|
|
129
|
+
this.depositsAssetTiers = fields.depositsAssetTiers
|
|
130
|
+
this.borrowsAssetTiers = fields.borrowsAssetTiers
|
|
131
|
+
this.elevationGroup = fields.elevationGroup
|
|
132
|
+
this.numOfObsoleteReserves = fields.numOfObsoleteReserves
|
|
133
|
+
this.hasDebt = fields.hasDebt
|
|
134
|
+
this.referrer = fields.referrer
|
|
135
|
+
this.borrowingDisabled = fields.borrowingDisabled
|
|
136
|
+
this.reserved = fields.reserved
|
|
137
|
+
this.highestBorrowFactorPct = fields.highestBorrowFactorPct
|
|
138
|
+
this.padding3 = fields.padding3
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static async fetch(
|
|
142
|
+
c: Connection,
|
|
143
|
+
address: PublicKey,
|
|
144
|
+
programId: PublicKey = PROGRAM_ID
|
|
145
|
+
): Promise<Obligation | null> {
|
|
146
|
+
const info = await c.getAccountInfo(address)
|
|
147
|
+
|
|
148
|
+
if (info === null) {
|
|
149
|
+
return null
|
|
150
|
+
}
|
|
151
|
+
if (!info.owner.equals(programId)) {
|
|
152
|
+
throw new Error("account doesn't belong to this program")
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return this.decode(info.data)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
static async fetchMultiple(
|
|
159
|
+
c: Connection,
|
|
160
|
+
addresses: PublicKey[],
|
|
161
|
+
programId: PublicKey = PROGRAM_ID
|
|
162
|
+
): Promise<Array<Obligation | null>> {
|
|
163
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
|
164
|
+
|
|
165
|
+
return infos.map((info) => {
|
|
166
|
+
if (info === null) {
|
|
167
|
+
return null
|
|
168
|
+
}
|
|
169
|
+
if (!info.owner.equals(programId)) {
|
|
170
|
+
throw new Error("account doesn't belong to this program")
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return this.decode(info.data)
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
static decode(data: Buffer): Obligation {
|
|
178
|
+
if (!data.slice(0, 8).equals(Obligation.discriminator)) {
|
|
179
|
+
throw new Error("invalid account discriminator")
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const dec = Obligation.layout.decode(data.slice(8))
|
|
183
|
+
|
|
184
|
+
return new Obligation({
|
|
185
|
+
tag: dec.tag,
|
|
186
|
+
lastUpdate: types.LastUpdate.fromDecoded(dec.lastUpdate),
|
|
187
|
+
lendingMarket: dec.lendingMarket,
|
|
188
|
+
owner: dec.owner,
|
|
189
|
+
deposits: dec.deposits.map(
|
|
190
|
+
(
|
|
191
|
+
item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
|
192
|
+
) => types.ObligationCollateral.fromDecoded(item)
|
|
193
|
+
),
|
|
194
|
+
lowestReserveDepositLiquidationLtv:
|
|
195
|
+
dec.lowestReserveDepositLiquidationLtv,
|
|
196
|
+
depositedValueSf: dec.depositedValueSf,
|
|
197
|
+
borrows: dec.borrows.map(
|
|
198
|
+
(
|
|
199
|
+
item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
|
200
|
+
) => types.ObligationLiquidity.fromDecoded(item)
|
|
201
|
+
),
|
|
202
|
+
borrowFactorAdjustedDebtValueSf: dec.borrowFactorAdjustedDebtValueSf,
|
|
203
|
+
borrowedAssetsMarketValueSf: dec.borrowedAssetsMarketValueSf,
|
|
204
|
+
allowedBorrowValueSf: dec.allowedBorrowValueSf,
|
|
205
|
+
unhealthyBorrowValueSf: dec.unhealthyBorrowValueSf,
|
|
206
|
+
depositsAssetTiers: dec.depositsAssetTiers,
|
|
207
|
+
borrowsAssetTiers: dec.borrowsAssetTiers,
|
|
208
|
+
elevationGroup: dec.elevationGroup,
|
|
209
|
+
numOfObsoleteReserves: dec.numOfObsoleteReserves,
|
|
210
|
+
hasDebt: dec.hasDebt,
|
|
211
|
+
referrer: dec.referrer,
|
|
212
|
+
borrowingDisabled: dec.borrowingDisabled,
|
|
213
|
+
reserved: dec.reserved,
|
|
214
|
+
highestBorrowFactorPct: dec.highestBorrowFactorPct,
|
|
215
|
+
padding3: dec.padding3,
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
toJSON(): ObligationJSON {
|
|
220
|
+
return {
|
|
221
|
+
tag: this.tag.toString(),
|
|
222
|
+
lastUpdate: this.lastUpdate.toJSON(),
|
|
223
|
+
lendingMarket: this.lendingMarket.toString(),
|
|
224
|
+
owner: this.owner.toString(),
|
|
225
|
+
deposits: this.deposits.map((item) => item.toJSON()),
|
|
226
|
+
lowestReserveDepositLiquidationLtv:
|
|
227
|
+
this.lowestReserveDepositLiquidationLtv.toString(),
|
|
228
|
+
depositedValueSf: this.depositedValueSf.toString(),
|
|
229
|
+
borrows: this.borrows.map((item) => item.toJSON()),
|
|
230
|
+
borrowFactorAdjustedDebtValueSf:
|
|
231
|
+
this.borrowFactorAdjustedDebtValueSf.toString(),
|
|
232
|
+
borrowedAssetsMarketValueSf: this.borrowedAssetsMarketValueSf.toString(),
|
|
233
|
+
allowedBorrowValueSf: this.allowedBorrowValueSf.toString(),
|
|
234
|
+
unhealthyBorrowValueSf: this.unhealthyBorrowValueSf.toString(),
|
|
235
|
+
depositsAssetTiers: this.depositsAssetTiers,
|
|
236
|
+
borrowsAssetTiers: this.borrowsAssetTiers,
|
|
237
|
+
elevationGroup: this.elevationGroup,
|
|
238
|
+
numOfObsoleteReserves: this.numOfObsoleteReserves,
|
|
239
|
+
hasDebt: this.hasDebt,
|
|
240
|
+
referrer: this.referrer.toString(),
|
|
241
|
+
borrowingDisabled: this.borrowingDisabled,
|
|
242
|
+
reserved: this.reserved,
|
|
243
|
+
highestBorrowFactorPct: this.highestBorrowFactorPct.toString(),
|
|
244
|
+
padding3: this.padding3.map((item) => item.toString()),
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
static fromJSON(obj: ObligationJSON): Obligation {
|
|
249
|
+
return new Obligation({
|
|
250
|
+
tag: new BN(obj.tag),
|
|
251
|
+
lastUpdate: types.LastUpdate.fromJSON(obj.lastUpdate),
|
|
252
|
+
lendingMarket: new PublicKey(obj.lendingMarket),
|
|
253
|
+
owner: new PublicKey(obj.owner),
|
|
254
|
+
deposits: obj.deposits.map((item) =>
|
|
255
|
+
types.ObligationCollateral.fromJSON(item)
|
|
256
|
+
),
|
|
257
|
+
lowestReserveDepositLiquidationLtv: new BN(
|
|
258
|
+
obj.lowestReserveDepositLiquidationLtv
|
|
259
|
+
),
|
|
260
|
+
depositedValueSf: new BN(obj.depositedValueSf),
|
|
261
|
+
borrows: obj.borrows.map((item) =>
|
|
262
|
+
types.ObligationLiquidity.fromJSON(item)
|
|
263
|
+
),
|
|
264
|
+
borrowFactorAdjustedDebtValueSf: new BN(
|
|
265
|
+
obj.borrowFactorAdjustedDebtValueSf
|
|
266
|
+
),
|
|
267
|
+
borrowedAssetsMarketValueSf: new BN(obj.borrowedAssetsMarketValueSf),
|
|
268
|
+
allowedBorrowValueSf: new BN(obj.allowedBorrowValueSf),
|
|
269
|
+
unhealthyBorrowValueSf: new BN(obj.unhealthyBorrowValueSf),
|
|
270
|
+
depositsAssetTiers: obj.depositsAssetTiers,
|
|
271
|
+
borrowsAssetTiers: obj.borrowsAssetTiers,
|
|
272
|
+
elevationGroup: obj.elevationGroup,
|
|
273
|
+
numOfObsoleteReserves: obj.numOfObsoleteReserves,
|
|
274
|
+
hasDebt: obj.hasDebt,
|
|
275
|
+
referrer: new PublicKey(obj.referrer),
|
|
276
|
+
borrowingDisabled: obj.borrowingDisabled,
|
|
277
|
+
reserved: obj.reserved,
|
|
278
|
+
highestBorrowFactorPct: new BN(obj.highestBorrowFactorPct),
|
|
279
|
+
padding3: obj.padding3.map((item) => new BN(item)),
|
|
280
|
+
})
|
|
281
|
+
}
|
|
282
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { PublicKey, Connection } from "@solana/web3.js"
|
|
2
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import { PROGRAM_ID } from "../programId"
|
|
4
|
+
|
|
5
|
+
export interface ReferrerStateFields {
|
|
6
|
+
shortUrl: PublicKey
|
|
7
|
+
owner: PublicKey
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ReferrerStateJSON {
|
|
11
|
+
shortUrl: string
|
|
12
|
+
owner: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class ReferrerState {
|
|
16
|
+
readonly shortUrl: PublicKey
|
|
17
|
+
readonly owner: PublicKey
|
|
18
|
+
|
|
19
|
+
static readonly discriminator = Buffer.from([194, 81, 217, 103, 12, 19, 12, 66])
|
|
20
|
+
|
|
21
|
+
static readonly layout = borsh.struct([borsh.publicKey("shortUrl"), borsh.publicKey("owner")])
|
|
22
|
+
|
|
23
|
+
constructor(fields: ReferrerStateFields) {
|
|
24
|
+
this.shortUrl = fields.shortUrl
|
|
25
|
+
this.owner = fields.owner
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static async fetch(
|
|
29
|
+
c: Connection,
|
|
30
|
+
address: PublicKey,
|
|
31
|
+
programId: PublicKey = PROGRAM_ID,
|
|
32
|
+
): Promise<ReferrerState | null> {
|
|
33
|
+
const info = await c.getAccountInfo(address)
|
|
34
|
+
|
|
35
|
+
if (info === null) {
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
if (!info.owner.equals(programId)) {
|
|
39
|
+
throw new Error("account doesn't belong to this program")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return this.decode(info.data)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static async fetchMultiple(
|
|
46
|
+
c: Connection,
|
|
47
|
+
addresses: PublicKey[],
|
|
48
|
+
programId: PublicKey = PROGRAM_ID,
|
|
49
|
+
): Promise<Array<ReferrerState | null>> {
|
|
50
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
|
51
|
+
|
|
52
|
+
return infos.map((info) => {
|
|
53
|
+
if (info === null) {
|
|
54
|
+
return null
|
|
55
|
+
}
|
|
56
|
+
if (!info.owner.equals(programId)) {
|
|
57
|
+
throw new Error("account doesn't belong to this program")
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return this.decode(info.data)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static decode(data: Buffer): ReferrerState {
|
|
65
|
+
if (!data.slice(0, 8).equals(ReferrerState.discriminator)) {
|
|
66
|
+
throw new Error("invalid account discriminator")
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const dec = ReferrerState.layout.decode(data.slice(8))
|
|
70
|
+
|
|
71
|
+
return new ReferrerState({
|
|
72
|
+
shortUrl: dec.shortUrl,
|
|
73
|
+
owner: dec.owner,
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
toJSON(): ReferrerStateJSON {
|
|
78
|
+
return {
|
|
79
|
+
shortUrl: this.shortUrl.toString(),
|
|
80
|
+
owner: this.owner.toString(),
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static fromJSON(obj: ReferrerStateJSON): ReferrerState {
|
|
85
|
+
return new ReferrerState({
|
|
86
|
+
shortUrl: new PublicKey(obj.shortUrl),
|
|
87
|
+
owner: new PublicKey(obj.owner),
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { PublicKey, Connection } from "@solana/web3.js"
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import { PROGRAM_ID } from "../programId"
|
|
5
|
+
|
|
6
|
+
export interface ReferrerTokenStateFields {
|
|
7
|
+
referrer: PublicKey
|
|
8
|
+
mint: PublicKey
|
|
9
|
+
amountUnclaimedSf: BN
|
|
10
|
+
amountCumulativeSf: BN
|
|
11
|
+
bump: BN
|
|
12
|
+
padding: Array<BN>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ReferrerTokenStateJSON {
|
|
16
|
+
referrer: string
|
|
17
|
+
mint: string
|
|
18
|
+
amountUnclaimedSf: string
|
|
19
|
+
amountCumulativeSf: string
|
|
20
|
+
bump: string
|
|
21
|
+
padding: Array<string>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class ReferrerTokenState {
|
|
25
|
+
readonly referrer: PublicKey
|
|
26
|
+
readonly mint: PublicKey
|
|
27
|
+
readonly amountUnclaimedSf: BN
|
|
28
|
+
readonly amountCumulativeSf: BN
|
|
29
|
+
readonly bump: BN
|
|
30
|
+
readonly padding: Array<BN>
|
|
31
|
+
|
|
32
|
+
static readonly discriminator = Buffer.from([39, 15, 208, 77, 32, 195, 105, 56])
|
|
33
|
+
|
|
34
|
+
static readonly layout = borsh.struct([
|
|
35
|
+
borsh.publicKey("referrer"),
|
|
36
|
+
borsh.publicKey("mint"),
|
|
37
|
+
borsh.u128("amountUnclaimedSf"),
|
|
38
|
+
borsh.u128("amountCumulativeSf"),
|
|
39
|
+
borsh.u64("bump"),
|
|
40
|
+
borsh.array(borsh.u64(), 31, "padding"),
|
|
41
|
+
])
|
|
42
|
+
|
|
43
|
+
constructor(fields: ReferrerTokenStateFields) {
|
|
44
|
+
this.referrer = fields.referrer
|
|
45
|
+
this.mint = fields.mint
|
|
46
|
+
this.amountUnclaimedSf = fields.amountUnclaimedSf
|
|
47
|
+
this.amountCumulativeSf = fields.amountCumulativeSf
|
|
48
|
+
this.bump = fields.bump
|
|
49
|
+
this.padding = fields.padding
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static async fetch(
|
|
53
|
+
c: Connection,
|
|
54
|
+
address: PublicKey,
|
|
55
|
+
programId: PublicKey = PROGRAM_ID,
|
|
56
|
+
): Promise<ReferrerTokenState | null> {
|
|
57
|
+
const info = await c.getAccountInfo(address)
|
|
58
|
+
|
|
59
|
+
if (info === null) {
|
|
60
|
+
return null
|
|
61
|
+
}
|
|
62
|
+
if (!info.owner.equals(programId)) {
|
|
63
|
+
throw new Error("account doesn't belong to this program")
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return this.decode(info.data)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static async fetchMultiple(
|
|
70
|
+
c: Connection,
|
|
71
|
+
addresses: PublicKey[],
|
|
72
|
+
programId: PublicKey = PROGRAM_ID,
|
|
73
|
+
): Promise<Array<ReferrerTokenState | null>> {
|
|
74
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
|
75
|
+
|
|
76
|
+
return infos.map((info) => {
|
|
77
|
+
if (info === null) {
|
|
78
|
+
return null
|
|
79
|
+
}
|
|
80
|
+
if (!info.owner.equals(programId)) {
|
|
81
|
+
throw new Error("account doesn't belong to this program")
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return this.decode(info.data)
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static decode(data: Buffer): ReferrerTokenState {
|
|
89
|
+
if (!data.slice(0, 8).equals(ReferrerTokenState.discriminator)) {
|
|
90
|
+
throw new Error("invalid account discriminator")
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const dec = ReferrerTokenState.layout.decode(data.slice(8))
|
|
94
|
+
|
|
95
|
+
return new ReferrerTokenState({
|
|
96
|
+
referrer: dec.referrer,
|
|
97
|
+
mint: dec.mint,
|
|
98
|
+
amountUnclaimedSf: dec.amountUnclaimedSf,
|
|
99
|
+
amountCumulativeSf: dec.amountCumulativeSf,
|
|
100
|
+
bump: dec.bump,
|
|
101
|
+
padding: dec.padding,
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
toJSON(): ReferrerTokenStateJSON {
|
|
106
|
+
return {
|
|
107
|
+
referrer: this.referrer.toString(),
|
|
108
|
+
mint: this.mint.toString(),
|
|
109
|
+
amountUnclaimedSf: this.amountUnclaimedSf.toString(),
|
|
110
|
+
amountCumulativeSf: this.amountCumulativeSf.toString(),
|
|
111
|
+
bump: this.bump.toString(),
|
|
112
|
+
padding: this.padding.map((item) => item.toString()),
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static fromJSON(obj: ReferrerTokenStateJSON): ReferrerTokenState {
|
|
117
|
+
return new ReferrerTokenState({
|
|
118
|
+
referrer: new PublicKey(obj.referrer),
|
|
119
|
+
mint: new PublicKey(obj.mint),
|
|
120
|
+
amountUnclaimedSf: new BN(obj.amountUnclaimedSf),
|
|
121
|
+
amountCumulativeSf: new BN(obj.amountCumulativeSf),
|
|
122
|
+
bump: new BN(obj.bump),
|
|
123
|
+
padding: obj.padding.map((item) => new BN(item)),
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
}
|