@temporalabs/treasury 0.1.2 → 0.1.4
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/README.md +45 -13
- package/THIRD_PARTY_NOTICES.connect-page.md +494 -24
- package/THIRD_PARTY_NOTICES.md +579 -6
- package/dist/cli.js +28 -5
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +50 -209
- package/dist/client.js +66 -11
- package/dist/client.js.map +1 -1
- package/dist/config/earn.d.ts +16 -1
- package/dist/config/earn.js +16 -1
- package/dist/config/earn.js.map +1 -1
- package/dist/connect/ack.d.ts +88 -1
- package/dist/connect/ack.js +177 -6
- package/dist/connect/ack.js.map +1 -1
- package/dist/connect/commands.d.ts +30 -0
- package/dist/connect/commands.js +846 -88
- package/dist/connect/commands.js.map +1 -1
- package/dist/connect/config.d.ts +7 -5
- package/dist/connect/config.js +8 -6
- package/dist/connect/config.js.map +1 -1
- package/dist/connect/gate-solana.d.ts +8 -0
- package/dist/connect/gate-solana.js +147 -0
- package/dist/connect/gate-solana.js.map +1 -0
- package/dist/connect/http.d.ts +17 -2
- package/dist/connect/http.js +45 -13
- package/dist/connect/http.js.map +1 -1
- package/dist/connect/page.d.ts +1 -1
- package/dist/connect/page.js +2 -2
- package/dist/connect/page.js.map +1 -1
- package/dist/connect/session.d.ts +40 -1
- package/dist/connect/session.js +243 -2
- package/dist/connect/session.js.map +1 -1
- package/dist/connect/solana.d.ts +112 -0
- package/dist/connect/solana.js +370 -0
- package/dist/connect/solana.js.map +1 -0
- package/dist/connect-page.js +835 -671
- package/dist/disclosures.d.ts +7 -4
- package/dist/disclosures.js +7 -4
- package/dist/disclosures.js.map +1 -1
- package/dist/earn/commands.js +127 -54
- package/dist/earn/commands.js.map +1 -1
- package/dist/earn/solana.d.ts +278 -0
- package/dist/earn/solana.js +316 -0
- package/dist/earn/solana.js.map +1 -0
- package/dist/guide.d.ts +15 -0
- package/dist/guide.js +50 -0
- package/dist/guide.js.map +1 -0
- package/dist/links.js +2 -0
- package/dist/links.js.map +1 -1
- package/dist/position.d.ts +3 -2
- package/dist/position.js +6 -3
- package/dist/position.js.map +1 -1
- package/dist/quote.js +2 -2
- package/dist/quote.js.map +1 -1
- package/dist/redact.js +7 -1
- package/dist/redact.js.map +1 -1
- package/dist/registry-schema.d.ts +79 -2
- package/dist/registry-schema.js +77 -1
- package/dist/registry-schema.js.map +1 -1
- package/dist/registry.d.ts +21 -1
- package/dist/registry.js +48 -10
- package/dist/registry.js.map +1 -1
- package/dist/solana/constants.d.ts +49 -0
- package/dist/solana/constants.js +50 -0
- package/dist/solana/constants.js.map +1 -0
- package/dist/solana/kvault.d.ts +99 -0
- package/dist/solana/kvault.js +192 -0
- package/dist/solana/kvault.js.map +1 -0
- package/dist/solana/layout.d.ts +143 -0
- package/dist/solana/layout.js +209 -0
- package/dist/solana/layout.js.map +1 -0
- package/dist/solana/rpc.d.ts +24 -0
- package/dist/solana/rpc.js +66 -0
- package/dist/solana/rpc.js.map +1 -0
- package/dist/solana/vault.d.ts +153 -0
- package/dist/solana/vault.js +322 -0
- package/dist/solana/vault.js.map +1 -0
- package/dist/treasury.mjs +37410 -27965
- package/dist/version.js +5 -10
- package/dist/version.js.map +1 -1
- package/llms.txt +637 -0
- package/package.json +14 -8
- package/registry/vaults.json +113 -0
package/dist/registry.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { readFileSync, realpathSync } from "node:fs";
|
|
2
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
1
|
import { registrySchema, erc4626Chassis } from "./registry-schema.js";
|
|
2
|
+
import registryJson from "../registry/vaults.json" with { type: "json" };
|
|
4
3
|
import { EARN } from "./config/earn.js";
|
|
5
|
-
import { CHAIN_INFO, chainIdForKey, supportedChainIds } from "./client.js";
|
|
6
|
-
// From this file's real path, not a symlink's: see PACKAGE_JSON_URL in version.ts.
|
|
7
|
-
const REGISTRY_URL = new URL("../registry/vaults.json", pathToFileURL(realpathSync(fileURLToPath(import.meta.url))));
|
|
4
|
+
import { CHAIN_INFO, chainIdForKey, SOLANA_INFO, supportedChainIds } from "./client.js";
|
|
8
5
|
let cached;
|
|
9
6
|
/** Parses and validates the shipped registry. Throws on any schema violation — a registry that does not parse is not a registry. */
|
|
10
7
|
export function loadRegistry() {
|
|
11
8
|
if (cached)
|
|
12
9
|
return cached;
|
|
13
|
-
const raw =
|
|
10
|
+
const raw = registryJson;
|
|
14
11
|
const parsed = registrySchema.parse(raw);
|
|
15
12
|
// The schema holds one default per chain THAT HAS A VAULT, so it cannot see a registry with no
|
|
16
13
|
// vault on the default chain at all — and then the discovery call itself is what fails, with an
|
|
@@ -38,13 +35,52 @@ export function listVaults() {
|
|
|
38
35
|
export function getVault(symbol) {
|
|
39
36
|
const v = loadRegistry().vaults.find((x) => x.symbol === symbol);
|
|
40
37
|
if (!v) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
if (loadRegistry().solanaVaults.some((x) => x.symbol === symbol)) {
|
|
39
|
+
throw new Error(`vault "${symbol}" is on solana, which this command does not handle`);
|
|
40
|
+
}
|
|
41
|
+
const known = [...loadRegistry().vaults, ...loadRegistry().solanaVaults].map((x) => x.symbol).join(", ");
|
|
44
42
|
throw new Error(`unknown vault "${symbol}"; known: ${known}`);
|
|
45
43
|
}
|
|
46
44
|
return v;
|
|
47
45
|
}
|
|
46
|
+
/** The vaults on Solana (`solanaVaults` in the registry). */
|
|
47
|
+
export function listSolanaVaults() {
|
|
48
|
+
return loadRegistry().solanaVaults;
|
|
49
|
+
}
|
|
50
|
+
/** Every chain a caller can name, EVM and Solana, the default chain first: the list a refusal names. */
|
|
51
|
+
export function offeredChainKeys() {
|
|
52
|
+
return [...offeredChains().map((c) => c.key), ...(listSolanaVaults().length > 0 ? [SOLANA_INFO.key] : [])];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* `resolveVault` across chain families: `chain: "solana"`, or a `vault` that is on Solana, resolves to the
|
|
56
|
+
* Solana row; anything else is `resolveVault`, unchanged. The same refusals hold: a vault and a chain that
|
|
57
|
+
* disagree are refused, and the error says which chain the vault is on.
|
|
58
|
+
*/
|
|
59
|
+
export function resolveAnyVault(symbol, chain) {
|
|
60
|
+
const sol = symbol ? listSolanaVaults().find((x) => x.symbol === symbol) : undefined;
|
|
61
|
+
if (chain === SOLANA_INFO.key) {
|
|
62
|
+
const vaults = listSolanaVaults();
|
|
63
|
+
if (vaults.length === 0)
|
|
64
|
+
throw new Error(`unknown chain "${chain}"; chains with a vault: ${offeredChainKeys().join(", ")}`);
|
|
65
|
+
if (!symbol)
|
|
66
|
+
return { family: "solana", vault: vaults.find((x) => x.isDefault) };
|
|
67
|
+
if (sol)
|
|
68
|
+
return { family: "solana", vault: sol };
|
|
69
|
+
const evm = getVault(symbol);
|
|
70
|
+
throw new Error(`vault "${symbol}" is on ${CHAIN_INFO[evm.chainId].key}, not solana. Name one or the other: drop \`chain\` to use ${symbol} on ${CHAIN_INFO[evm.chainId].key}, or pick a vault on solana (${vaults.map((x) => x.symbol).join(", ")}).`);
|
|
71
|
+
}
|
|
72
|
+
if (sol) {
|
|
73
|
+
if (chain) {
|
|
74
|
+
throw new Error(`vault "${symbol}" is on solana, not ${chain}. Name one or the other: drop \`chain\` to use ${symbol} on solana, or pick a vault on ${chain}.`);
|
|
75
|
+
}
|
|
76
|
+
return { family: "solana", vault: sol };
|
|
77
|
+
}
|
|
78
|
+
return { family: "evm", vault: resolveVault(symbol, chain) };
|
|
79
|
+
}
|
|
80
|
+
/** The Solana vaults any account can put money into: measured open. */
|
|
81
|
+
export function depositableSolanaVaults() {
|
|
82
|
+
return listSolanaVaults().filter((v) => v.depositOpen.open);
|
|
83
|
+
}
|
|
48
84
|
/** The chain used when a caller names neither a chain nor a vault: `EARN.defaultChain`. */
|
|
49
85
|
export function defaultChainId() {
|
|
50
86
|
const id = chainIdForKey(EARN.defaultChain);
|
|
@@ -98,10 +134,12 @@ export function resolveVault(symbol, chain) {
|
|
|
98
134
|
// An EMPTY string is an omitted argument, for `chain` exactly as for `vault` (`!symbol` below):
|
|
99
135
|
// a host that sends "" for every optional it did not fill must get the default, not a refusal.
|
|
100
136
|
if (chain) {
|
|
137
|
+
if (chain === SOLANA_INFO.key)
|
|
138
|
+
throw new Error(`chain "${chain}" has no ERC-4626 vault; this resolves the EVM vaults only, and the Solana vault is reached through the CLI (\`treasury earn … --chain solana\`)`);
|
|
101
139
|
chainId = chainIdForKey(chain);
|
|
102
140
|
const offered = offeredChains();
|
|
103
141
|
if (chainId === undefined || !offered.some((c) => c.chainId === chainId)) {
|
|
104
|
-
throw new Error(`unknown chain "${chain}"; chains with a vault: ${
|
|
142
|
+
throw new Error(`unknown chain "${chain}"; chains with a vault: ${offeredChainKeys().join(", ")}`);
|
|
105
143
|
}
|
|
106
144
|
}
|
|
107
145
|
if (!symbol)
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAyD,MAAM,sBAAsB,CAAC;AAC7H,OAAO,YAAY,MAAM,yBAAyB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAwC,MAAM,aAAa,CAAC;AAE9H,IAAI,MAA4B,CAAC;AAEjC,oIAAoI;AACpI,MAAM,UAAU,YAAY;IAC1B,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,GAAG,GAAY,YAAY,CAAC;IAClC,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC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,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC;aAC3C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;aACpB,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,IAAI,KAAK,CACb,UAAU,MAAM,WAAW,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,KAAK,kDAAkD,MAAM,OAAO,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,wBAAwB,KAAK,KAAK,EAAE,IAAI,CACnM,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,YAAY,EAAE,CAAC,MAAM,CAAC,MAAM,CACjC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,IAAI,CAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solana constants: the programs a Kamino vault deposit or withdrawal names, and the cluster.
|
|
3
|
+
*
|
|
4
|
+
* Every program id below was read on Solana mainnet-beta. Both Kamino programs are UPGRADEABLE by their
|
|
5
|
+
* upgrade authority, so a later upgrade can change any behaviour this client relies on. The decoders in
|
|
6
|
+
* `layout.ts` refuse an account of the wrong size or type rather than read it, which is the one change this
|
|
7
|
+
* client can notice; anything else is a disclosure, not a check.
|
|
8
|
+
*/
|
|
9
|
+
/** Kamino's vault program (a curated single-asset vault over Kamino lending reserves). */
|
|
10
|
+
export declare const KVAULT_PROGRAM_ID: "KvauGMspG5k6rtzrqqn7WNn3oZdyKqLKwK2XWQ8FLjd";
|
|
11
|
+
/** Kamino's lending program, where the vault's reserves live. */
|
|
12
|
+
export declare const KLEND_PROGRAM_ID: "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD";
|
|
13
|
+
/** SPL Token: the program that owns USDC and the vault's share mint. */
|
|
14
|
+
export declare const SPL_TOKEN_PROGRAM_ID: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
15
|
+
/** The Associated Token Account program. */
|
|
16
|
+
export declare const ASSOCIATED_TOKEN_PROGRAM_ID: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
17
|
+
/** The System Program. */
|
|
18
|
+
export declare const SYSTEM_PROGRAM_ID: "11111111111111111111111111111111";
|
|
19
|
+
/** The instructions sysvar, which a kVault withdrawal from a reserve names. */
|
|
20
|
+
export declare const SYSVAR_INSTRUCTIONS_ID: "Sysvar1nstructions1111111111111111111111111";
|
|
21
|
+
/** The Compute Budget program. */
|
|
22
|
+
export declare const COMPUTE_BUDGET_PROGRAM_ID: "ComputeBudget111111111111111111111111111111";
|
|
23
|
+
/** The all-zero key: an empty allocation slot's reserve. */
|
|
24
|
+
export declare const DEFAULT_PUBKEY: "11111111111111111111111111111111";
|
|
25
|
+
/**
|
|
26
|
+
* Solana mainnet-beta's genesis hash. An RPC endpoint is on mainnet exactly when `getGenesisHash` returns this:
|
|
27
|
+
* the Solana counterpart of an EVM endpoint's `eth_chainId`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const MAINNET_GENESIS_HASH: "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
|
|
30
|
+
/** PDA seeds, as Kamino's vault program spells them. */
|
|
31
|
+
export declare const SEEDS: {
|
|
32
|
+
readonly tokenVault: "token_vault";
|
|
33
|
+
readonly ctokenVault: "ctoken_vault";
|
|
34
|
+
readonly baseVaultAuthority: "authority";
|
|
35
|
+
readonly shares: "shares";
|
|
36
|
+
readonly globalConfig: "global_config";
|
|
37
|
+
readonly eventAuthority: "__event_authority";
|
|
38
|
+
/** The lending program's market authority. */
|
|
39
|
+
readonly lendingMarketAuthority: "lma";
|
|
40
|
+
};
|
|
41
|
+
/** Account sizes INCLUDING the 8-byte Anchor discriminator, from Kamino's IDL and measured on chain. */
|
|
42
|
+
export declare const VAULT_STATE_SIZE = 62552;
|
|
43
|
+
export declare const RESERVE_SIZE = 8624;
|
|
44
|
+
/** A vault has this many allocation slots; an empty slot's `reserve` is the default key. */
|
|
45
|
+
export declare const MAX_RESERVES = 25;
|
|
46
|
+
/** Solana's packet limit for one serialized transaction. */
|
|
47
|
+
export declare const MAX_TRANSACTION_BYTES = 1232;
|
|
48
|
+
/** The most compute one transaction may request. */
|
|
49
|
+
export declare const MAX_COMPUTE_UNITS = 1400000;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solana constants: the programs a Kamino vault deposit or withdrawal names, and the cluster.
|
|
3
|
+
*
|
|
4
|
+
* Every program id below was read on Solana mainnet-beta. Both Kamino programs are UPGRADEABLE by their
|
|
5
|
+
* upgrade authority, so a later upgrade can change any behaviour this client relies on. The decoders in
|
|
6
|
+
* `layout.ts` refuse an account of the wrong size or type rather than read it, which is the one change this
|
|
7
|
+
* client can notice; anything else is a disclosure, not a check.
|
|
8
|
+
*/
|
|
9
|
+
/** Kamino's vault program (a curated single-asset vault over Kamino lending reserves). */
|
|
10
|
+
export const KVAULT_PROGRAM_ID = "KvauGMspG5k6rtzrqqn7WNn3oZdyKqLKwK2XWQ8FLjd";
|
|
11
|
+
/** Kamino's lending program, where the vault's reserves live. */
|
|
12
|
+
export const KLEND_PROGRAM_ID = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD";
|
|
13
|
+
/** SPL Token: the program that owns USDC and the vault's share mint. */
|
|
14
|
+
export const SPL_TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
15
|
+
/** The Associated Token Account program. */
|
|
16
|
+
export const ASSOCIATED_TOKEN_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
17
|
+
/** The System Program. */
|
|
18
|
+
export const SYSTEM_PROGRAM_ID = "11111111111111111111111111111111";
|
|
19
|
+
/** The instructions sysvar, which a kVault withdrawal from a reserve names. */
|
|
20
|
+
export const SYSVAR_INSTRUCTIONS_ID = "Sysvar1nstructions1111111111111111111111111";
|
|
21
|
+
/** The Compute Budget program. */
|
|
22
|
+
export const COMPUTE_BUDGET_PROGRAM_ID = "ComputeBudget111111111111111111111111111111";
|
|
23
|
+
/** The all-zero key: an empty allocation slot's reserve. */
|
|
24
|
+
export const DEFAULT_PUBKEY = SYSTEM_PROGRAM_ID;
|
|
25
|
+
/**
|
|
26
|
+
* Solana mainnet-beta's genesis hash. An RPC endpoint is on mainnet exactly when `getGenesisHash` returns this:
|
|
27
|
+
* the Solana counterpart of an EVM endpoint's `eth_chainId`.
|
|
28
|
+
*/
|
|
29
|
+
export const MAINNET_GENESIS_HASH = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
|
|
30
|
+
/** PDA seeds, as Kamino's vault program spells them. */
|
|
31
|
+
export const SEEDS = {
|
|
32
|
+
tokenVault: "token_vault",
|
|
33
|
+
ctokenVault: "ctoken_vault",
|
|
34
|
+
baseVaultAuthority: "authority",
|
|
35
|
+
shares: "shares",
|
|
36
|
+
globalConfig: "global_config",
|
|
37
|
+
eventAuthority: "__event_authority",
|
|
38
|
+
/** The lending program's market authority. */
|
|
39
|
+
lendingMarketAuthority: "lma",
|
|
40
|
+
};
|
|
41
|
+
/** Account sizes INCLUDING the 8-byte Anchor discriminator, from Kamino's IDL and measured on chain. */
|
|
42
|
+
export const VAULT_STATE_SIZE = 62_552;
|
|
43
|
+
export const RESERVE_SIZE = 8_624;
|
|
44
|
+
/** A vault has this many allocation slots; an empty slot's `reserve` is the default key. */
|
|
45
|
+
export const MAX_RESERVES = 25;
|
|
46
|
+
/** Solana's packet limit for one serialized transaction. */
|
|
47
|
+
export const MAX_TRANSACTION_BYTES = 1232;
|
|
48
|
+
/** The most compute one transaction may request. */
|
|
49
|
+
export const MAX_COMPUTE_UNITS = 1_400_000;
|
|
50
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/solana/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,iBAAiB,GAAG,6CAAsD,CAAC;AACxF,iEAAiE;AACjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,6CAAsD,CAAC;AACvF,wEAAwE;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG,6CAAsD,CAAC;AAC3F,4CAA4C;AAC5C,MAAM,CAAC,MAAM,2BAA2B,GAAG,8CAAuD,CAAC;AACnG,0BAA0B;AAC1B,MAAM,CAAC,MAAM,iBAAiB,GAAG,kCAA2C,CAAC;AAC7E,+EAA+E;AAC/E,MAAM,CAAC,MAAM,sBAAsB,GAAG,6CAAsD,CAAC;AAC7F,kCAAkC;AAClC,MAAM,CAAC,MAAM,yBAAyB,GAAG,6CAAsD,CAAC;AAEhG,4DAA4D;AAC5D,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,8CAAuD,CAAC;AAE5F,wDAAwD;AACxD,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,UAAU,EAAE,aAAa;IACzB,WAAW,EAAE,cAAc;IAC3B,kBAAkB,EAAE,WAAW;IAC/B,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,eAAe;IAC7B,cAAc,EAAE,mBAAmB;IACnC,8CAA8C;IAC9C,sBAAsB,EAAE,KAAK;CACrB,CAAC;AAEX,wGAAwG;AACxG,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACvC,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC;AAClC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,4DAA4D;AAC5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,oDAAoD;AACpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The depositor's side of a Kamino vault: the PDAs a deposit or withdrawal names, the two instructions
|
|
3
|
+
* (`deposit`, `withdraw`), the token-account instruction a first deposit needs, and an UNSIGNED transaction.
|
|
4
|
+
*
|
|
5
|
+
* 🔴 HAND-WRITTEN, PINNED TO THE VENDOR'S BYTES. Each builder must produce exactly the data bytes and the
|
|
6
|
+
* account metas (address, role, order) Kamino's own SDK produces for the same inputs:
|
|
7
|
+
* `tests/solana-kvault.unit.test.ts` asserts byte equality against `vendor/kamino/instruction-fixtures.json`,
|
|
8
|
+
* written by Kamino's SDK (`vendor/kamino/generate-fixtures.mjs`, version in `vendor/kamino/PINNED`).
|
|
9
|
+
*
|
|
10
|
+
* Nothing here signs or sends. The signer slot is an ADDRESS: the operator's wallet signs.
|
|
11
|
+
*/
|
|
12
|
+
import { type Address, type Instruction } from "@solana/kit";
|
|
13
|
+
/** `sha256("global:<name>")[0..8]`, per instruction. */
|
|
14
|
+
export declare const DISCRIMINATORS: {
|
|
15
|
+
readonly deposit: readonly [242, 35, 198, 137, 82, 225, 242, 182];
|
|
16
|
+
readonly withdraw: readonly [183, 18, 70, 156, 148, 109, 161, 34];
|
|
17
|
+
};
|
|
18
|
+
/** Every PDA a vault owns, from its vault-state address alone. */
|
|
19
|
+
export declare function vaultPdas(vaultState: string): Promise<{
|
|
20
|
+
tokenVault: Address;
|
|
21
|
+
baseVaultAuthority: Address;
|
|
22
|
+
sharesMint: Address;
|
|
23
|
+
}>;
|
|
24
|
+
/** The vault's ctoken account for one reserve. */
|
|
25
|
+
export declare const ctokenVaultPda: (vaultState: string, reserve: string) => Promise<Address>;
|
|
26
|
+
export declare const kvaultGlobalConfigPda: () => Promise<Address>;
|
|
27
|
+
/** Anchor's event-CPI authority for the vault program: `deposit` and `withdraw` name it. */
|
|
28
|
+
export declare const kvaultEventAuthorityPda: () => Promise<Address>;
|
|
29
|
+
/** The lending program's authority for one market. */
|
|
30
|
+
export declare const lendingMarketAuthorityPda: (lendingMarket: string) => Promise<Address>;
|
|
31
|
+
/** The owner's associated token account for `mint` (SPL Token). */
|
|
32
|
+
export declare function associatedTokenAccount(owner: string, mint: string): Promise<Address>;
|
|
33
|
+
/** A reserve and its market, as every deposit and withdrawal lists them for the program to refresh. */
|
|
34
|
+
export interface VaultReserve {
|
|
35
|
+
readonly reserve: string;
|
|
36
|
+
readonly lendingMarket: string;
|
|
37
|
+
}
|
|
38
|
+
/** What a withdrawal from one reserve needs to know about it (all read on chain). */
|
|
39
|
+
export interface ReserveAccounts extends VaultReserve {
|
|
40
|
+
readonly liquiditySupplyVault: string;
|
|
41
|
+
readonly collateralMint: string;
|
|
42
|
+
}
|
|
43
|
+
/** The accounts both depositor instructions share, all derived from or read off the vault. */
|
|
44
|
+
export interface VaultAccounts {
|
|
45
|
+
readonly vaultState: string;
|
|
46
|
+
readonly tokenVault: string;
|
|
47
|
+
readonly tokenMint: string;
|
|
48
|
+
readonly baseVaultAuthority: string;
|
|
49
|
+
readonly sharesMint: string;
|
|
50
|
+
readonly vaultReserves: readonly VaultReserve[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* `deposit(max_amount)`: the USER's tokens in, shares out to the user's own share account. The program
|
|
54
|
+
* refreshes every vault reserve first, which is why each reserve and its market follow the fixed accounts.
|
|
55
|
+
* There is no receiver: the shares can only land in the signer's own account.
|
|
56
|
+
*/
|
|
57
|
+
export declare function depositIx(p: VaultAccounts & {
|
|
58
|
+
user: string;
|
|
59
|
+
userTokenAta: string;
|
|
60
|
+
userSharesAta: string;
|
|
61
|
+
maxAmount: bigint;
|
|
62
|
+
}): Promise<Instruction>;
|
|
63
|
+
/**
|
|
64
|
+
* `withdraw(shares_amount)`: the user burns shares for the vault's token, paid from the vault's idle balance
|
|
65
|
+
* first and then from `reserve`. One reserve per instruction; a withdrawal larger than idle plus what one
|
|
66
|
+
* reserve can release takes one instruction per reserve. Paid to the signer's own token account only.
|
|
67
|
+
*/
|
|
68
|
+
export declare function withdrawIx(p: VaultAccounts & {
|
|
69
|
+
user: string;
|
|
70
|
+
userTokenAta: string;
|
|
71
|
+
userSharesAta: string;
|
|
72
|
+
sharesAmount: bigint;
|
|
73
|
+
reserve: ReserveAccounts;
|
|
74
|
+
}): Promise<Instruction>;
|
|
75
|
+
/**
|
|
76
|
+
* The Associated Token Account program's `CreateIdempotent` (instruction 1): creates `owner`'s token account for
|
|
77
|
+
* `mint` if it does not exist, and does nothing if it does. The payer is the owner, who pays its rent (about
|
|
78
|
+
* 0.002 SOL, returned if the account is ever closed). A first deposit needs it for the share account.
|
|
79
|
+
*/
|
|
80
|
+
export declare function createAtaIdempotentIx(owner: string, mint: string): Promise<Instruction>;
|
|
81
|
+
/**
|
|
82
|
+
* `SetComputeUnitLimit(units)` (Compute Budget instruction 2, a u32). A deposit or withdrawal refreshes every
|
|
83
|
+
* vault reserve inside the program, which can exceed the default 200,000 units.
|
|
84
|
+
*/
|
|
85
|
+
export declare function setComputeUnitLimitIx(units: number): Instruction;
|
|
86
|
+
/** A recent blockhash and the block height after which a transaction naming it can no longer land. */
|
|
87
|
+
export interface Lifetime {
|
|
88
|
+
readonly blockhash: string;
|
|
89
|
+
readonly lastValidBlockHeight: bigint;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A legacy transaction, UNSIGNED (every signature slot zero), as base64 wire bytes. The fee payer is the
|
|
93
|
+
* signer; a wallet adds the signature. It lands only before `lifetime.lastValidBlockHeight`, about a minute
|
|
94
|
+
* after the blockhash was read.
|
|
95
|
+
*/
|
|
96
|
+
export declare function compileUnsigned(instructions: readonly Instruction[], feePayer: string, lifetime: Lifetime): {
|
|
97
|
+
base64: string;
|
|
98
|
+
bytes: number;
|
|
99
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The depositor's side of a Kamino vault: the PDAs a deposit or withdrawal names, the two instructions
|
|
3
|
+
* (`deposit`, `withdraw`), the token-account instruction a first deposit needs, and an UNSIGNED transaction.
|
|
4
|
+
*
|
|
5
|
+
* 🔴 HAND-WRITTEN, PINNED TO THE VENDOR'S BYTES. Each builder must produce exactly the data bytes and the
|
|
6
|
+
* account metas (address, role, order) Kamino's own SDK produces for the same inputs:
|
|
7
|
+
* `tests/solana-kvault.unit.test.ts` asserts byte equality against `vendor/kamino/instruction-fixtures.json`,
|
|
8
|
+
* written by Kamino's SDK (`vendor/kamino/generate-fixtures.mjs`, version in `vendor/kamino/PINNED`).
|
|
9
|
+
*
|
|
10
|
+
* Nothing here signs or sends. The signer slot is an ADDRESS: the operator's wallet signs.
|
|
11
|
+
*/
|
|
12
|
+
import { AccountRole, address, appendTransactionMessageInstructions, compileTransaction, createTransactionMessage, getAddressEncoder, getBase64EncodedWireTransaction, getProgramDerivedAddress, pipe, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, } from "@solana/kit";
|
|
13
|
+
import { ASSOCIATED_TOKEN_PROGRAM_ID, COMPUTE_BUDGET_PROGRAM_ID, KLEND_PROGRAM_ID, KVAULT_PROGRAM_ID, MAX_COMPUTE_UNITS, SEEDS, SPL_TOKEN_PROGRAM_ID, SYSTEM_PROGRAM_ID, SYSVAR_INSTRUCTIONS_ID, } from "./constants.js";
|
|
14
|
+
/** `sha256("global:<name>")[0..8]`, per instruction. */
|
|
15
|
+
export const DISCRIMINATORS = {
|
|
16
|
+
deposit: [242, 35, 198, 137, 82, 225, 242, 182],
|
|
17
|
+
withdraw: [183, 18, 70, 156, 148, 109, 161, 34],
|
|
18
|
+
};
|
|
19
|
+
const encoder = getAddressEncoder();
|
|
20
|
+
const utf8 = (s) => new TextEncoder().encode(s);
|
|
21
|
+
const ro = (a) => ({ address: address(a), role: AccountRole.READONLY });
|
|
22
|
+
const rw = (a) => ({ address: address(a), role: AccountRole.WRITABLE });
|
|
23
|
+
const signer = (a, writable) => ({
|
|
24
|
+
address: address(a),
|
|
25
|
+
role: writable ? AccountRole.WRITABLE_SIGNER : AccountRole.READONLY_SIGNER,
|
|
26
|
+
});
|
|
27
|
+
function u64le(v) {
|
|
28
|
+
if (v < 0n || v > 0xffffffffffffffffn)
|
|
29
|
+
throw new Error(`${v} does not fit a u64`);
|
|
30
|
+
const b = new Uint8Array(8);
|
|
31
|
+
new DataView(b.buffer).setBigUint64(0, v, true);
|
|
32
|
+
return b;
|
|
33
|
+
}
|
|
34
|
+
function concat(...parts) {
|
|
35
|
+
const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
|
|
36
|
+
let i = 0;
|
|
37
|
+
for (const p of parts) {
|
|
38
|
+
out.set(p, i);
|
|
39
|
+
i += p.length;
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
async function pda(program, seeds) {
|
|
44
|
+
const [found] = await getProgramDerivedAddress({
|
|
45
|
+
programAddress: address(program),
|
|
46
|
+
seeds: seeds.map((s) => (typeof s === "string" ? encoder.encode(address(s)) : utf8(s.text))),
|
|
47
|
+
});
|
|
48
|
+
return found;
|
|
49
|
+
}
|
|
50
|
+
/** Every PDA a vault owns, from its vault-state address alone. */
|
|
51
|
+
export async function vaultPdas(vaultState) {
|
|
52
|
+
const [tokenVault, baseVaultAuthority, sharesMint] = await Promise.all([
|
|
53
|
+
pda(KVAULT_PROGRAM_ID, [{ text: SEEDS.tokenVault }, vaultState]),
|
|
54
|
+
pda(KVAULT_PROGRAM_ID, [{ text: SEEDS.baseVaultAuthority }, vaultState]),
|
|
55
|
+
pda(KVAULT_PROGRAM_ID, [{ text: SEEDS.shares }, vaultState]),
|
|
56
|
+
]);
|
|
57
|
+
return { tokenVault, baseVaultAuthority, sharesMint };
|
|
58
|
+
}
|
|
59
|
+
/** The vault's ctoken account for one reserve. */
|
|
60
|
+
export const ctokenVaultPda = (vaultState, reserve) => pda(KVAULT_PROGRAM_ID, [{ text: SEEDS.ctokenVault }, vaultState, reserve]);
|
|
61
|
+
export const kvaultGlobalConfigPda = () => pda(KVAULT_PROGRAM_ID, [{ text: SEEDS.globalConfig }]);
|
|
62
|
+
/** Anchor's event-CPI authority for the vault program: `deposit` and `withdraw` name it. */
|
|
63
|
+
export const kvaultEventAuthorityPda = () => pda(KVAULT_PROGRAM_ID, [{ text: SEEDS.eventAuthority }]);
|
|
64
|
+
/** The lending program's authority for one market. */
|
|
65
|
+
export const lendingMarketAuthorityPda = (lendingMarket) => pda(KLEND_PROGRAM_ID, [{ text: SEEDS.lendingMarketAuthority }, lendingMarket]);
|
|
66
|
+
/** The owner's associated token account for `mint` (SPL Token). */
|
|
67
|
+
export async function associatedTokenAccount(owner, mint) {
|
|
68
|
+
const [found] = await getProgramDerivedAddress({
|
|
69
|
+
programAddress: address(ASSOCIATED_TOKEN_PROGRAM_ID),
|
|
70
|
+
seeds: [encoder.encode(address(owner)), encoder.encode(address(SPL_TOKEN_PROGRAM_ID)), encoder.encode(address(mint))],
|
|
71
|
+
});
|
|
72
|
+
return found;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* `deposit(max_amount)`: the USER's tokens in, shares out to the user's own share account. The program
|
|
76
|
+
* refreshes every vault reserve first, which is why each reserve and its market follow the fixed accounts.
|
|
77
|
+
* There is no receiver: the shares can only land in the signer's own account.
|
|
78
|
+
*/
|
|
79
|
+
export async function depositIx(p) {
|
|
80
|
+
return {
|
|
81
|
+
programAddress: address(KVAULT_PROGRAM_ID),
|
|
82
|
+
accounts: [
|
|
83
|
+
signer(p.user, true),
|
|
84
|
+
rw(p.vaultState),
|
|
85
|
+
rw(p.tokenVault),
|
|
86
|
+
ro(p.tokenMint),
|
|
87
|
+
ro(p.baseVaultAuthority),
|
|
88
|
+
rw(p.sharesMint),
|
|
89
|
+
rw(p.userTokenAta),
|
|
90
|
+
rw(p.userSharesAta),
|
|
91
|
+
ro(KLEND_PROGRAM_ID),
|
|
92
|
+
ro(SPL_TOKEN_PROGRAM_ID),
|
|
93
|
+
ro(SPL_TOKEN_PROGRAM_ID),
|
|
94
|
+
ro(await kvaultEventAuthorityPda()),
|
|
95
|
+
ro(KVAULT_PROGRAM_ID),
|
|
96
|
+
...p.vaultReserves.map((r) => rw(r.reserve)),
|
|
97
|
+
...p.vaultReserves.map((r) => ro(r.lendingMarket)),
|
|
98
|
+
],
|
|
99
|
+
data: concat(DISCRIMINATORS.deposit, u64le(p.maxAmount)),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* `withdraw(shares_amount)`: the user burns shares for the vault's token, paid from the vault's idle balance
|
|
104
|
+
* first and then from `reserve`. One reserve per instruction; a withdrawal larger than idle plus what one
|
|
105
|
+
* reserve can release takes one instruction per reserve. Paid to the signer's own token account only.
|
|
106
|
+
*/
|
|
107
|
+
export async function withdrawIx(p) {
|
|
108
|
+
const [ctokenVault, lma, eventAuthority, globalConfig] = await Promise.all([
|
|
109
|
+
ctokenVaultPda(p.vaultState, p.reserve.reserve),
|
|
110
|
+
lendingMarketAuthorityPda(p.reserve.lendingMarket),
|
|
111
|
+
kvaultEventAuthorityPda(),
|
|
112
|
+
kvaultGlobalConfigPda(),
|
|
113
|
+
]);
|
|
114
|
+
return {
|
|
115
|
+
programAddress: address(KVAULT_PROGRAM_ID),
|
|
116
|
+
accounts: [
|
|
117
|
+
// withdrawFromAvailable
|
|
118
|
+
signer(p.user, false),
|
|
119
|
+
rw(p.vaultState),
|
|
120
|
+
ro(globalConfig),
|
|
121
|
+
rw(p.tokenVault),
|
|
122
|
+
ro(p.baseVaultAuthority),
|
|
123
|
+
rw(p.userTokenAta),
|
|
124
|
+
rw(p.tokenMint),
|
|
125
|
+
rw(p.userSharesAta),
|
|
126
|
+
rw(p.sharesMint),
|
|
127
|
+
ro(SPL_TOKEN_PROGRAM_ID),
|
|
128
|
+
ro(SPL_TOKEN_PROGRAM_ID),
|
|
129
|
+
ro(KLEND_PROGRAM_ID),
|
|
130
|
+
ro(eventAuthority),
|
|
131
|
+
ro(KVAULT_PROGRAM_ID),
|
|
132
|
+
// withdrawFromReserveAccounts
|
|
133
|
+
rw(p.vaultState),
|
|
134
|
+
rw(p.reserve.reserve),
|
|
135
|
+
rw(ctokenVault),
|
|
136
|
+
ro(p.reserve.lendingMarket),
|
|
137
|
+
ro(lma),
|
|
138
|
+
rw(p.reserve.liquiditySupplyVault),
|
|
139
|
+
rw(p.reserve.collateralMint),
|
|
140
|
+
ro(SPL_TOKEN_PROGRAM_ID),
|
|
141
|
+
ro(SYSVAR_INSTRUCTIONS_ID),
|
|
142
|
+
ro(eventAuthority),
|
|
143
|
+
ro(KVAULT_PROGRAM_ID),
|
|
144
|
+
...p.vaultReserves.map((r) => rw(r.reserve)),
|
|
145
|
+
...p.vaultReserves.map((r) => ro(r.lendingMarket)),
|
|
146
|
+
],
|
|
147
|
+
data: concat(DISCRIMINATORS.withdraw, u64le(p.sharesAmount)),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The Associated Token Account program's `CreateIdempotent` (instruction 1): creates `owner`'s token account for
|
|
152
|
+
* `mint` if it does not exist, and does nothing if it does. The payer is the owner, who pays its rent (about
|
|
153
|
+
* 0.002 SOL, returned if the account is ever closed). A first deposit needs it for the share account.
|
|
154
|
+
*/
|
|
155
|
+
export async function createAtaIdempotentIx(owner, mint) {
|
|
156
|
+
return {
|
|
157
|
+
programAddress: address(ASSOCIATED_TOKEN_PROGRAM_ID),
|
|
158
|
+
accounts: [
|
|
159
|
+
signer(owner, true),
|
|
160
|
+
rw(await associatedTokenAccount(owner, mint)),
|
|
161
|
+
ro(owner),
|
|
162
|
+
ro(mint),
|
|
163
|
+
ro(SYSTEM_PROGRAM_ID),
|
|
164
|
+
ro(SPL_TOKEN_PROGRAM_ID),
|
|
165
|
+
],
|
|
166
|
+
data: Uint8Array.from([1]),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* `SetComputeUnitLimit(units)` (Compute Budget instruction 2, a u32). A deposit or withdrawal refreshes every
|
|
171
|
+
* vault reserve inside the program, which can exceed the default 200,000 units.
|
|
172
|
+
*/
|
|
173
|
+
export function setComputeUnitLimitIx(units) {
|
|
174
|
+
if (!Number.isInteger(units) || units <= 0 || units > MAX_COMPUTE_UNITS) {
|
|
175
|
+
throw new Error(`compute unit limit must be an integer in (0, ${MAX_COMPUTE_UNITS}], got ${units}`);
|
|
176
|
+
}
|
|
177
|
+
const data = new Uint8Array(5);
|
|
178
|
+
data[0] = 2;
|
|
179
|
+
new DataView(data.buffer).setUint32(1, units, true);
|
|
180
|
+
return { programAddress: address(COMPUTE_BUDGET_PROGRAM_ID), data };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A legacy transaction, UNSIGNED (every signature slot zero), as base64 wire bytes. The fee payer is the
|
|
184
|
+
* signer; a wallet adds the signature. It lands only before `lifetime.lastValidBlockHeight`, about a minute
|
|
185
|
+
* after the blockhash was read.
|
|
186
|
+
*/
|
|
187
|
+
export function compileUnsigned(instructions, feePayer, lifetime) {
|
|
188
|
+
const message = pipe(createTransactionMessage({ version: "legacy" }), (m) => setTransactionMessageFeePayer(address(feePayer), m), (m) => setTransactionMessageLifetimeUsingBlockhash({ blockhash: lifetime.blockhash, lastValidBlockHeight: lifetime.lastValidBlockHeight }, m), (m) => appendTransactionMessageInstructions(instructions, m));
|
|
189
|
+
const base64 = getBase64EncodedWireTransaction(compileTransaction(message));
|
|
190
|
+
return { base64, bytes: Buffer.from(base64, "base64").length };
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=kvault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kvault.js","sourceRoot":"","sources":["../../src/solana/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