@kamino-finance/klend-sdk 5.14.1-beta.0 → 5.14.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.
Files changed (140) hide show
  1. package/dist/classes/farm_utils.d.ts.map +1 -1
  2. package/dist/classes/farm_utils.js +10 -3
  3. package/dist/classes/farm_utils.js.map +1 -1
  4. package/dist/classes/manager.d.ts +21 -6
  5. package/dist/classes/manager.d.ts.map +1 -1
  6. package/dist/classes/manager.js +311 -40
  7. package/dist/classes/manager.js.map +1 -1
  8. package/dist/classes/obligation.d.ts.map +1 -1
  9. package/dist/classes/obligation.js +0 -14
  10. package/dist/classes/obligation.js.map +1 -1
  11. package/dist/classes/reserve.d.ts +14 -5
  12. package/dist/classes/reserve.d.ts.map +1 -1
  13. package/dist/classes/reserve.js +463 -91
  14. package/dist/classes/reserve.js.map +1 -1
  15. package/dist/classes/shared.d.ts +1 -0
  16. package/dist/classes/shared.d.ts.map +1 -1
  17. package/dist/classes/shared.js.map +1 -1
  18. package/dist/classes/utils.d.ts +0 -1
  19. package/dist/classes/utils.d.ts.map +1 -1
  20. package/dist/classes/utils.js +0 -12
  21. package/dist/classes/utils.js.map +1 -1
  22. package/dist/classes/vault.d.ts +11 -1
  23. package/dist/classes/vault.d.ts.map +1 -1
  24. package/dist/classes/vault.js +54 -6
  25. package/dist/classes/vault.js.map +1 -1
  26. package/dist/client_kamino_manager.d.ts.map +1 -1
  27. package/dist/client_kamino_manager.js +26 -27
  28. package/dist/client_kamino_manager.js.map +1 -1
  29. package/dist/idl.json +9 -186
  30. package/dist/idl_codegen/accounts/LendingMarket.d.ts +3 -24
  31. package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
  32. package/dist/idl_codegen/accounts/LendingMarket.js +7 -25
  33. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  34. package/dist/idl_codegen/accounts/index.d.ts +0 -2
  35. package/dist/idl_codegen/accounts/index.d.ts.map +1 -1
  36. package/dist/idl_codegen/accounts/index.js +1 -3
  37. package/dist/idl_codegen/accounts/index.js.map +1 -1
  38. package/dist/idl_codegen/errors/custom.d.ts +1 -25
  39. package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
  40. package/dist/idl_codegen/errors/custom.js +1 -43
  41. package/dist/idl_codegen/errors/custom.js.map +1 -1
  42. package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +1 -2
  43. package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -1
  44. package/dist/idl_codegen/instructions/idlMissingTypes.js +1 -2
  45. package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
  46. package/dist/idl_codegen/instructions/index.d.ts +0 -6
  47. package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
  48. package/dist/idl_codegen/instructions/index.js +1 -7
  49. package/dist/idl_codegen/instructions/index.js.map +1 -1
  50. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +3 -4
  51. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -1
  52. package/dist/idl_codegen/instructions/updateReserveConfig.js +3 -5
  53. package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
  54. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +2 -2
  55. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts.map +1 -1
  56. package/dist/idl_codegen/instructions/withdrawProtocolFee.js +6 -2
  57. package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
  58. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +7 -33
  59. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
  60. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +12 -60
  61. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  62. package/dist/idl_codegen/types/index.d.ts +2 -6
  63. package/dist/idl_codegen/types/index.d.ts.map +1 -1
  64. package/dist/idl_codegen/types/index.js +1 -3
  65. package/dist/idl_codegen/types/index.js.map +1 -1
  66. package/dist/utils/accountListing.d.ts +1 -1
  67. package/dist/utils/accountListing.d.ts.map +1 -1
  68. package/dist/utils/accountListing.js +2 -2
  69. package/dist/utils/accountListing.js.map +1 -1
  70. package/dist/utils/api.d.ts +5 -1
  71. package/dist/utils/api.d.ts.map +1 -1
  72. package/dist/utils/api.js +12 -6
  73. package/dist/utils/api.js.map +1 -1
  74. package/dist/utils/constants.d.ts +1 -1
  75. package/dist/utils/constants.js +1 -1
  76. package/dist/utils/lookupTable.d.ts.map +1 -1
  77. package/dist/utils/lookupTable.js +6 -1
  78. package/dist/utils/lookupTable.js.map +1 -1
  79. package/dist/utils/managerTypes.d.ts.map +1 -1
  80. package/dist/utils/managerTypes.js +4 -10
  81. package/dist/utils/managerTypes.js.map +1 -1
  82. package/dist/utils/seeds.d.ts +0 -16
  83. package/dist/utils/seeds.d.ts.map +1 -1
  84. package/dist/utils/seeds.js +1 -23
  85. package/dist/utils/seeds.js.map +1 -1
  86. package/package.json +1 -1
  87. package/src/classes/farm_utils.ts +11 -3
  88. package/src/classes/manager.ts +417 -52
  89. package/src/classes/obligation.ts +0 -16
  90. package/src/classes/reserve.ts +783 -119
  91. package/src/classes/shared.ts +1 -0
  92. package/src/classes/utils.ts +0 -12
  93. package/src/classes/vault.ts +75 -7
  94. package/src/client_kamino_manager.ts +34 -42
  95. package/src/idl.json +9 -186
  96. package/src/idl_codegen/accounts/LendingMarket.ts +9 -41
  97. package/src/idl_codegen/accounts/index.ts +0 -2
  98. package/src/idl_codegen/errors/custom.ts +0 -45
  99. package/src/idl_codegen/instructions/idlMissingTypes.ts +2 -4
  100. package/src/idl_codegen/instructions/index.ts +0 -9
  101. package/src/idl_codegen/instructions/updateReserveConfig.ts +5 -7
  102. package/src/idl_codegen/instructions/withdrawProtocolFee.ts +8 -4
  103. package/src/idl_codegen/types/UpdateLendingMarketMode.ts +13 -73
  104. package/src/idl_codegen/types/index.ts +2 -16
  105. package/src/utils/accountListing.ts +3 -2
  106. package/src/utils/api.ts +19 -7
  107. package/src/utils/constants.ts +1 -1
  108. package/src/utils/lookupTable.ts +7 -1
  109. package/src/utils/managerTypes.ts +4 -10
  110. package/src/utils/seeds.ts +0 -25
  111. package/dist/classes/configItems.d.ts +0 -166
  112. package/dist/classes/configItems.d.ts.map +0 -1
  113. package/dist/classes/configItems.js +0 -202
  114. package/dist/classes/configItems.js.map +0 -1
  115. package/dist/idl_codegen/accounts/GlobalConfig.d.ts +0 -40
  116. package/dist/idl_codegen/accounts/GlobalConfig.d.ts.map +0 -1
  117. package/dist/idl_codegen/accounts/GlobalConfig.js +0 -116
  118. package/dist/idl_codegen/accounts/GlobalConfig.js.map +0 -1
  119. package/dist/idl_codegen/instructions/initGlobalConfig.d.ts +0 -10
  120. package/dist/idl_codegen/instructions/initGlobalConfig.d.ts.map +0 -1
  121. package/dist/idl_codegen/instructions/initGlobalConfig.js +0 -19
  122. package/dist/idl_codegen/instructions/initGlobalConfig.js.map +0 -1
  123. package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts +0 -13
  124. package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts.map +0 -1
  125. package/dist/idl_codegen/instructions/updateGlobalConfig.js +0 -61
  126. package/dist/idl_codegen/instructions/updateGlobalConfig.js.map +0 -1
  127. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts +0 -7
  128. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts.map +0 -1
  129. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js +0 -16
  130. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js.map +0 -1
  131. package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts +0 -32
  132. package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts.map +0 -1
  133. package/dist/idl_codegen/types/UpdateGlobalConfigMode.js +0 -108
  134. package/dist/idl_codegen/types/UpdateGlobalConfigMode.js.map +0 -1
  135. package/src/classes/configItems.ts +0 -295
  136. package/src/idl_codegen/accounts/GlobalConfig.ts +0 -125
  137. package/src/idl_codegen/instructions/initGlobalConfig.ts +0 -30
  138. package/src/idl_codegen/instructions/updateGlobalConfig.ts +0 -47
  139. package/src/idl_codegen/instructions/updateGlobalConfigAdmin.ts +0 -24
  140. package/src/idl_codegen/types/UpdateGlobalConfigMode.ts +0 -90
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.layout = void 0;
37
- exports.updateGlobalConfig = updateGlobalConfig;
38
- const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
39
- const borsh = __importStar(require("@coral-xyz/borsh")); // eslint-disable-line @typescript-eslint/no-unused-vars
40
- const types = __importStar(require("../types")); // eslint-disable-line @typescript-eslint/no-unused-vars
41
- const programId_1 = require("../programId");
42
- exports.layout = borsh.struct([
43
- types.UpdateGlobalConfigMode.layout("mode"),
44
- borsh.vecU8("value"),
45
- ]);
46
- function updateGlobalConfig(args, accounts, programId = programId_1.PROGRAM_ID) {
47
- const keys = [
48
- { pubkey: accounts.globalAdmin, isSigner: true, isWritable: false },
49
- { pubkey: accounts.globalConfig, isSigner: false, isWritable: true },
50
- ];
51
- const identifier = Buffer.from([164, 84, 130, 189, 111, 58, 250, 200]);
52
- const buffer = Buffer.alloc(1000);
53
- const len = exports.layout.encode({
54
- mode: args.mode.toEncodable(),
55
- value: Buffer.from(args.value.buffer, args.value.byteOffset, args.value.length),
56
- }, buffer);
57
- const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
58
- const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
59
- return ix;
60
- }
61
- //# sourceMappingURL=updateGlobalConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateGlobalConfig.js","sourceRoot":"","sources":["../../../src/idl_codegen/instructions/updateGlobalConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,gDAyBC;AA9CD,6CAAgF,CAAC,wDAAwD;AAEzI,wDAAyC,CAAC,wDAAwD;AAClG,gDAAiC,CAAC,wDAAwD;AAC1F,4CAAyC;AAY5B,QAAA,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IACjC,KAAK,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC;IAC3C,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;CACrB,CAAC,CAAA;AAEF,SAAgB,kBAAkB,CAChC,IAA4B,EAC5B,QAAoC,EACpC,YAAuB,sBAAU;IAEjC,MAAM,IAAI,GAAuB;QAC/B,EAAE,MAAM,EAAE,QAAQ,CAAC,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE;QACnE,EAAE,MAAM,EAAE,QAAQ,CAAC,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE;KACrE,CAAA;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;IACtE,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,GAAG,GAAG,cAAM,CAAC,MAAM,CACvB;QACE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QAC7B,KAAK,EAAE,MAAM,CAAC,IAAI,CAChB,IAAI,CAAC,KAAK,CAAC,MAAM,EACjB,IAAI,CAAC,KAAK,CAAC,UAAU,EACrB,IAAI,CAAC,KAAK,CAAC,MAAM,CAClB;KACF,EACD,MAAM,CACP,CAAA;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAA;IAClE,MAAM,EAAE,GAAG,IAAI,gCAAsB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAChE,OAAO,EAAE,CAAA;AACX,CAAC"}
@@ -1,7 +0,0 @@
1
- import { TransactionInstruction, PublicKey } from "@solana/web3.js";
2
- export interface UpdateGlobalConfigAdminAccounts {
3
- pendingAdmin: PublicKey;
4
- globalConfig: PublicKey;
5
- }
6
- export declare function updateGlobalConfigAdmin(accounts: UpdateGlobalConfigAdminAccounts, programId?: PublicKey): TransactionInstruction;
7
- //# sourceMappingURL=updateGlobalConfigAdmin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateGlobalConfigAdmin.d.ts","sourceRoot":"","sources":["../../../src/idl_codegen/instructions/updateGlobalConfigAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAe,MAAM,iBAAiB,CAAA;AAMhF,MAAM,WAAW,+BAA+B;IAC9C,YAAY,EAAE,SAAS,CAAA;IACvB,YAAY,EAAE,SAAS,CAAA;CACxB;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,+BAA+B,EACzC,SAAS,GAAE,SAAsB,0BAUlC"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateGlobalConfigAdmin = updateGlobalConfigAdmin;
4
- const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
5
- const programId_1 = require("../programId");
6
- function updateGlobalConfigAdmin(accounts, programId = programId_1.PROGRAM_ID) {
7
- const keys = [
8
- { pubkey: accounts.pendingAdmin, isSigner: true, isWritable: false },
9
- { pubkey: accounts.globalConfig, isSigner: false, isWritable: true },
10
- ];
11
- const identifier = Buffer.from([184, 87, 23, 193, 156, 238, 175, 119]);
12
- const data = identifier;
13
- const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
14
- return ix;
15
- }
16
- //# sourceMappingURL=updateGlobalConfigAdmin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateGlobalConfigAdmin.js","sourceRoot":"","sources":["../../../src/idl_codegen/instructions/updateGlobalConfigAdmin.ts"],"names":[],"mappings":";;AAWA,0DAYC;AAvBD,6CAAgF,CAAC,wDAAwD;AAIzI,4CAAyC;AAOzC,SAAgB,uBAAuB,CACrC,QAAyC,EACzC,YAAuB,sBAAU;IAEjC,MAAM,IAAI,GAAuB;QAC/B,EAAE,MAAM,EAAE,QAAQ,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE;QACpE,EAAE,MAAM,EAAE,QAAQ,CAAC,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE;KACrE,CAAA;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;IACtE,MAAM,IAAI,GAAG,UAAU,CAAA;IACvB,MAAM,EAAE,GAAG,IAAI,gCAAsB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAChE,OAAO,EAAE,CAAA;AACX,CAAC"}
@@ -1,32 +0,0 @@
1
- import * as types from "../types";
2
- import * as borsh from "@coral-xyz/borsh";
3
- export interface PendingAdminJSON {
4
- kind: "PendingAdmin";
5
- }
6
- export declare class PendingAdmin {
7
- static readonly discriminator = 0;
8
- static readonly kind = "PendingAdmin";
9
- readonly discriminator = 0;
10
- readonly kind = "PendingAdmin";
11
- toJSON(): PendingAdminJSON;
12
- toEncodable(): {
13
- PendingAdmin: {};
14
- };
15
- }
16
- export interface FeeCollectorJSON {
17
- kind: "FeeCollector";
18
- }
19
- export declare class FeeCollector {
20
- static readonly discriminator = 1;
21
- static readonly kind = "FeeCollector";
22
- readonly discriminator = 1;
23
- readonly kind = "FeeCollector";
24
- toJSON(): FeeCollectorJSON;
25
- toEncodable(): {
26
- FeeCollector: {};
27
- };
28
- }
29
- export declare function fromDecoded(obj: any): types.UpdateGlobalConfigModeKind;
30
- export declare function fromJSON(obj: types.UpdateGlobalConfigModeJSON): types.UpdateGlobalConfigModeKind;
31
- export declare function layout(property?: string): borsh.EnumLayout<unknown>;
32
- //# sourceMappingURL=UpdateGlobalConfigMode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UpdateGlobalConfigMode.d.ts","sourceRoot":"","sources":["../../../src/idl_codegen/types/UpdateGlobalConfigMode.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AAEzC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAA;CACrB;AAED,qBAAa,YAAY;IACvB,MAAM,CAAC,QAAQ,CAAC,aAAa,KAAI;IACjC,MAAM,CAAC,QAAQ,CAAC,IAAI,kBAAiB;IACrC,QAAQ,CAAC,aAAa,KAAI;IAC1B,QAAQ,CAAC,IAAI,kBAAiB;IAE9B,MAAM,IAAI,gBAAgB;IAM1B,WAAW;;;CAKZ;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAA;CACrB;AAED,qBAAa,YAAY;IACvB,MAAM,CAAC,QAAQ,CAAC,aAAa,KAAI;IACjC,MAAM,CAAC,QAAQ,CAAC,IAAI,kBAAiB;IACrC,QAAQ,CAAC,aAAa,KAAI;IAC1B,QAAQ,CAAC,IAAI,kBAAiB;IAE9B,MAAM,IAAI,gBAAgB;IAM1B,WAAW;;;CAKZ;AAGD,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,KAAK,CAAC,0BAA0B,CAatE;AAED,wBAAgB,QAAQ,CACtB,GAAG,EAAE,KAAK,CAAC,0BAA0B,GACpC,KAAK,CAAC,0BAA0B,CASlC;AAED,wBAAgB,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,6BASvC"}
@@ -1,108 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.FeeCollector = exports.PendingAdmin = void 0;
37
- exports.fromDecoded = fromDecoded;
38
- exports.fromJSON = fromJSON;
39
- exports.layout = layout;
40
- const borsh = __importStar(require("@coral-xyz/borsh"));
41
- class PendingAdmin {
42
- static discriminator = 0;
43
- static kind = "PendingAdmin";
44
- discriminator = 0;
45
- kind = "PendingAdmin";
46
- toJSON() {
47
- return {
48
- kind: "PendingAdmin",
49
- };
50
- }
51
- toEncodable() {
52
- return {
53
- PendingAdmin: {},
54
- };
55
- }
56
- }
57
- exports.PendingAdmin = PendingAdmin;
58
- class FeeCollector {
59
- static discriminator = 1;
60
- static kind = "FeeCollector";
61
- discriminator = 1;
62
- kind = "FeeCollector";
63
- toJSON() {
64
- return {
65
- kind: "FeeCollector",
66
- };
67
- }
68
- toEncodable() {
69
- return {
70
- FeeCollector: {},
71
- };
72
- }
73
- }
74
- exports.FeeCollector = FeeCollector;
75
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
- function fromDecoded(obj) {
77
- if (typeof obj !== "object") {
78
- throw new Error("Invalid enum object");
79
- }
80
- if ("PendingAdmin" in obj) {
81
- return new PendingAdmin();
82
- }
83
- if ("FeeCollector" in obj) {
84
- return new FeeCollector();
85
- }
86
- throw new Error("Invalid enum object");
87
- }
88
- function fromJSON(obj) {
89
- switch (obj.kind) {
90
- case "PendingAdmin": {
91
- return new PendingAdmin();
92
- }
93
- case "FeeCollector": {
94
- return new FeeCollector();
95
- }
96
- }
97
- }
98
- function layout(property) {
99
- const ret = borsh.rustEnum([
100
- borsh.struct([], "PendingAdmin"),
101
- borsh.struct([], "FeeCollector"),
102
- ]);
103
- if (property !== undefined) {
104
- return ret.replicate(property);
105
- }
106
- return ret;
107
- }
108
- //# sourceMappingURL=UpdateGlobalConfigMode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UpdateGlobalConfigMode.js","sourceRoot":"","sources":["../../../src/idl_codegen/types/UpdateGlobalConfigMode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,kCAaC;AAED,4BAWC;AAED,wBASC;AAtFD,wDAAyC;AAMzC,MAAa,YAAY;IACvB,MAAM,CAAU,aAAa,GAAG,CAAC,CAAA;IACjC,MAAM,CAAU,IAAI,GAAG,cAAc,CAAA;IAC5B,aAAa,GAAG,CAAC,CAAA;IACjB,IAAI,GAAG,cAAc,CAAA;IAE9B,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,cAAc;SACrB,CAAA;IACH,CAAC;IAED,WAAW;QACT,OAAO;YACL,YAAY,EAAE,EAAE;SACjB,CAAA;IACH,CAAC;;AAhBH,oCAiBC;AAMD,MAAa,YAAY;IACvB,MAAM,CAAU,aAAa,GAAG,CAAC,CAAA;IACjC,MAAM,CAAU,IAAI,GAAG,cAAc,CAAA;IAC5B,aAAa,GAAG,CAAC,CAAA;IACjB,IAAI,GAAG,cAAc,CAAA;IAE9B,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,cAAc;SACrB,CAAA;IACH,CAAC;IAED,WAAW;QACT,OAAO;YACL,YAAY,EAAE,EAAE;SACjB,CAAA;IACH,CAAC;;AAhBH,oCAiBC;AAED,8DAA8D;AAC9D,SAAgB,WAAW,CAAC,GAAQ;IAClC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACxC,CAAC;IAED,IAAI,cAAc,IAAI,GAAG,EAAE,CAAC;QAC1B,OAAO,IAAI,YAAY,EAAE,CAAA;IAC3B,CAAC;IACD,IAAI,cAAc,IAAI,GAAG,EAAE,CAAC;QAC1B,OAAO,IAAI,YAAY,EAAE,CAAA;IAC3B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;AACxC,CAAC;AAED,SAAgB,QAAQ,CACtB,GAAqC;IAErC,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,cAAc,CAAC,CAAC,CAAC;YACpB,OAAO,IAAI,YAAY,EAAE,CAAA;QAC3B,CAAC;QACD,KAAK,cAAc,CAAC,CAAC,CAAC;YACpB,OAAO,IAAI,YAAY,EAAE,CAAA;QAC3B,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAgB,MAAM,CAAC,QAAiB;IACtC,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC;QACzB,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC;QAChC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC;KACjC,CAAC,CAAA;IACF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IAChC,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -1,295 +0,0 @@
1
- import { struct, Layout } from '@coral-xyz/borsh';
2
- import { blobEquals, orThrow, toJson } from './utils';
3
- import { Buffer } from 'buffer';
4
-
5
- /**
6
- * An object literal specifying *all* "update mode" enum values (of type {@code M}) and their corresponding config items
7
- * (belonging to a top-level config struct {@code C}).
8
- *
9
- * An instance of this type is needed to construct a {@link ConfigUpdater}, as shown below.
10
- *
11
- * @example
12
- * ```
13
- * // Define the updater using a "map" - the line below would NOT compile if you forgot about any `StarWarsUpdateMode`:
14
- * const STAR_WARS_UPDATER = new ConfigUpdater(StarWarsUpdateMode.fromDecoded, StarWars, (config) => ({
15
- * [StarWarsUpdateMode.ANewHope.kind]: config.aNewHope,
16
- * [StarWarsUpdateMode.TheEmpireStrikesBack.kind]: config.theEmpireStrikesBack,
17
- * [StarWarsUpdateMode.ReturnOfTheJedi.kind]: config.returnOfTheJedi,
18
- * }));
19
- * ```
20
- */
21
- export type ConfigItemMap<M extends BorshEnum, C> = BorshEnumMap<M, SingleOrArray<ConfigItem<C, any>>>;
22
-
23
- /**
24
- * As advertised.
25
- */
26
- export type SingleOrArray<T> = T | T[];
27
-
28
- /**
29
- * A set of everything required to create an update ix for a single config item of type {@code A} belonging to a
30
- * config object of type {@code C}.
31
- */
32
- export type ConfigItem<C, A> = {
33
- readonly __layout: Layout<A>;
34
- readonly __getter: Getter<C, A>;
35
- };
36
-
37
- /**
38
- * A {@link ConfigItem} representing a borsh structure.
39
- *
40
- * Such structure may be used:
41
- * - either directly (i.e. a borsh-serialized "fat" config item, e.g. `ReserveConfig.borrowRateCurve`),
42
- * - or just to access its fields (e.g. `ReserveConfig.tokenInfo.pythConfiguration.price`).
43
- */
44
- export type StructConfigItem<C, A extends Record<string, any>> = ConfigItem<C, A> & {
45
- [K in keyof A]: A[K] extends object ? StructConfigItem<C, A[K]> : ConfigItem<C, A>;
46
- };
47
-
48
- /**
49
- * A syntactic sugar allowing for auto-completion of values within {@link ConfigItemMap}.
50
- */
51
- export type AnyConfigItem<C, A> = A extends Record<string, any> ? StructConfigItem<C, A> : ConfigItem<C, A>;
52
-
53
- /**
54
- * A composite {@link ConfigItem}, allowing to encode multiple fields together.
55
- *
56
- * @example
57
- * ```
58
- * ...
59
- * [CartoonsUpdateMode.UpdateTomAndJerry.discriminator]: new CompositeConfigItem(
60
- * CARTOONS.value().characters.cats.tom,
61
- * CARTOONS.value().characters.rodents.jerry
62
- * ),
63
- * ...
64
- * ```
65
- */
66
- export class CompositeConfigItem<C> implements ConfigItem<C, Record<string, any>> {
67
- readonly __layout: Layout<Record<string, any>>;
68
- readonly __getter: Getter<C, Record<string, any>>;
69
-
70
- constructor(...components: AnyConfigItem<C, any>[]) {
71
- this.__layout = struct<any>(components.map((component, index) => component.__layout.replicate(index.toString())));
72
- this.__getter = (config) =>
73
- Object.fromEntries(components.map((component, index) => [index.toString(), component.__getter(config)]));
74
- }
75
- }
76
-
77
- /**
78
- * Creates an array of config items - one per each element of the given array.
79
- *
80
- * An example use-case is `LendingMarket.elevationGroups[]`: to update all of them, we need N ixs:
81
- * - `updateLendingMarket(mode = ElevationGroup, value = elevationGroups[0])`
82
- * - `updateLendingMarket(mode = ElevationGroup, value = elevationGroups[1])`
83
- * - `updateLendingMarket(mode = ElevationGroup, value = elevationGroups[2])`
84
- * ...
85
- *
86
- * So: conceptually, the *array* is not "a config item". Each *slot* in that array is its own config item.
87
- */
88
- export function arrayElementConfigItems<C, A>(arrayConfigItem: ConfigItem<C, A[]>): ConfigItem<C, A>[] {
89
- const arrayGetter = arrayConfigItem.__getter;
90
- const wrappedSequenceLayout = arrayConfigItem.__layout as any;
91
- const sequenceLayout = wrappedSequenceLayout.layout?.fields?.[0];
92
- if (sequenceLayout === undefined) {
93
- throw new Error(`unexpected layout of the input array config item: ${toJson(wrappedSequenceLayout, true)}`);
94
- }
95
- return new Array(sequenceLayout.count)
96
- .fill(sequenceLayout.elementLayout as Layout<A>)
97
- .map((elementLayout, index) => ({
98
- __layout: elementLayout,
99
- __getter: (config) => arrayGetter(config)[index],
100
- }));
101
- }
102
-
103
- /**
104
- * A constructor reference of a borsh structure.
105
- */
106
- export interface BorshStructClass<C> {
107
- new (...args: any[]): C;
108
- layout: any;
109
- }
110
-
111
- /**
112
- * A missing common type for borsh enums, which borsh should really have provided itself.
113
- */
114
- export interface BorshEnum {
115
- kind: string;
116
- }
117
-
118
- /**
119
- * A part of a {@link ConfigUpdater} responsible for a single config item.
120
- */
121
- export class ConfigItemUpdater<C, A> {
122
- constructor(private readonly item: ConfigItem<C, A>) {}
123
-
124
- /**
125
- * Returns a serialized value of the specific config item extracted from the given top-level {@code newConfig}, or
126
- * `undefined` if the value has not changed from the given {@code currentConfig}.
127
- */
128
- encodeUpdatedItemFrom(currentConfig: C | undefined, newConfig: C): Uint8Array | undefined {
129
- const getter = this.item.__getter;
130
- const newItemValue = this.encodeItem(getter(newConfig));
131
- if (currentConfig === undefined) {
132
- return newItemValue;
133
- }
134
- if (blobEquals(newItemValue, this.encodeItem(getter(currentConfig)))) {
135
- return undefined;
136
- }
137
- return newItemValue;
138
- }
139
-
140
- /**
141
- * Borsh-serializes the given value.
142
- *
143
- * Only exposed for some legacy callers which still construct the update ixs manually (in tests).
144
- */
145
- encodeItem(item: A): Uint8Array {
146
- return encodeUsingLayout(this.item.__layout, item);
147
- }
148
- }
149
-
150
- /**
151
- * A resolver of config item changes.
152
- */
153
- export class ConfigUpdater<M extends BorshEnum, C> {
154
- private readonly itemUpdaters: Map<M['kind'], [M, ConfigItemUpdater<C, any>[]]>;
155
-
156
- /**
157
- * A resolving constructor.
158
- *
159
- * The inputs:
160
- * - `fromDecoded`: a reference to the codegen'ed enum-decoding function, e.g. `UpdateConfigMode.fromDecoded`. Needed
161
- * to turn the `<enumClass>.kind` strings into enums (i.e. instances of `M`).
162
- * - `configClass`: a reference to the codegen'ed top-level config class, e.g. `ReserveConfig`. Need to create a
163
- * completion helper for the `itemMapBuilder`.
164
- * - `itemMapBuilder`: a function building a {@link ConfigItemMap} using the completion helper provided as its
165
- * argument, e.g. `(config) => ({[UpdateLendingMarketMode.UpdateImmutableFlag.kind]: config.immutable, ...})`.
166
- *
167
- * See the usage example at {@link ConfigItemMap}.
168
- */
169
- constructor(
170
- fromDecoded: (mode: any) => M,
171
- configClass: BorshStructClass<C>,
172
- itemMapBuilder: (config: AnyConfigItem<C, C>) => ConfigItemMap<M, C>
173
- ) {
174
- this.itemUpdaters = new Map(
175
- Object.entries(itemMapBuilder(wrap(configClass))).map(([kind, itemOrArray]) => [
176
- kind,
177
- [
178
- fromDecoded({ [kind]: {} }),
179
- toArray(itemOrArray as SingleOrArray<ConfigItem<C, any>>).map((item) => new ConfigItemUpdater(item)),
180
- ],
181
- ])
182
- );
183
- }
184
-
185
- /**
186
- * Returns all changes between the given current and new configs - in particular, this will be *all* supported fields'
187
- * changes if the previous config does not exist.
188
- *
189
- * Please note that more than one {@link EncodedConfigUpdate}s can be associated with a single `M` enum value (in
190
- * cases where e.g. an array property is updated by individual updates of its elements).
191
- */
192
- encodeAllUpdates(currentConfig: C | undefined, newConfig: C): EncodedConfigUpdate<M>[] {
193
- const updates: EncodedConfigUpdate<M>[] = [];
194
- for (const [mode, itemUpdaters] of this.itemUpdaters.values()) {
195
- for (const itemUpdater of itemUpdaters) {
196
- const value = itemUpdater.encodeUpdatedItemFrom(currentConfig, newConfig);
197
- if (value === undefined) {
198
- continue;
199
- }
200
- updates.push({ mode, value });
201
- }
202
- }
203
- return updates;
204
- }
205
-
206
- /**
207
- * Gets the single updater of the given config item.
208
- *
209
- * Throws an error if the updates are not supported (e.g. for deprecated modes) or if the given item is handled by
210
- * multiple updaters (e.g. for an array property) - to handle these cases, use {@link allForMode()}.
211
- */
212
- forMode(mode: M): ConfigItemUpdater<C, any> {
213
- const itemUpdaters = this.allForMode(mode);
214
- switch (itemUpdaters.length) {
215
- case 0:
216
- throw new Error(`updates not supported (updaters for ${mode.kind} were explicitly set to [])`);
217
- case 1:
218
- return itemUpdaters[0];
219
- default:
220
- throw new Error(`${mode.kind} defines multiple (${itemUpdaters.length}) updaters`);
221
- }
222
- }
223
-
224
- /**
225
- * Gets all the updaters of the given config item.
226
- *
227
- * This may be an empty array (e.g. for deprecated modes), or multiple elements (e.g. if an array property is updated
228
- * by individual updates of its elements). If you expect a single updater, use {@link forMode()}.
229
- */
230
- allForMode(mode: M): ConfigItemUpdater<C, any>[] {
231
- const [_mode, itemUpdaters] =
232
- this.itemUpdaters.get(mode.kind) ??
233
- orThrow(`updaters for ${mode.kind} were not set (should not be possible, due to type-safety)`);
234
- return itemUpdaters;
235
- }
236
- }
237
-
238
- /**
239
- * The update mode discriminator and the serialized value needed to construct an update ix.
240
- */
241
- export type EncodedConfigUpdate<M extends BorshEnum> = {
242
- mode: M;
243
- value: Uint8Array;
244
- };
245
-
246
- /**
247
- * Borsh-serializes the given value according to the given layout.
248
- *
249
- * Only exposed for some legacy callers which still construct the update ixs manually (in tests).
250
- */
251
- export function encodeUsingLayout<T>(layout: Layout<T>, value: T): Uint8Array {
252
- const buffer = Buffer.alloc(layout.span);
253
- const length = layout.encode(value, buffer, 0);
254
- if (length !== layout.span) {
255
- throw new Error(`layout span declared incorrect length ${layout.span}; got ${length}`);
256
- }
257
- return Uint8Array.from(buffer);
258
- }
259
-
260
- // Only internals below:
261
-
262
- function wrap<C>(configClass: BorshStructClass<C>): AnyConfigItem<C, C> {
263
- return withPotentialChildren({
264
- __layout: typeof configClass.layout === 'function' ? configClass.layout() : configClass.layout,
265
- __getter: (config: C) => config,
266
- } as any);
267
- }
268
-
269
- function wrapChild<C, A extends Record<string, any>>(
270
- layout: Layout<A>,
271
- parent: StructConfigItem<C, A>
272
- ): AnyConfigItem<C, any> {
273
- return withPotentialChildren({
274
- __layout: layout,
275
- __getter: (config: C) => parent.__getter(config)[layout.property!],
276
- });
277
- }
278
-
279
- function withPotentialChildren<C, A>(item: AnyConfigItem<C, A>): AnyConfigItem<C, A> {
280
- for (const fieldLayout of (item.__layout as any).fields ?? []) {
281
- const structItem = item as StructConfigItem<C, any>;
282
- structItem[fieldLayout.property] = wrapChild(fieldLayout, structItem);
283
- }
284
- return item;
285
- }
286
-
287
- type BorshEnumMap<M extends BorshEnum, T> = {
288
- [Key in M['kind']]: T;
289
- };
290
-
291
- type Getter<C, A> = (config: C) => A;
292
-
293
- function toArray<T>(singleOrArray: SingleOrArray<T>): T[] {
294
- return Array.isArray(singleOrArray) ? singleOrArray : [singleOrArray];
295
- }
@@ -1,125 +0,0 @@
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 GlobalConfigFields {
8
- /** Global admin of the program */
9
- globalAdmin: PublicKey
10
- /** Pending admin must sign a specific transaction to become the global admin */
11
- pendingAdmin: PublicKey
12
- /** Fee collector is the only allowed owner of token accounts receiving protocol fees */
13
- feeCollector: PublicKey
14
- /** Padding to make the struct size 1024 bytes */
15
- padding: Array<number>
16
- }
17
-
18
- export interface GlobalConfigJSON {
19
- /** Global admin of the program */
20
- globalAdmin: string
21
- /** Pending admin must sign a specific transaction to become the global admin */
22
- pendingAdmin: string
23
- /** Fee collector is the only allowed owner of token accounts receiving protocol fees */
24
- feeCollector: string
25
- /** Padding to make the struct size 1024 bytes */
26
- padding: Array<number>
27
- }
28
-
29
- export class GlobalConfig {
30
- /** Global admin of the program */
31
- readonly globalAdmin: PublicKey
32
- /** Pending admin must sign a specific transaction to become the global admin */
33
- readonly pendingAdmin: PublicKey
34
- /** Fee collector is the only allowed owner of token accounts receiving protocol fees */
35
- readonly feeCollector: PublicKey
36
- /** Padding to make the struct size 1024 bytes */
37
- readonly padding: Array<number>
38
-
39
- static readonly discriminator = Buffer.from([
40
- 149, 8, 156, 202, 160, 252, 176, 217,
41
- ])
42
-
43
- static readonly layout = borsh.struct([
44
- borsh.publicKey("globalAdmin"),
45
- borsh.publicKey("pendingAdmin"),
46
- borsh.publicKey("feeCollector"),
47
- borsh.array(borsh.u8(), 928, "padding"),
48
- ])
49
-
50
- constructor(fields: GlobalConfigFields) {
51
- this.globalAdmin = fields.globalAdmin
52
- this.pendingAdmin = fields.pendingAdmin
53
- this.feeCollector = fields.feeCollector
54
- this.padding = fields.padding
55
- }
56
-
57
- static async fetch(
58
- c: Connection,
59
- address: PublicKey,
60
- programId: PublicKey = PROGRAM_ID
61
- ): Promise<GlobalConfig | null> {
62
- const info = await c.getAccountInfo(address)
63
-
64
- if (info === null) {
65
- return null
66
- }
67
- if (!info.owner.equals(programId)) {
68
- throw new Error("account doesn't belong to this program")
69
- }
70
-
71
- return this.decode(info.data)
72
- }
73
-
74
- static async fetchMultiple(
75
- c: Connection,
76
- addresses: PublicKey[],
77
- programId: PublicKey = PROGRAM_ID
78
- ): Promise<Array<GlobalConfig | null>> {
79
- const infos = await c.getMultipleAccountsInfo(addresses)
80
-
81
- return infos.map((info) => {
82
- if (info === null) {
83
- return null
84
- }
85
- if (!info.owner.equals(programId)) {
86
- throw new Error("account doesn't belong to this program")
87
- }
88
-
89
- return this.decode(info.data)
90
- })
91
- }
92
-
93
- static decode(data: Buffer): GlobalConfig {
94
- if (!data.slice(0, 8).equals(GlobalConfig.discriminator)) {
95
- throw new Error("invalid account discriminator")
96
- }
97
-
98
- const dec = GlobalConfig.layout.decode(data.slice(8))
99
-
100
- return new GlobalConfig({
101
- globalAdmin: dec.globalAdmin,
102
- pendingAdmin: dec.pendingAdmin,
103
- feeCollector: dec.feeCollector,
104
- padding: dec.padding,
105
- })
106
- }
107
-
108
- toJSON(): GlobalConfigJSON {
109
- return {
110
- globalAdmin: this.globalAdmin.toString(),
111
- pendingAdmin: this.pendingAdmin.toString(),
112
- feeCollector: this.feeCollector.toString(),
113
- padding: this.padding,
114
- }
115
- }
116
-
117
- static fromJSON(obj: GlobalConfigJSON): GlobalConfig {
118
- return new GlobalConfig({
119
- globalAdmin: new PublicKey(obj.globalAdmin),
120
- pendingAdmin: new PublicKey(obj.pendingAdmin),
121
- feeCollector: new PublicKey(obj.feeCollector),
122
- padding: obj.padding,
123
- })
124
- }
125
- }