@whisk/steakhouse 0.3.9 → 0.4.0

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.
@@ -0,0 +1,197 @@
1
+ import { graphql } from "@whisk/graphql";
2
+ import {
3
+ apyFragment,
4
+ erc20Fragment,
5
+ morphoMarketAllocationFragment,
6
+ resolveVaultConfig,
7
+ riskAssessmentFragment,
8
+ tokenAmountFragment,
9
+ vaultSummaryFragment
10
+ } from "./fragments.js";
11
+ const vaultDetailQuery = graphql(
12
+ `
13
+ query GetSteakhouseVault($keys: [Erc4626VaultKey!]!) {
14
+ erc4626Vaults(where: { keys: $keys }) {
15
+ items {
16
+ ...VaultSummaryFields
17
+
18
+ # Morpho Vault V1 - full details
19
+ ... on MorphoVault {
20
+ totalLiquidity {
21
+ ...TokenAmountFields
22
+ }
23
+ deploymentTimestamp
24
+ performanceFeeV1: performanceFee
25
+ curatorAddress
26
+ guardianAddress
27
+ allocations: marketAllocations {
28
+ supplyCap {
29
+ ...TokenAmountFields
30
+ }
31
+ market {
32
+ ...MorphoMarketAllocationFields
33
+ }
34
+ position {
35
+ supplyAmount {
36
+ ...TokenAmountFields
37
+ }
38
+ }
39
+ }
40
+ }
41
+
42
+ # Box Vault - full details
43
+ ... on BoxVault {
44
+ leverage
45
+ allocations {
46
+ token {
47
+ ...Erc20Fields
48
+ yield {
49
+ intrinsicApy
50
+ }
51
+ }
52
+ balance {
53
+ ...TokenAmountFields
54
+ }
55
+ }
56
+ fundingModules {
57
+ fundingModuleAddress
58
+ nav {
59
+ ...TokenAmountFields
60
+ }
61
+ ... on BoxMorphoFundingModule {
62
+ positions {
63
+ market {
64
+ ...MorphoMarketAllocationFields
65
+ borrowApy {
66
+ ...ApyFields
67
+ }
68
+ borrowApy1d {
69
+ ...ApyFields
70
+ }
71
+ borrowApy7d {
72
+ ...ApyFields
73
+ }
74
+ borrowApy30d {
75
+ ...ApyFields
76
+ }
77
+ }
78
+ loopingLeverage
79
+ loopingNetApy
80
+ collateralAmount {
81
+ ...TokenAmountFields
82
+ }
83
+ borrowAmount {
84
+ ...TokenAmountFields
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+
91
+ # Morpho Vault V2 - full details for market adapter, user meant to fetch vault adapter details separately if they want those
92
+ ... on MorphoVaultV2 {
93
+ deploymentTimestamp
94
+ performanceFee {
95
+ raw
96
+ formatted
97
+ }
98
+ managementFee {
99
+ raw
100
+ formatted
101
+ }
102
+ nav {
103
+ ...TokenAmountFields
104
+ }
105
+ liquidityAssets {
106
+ ...TokenAmountFields
107
+ }
108
+ idleAssets {
109
+ ...TokenAmountFields
110
+ }
111
+ allocations {
112
+ adapterAddress
113
+ name
114
+ riskAssessment {
115
+ ...RiskAssessmentFields
116
+ }
117
+ adapterCap {
118
+ allocation {
119
+ ...TokenAmountFields
120
+ }
121
+ absoluteCap {
122
+ ...TokenAmountFields
123
+ }
124
+ relativeCap {
125
+ raw
126
+ formatted
127
+ }
128
+ }
129
+
130
+ # For ERC-4626, expect user to call this again if they want full details on the adapters vault
131
+ ... on Erc4626VaultAdapter {
132
+ vault {
133
+ __typename
134
+ address
135
+ }
136
+ }
137
+
138
+ ... on MarketV1Adapter {
139
+ marketCaps {
140
+ allocation {
141
+ ...TokenAmountFields
142
+ }
143
+ absoluteCap {
144
+ ...TokenAmountFields
145
+ }
146
+ market {
147
+ ...MorphoMarketAllocationFields
148
+ }
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
155
+ }
156
+ `,
157
+ [
158
+ vaultSummaryFragment,
159
+ erc20Fragment,
160
+ tokenAmountFragment,
161
+ riskAssessmentFragment,
162
+ apyFragment,
163
+ morphoMarketAllocationFragment
164
+ ]
165
+ );
166
+ async function getVault(client, variables) {
167
+ const config = resolveVaultConfig(variables);
168
+ if (!config && !variables.isBox) {
169
+ throw new Error(
170
+ `Vault ${variables.vaultAddress} on chain ${variables.chainId} is not a known Steakhouse vault`
171
+ );
172
+ }
173
+ const result = await client.query(vaultDetailQuery, {
174
+ keys: [
175
+ {
176
+ chainId: variables.chainId,
177
+ vaultAddress: config?.address ?? variables.vaultAddress,
178
+ protocol: config?.protocol ?? "box"
179
+ }
180
+ ]
181
+ });
182
+ const item = result.erc4626Vaults.items[0];
183
+ if (!item) {
184
+ throw new Error(`Vault ${variables.vaultAddress} on chain ${variables.chainId} was not found`);
185
+ }
186
+ return {
187
+ ...item,
188
+ name: config?.name ?? item.name,
189
+ strategy: config?.strategy,
190
+ description: config?.description,
191
+ isListed: config?.isListed ?? false
192
+ };
193
+ }
194
+ export {
195
+ getVault
196
+ };
197
+ //# sourceMappingURL=getVault.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/queries/getVault.ts"],"sourcesContent":["import { graphql, type ResultOf } from \"@whisk/graphql\"\nimport type { SteakhouseClient } from \"../client.js\"\nimport type { VaultConfig } from \"../metadata/types.js\"\nimport {\n apyFragment,\n erc20Fragment,\n morphoMarketAllocationFragment,\n type Prettify,\n resolveVaultConfig,\n riskAssessmentFragment,\n tokenAmountFragment,\n type VaultKeyVariables,\n vaultSummaryFragment,\n} from \"./fragments.js\"\n\nconst vaultDetailQuery = graphql(\n `\n query GetSteakhouseVault($keys: [Erc4626VaultKey!]!) {\n erc4626Vaults(where: { keys: $keys }) {\n items {\n ...VaultSummaryFields\n\n # Morpho Vault V1 - full details\n ... on MorphoVault {\n totalLiquidity {\n ...TokenAmountFields\n }\n deploymentTimestamp\n performanceFeeV1: performanceFee\n curatorAddress\n guardianAddress\n allocations: marketAllocations {\n supplyCap {\n ...TokenAmountFields\n }\n market {\n ...MorphoMarketAllocationFields\n }\n position {\n supplyAmount {\n ...TokenAmountFields\n }\n }\n }\n }\n\n # Box Vault - full details\n ... on BoxVault {\n leverage\n allocations {\n token {\n ...Erc20Fields\n yield {\n intrinsicApy\n }\n }\n balance {\n ...TokenAmountFields\n }\n }\n fundingModules {\n fundingModuleAddress\n nav {\n ...TokenAmountFields\n }\n ... on BoxMorphoFundingModule {\n positions {\n market {\n ...MorphoMarketAllocationFields\n borrowApy {\n ...ApyFields\n }\n borrowApy1d {\n ...ApyFields\n }\n borrowApy7d {\n ...ApyFields\n }\n borrowApy30d {\n ...ApyFields\n }\n }\n loopingLeverage\n loopingNetApy\n collateralAmount {\n ...TokenAmountFields\n }\n borrowAmount {\n ...TokenAmountFields\n }\n }\n }\n }\n }\n\n # Morpho Vault V2 - full details for market adapter, user meant to fetch vault adapter details separately if they want those\n ... on MorphoVaultV2 {\n deploymentTimestamp\n performanceFee {\n raw\n formatted\n }\n managementFee {\n raw\n formatted\n }\n nav {\n ...TokenAmountFields\n }\n liquidityAssets {\n ...TokenAmountFields\n }\n idleAssets {\n ...TokenAmountFields\n }\n allocations {\n adapterAddress\n name\n riskAssessment {\n ...RiskAssessmentFields\n }\n adapterCap {\n allocation {\n ...TokenAmountFields\n }\n absoluteCap {\n ...TokenAmountFields\n }\n relativeCap {\n raw\n formatted\n }\n }\n\n # For ERC-4626, expect user to call this again if they want full details on the adapters vault\n ... on Erc4626VaultAdapter {\n vault {\n __typename\n address\n }\n }\n\n ... on MarketV1Adapter {\n marketCaps {\n allocation {\n ...TokenAmountFields\n }\n absoluteCap {\n ...TokenAmountFields\n }\n market {\n ...MorphoMarketAllocationFields\n }\n }\n }\n }\n }\n }\n }\n }\n`,\n [\n vaultSummaryFragment,\n erc20Fragment,\n tokenAmountFragment,\n riskAssessmentFragment,\n apyFragment,\n morphoMarketAllocationFragment,\n ],\n)\n\ntype VaultDetailItem = NonNullable<\n ResultOf<typeof vaultDetailQuery>[\"erc4626Vaults\"][\"items\"][number]\n>\n\nexport type SteakhouseVaultDetail = Prettify<\n VaultDetailItem & {\n strategy: VaultConfig[\"strategy\"] | undefined\n description: VaultConfig[\"description\"] | undefined\n isListed: boolean\n }\n>\n\nexport interface GetVaultVariables extends VaultKeyVariables {\n isBox?: boolean\n}\n\nexport async function getVault(\n client: SteakhouseClient,\n variables: GetVaultVariables,\n): Promise<SteakhouseVaultDetail> {\n const config = resolveVaultConfig(variables)\n\n if (!config && !variables.isBox) {\n throw new Error(\n `Vault ${variables.vaultAddress} on chain ${variables.chainId} is not a known Steakhouse vault`,\n )\n }\n\n const result = await client.query(vaultDetailQuery, {\n keys: [\n {\n chainId: variables.chainId,\n vaultAddress: config?.address ?? variables.vaultAddress,\n protocol: config?.protocol ?? \"box\",\n },\n ],\n })\n\n const item = result.erc4626Vaults.items[0]\n if (!item) {\n throw new Error(`Vault ${variables.vaultAddress} on chain ${variables.chainId} was not found`)\n }\n\n return {\n ...item,\n name: config?.name ?? item.name,\n strategy: config?.strategy,\n description: config?.description,\n isListed: config?.isListed ?? false,\n }\n}\n"],"mappings":"AAAA,SAAS,eAA8B;AAGvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAEP,MAAM,mBAAmB;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiJA;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAkBA,eAAsB,SACpB,QACA,WACgC;AAChC,QAAM,SAAS,mBAAmB,SAAS;AAE3C,MAAI,CAAC,UAAU,CAAC,UAAU,OAAO;AAC/B,UAAM,IAAI;AAAA,MACR,SAAS,UAAU,YAAY,aAAa,UAAU,OAAO;AAAA,IAC/D;AAAA,EACF;AAEA,QAAM,SAAS,MAAM,OAAO,MAAM,kBAAkB;AAAA,IAClD,MAAM;AAAA,MACJ;AAAA,QACE,SAAS,UAAU;AAAA,QACnB,cAAc,QAAQ,WAAW,UAAU;AAAA,QAC3C,UAAU,QAAQ,YAAY;AAAA,MAChC;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,OAAO,OAAO,cAAc,MAAM,CAAC;AACzC,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,SAAS,UAAU,YAAY,aAAa,UAAU,OAAO,gBAAgB;AAAA,EAC/F;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM,QAAQ,QAAQ,KAAK;AAAA,IAC3B,UAAU,QAAQ;AAAA,IAClB,aAAa,QAAQ;AAAA,IACrB,UAAU,QAAQ,YAAY;AAAA,EAChC;AACF;","names":[]}
@@ -0,0 +1,15 @@
1
+ import { FragmentOf } from '@whisk/graphql';
2
+ import { WhiskClient } from '@whisk/client';
3
+ import { VaultKeyVariables, morphoVaultHistoricalEntryFragment } from './fragments.js';
4
+ import 'gql.tada';
5
+ import '../metadata/types.js';
6
+
7
+ type HistoricalEntry = FragmentOf<typeof morphoVaultHistoricalEntryFragment>;
8
+ interface SteakhouseVaultHistory {
9
+ daily: ReadonlyArray<HistoricalEntry> | null;
10
+ weekly: ReadonlyArray<HistoricalEntry> | null;
11
+ }
12
+ type GetVaultHistoryVariables = VaultKeyVariables;
13
+ declare function getVaultHistory(client: WhiskClient, variables: GetVaultHistoryVariables): Promise<SteakhouseVaultHistory>;
14
+
15
+ export { type GetVaultHistoryVariables, type SteakhouseVaultHistory, getVaultHistory };
@@ -0,0 +1,55 @@
1
+ import { graphql } from "@whisk/graphql";
2
+ import {
3
+ morphoVaultHistoricalEntryFragment,
4
+ resolveVaultConfig
5
+ } from "./fragments.js";
6
+ const vaultHistoricalQuery = graphql(
7
+ `
8
+ query GetSteakhouseVaultHistory($keys: [Erc4626VaultKey!]!) {
9
+ erc4626Vaults(where: { keys: $keys }) {
10
+ items {
11
+ address
12
+ historical {
13
+ ... on MorphoVaultHistorical {
14
+ daily {
15
+ ...MorphoVaultHistoricalEntryFields
16
+ }
17
+ weekly {
18
+ ...MorphoVaultHistoricalEntryFields
19
+ }
20
+ }
21
+ }
22
+ }
23
+ }
24
+ }
25
+ `,
26
+ [morphoVaultHistoricalEntryFragment]
27
+ );
28
+ async function getVaultHistory(client, variables) {
29
+ const config = resolveVaultConfig(variables);
30
+ if (!config) {
31
+ return { daily: null, weekly: null };
32
+ }
33
+ const result = await client.query(vaultHistoricalQuery, {
34
+ keys: [
35
+ {
36
+ chainId: config.chainId,
37
+ vaultAddress: config.address,
38
+ protocol: config.protocol
39
+ }
40
+ ]
41
+ });
42
+ const item = result.erc4626Vaults.items[0];
43
+ if (!item?.historical) {
44
+ return { daily: null, weekly: null };
45
+ }
46
+ const historical = item.historical;
47
+ return {
48
+ daily: "daily" in historical ? historical.daily ?? null : null,
49
+ weekly: "weekly" in historical ? historical.weekly ?? null : null
50
+ };
51
+ }
52
+ export {
53
+ getVaultHistory
54
+ };
55
+ //# sourceMappingURL=getVaultHistory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/queries/getVaultHistory.ts"],"sourcesContent":["import { type FragmentOf, graphql } from \"@whisk/graphql\"\nimport type { SteakhouseClient } from \"../client.js\"\nimport {\n morphoVaultHistoricalEntryFragment,\n resolveVaultConfig,\n type VaultKeyVariables,\n} from \"./fragments.js\"\n\nconst vaultHistoricalQuery = graphql(\n `\n query GetSteakhouseVaultHistory($keys: [Erc4626VaultKey!]!) {\n erc4626Vaults(where: { keys: $keys }) {\n items {\n address\n historical {\n ... on MorphoVaultHistorical {\n daily {\n ...MorphoVaultHistoricalEntryFields\n }\n weekly {\n ...MorphoVaultHistoricalEntryFields\n }\n }\n }\n }\n }\n }\n`,\n [morphoVaultHistoricalEntryFragment],\n)\n\ntype HistoricalEntry = FragmentOf<typeof morphoVaultHistoricalEntryFragment>\n\nexport interface SteakhouseVaultHistory {\n daily: ReadonlyArray<HistoricalEntry> | null\n weekly: ReadonlyArray<HistoricalEntry> | null\n}\n\nexport type GetVaultHistoryVariables = VaultKeyVariables\n\nexport async function getVaultHistory(\n client: SteakhouseClient,\n variables: GetVaultHistoryVariables,\n): Promise<SteakhouseVaultHistory> {\n const config = resolveVaultConfig(variables)\n\n if (!config) {\n return { daily: null, weekly: null }\n }\n\n const result = await client.query(vaultHistoricalQuery, {\n keys: [\n {\n chainId: config.chainId,\n vaultAddress: config.address,\n protocol: config.protocol,\n },\n ],\n })\n\n const item = result.erc4626Vaults.items[0]\n if (!item?.historical) {\n return { daily: null, weekly: null }\n }\n\n const historical = item.historical\n\n return {\n daily: \"daily\" in historical ? (historical.daily ?? null) : null,\n weekly: \"weekly\" in historical ? (historical.weekly ?? null) : null,\n }\n}\n"],"mappings":"AAAA,SAA0B,eAAe;AAEzC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,MAAM,uBAAuB;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBA,CAAC,kCAAkC;AACrC;AAWA,eAAsB,gBACpB,QACA,WACiC;AACjC,QAAM,SAAS,mBAAmB,SAAS;AAE3C,MAAI,CAAC,QAAQ;AACX,WAAO,EAAE,OAAO,MAAM,QAAQ,KAAK;AAAA,EACrC;AAEA,QAAM,SAAS,MAAM,OAAO,MAAM,sBAAsB;AAAA,IACtD,MAAM;AAAA,MACJ;AAAA,QACE,SAAS,OAAO;AAAA,QAChB,cAAc,OAAO;AAAA,QACrB,UAAU,OAAO;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,OAAO,OAAO,cAAc,MAAM,CAAC;AACzC,MAAI,CAAC,MAAM,YAAY;AACrB,WAAO,EAAE,OAAO,MAAM,QAAQ,KAAK;AAAA,EACrC;AAEA,QAAM,aAAa,KAAK;AAExB,SAAO;AAAA,IACL,OAAO,WAAW,aAAc,WAAW,SAAS,OAAQ;AAAA,IAC5D,QAAQ,YAAY,aAAc,WAAW,UAAU,OAAQ;AAAA,EACjE;AACF;","names":[]}