@exponent-labs/kamino-reserve-deserializer 0.0.3
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/CHANGELOG.md +16 -0
- package/build/fraction.d.ts +23 -0
- package/build/fraction.js +61 -0
- package/build/fraction.js.map +1 -0
- package/build/index.d.ts +102 -0
- package/build/index.js +214 -0
- package/build/index.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/LastUpdate.d.ts +46 -0
- package/build/types/LastUpdate.js +88 -0
- package/build/types/LastUpdate.js.map +1 -0
- package/build/types/PriceHeuristic.d.ts +40 -0
- package/build/types/PriceHeuristic.js +81 -0
- package/build/types/PriceHeuristic.js.map +1 -0
- package/build/types/PythConfiguration.d.ts +24 -0
- package/build/types/PythConfiguration.js +64 -0
- package/build/types/PythConfiguration.js.map +1 -0
- package/build/types/ReserveCollateral.d.ts +52 -0
- package/build/types/ReserveCollateral.js +101 -0
- package/build/types/ReserveCollateral.js.map +1 -0
- package/build/types/ReserveConfig.d.ts +366 -0
- package/build/types/ReserveConfig.js +307 -0
- package/build/types/ReserveConfig.js.map +1 -0
- package/build/types/ReserveFees.d.ts +77 -0
- package/build/types/ReserveFees.js +98 -0
- package/build/types/ReserveFees.js.map +1 -0
- package/build/types/ReserveLiquidity.d.ts +181 -0
- package/build/types/ReserveLiquidity.js +214 -0
- package/build/types/ReserveLiquidity.js.map +1 -0
- package/build/types/ScopeConfiguration.d.ts +40 -0
- package/build/types/ScopeConfiguration.js +82 -0
- package/build/types/ScopeConfiguration.js.map +1 -0
- package/build/types/SwitchboardConfiguration.d.ts +29 -0
- package/build/types/SwitchboardConfiguration.js +70 -0
- package/build/types/SwitchboardConfiguration.js.map +1 -0
- package/build/types/TokenInfo.d.ts +121 -0
- package/build/types/TokenInfo.js +154 -0
- package/build/types/TokenInfo.js.map +1 -0
- package/build/types/WithdrawalCaps.d.ts +37 -0
- package/build/types/WithdrawalCaps.js +90 -0
- package/build/types/WithdrawalCaps.js.map +1 -0
- package/build/types/index.d.ts +46 -0
- package/build/types/index.js +88 -0
- package/build/types/index.js.map +1 -0
- package/package.json +20 -0
- package/src/fraction.ts +70 -0
- package/src/index.ts +269 -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/LastUpdate.ts +88 -0
- package/src/types/PriceHeuristic.ts +76 -0
- package/src/types/PythConfiguration.ts +54 -0
- package/src/types/ReserveCollateral.ts +103 -0
- package/src/types/ReserveConfig.ts +431 -0
- package/src/types/ReserveFees.ts +116 -0
- package/src/types/ReserveLiquidity.ts +280 -0
- package/src/types/ScopeConfiguration.ts +83 -0
- package/src/types/SwitchboardConfiguration.ts +62 -0
- package/src/types/TokenInfo.ts +178 -0
- package/src/types/WithdrawalCaps.ts +84 -0
- package/src/types/index.ts +88 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
3
|
+
|
|
4
|
+
export interface LastUpdateFields {
|
|
5
|
+
/** Last slot when updated */
|
|
6
|
+
slot: BN
|
|
7
|
+
/** True when marked stale, false when slot updated */
|
|
8
|
+
stale: number
|
|
9
|
+
/** Status of the prices used to calculate the last update */
|
|
10
|
+
priceStatus: number
|
|
11
|
+
placeholder: Array<number>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface LastUpdateJSON {
|
|
15
|
+
/** Last slot when updated */
|
|
16
|
+
slot: string
|
|
17
|
+
/** True when marked stale, false when slot updated */
|
|
18
|
+
stale: number
|
|
19
|
+
/** Status of the prices used to calculate the last update */
|
|
20
|
+
priceStatus: number
|
|
21
|
+
placeholder: Array<number>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Last update state */
|
|
25
|
+
export class LastUpdate {
|
|
26
|
+
/** Last slot when updated */
|
|
27
|
+
readonly slot: BN
|
|
28
|
+
/** True when marked stale, false when slot updated */
|
|
29
|
+
readonly stale: number
|
|
30
|
+
/** Status of the prices used to calculate the last update */
|
|
31
|
+
readonly priceStatus: number
|
|
32
|
+
readonly placeholder: Array<number>
|
|
33
|
+
|
|
34
|
+
constructor(fields: LastUpdateFields) {
|
|
35
|
+
this.slot = fields.slot
|
|
36
|
+
this.stale = fields.stale
|
|
37
|
+
this.priceStatus = fields.priceStatus
|
|
38
|
+
this.placeholder = fields.placeholder
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static layout(property?: string) {
|
|
42
|
+
return borsh.struct(
|
|
43
|
+
[borsh.u64("slot"), borsh.u8("stale"), borsh.u8("priceStatus"), borsh.array(borsh.u8(), 6, "placeholder")],
|
|
44
|
+
property,
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
static fromDecoded(obj: any) {
|
|
50
|
+
return new LastUpdate({
|
|
51
|
+
slot: obj.slot,
|
|
52
|
+
stale: obj.stale,
|
|
53
|
+
priceStatus: obj.priceStatus,
|
|
54
|
+
placeholder: obj.placeholder,
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static toEncodable(fields: LastUpdateFields) {
|
|
59
|
+
return {
|
|
60
|
+
slot: fields.slot,
|
|
61
|
+
stale: fields.stale,
|
|
62
|
+
priceStatus: fields.priceStatus,
|
|
63
|
+
placeholder: fields.placeholder,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
toJSON(): LastUpdateJSON {
|
|
68
|
+
return {
|
|
69
|
+
slot: this.slot.toString(),
|
|
70
|
+
stale: this.stale,
|
|
71
|
+
priceStatus: this.priceStatus,
|
|
72
|
+
placeholder: this.placeholder,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static fromJSON(obj: LastUpdateJSON): LastUpdate {
|
|
77
|
+
return new LastUpdate({
|
|
78
|
+
slot: new BN(obj.slot),
|
|
79
|
+
stale: obj.stale,
|
|
80
|
+
priceStatus: obj.priceStatus,
|
|
81
|
+
placeholder: obj.placeholder,
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
toEncodable() {
|
|
86
|
+
return LastUpdate.toEncodable(this)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
3
|
+
|
|
4
|
+
export interface PriceHeuristicFields {
|
|
5
|
+
/** Lower value of acceptable price */
|
|
6
|
+
lower: BN
|
|
7
|
+
/** Upper value of acceptable price */
|
|
8
|
+
upper: BN
|
|
9
|
+
/** Number of decimals of the previously defined values */
|
|
10
|
+
exp: BN
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface PriceHeuristicJSON {
|
|
14
|
+
/** Lower value of acceptable price */
|
|
15
|
+
lower: string
|
|
16
|
+
/** Upper value of acceptable price */
|
|
17
|
+
upper: string
|
|
18
|
+
/** Number of decimals of the previously defined values */
|
|
19
|
+
exp: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class PriceHeuristic {
|
|
23
|
+
/** Lower value of acceptable price */
|
|
24
|
+
readonly lower: BN
|
|
25
|
+
/** Upper value of acceptable price */
|
|
26
|
+
readonly upper: BN
|
|
27
|
+
/** Number of decimals of the previously defined values */
|
|
28
|
+
readonly exp: BN
|
|
29
|
+
|
|
30
|
+
constructor(fields: PriceHeuristicFields) {
|
|
31
|
+
this.lower = fields.lower
|
|
32
|
+
this.upper = fields.upper
|
|
33
|
+
this.exp = fields.exp
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static layout(property?: string) {
|
|
37
|
+
return borsh.struct([borsh.u64("lower"), borsh.u64("upper"), borsh.u64("exp")], property)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
static fromDecoded(obj: any) {
|
|
42
|
+
return new PriceHeuristic({
|
|
43
|
+
lower: obj.lower,
|
|
44
|
+
upper: obj.upper,
|
|
45
|
+
exp: obj.exp,
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static toEncodable(fields: PriceHeuristicFields) {
|
|
50
|
+
return {
|
|
51
|
+
lower: fields.lower,
|
|
52
|
+
upper: fields.upper,
|
|
53
|
+
exp: fields.exp,
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
toJSON(): PriceHeuristicJSON {
|
|
58
|
+
return {
|
|
59
|
+
lower: this.lower.toString(),
|
|
60
|
+
upper: this.upper.toString(),
|
|
61
|
+
exp: this.exp.toString(),
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static fromJSON(obj: PriceHeuristicJSON): PriceHeuristic {
|
|
66
|
+
return new PriceHeuristic({
|
|
67
|
+
lower: new BN(obj.lower),
|
|
68
|
+
upper: new BN(obj.upper),
|
|
69
|
+
exp: new BN(obj.exp),
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
toEncodable() {
|
|
74
|
+
return PriceHeuristic.toEncodable(this)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
3
|
+
|
|
4
|
+
export interface PythConfigurationFields {
|
|
5
|
+
/** Pubkey of the base price feed (disabled if `null` or `default`) */
|
|
6
|
+
price: PublicKey
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface PythConfigurationJSON {
|
|
10
|
+
/** Pubkey of the base price feed (disabled if `null` or `default`) */
|
|
11
|
+
price: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class PythConfiguration {
|
|
15
|
+
/** Pubkey of the base price feed (disabled if `null` or `default`) */
|
|
16
|
+
readonly price: PublicKey
|
|
17
|
+
|
|
18
|
+
constructor(fields: PythConfigurationFields) {
|
|
19
|
+
this.price = fields.price
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static layout(property?: string) {
|
|
23
|
+
return borsh.struct([borsh.publicKey("price")], property)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
static fromDecoded(obj: any) {
|
|
28
|
+
return new PythConfiguration({
|
|
29
|
+
price: obj.price,
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static toEncodable(fields: PythConfigurationFields) {
|
|
34
|
+
return {
|
|
35
|
+
price: fields.price,
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
toJSON(): PythConfigurationJSON {
|
|
40
|
+
return {
|
|
41
|
+
price: this.price.toString(),
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static fromJSON(obj: PythConfigurationJSON): PythConfiguration {
|
|
46
|
+
return new PythConfiguration({
|
|
47
|
+
price: new PublicKey(obj.price),
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
toEncodable() {
|
|
52
|
+
return PythConfiguration.toEncodable(this)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
4
|
+
|
|
5
|
+
export interface ReserveCollateralFields {
|
|
6
|
+
/** Reserve collateral mint address */
|
|
7
|
+
mintPubkey: PublicKey
|
|
8
|
+
/** Reserve collateral mint supply, used for exchange rate */
|
|
9
|
+
mintTotalSupply: BN
|
|
10
|
+
/** Reserve collateral supply address */
|
|
11
|
+
supplyVault: PublicKey
|
|
12
|
+
padding1: Array<BN>
|
|
13
|
+
padding2: Array<BN>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ReserveCollateralJSON {
|
|
17
|
+
/** Reserve collateral mint address */
|
|
18
|
+
mintPubkey: string
|
|
19
|
+
/** Reserve collateral mint supply, used for exchange rate */
|
|
20
|
+
mintTotalSupply: string
|
|
21
|
+
/** Reserve collateral supply address */
|
|
22
|
+
supplyVault: string
|
|
23
|
+
padding1: Array<string>
|
|
24
|
+
padding2: Array<string>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Reserve collateral */
|
|
28
|
+
export class ReserveCollateral {
|
|
29
|
+
/** Reserve collateral mint address */
|
|
30
|
+
readonly mintPubkey: PublicKey
|
|
31
|
+
/** Reserve collateral mint supply, used for exchange rate */
|
|
32
|
+
readonly mintTotalSupply: BN
|
|
33
|
+
/** Reserve collateral supply address */
|
|
34
|
+
readonly supplyVault: PublicKey
|
|
35
|
+
readonly padding1: Array<BN>
|
|
36
|
+
readonly padding2: Array<BN>
|
|
37
|
+
|
|
38
|
+
constructor(fields: ReserveCollateralFields) {
|
|
39
|
+
this.mintPubkey = fields.mintPubkey
|
|
40
|
+
this.mintTotalSupply = fields.mintTotalSupply
|
|
41
|
+
this.supplyVault = fields.supplyVault
|
|
42
|
+
this.padding1 = fields.padding1
|
|
43
|
+
this.padding2 = fields.padding2
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static layout(property?: string) {
|
|
47
|
+
return borsh.struct(
|
|
48
|
+
[
|
|
49
|
+
borsh.publicKey("mintPubkey"),
|
|
50
|
+
borsh.u64("mintTotalSupply"),
|
|
51
|
+
borsh.publicKey("supplyVault"),
|
|
52
|
+
borsh.array(borsh.u128(), 32, "padding1"),
|
|
53
|
+
borsh.array(borsh.u128(), 32, "padding2"),
|
|
54
|
+
],
|
|
55
|
+
property,
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
static fromDecoded(obj: any) {
|
|
61
|
+
return new ReserveCollateral({
|
|
62
|
+
mintPubkey: obj.mintPubkey,
|
|
63
|
+
mintTotalSupply: obj.mintTotalSupply,
|
|
64
|
+
supplyVault: obj.supplyVault,
|
|
65
|
+
padding1: obj.padding1,
|
|
66
|
+
padding2: obj.padding2,
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static toEncodable(fields: ReserveCollateralFields) {
|
|
71
|
+
return {
|
|
72
|
+
mintPubkey: fields.mintPubkey,
|
|
73
|
+
mintTotalSupply: fields.mintTotalSupply,
|
|
74
|
+
supplyVault: fields.supplyVault,
|
|
75
|
+
padding1: fields.padding1,
|
|
76
|
+
padding2: fields.padding2,
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
toJSON(): ReserveCollateralJSON {
|
|
81
|
+
return {
|
|
82
|
+
mintPubkey: this.mintPubkey.toString(),
|
|
83
|
+
mintTotalSupply: this.mintTotalSupply.toString(),
|
|
84
|
+
supplyVault: this.supplyVault.toString(),
|
|
85
|
+
padding1: this.padding1.map((item) => item.toString()),
|
|
86
|
+
padding2: this.padding2.map((item) => item.toString()),
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static fromJSON(obj: ReserveCollateralJSON): ReserveCollateral {
|
|
91
|
+
return new ReserveCollateral({
|
|
92
|
+
mintPubkey: new PublicKey(obj.mintPubkey),
|
|
93
|
+
mintTotalSupply: new BN(obj.mintTotalSupply),
|
|
94
|
+
supplyVault: new PublicKey(obj.supplyVault),
|
|
95
|
+
padding1: obj.padding1.map((item) => new BN(item)),
|
|
96
|
+
padding2: obj.padding2.map((item) => new BN(item)),
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
toEncodable() {
|
|
101
|
+
return ReserveCollateral.toEncodable(this)
|
|
102
|
+
}
|
|
103
|
+
}
|