|
1 |
| ---- |
2 |
| -description: Craft Your Own Metrics On-the-Fly |
3 |
| ---- |
| 1 | +# Custom columns |
4 | 2 |
|
5 |
| -## Custom Columns |
6 |
| - |
7 |
| -Transform your DeFiLlama experience with **Custom Columns**. Go beyond our standard metrics and define your own, turning the protocol table into a personalized analysis powerhouse. Calculate bespoke ratios, track hyper-specific growth rates, combine data points in novel ways, or set conditional flags to instantly spot protocols meeting your criteria – all directly within DeFiLlama. |
8 |
| - |
9 |
| -### Adding Custom Columns |
10 |
| -You can access this feature on the main page, at the bottom of the column selection dropdown. |
11 |
| - |
12 |
| -After pressing "Add Custom Column" you'll be able to input name and formula for your custom columns |
13 |
| - |
14 |
| -### Defining Your Columns |
15 |
| -* Formula: Input your custom expression here. This field supports a rich syntax leveraging available protocol data, mathematical operators, and curated functions (detailed below). Real-time feedback warns about unrecognized inputs, and a preview shows the calculated result. |
16 |
| -* Format: Select the desired display format for your calculated values (`Auto`, `Number`, `USD`, `Percent`, `Boolean (✅/❌)`). "Auto" intelligently handles most types, including rendering boolean results as checkmarks. |
17 |
| - |
18 |
| -### Crafting Formulas |
19 |
| -The formula engine supports curated set of powerful operations, giving you flexibility in creating the metrics that you need |
20 |
| - |
21 |
| -**Available Data Fields** |
22 |
| -* `mcap`, `tvl` |
23 |
| -* `tvlPrevDay`, `tvlPrevWeek`, `tvlPrevMonth` |
24 |
| -* `change_1d`, `change_7d`, `change_1m` (TVL changes in decimal format, e.g., `0.05`) |
25 |
| -* `fees_24h`, `fees_7d`, `fees_30d`, `fees_1y`, `average_fees_1y`, `cumulativeFees` |
26 |
| -* `pf` (Market Cap / Annualized Fees), `ps` (Market Cap / Annualized Revenue) |
27 |
| -* `revenue_24h`, `revenue_7d`, `revenue_30d`, `revenue_1y`, `average_revenue_1y`, `cumulativeRevenue` |
28 |
| -* `volume_24h`, `volume_7d`, `volumeChange_7d`, `cumulativeVolume` |
29 |
| -* `category` (String, e.g., "DEX", "Lending") |
30 |
| - |
31 |
| -{% hint style="info" %} |
32 |
| -Not every fields is available in all protocols, for example volume is only available to protocol with DEXs category, if a protocol lacks a field your formula depends on, the result will be skipped for that row |
33 |
| -{% endhint %} |
34 |
| - |
35 |
| -**Operators** |
36 |
| -Standard mathematical (`+`, `-`, `*`, `/`, `%`, `^`) and logical (`and`, `or`, `not`) operators are available, along with comparison operators (`==`, `!=`, `>`, `>=`, `<`, `<=`). Use parentheses `()` for grouping. The ternary operator (`condition ? value_if_true : value_if_false`) is supported for conditional expressions. |
37 |
| - |
38 |
| -**Built-in Functions** |
39 |
| -We provide a focused set of functions relevant for protocol analysis. Autocomplete (`ƒ` prefix) suggests these as you type, and selecting one adds `()` automatically. |
40 |
| - |
41 |
| -* `abs(x)`: Absolute value of x. |
42 |
| -* `ceil(x)`: Smallest integer greater than or equal to x (rounds up). |
43 |
| -* `floor(x)`: Largest integer less than or equal to x (rounds down). |
44 |
| -* `round(x)`: Rounds x to the nearest integer. |
45 |
| -* `roundTo(x, n)`: Rounds x to n decimal places. **(Highly useful for ratios)** |
46 |
| -* `sqrt(x)`: Square root of x. |
47 |
| -* `min(a, b, ...)`: Minimum value from the provided arguments. |
48 |
| -* `max(a, b, ...)`: Maximum value from the provided arguments. |
49 |
| -* `if(condition, true_val, false_val)`: Returns `true_val` if `condition` is true, else `false_val`. (Ternary `? :` is often cleaner). |
50 |
| -* `not(x)`: Logical NOT (inverts a boolean value). |
51 |
| - |
52 |
| -**Conditional Expressions & Flags** |
53 |
| -Create formulas that evaluate to `true` or `false`. Ideal for flagging protocols meeting specific criteria. With the "Format" set to "Auto" or "Boolean (✅/❌)", these display as intuitive checkmarks. |
54 |
| - |
55 |
| -* Example: `change_7d > 0.1 and revenue_7d > 100000` (Is 7d TVL growth > 10% AND 7d revenue > $100k?) -> ✅ / ❌ |
56 |
| -* Example: `category == "Lending" and tvl > 50000000` (Is it a Lending protocol with TVL > $50M?) -> ✅ / ❌ |
57 |
| - |
58 |
| -**Formatting** |
59 |
| - |
60 |
| -* Use the **Format** dropdown to control the appearance of results (Number, USD, Percent, etc.). "Auto" is often sufficient and handles booleans correctly. |
61 |
| - |
62 |
| -### Use-Case examples |
63 |
| -1. High Growth Alert |
64 |
| -* Formula: `change_7d > 0.15 and fees_7d > (fees_30d / 30 * 7 * 1.2)` |
65 |
| -* This will show you protocols that has >15% gain in the last 7 days and recent 7d fees significantly above prior run rate. |
66 |
| - |
67 |
| -2. Revenue per TVL |
68 |
| -* Formula: `revenue_30d / tvl` |
69 |
| -* Give you ratio of protocol revenue (for the last 30 days) compared to their TVL |
70 |
| - |
71 |
| -3. Annualized Fee Yield |
72 |
| -* Formula: `fees_1y / tvl` |
73 |
| -* Measures how well protocol monetizes its TVL |
0 commit comments