@exponent-labs/exponent-sdk 0.9.0 → 0.9.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 (153) hide show
  1. package/build/client/vaults/index.d.ts +2 -0
  2. package/build/client/vaults/index.js +2 -0
  3. package/build/client/vaults/index.js.map +1 -1
  4. package/build/client/vaults/types/index.d.ts +2 -0
  5. package/build/client/vaults/types/index.js +2 -0
  6. package/build/client/vaults/types/index.js.map +1 -1
  7. package/build/client/vaults/types/kaminoFarmEntry.d.ts +15 -0
  8. package/build/client/vaults/types/kaminoFarmEntry.js +17 -0
  9. package/build/client/vaults/types/kaminoFarmEntry.js.map +1 -0
  10. package/build/client/vaults/types/kaminoObligationEntry.d.ts +24 -7
  11. package/build/client/vaults/types/kaminoObligationEntry.js +2 -1
  12. package/build/client/vaults/types/kaminoObligationEntry.js.map +1 -1
  13. package/build/client/vaults/types/obligationType.d.ts +1 -1
  14. package/build/client/vaults/types/positionUpdate.d.ts +9 -0
  15. package/build/client/vaults/types/positionUpdate.js +23 -0
  16. package/build/client/vaults/types/positionUpdate.js.map +1 -1
  17. package/build/client/vaults/types/proposalAction.d.ts +54 -54
  18. package/build/client/vaults/types/proposalAction.js +0 -3
  19. package/build/client/vaults/types/proposalAction.js.map +1 -1
  20. package/build/client/vaults/types/reserveFarmMapping.d.ts +19 -0
  21. package/build/client/vaults/types/reserveFarmMapping.js +18 -0
  22. package/build/client/vaults/types/reserveFarmMapping.js.map +1 -0
  23. package/build/client/vaults/types/strategyPosition.d.ts +6 -1
  24. package/build/client/vaults/types/strategyPosition.js +5 -0
  25. package/build/client/vaults/types/strategyPosition.js.map +1 -1
  26. package/build/exponentVaults/aumCalculator.d.ts +25 -4
  27. package/build/exponentVaults/aumCalculator.js +236 -15
  28. package/build/exponentVaults/aumCalculator.js.map +1 -1
  29. package/build/exponentVaults/fetcher.d.ts +52 -0
  30. package/build/exponentVaults/fetcher.js +199 -0
  31. package/build/exponentVaults/fetcher.js.map +1 -0
  32. package/build/exponentVaults/index.d.ts +10 -9
  33. package/build/exponentVaults/index.js +25 -8
  34. package/build/exponentVaults/index.js.map +1 -1
  35. package/build/exponentVaults/kamino-farms.d.ts +144 -0
  36. package/build/exponentVaults/kamino-farms.js +396 -0
  37. package/build/exponentVaults/kamino-farms.js.map +1 -0
  38. package/build/exponentVaults/loopscale/client.d.ts +240 -0
  39. package/build/exponentVaults/loopscale/client.js +590 -0
  40. package/build/exponentVaults/loopscale/client.js.map +1 -0
  41. package/build/exponentVaults/loopscale/client.test.d.ts +1 -0
  42. package/build/exponentVaults/loopscale/client.test.js +183 -0
  43. package/build/exponentVaults/loopscale/client.test.js.map +1 -0
  44. package/build/exponentVaults/loopscale/helpers.d.ts +29 -0
  45. package/build/exponentVaults/loopscale/helpers.js +119 -0
  46. package/build/exponentVaults/loopscale/helpers.js.map +1 -0
  47. package/build/exponentVaults/loopscale/index.d.ts +3 -0
  48. package/build/exponentVaults/loopscale/index.js +12 -0
  49. package/build/exponentVaults/loopscale/index.js.map +1 -0
  50. package/build/exponentVaults/loopscale/prepared-transactions.d.ts +13 -0
  51. package/build/exponentVaults/loopscale/prepared-transactions.js +271 -0
  52. package/build/exponentVaults/loopscale/prepared-transactions.js.map +1 -0
  53. package/build/exponentVaults/loopscale/prepared-transactions.test.d.ts +1 -0
  54. package/build/exponentVaults/loopscale/prepared-transactions.test.js +400 -0
  55. package/build/exponentVaults/loopscale/prepared-transactions.test.js.map +1 -0
  56. package/build/exponentVaults/loopscale/prepared-types.d.ts +62 -0
  57. package/build/exponentVaults/loopscale/prepared-types.js +3 -0
  58. package/build/exponentVaults/loopscale/prepared-types.js.map +1 -0
  59. package/build/exponentVaults/loopscale/response-plan.d.ts +69 -0
  60. package/build/exponentVaults/loopscale/response-plan.js +141 -0
  61. package/build/exponentVaults/loopscale/response-plan.js.map +1 -0
  62. package/build/exponentVaults/loopscale/response-plan.test.d.ts +1 -0
  63. package/build/exponentVaults/loopscale/response-plan.test.js +139 -0
  64. package/build/exponentVaults/loopscale/response-plan.test.js.map +1 -0
  65. package/build/exponentVaults/loopscale/send-plan.d.ts +75 -0
  66. package/build/exponentVaults/loopscale/send-plan.js +235 -0
  67. package/build/exponentVaults/loopscale/send-plan.js.map +1 -0
  68. package/build/exponentVaults/loopscale/types.d.ts +443 -0
  69. package/build/exponentVaults/loopscale/types.js +3 -0
  70. package/build/exponentVaults/loopscale/types.js.map +1 -0
  71. package/build/exponentVaults/loopscale-client.d.ts +113 -524
  72. package/build/exponentVaults/loopscale-client.js +296 -539
  73. package/build/exponentVaults/loopscale-client.js.map +1 -1
  74. package/build/exponentVaults/loopscale-client.test.d.ts +1 -0
  75. package/build/exponentVaults/loopscale-client.test.js +162 -0
  76. package/build/exponentVaults/loopscale-client.test.js.map +1 -0
  77. package/build/exponentVaults/loopscale-client.types.d.ts +425 -0
  78. package/build/exponentVaults/loopscale-client.types.js +3 -0
  79. package/build/exponentVaults/loopscale-client.types.js.map +1 -0
  80. package/build/exponentVaults/loopscale-execution.d.ts +125 -0
  81. package/build/exponentVaults/loopscale-execution.js +341 -0
  82. package/build/exponentVaults/loopscale-execution.js.map +1 -0
  83. package/build/exponentVaults/loopscale-execution.test.d.ts +1 -0
  84. package/build/exponentVaults/loopscale-execution.test.js +139 -0
  85. package/build/exponentVaults/loopscale-execution.test.js.map +1 -0
  86. package/build/exponentVaults/loopscale-vault.d.ts +115 -0
  87. package/build/exponentVaults/loopscale-vault.js +275 -0
  88. package/build/exponentVaults/loopscale-vault.js.map +1 -0
  89. package/build/exponentVaults/loopscale-vault.test.d.ts +1 -0
  90. package/build/exponentVaults/loopscale-vault.test.js +102 -0
  91. package/build/exponentVaults/loopscale-vault.test.js.map +1 -0
  92. package/build/exponentVaults/policyBuilders.d.ts +62 -0
  93. package/build/exponentVaults/policyBuilders.js +119 -2
  94. package/build/exponentVaults/policyBuilders.js.map +1 -1
  95. package/build/exponentVaults/pricePathResolver.d.ts +45 -0
  96. package/build/exponentVaults/pricePathResolver.js +198 -0
  97. package/build/exponentVaults/pricePathResolver.js.map +1 -0
  98. package/build/exponentVaults/pricePathResolver.test.d.ts +1 -0
  99. package/build/exponentVaults/pricePathResolver.test.js +369 -0
  100. package/build/exponentVaults/pricePathResolver.test.js.map +1 -0
  101. package/build/exponentVaults/syncTransaction.js +4 -1
  102. package/build/exponentVaults/syncTransaction.js.map +1 -1
  103. package/build/exponentVaults/titan-quote.js +170 -36
  104. package/build/exponentVaults/titan-quote.js.map +1 -1
  105. package/build/exponentVaults/vault-instruction-types.d.ts +363 -0
  106. package/build/exponentVaults/vault-instruction-types.js +128 -0
  107. package/build/exponentVaults/vault-instruction-types.js.map +1 -0
  108. package/build/exponentVaults/vault-interaction.d.ts +156 -313
  109. package/build/exponentVaults/vault-interaction.js +1581 -353
  110. package/build/exponentVaults/vault-interaction.js.map +1 -1
  111. package/build/exponentVaults/vault.d.ts +51 -2
  112. package/build/exponentVaults/vault.js +324 -48
  113. package/build/exponentVaults/vault.js.map +1 -1
  114. package/build/exponentVaults/vaultTransactionBuilder.d.ts +100 -134
  115. package/build/exponentVaults/vaultTransactionBuilder.js +359 -266
  116. package/build/exponentVaults/vaultTransactionBuilder.js.map +1 -1
  117. package/build/exponentVaults/vaultTransactionBuilder.test.d.ts +1 -0
  118. package/build/exponentVaults/vaultTransactionBuilder.test.js +214 -0
  119. package/build/exponentVaults/vaultTransactionBuilder.test.js.map +1 -0
  120. package/build/marketThree.d.ts +6 -2
  121. package/build/marketThree.js +10 -8
  122. package/build/marketThree.js.map +1 -1
  123. package/package.json +32 -32
  124. package/src/client/vaults/index.ts +2 -0
  125. package/src/client/vaults/types/index.ts +2 -0
  126. package/src/client/vaults/types/kaminoFarmEntry.ts +32 -0
  127. package/src/client/vaults/types/kaminoObligationEntry.ts +6 -3
  128. package/src/client/vaults/types/positionUpdate.ts +62 -0
  129. package/src/client/vaults/types/proposalAction.ts +0 -3
  130. package/src/client/vaults/types/reserveFarmMapping.ts +35 -0
  131. package/src/client/vaults/types/strategyPosition.ts +18 -1
  132. package/src/exponentVaults/aumCalculator.ts +353 -16
  133. package/src/exponentVaults/fetcher.ts +257 -0
  134. package/src/exponentVaults/index.ts +64 -40
  135. package/src/exponentVaults/kamino-farms.ts +538 -0
  136. package/src/exponentVaults/loopscale/client.ts +808 -0
  137. package/src/exponentVaults/loopscale/helpers.ts +172 -0
  138. package/src/exponentVaults/loopscale/index.ts +57 -0
  139. package/src/exponentVaults/loopscale/prepared-transactions.ts +435 -0
  140. package/src/exponentVaults/loopscale/prepared-types.ts +73 -0
  141. package/src/exponentVaults/loopscale/types.ts +466 -0
  142. package/src/exponentVaults/policyBuilders.ts +170 -0
  143. package/src/exponentVaults/pricePathResolver.test.ts +466 -0
  144. package/src/exponentVaults/pricePathResolver.ts +273 -0
  145. package/src/exponentVaults/syncTransaction.ts +6 -1
  146. package/src/exponentVaults/titan-quote.ts +231 -45
  147. package/src/exponentVaults/vault-instruction-types.ts +493 -0
  148. package/src/exponentVaults/vault-interaction.ts +2227 -636
  149. package/src/exponentVaults/vault.ts +474 -63
  150. package/src/exponentVaults/vaultTransactionBuilder.test.ts +256 -0
  151. package/src/exponentVaults/vaultTransactionBuilder.ts +555 -413
  152. package/src/marketThree.ts +14 -6
  153. package/src/exponentVaults/loopscale-client.ts +0 -1373
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const globals_1 = require("@jest/globals");
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const policyBuilders_1 = require("../policyBuilders");
6
+ const client_1 = require("./client");
7
+ function createJsonResponse(body, status = 200) {
8
+ return {
9
+ ok: status >= 200 && status < 300,
10
+ status,
11
+ json: async () => body,
12
+ text: async () => JSON.stringify(body),
13
+ };
14
+ }
15
+ function buildLoopscaleInstruction(name, keys) {
16
+ return new web3_js_1.TransactionInstruction({
17
+ programId: policyBuilders_1.LOOPSCALE_PROGRAM_ID,
18
+ keys: keys.map((key) => ({
19
+ pubkey: key.pubkey,
20
+ isSigner: key.isSigner ?? false,
21
+ isWritable: key.isWritable ?? false,
22
+ })),
23
+ data: Buffer.concat([
24
+ Buffer.from(policyBuilders_1.LOOPSCALE_DISCRIMINATORS[name]),
25
+ Buffer.alloc(8),
26
+ ]),
27
+ });
28
+ }
29
+ function encodeTransactionResponse(instructions, payer = new web3_js_1.PublicKey("11111111111111111111111111111111")) {
30
+ const message = new web3_js_1.TransactionMessage({
31
+ payerKey: payer,
32
+ recentBlockhash: "11111111111111111111111111111111",
33
+ instructions,
34
+ }).compileToV0Message([]);
35
+ const transaction = new web3_js_1.VersionedTransaction(message);
36
+ return {
37
+ message: Buffer.from(transaction.message.serialize()).toString("base64"),
38
+ signatures: message.staticAccountKeys
39
+ .slice(0, message.header.numRequiredSignatures)
40
+ .map((publicKey) => ({
41
+ publicKey: publicKey.toBase58(),
42
+ signature: Buffer.alloc(64).toString("base64"),
43
+ })),
44
+ };
45
+ }
46
+ (0, globals_1.describe)("LoopscaleClient", () => {
47
+ const userWallet = new web3_js_1.PublicKey("11111111111111111111111111111111");
48
+ const payer = new web3_js_1.PublicKey("4Nd1mY7V4KJ1mQ9MJ2VYfXh7WvyaManEXZDV4xQSSHqK");
49
+ const connection = new web3_js_1.Connection("http://127.0.0.1:8899");
50
+ const originalFetch = globalThis.fetch;
51
+ (0, globals_1.beforeEach)(() => {
52
+ globalThis.fetch = globals_1.jest.fn();
53
+ });
54
+ (0, globals_1.afterEach)(() => {
55
+ globalThis.fetch = originalFetch;
56
+ });
57
+ (0, globals_1.it)("serializes getQuotes with the docs-aligned user-wallet header", async () => {
58
+ const mockFetch = globalThis.fetch;
59
+ mockFetch.mockImplementation(async () => createJsonResponse([
60
+ { apy: 1, ltv: 2, liquidationThreshold: 3, maxPrincipalAvailable: 4 },
61
+ ]));
62
+ const client = new client_1.LoopscaleClient({ connection, userWallet });
63
+ await client.getQuotes({
64
+ durationType: 0,
65
+ duration: 1,
66
+ principal: userWallet,
67
+ collateral: [payer],
68
+ minPrincipalAmount: 42n,
69
+ });
70
+ (0, globals_1.expect)(mockFetch).toHaveBeenCalledTimes(1);
71
+ const [url, init] = mockFetch.mock.calls[0];
72
+ (0, globals_1.expect)(url).toBe("https://tars.loopscale.com/v1/markets/quote");
73
+ (0, globals_1.expect)(init?.headers).toMatchObject({
74
+ "Content-Type": "application/json",
75
+ "user-wallet": userWallet.toBase58(),
76
+ });
77
+ (0, globals_1.expect)(JSON.parse(init?.body)).toEqual({
78
+ durationType: 0,
79
+ duration: 1,
80
+ principal: userWallet.toBase58(),
81
+ collateral: [payer.toBase58()],
82
+ limit: 10,
83
+ offset: 0,
84
+ minPrincipalAmount: 42,
85
+ });
86
+ });
87
+ (0, globals_1.it)("serializes strategy deposit headers with User-Wallet and payer", async () => {
88
+ const mockFetch = globalThis.fetch;
89
+ const rawResponse = encodeTransactionResponse([]);
90
+ mockFetch.mockImplementation(async () => createJsonResponse(rawResponse));
91
+ const client = new client_1.LoopscaleClient({ connection, userWallet, payer });
92
+ const result = await client.depositStrategy({
93
+ strategy: payer,
94
+ amount: 10,
95
+ });
96
+ (0, globals_1.expect)(result).toEqual(rawResponse);
97
+ const [, init] = mockFetch.mock.calls[0];
98
+ (0, globals_1.expect)(init?.headers).toMatchObject({
99
+ "Content-Type": "application/json",
100
+ "User-Wallet": userWallet.toBase58(),
101
+ payer: payer.toBase58(),
102
+ });
103
+ });
104
+ (0, globals_1.it)("returns createStrategy as the raw Loopscale batch response", async () => {
105
+ const mockFetch = globalThis.fetch;
106
+ const rawBatch = [encodeTransactionResponse([])];
107
+ mockFetch.mockImplementation(async () => createJsonResponse(rawBatch));
108
+ const client = new client_1.LoopscaleClient({ connection, userWallet });
109
+ const result = await client.createStrategy({
110
+ principalMint: userWallet,
111
+ lender: payer,
112
+ amount: 1,
113
+ });
114
+ (0, globals_1.expect)(result).toEqual(rawBatch);
115
+ });
116
+ (0, globals_1.it)("returns borrowPrincipal in the wrapped transactions shape when Loopscale does", async () => {
117
+ const mockFetch = globalThis.fetch;
118
+ const rawTransaction = encodeTransactionResponse([]);
119
+ const rawResponse = {
120
+ transactions: [rawTransaction],
121
+ expectedLoanInfo: {
122
+ loan: { address: payer.toBase58() },
123
+ },
124
+ };
125
+ mockFetch.mockImplementation(async () => createJsonResponse(rawResponse));
126
+ const client = new client_1.LoopscaleClient({ connection, userWallet, payer });
127
+ const result = await client.borrowPrincipal({
128
+ loan: payer,
129
+ borrowParams: {
130
+ amount: 10,
131
+ durationIndex: 2,
132
+ },
133
+ strategy: userWallet,
134
+ });
135
+ (0, globals_1.expect)(result).toEqual(rawResponse);
136
+ (0, globals_1.expect)((0, client_1.getLoopscaleTransactionResponses)(result)).toEqual([rawTransaction]);
137
+ const [, init] = mockFetch.mock.calls[0];
138
+ (0, globals_1.expect)(JSON.parse(init?.body)).toEqual({
139
+ loan: payer.toBase58(),
140
+ borrowParams: {
141
+ amount: 10,
142
+ duration: 2,
143
+ },
144
+ strategy: userWallet.toBase58(),
145
+ });
146
+ });
147
+ (0, globals_1.it)("keeps cleanup endpoints first-class in the raw client", async () => {
148
+ const mockFetch = globalThis.fetch;
149
+ const rawTransaction = encodeTransactionResponse([]);
150
+ const rawResponse = { transactions: [rawTransaction] };
151
+ mockFetch.mockImplementation(async () => createJsonResponse(rawResponse));
152
+ const client = new client_1.LoopscaleClient({ connection, userWallet, payer });
153
+ const repayResult = await client.repayLoanSimple({
154
+ loan: payer,
155
+ repayParams: {
156
+ amount: 25,
157
+ ledgerIndex: 0,
158
+ repayAll: true,
159
+ },
160
+ strategy: userWallet,
161
+ });
162
+ (0, globals_1.expect)(repayResult).toEqual(rawResponse);
163
+ (0, globals_1.expect)((0, client_1.getLoopscaleTransactionResponses)(repayResult)).toEqual([rawTransaction]);
164
+ });
165
+ (0, globals_1.it)("deserializes raw transaction responses and extracts create-strategy accounts", async () => {
166
+ const nonce = new web3_js_1.PublicKey("8W2Y29Jw6dBfS4M7N6KBiD5D4Q2qk4VmF1jM7c3M4bXv");
167
+ const strategy = new web3_js_1.PublicKey("9b3BfUqKNAYdP9KJ3cVd7hYjW4M5w2v8s2Q2Mmj74o8D");
168
+ const createStrategyIx = buildLoopscaleInstruction("createStrategy", [
169
+ { pubkey: userWallet, isSigner: true, isWritable: true },
170
+ { pubkey: payer, isSigner: false, isWritable: true },
171
+ { pubkey: nonce, isSigner: false, isWritable: true },
172
+ { pubkey: strategy, isSigner: false, isWritable: true },
173
+ ]);
174
+ const rawResponse = encodeTransactionResponse([createStrategyIx], userWallet);
175
+ const transaction = (0, client_1.deserializeLoopscaleTransactionResponse)(rawResponse);
176
+ const batch = (0, client_1.deserializeLoopscaleTransactionBatchResponse)([rawResponse]);
177
+ (0, globals_1.expect)(transaction).toBeInstanceOf(web3_js_1.VersionedTransaction);
178
+ (0, globals_1.expect)(batch).toHaveLength(1);
179
+ (0, globals_1.expect)(await (0, client_1.extractCreatedStrategyAddress)(connection, [rawResponse])).toEqual(strategy);
180
+ (0, globals_1.expect)(await (0, client_1.extractCreatedStrategyNonce)(connection, [rawResponse])).toEqual(nonce);
181
+ });
182
+ });
183
+ //# sourceMappingURL=client.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.test.js","sourceRoot":"","sources":["../../../src/exponentVaults/loopscale/client.test.ts"],"names":[],"mappings":";;AAAA,2CAAiF;AACjF,6CAMwB;AAExB,sDAAkF;AAClF,qCAOiB;AAGjB,SAAS,kBAAkB,CAAC,IAAa,EAAE,MAAM,GAAG,GAAG;IACrD,OAAO;QACL,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG;QACjC,MAAM;QACN,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;QACtB,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAA;AACf,CAAC;AAED,SAAS,yBAAyB,CAChC,IAA8B,EAC9B,IAA4E;IAE5E,OAAO,IAAI,gCAAsB,CAAC;QACh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U,CAAC,CAAA;QAE7E,MAAM,WAAW,GAAG,IAAA,gDAAuC,EAAC,WAAW,CAAC,CAAA;QACxE,MAAM,KAAK,GAAG,IAAA,qDAA4C,EAAC,CAAC,WAAW,CAAC,CAAC,CAAA;QAEzE,IAAA,gBAAM,EAAC,WAAW,CAAC,CAAC,cAAc,CAAC,8BAAoB,CAAC,CAAA;QACxD,IAAA,gBAAM,EAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QAC7B,IAAA,gBAAM,EAAC,MAAM,IAAA,sCAA6B,EAAC,UAAU,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACxF,IAAA,gBAAM,EAAC,MAAM,IAAA,oCAA2B,EAAC,UAAU,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IACrF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,29 @@
1
+ import { Connection, PublicKey, TransactionInstruction, VersionedTransaction } from "@solana/web3.js";
2
+ import type { LoopscaleInstructionName, LoopscaleTransactionResponse, LoopscaleVersionedTransactionBatchResponse, LoopscaleVersionedTransactionResponse } from "./types";
3
+ /**
4
+ * Identify a Loopscale strategy or loan instruction from its discriminator.
5
+ *
6
+ * Returns `null` for non-Loopscale instructions and for unsupported Loopscale
7
+ * instructions outside the strategies + loans scope of this SDK module.
8
+ */
9
+ export declare function identifyLoopscaleInstruction(instruction: TransactionInstruction): LoopscaleInstructionName | null;
10
+ /**
11
+ * Deserialize a raw Loopscale transaction response into a `VersionedTransaction`.
12
+ */
13
+ export declare function deserializeLoopscaleTransactionResponse(response: LoopscaleVersionedTransactionResponse): VersionedTransaction;
14
+ /**
15
+ * Deserialize a raw Loopscale transaction batch response into `VersionedTransaction`s.
16
+ */
17
+ export declare function deserializeLoopscaleTransactionBatchResponse(response: LoopscaleVersionedTransactionBatchResponse): VersionedTransaction[];
18
+ /**
19
+ * Extract the raw transaction responses from any supported Loopscale transaction response shape.
20
+ */
21
+ export declare function getLoopscaleTransactionResponses(response: LoopscaleTransactionResponse): LoopscaleVersionedTransactionResponse[];
22
+ /**
23
+ * Extract the strategy PDA created by a Loopscale `createStrategy` response.
24
+ */
25
+ export declare function extractCreatedStrategyAddress(connection: Connection, response: LoopscaleTransactionResponse): Promise<PublicKey>;
26
+ /**
27
+ * Extract the nonce public key used by a Loopscale `createStrategy` response.
28
+ */
29
+ export declare function extractCreatedStrategyNonce(connection: Connection, response: LoopscaleTransactionResponse): Promise<PublicKey>;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractCreatedStrategyNonce = exports.extractCreatedStrategyAddress = exports.getLoopscaleTransactionResponses = exports.deserializeLoopscaleTransactionBatchResponse = exports.deserializeLoopscaleTransactionResponse = exports.identifyLoopscaleInstruction = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const policyBuilders_1 = require("../policyBuilders");
6
+ const DISCRIMINATOR_HEX_TO_NAME = new Map(Object.entries(policyBuilders_1.LOOPSCALE_DISCRIMINATORS).map(([name, discriminator]) => [
7
+ Buffer.from(discriminator).toString("hex"),
8
+ name,
9
+ ]));
10
+ function buildTransactionFromResponse(response) {
11
+ const message = web3_js_1.VersionedMessage.deserialize(Buffer.from(response.message, "base64"));
12
+ const transaction = new web3_js_1.VersionedTransaction(message);
13
+ const signerKeys = message.staticAccountKeys.slice(0, message.header.numRequiredSignatures);
14
+ for (const signature of response.signatures) {
15
+ const signer = new web3_js_1.PublicKey(signature.publicKey);
16
+ const bytes = Buffer.from(signature.signature, "base64");
17
+ if (bytes.length !== 64) {
18
+ throw new Error(`Invalid signature for ${signature.publicKey}`);
19
+ }
20
+ const signerIndex = signerKeys.findIndex((candidate) => candidate.equals(signer));
21
+ if (signerIndex >= 0) {
22
+ transaction.signatures[signerIndex] = new Uint8Array(bytes);
23
+ }
24
+ }
25
+ return transaction;
26
+ }
27
+ async function resolveAddressLookupTables(connection, transaction) {
28
+ return Promise.all(transaction.message.addressTableLookups.map(async (lookup) => {
29
+ const result = await connection.getAddressLookupTable(lookup.accountKey);
30
+ if (!result.value) {
31
+ throw new Error(`Missing lookup table ${lookup.accountKey.toBase58()}`);
32
+ }
33
+ return result.value;
34
+ }));
35
+ }
36
+ async function findInstructionByName(connection, transactions, name) {
37
+ for (const transaction of transactions) {
38
+ const addressLookupTableAccounts = await resolveAddressLookupTables(connection, transaction);
39
+ const instructions = web3_js_1.TransactionMessage.decompile(transaction.message, { addressLookupTableAccounts }).instructions;
40
+ const match = instructions.find((instruction) => identifyLoopscaleInstruction(instruction) === name);
41
+ if (match) {
42
+ return match;
43
+ }
44
+ }
45
+ return null;
46
+ }
47
+ /**
48
+ * Identify a Loopscale strategy or loan instruction from its discriminator.
49
+ *
50
+ * Returns `null` for non-Loopscale instructions and for unsupported Loopscale
51
+ * instructions outside the strategies + loans scope of this SDK module.
52
+ */
53
+ function identifyLoopscaleInstruction(instruction) {
54
+ if (!instruction.programId.equals(policyBuilders_1.LOOPSCALE_PROGRAM_ID)) {
55
+ return null;
56
+ }
57
+ const discriminator = Buffer.from(instruction.data).subarray(0, 8).toString("hex");
58
+ return DISCRIMINATOR_HEX_TO_NAME.get(discriminator) ?? null;
59
+ }
60
+ exports.identifyLoopscaleInstruction = identifyLoopscaleInstruction;
61
+ /**
62
+ * Deserialize a raw Loopscale transaction response into a `VersionedTransaction`.
63
+ */
64
+ function deserializeLoopscaleTransactionResponse(response) {
65
+ return buildTransactionFromResponse(response);
66
+ }
67
+ exports.deserializeLoopscaleTransactionResponse = deserializeLoopscaleTransactionResponse;
68
+ /**
69
+ * Deserialize a raw Loopscale transaction batch response into `VersionedTransaction`s.
70
+ */
71
+ function deserializeLoopscaleTransactionBatchResponse(response) {
72
+ return response.map((entry) => deserializeLoopscaleTransactionResponse(entry));
73
+ }
74
+ exports.deserializeLoopscaleTransactionBatchResponse = deserializeLoopscaleTransactionBatchResponse;
75
+ /**
76
+ * Extract the raw transaction responses from any supported Loopscale transaction response shape.
77
+ */
78
+ function getLoopscaleTransactionResponses(response) {
79
+ if (Array.isArray(response)) {
80
+ return response;
81
+ }
82
+ if ("transactions" in response) {
83
+ return response.transactions;
84
+ }
85
+ if ("transaction" in response) {
86
+ return [response.transaction];
87
+ }
88
+ return [response];
89
+ }
90
+ exports.getLoopscaleTransactionResponses = getLoopscaleTransactionResponses;
91
+ /**
92
+ * Extract the strategy PDA created by a Loopscale `createStrategy` response.
93
+ */
94
+ async function extractCreatedStrategyAddress(connection, response) {
95
+ const transactions = getLoopscaleTransactionResponses(response)
96
+ .map((entry) => deserializeLoopscaleTransactionResponse(entry));
97
+ const instruction = await findInstructionByName(connection, transactions, "createStrategy");
98
+ const strategy = instruction?.keys[3]?.pubkey;
99
+ if (!strategy) {
100
+ throw new Error("Loopscale createStrategy response did not contain a createStrategy instruction");
101
+ }
102
+ return strategy;
103
+ }
104
+ exports.extractCreatedStrategyAddress = extractCreatedStrategyAddress;
105
+ /**
106
+ * Extract the nonce public key used by a Loopscale `createStrategy` response.
107
+ */
108
+ async function extractCreatedStrategyNonce(connection, response) {
109
+ const transactions = getLoopscaleTransactionResponses(response)
110
+ .map((entry) => deserializeLoopscaleTransactionResponse(entry));
111
+ const instruction = await findInstructionByName(connection, transactions, "createStrategy");
112
+ const nonce = instruction?.keys[2]?.pubkey;
113
+ if (!nonce) {
114
+ throw new Error("Loopscale createStrategy response did not contain the strategy nonce account");
115
+ }
116
+ return nonce;
117
+ }
118
+ exports.extractCreatedStrategyNonce = extractCreatedStrategyNonce;
119
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/exponentVaults/loopscale/helpers.ts"],"names":[],"mappings":";;;AAAA,6CAOwB;AAQxB,sDAAkF;AAElF,MAAM,yBAAyB,GAAG,IAAI,GAAG,CACvC,MAAM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AM,QAAQ,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAA;IAC7C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAA;IACnG,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC;AAdD,sEAcC;AAED;;GAEG;AACI,KAAK,UAAU,2BAA2B,CAC/C,UAAsB,EACtB,QAAsC;IAEtC,MAAM,YAAY,GAAG,gCAAgC,CAAC,QAAQ,CAAC;SAC5D,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,uCAAuC,CAAC,KAAK,CAAC,CAAC,CAAA;IACjE,MAAM,WAAW,GAAG,MAAM,qBAAqB,CAAC,UAAU,EAAE,YAAY,EAAE,gBAAgB,CAAC,CAAA;IAE3F,MAAM,KAAK,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAA;IAC1C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAA;IACjG,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAdD,kEAcC"}
@@ -0,0 +1,3 @@
1
+ export { LoopscaleClient, deserializeLoopscaleTransactionResponse, deserializeLoopscaleTransactionBatchResponse, extractCreatedStrategyAddress, extractCreatedStrategyNonce, getLoopscaleTransactionResponses, identifyLoopscaleInstruction, } from "./client";
2
+ export type { AddCollateralArgs, CollateralAllocationUpdateArgs, CollateralParamsUpdateArgs, EditStrategySettingsArgs, ExternalYieldSourceParams, LoopscaleBorrowPrincipalParams, LoopscaleClientConfig, LoopscaleCloseLoanParams, LoopscaleCloseStrategyParams, LoopscaleCreateLoanParams, LoopscaleCreateLoanResponse, LoopscaleCreateStrategyParams, LoopscaleDepositCollateralParams, LoopscaleDepositStrategyParams, LoopscaleExpectedLoanInfo, LoopscaleGetStrategiesParams, LoopscaleInstructionName, LoopscaleLoanInfoParams, LoopscaleLoanInfoResponse, LoopscaleLoanTransactionResponse, LoopscaleMaxQuote, LoopscaleMaxQuoteParams, LoopscaleQuote, LoopscaleQuoteParams, LoopscaleRepayLoanSimpleParams, LoopscaleStrategyInfoResponse, LoopscaleTransactionResponse, LoopscaleTransactionSignature, LoopscaleTransactionsResponse, LoopscaleUpdateStrategyParams, LoopscaleVersionedTransactionBatchResponse, LoopscaleVersionedTransactionResponse, LoopscaleWithdrawCollateralParams, LoopscaleWithdrawStrategyParams, RemoveCollateralArgs, StrategyCollateralUpdates, StrategyDuration, TxnExternalYieldSourceArgs, } from "./types";
3
+ export type { LoopscaleBuildTransactionsContext, LoopscaleBuiltTransaction, LoopscalePreparedTransaction, LoopscaleVaultPreparationContext, } from "./prepared-types";
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.identifyLoopscaleInstruction = exports.getLoopscaleTransactionResponses = exports.extractCreatedStrategyNonce = exports.extractCreatedStrategyAddress = exports.deserializeLoopscaleTransactionBatchResponse = exports.deserializeLoopscaleTransactionResponse = exports.LoopscaleClient = void 0;
4
+ var client_1 = require("./client");
5
+ Object.defineProperty(exports, "LoopscaleClient", { enumerable: true, get: function () { return client_1.LoopscaleClient; } });
6
+ Object.defineProperty(exports, "deserializeLoopscaleTransactionResponse", { enumerable: true, get: function () { return client_1.deserializeLoopscaleTransactionResponse; } });
7
+ Object.defineProperty(exports, "deserializeLoopscaleTransactionBatchResponse", { enumerable: true, get: function () { return client_1.deserializeLoopscaleTransactionBatchResponse; } });
8
+ Object.defineProperty(exports, "extractCreatedStrategyAddress", { enumerable: true, get: function () { return client_1.extractCreatedStrategyAddress; } });
9
+ Object.defineProperty(exports, "extractCreatedStrategyNonce", { enumerable: true, get: function () { return client_1.extractCreatedStrategyNonce; } });
10
+ Object.defineProperty(exports, "getLoopscaleTransactionResponses", { enumerable: true, get: function () { return client_1.getLoopscaleTransactionResponses; } });
11
+ Object.defineProperty(exports, "identifyLoopscaleInstruction", { enumerable: true, get: function () { return client_1.identifyLoopscaleInstruction; } });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exponentVaults/loopscale/index.ts"],"names":[],"mappings":";;;AAAA,mCAQiB;AAPf,yGAAA,eAAe,OAAA;AACf,iIAAA,uCAAuC,OAAA;AACvC,sIAAA,4CAA4C,OAAA;AAC5C,uHAAA,6BAA6B,OAAA;AAC7B,qHAAA,2BAA2B,OAAA;AAC3B,0HAAA,gCAAgC,OAAA;AAChC,sHAAA,4BAA4B,OAAA"}
@@ -0,0 +1,13 @@
1
+ import type { LoopscalePreparedTransaction, LoopscaleVaultPreparationContext } from "./prepared-types";
2
+ import type { LoopscaleTransactionResponse } from "./types";
3
+ /**
4
+ * Internal adapter used by `LoopscaleClient.prepareVaultTransactions(...)`.
5
+ *
6
+ * It converts raw Loopscale responses into manager-ready transaction pieces:
7
+ * standalone top-level transactions, wrapped top-level vault-signed
8
+ * transactions, or wrapped Loopscale sync transactions.
9
+ */
10
+ export declare function prepareLoopscaleVaultTransactions({ response, context, }: {
11
+ response: LoopscaleTransactionResponse;
12
+ context: LoopscaleVaultPreparationContext;
13
+ }): Promise<LoopscalePreparedTransaction[]>;