@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.
Files changed (71) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/fraction.d.ts +23 -0
  3. package/build/fraction.js +61 -0
  4. package/build/fraction.js.map +1 -0
  5. package/build/index.d.ts +102 -0
  6. package/build/index.js +214 -0
  7. package/build/index.js.map +1 -0
  8. package/build/types/BigFractionBytes.d.ts +26 -0
  9. package/build/types/BigFractionBytes.js +72 -0
  10. package/build/types/BigFractionBytes.js.map +1 -0
  11. package/build/types/BorrowRateCurve.d.ts +27 -0
  12. package/build/types/BorrowRateCurve.js +63 -0
  13. package/build/types/BorrowRateCurve.js.map +1 -0
  14. package/build/types/CurvePoint.d.ts +25 -0
  15. package/build/types/CurvePoint.js +68 -0
  16. package/build/types/CurvePoint.js.map +1 -0
  17. package/build/types/LastUpdate.d.ts +46 -0
  18. package/build/types/LastUpdate.js +88 -0
  19. package/build/types/LastUpdate.js.map +1 -0
  20. package/build/types/PriceHeuristic.d.ts +40 -0
  21. package/build/types/PriceHeuristic.js +81 -0
  22. package/build/types/PriceHeuristic.js.map +1 -0
  23. package/build/types/PythConfiguration.d.ts +24 -0
  24. package/build/types/PythConfiguration.js +64 -0
  25. package/build/types/PythConfiguration.js.map +1 -0
  26. package/build/types/ReserveCollateral.d.ts +52 -0
  27. package/build/types/ReserveCollateral.js +101 -0
  28. package/build/types/ReserveCollateral.js.map +1 -0
  29. package/build/types/ReserveConfig.d.ts +366 -0
  30. package/build/types/ReserveConfig.js +307 -0
  31. package/build/types/ReserveConfig.js.map +1 -0
  32. package/build/types/ReserveFees.d.ts +77 -0
  33. package/build/types/ReserveFees.js +98 -0
  34. package/build/types/ReserveFees.js.map +1 -0
  35. package/build/types/ReserveLiquidity.d.ts +181 -0
  36. package/build/types/ReserveLiquidity.js +214 -0
  37. package/build/types/ReserveLiquidity.js.map +1 -0
  38. package/build/types/ScopeConfiguration.d.ts +40 -0
  39. package/build/types/ScopeConfiguration.js +82 -0
  40. package/build/types/ScopeConfiguration.js.map +1 -0
  41. package/build/types/SwitchboardConfiguration.d.ts +29 -0
  42. package/build/types/SwitchboardConfiguration.js +70 -0
  43. package/build/types/SwitchboardConfiguration.js.map +1 -0
  44. package/build/types/TokenInfo.d.ts +121 -0
  45. package/build/types/TokenInfo.js +154 -0
  46. package/build/types/TokenInfo.js.map +1 -0
  47. package/build/types/WithdrawalCaps.d.ts +37 -0
  48. package/build/types/WithdrawalCaps.js +90 -0
  49. package/build/types/WithdrawalCaps.js.map +1 -0
  50. package/build/types/index.d.ts +46 -0
  51. package/build/types/index.js +88 -0
  52. package/build/types/index.js.map +1 -0
  53. package/package.json +20 -0
  54. package/src/fraction.ts +70 -0
  55. package/src/index.ts +269 -0
  56. package/src/types/BigFractionBytes.ts +59 -0
  57. package/src/types/BorrowRateCurve.ts +53 -0
  58. package/src/types/CurvePoint.ts +58 -0
  59. package/src/types/LastUpdate.ts +88 -0
  60. package/src/types/PriceHeuristic.ts +76 -0
  61. package/src/types/PythConfiguration.ts +54 -0
  62. package/src/types/ReserveCollateral.ts +103 -0
  63. package/src/types/ReserveConfig.ts +431 -0
  64. package/src/types/ReserveFees.ts +116 -0
  65. package/src/types/ReserveLiquidity.ts +280 -0
  66. package/src/types/ScopeConfiguration.ts +83 -0
  67. package/src/types/SwitchboardConfiguration.ts +62 -0
  68. package/src/types/TokenInfo.ts +178 -0
  69. package/src/types/WithdrawalCaps.ts +84 -0
  70. package/src/types/index.ts +88 -0
  71. 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
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "src",
4
+ "sourceMap": true,
5
+ "incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */,
6
+ "composite": true /* Enable constraints that allow a TypeScript project to be used with project references. */,
7
+ "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
8
+ "module": "CommonJS" /* Specify what module code is generated. */,
9
+ "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
10
+ "outDir": "./build" /* Specify an output folder for all emitted files. */,
11
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
12
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
13
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */,
14
+ "resolveJsonModule": true
15
+ },
16
+ "include": ["src", "src/**/*.json"],
17
+ "exclude": ["build"]
18
+ }