@augustdigital/sdk 9.0.0 → 9.2.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.
- package/lib/adapters/stellar/actions.d.ts +13 -0
- package/lib/adapters/stellar/actions.js +51 -2
- package/lib/adapters/stellar/index.d.ts +12 -0
- package/lib/adapters/stellar/index.js +12 -0
- package/lib/adapters/stellar/invocation.d.ts +55 -0
- package/lib/adapters/stellar/invocation.js +92 -0
- package/lib/adapters/stellar/soroban.d.ts +8 -0
- package/lib/adapters/stellar/soroban.js +18 -4
- package/lib/adapters/stellar/submit.d.ts +8 -0
- package/lib/adapters/stellar/submit.js +46 -0
- package/lib/core/analytics/env.d.ts +17 -0
- package/lib/core/analytics/env.js +88 -0
- package/lib/core/analytics/sentry.js +1 -21
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/base.class.d.ts +22 -0
- package/lib/core/base.class.js +11 -0
- package/lib/core/logger/curator-alert.d.ts +217 -0
- package/lib/core/logger/curator-alert.js +276 -0
- package/lib/core/logger/index.d.ts +1 -0
- package/lib/core/logger/index.js +20 -1
- package/lib/main.d.ts +6 -0
- package/lib/main.js +6 -0
- package/lib/modules/vaults/getters.d.ts +9 -0
- package/lib/modules/vaults/getters.js +25 -0
- package/lib/sdk.d.ts +153 -0
- package/lib/services/untangled/fetcher.d.ts +40 -0
- package/lib/services/untangled/fetcher.js +110 -0
- package/lib/services/untangled/index.d.ts +3 -0
- package/lib/services/untangled/index.js +20 -0
- package/lib/services/untangled/types.d.ts +82 -0
- package/lib/services/untangled/types.js +10 -0
- package/lib/services/untangled/utils.d.ts +55 -0
- package/lib/services/untangled/utils.js +157 -0
- package/package.json +1 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNTANGLED_PROTOCOL_REGISTRY = void 0;
|
|
4
|
+
exports.transformUntangledToDebank = transformUntangledToDebank;
|
|
5
|
+
/**
|
|
6
|
+
* Display metadata for the protocol slugs Untangled reports today.
|
|
7
|
+
*
|
|
8
|
+
* Untangled does not return protocol names or chains, so they are mapped here.
|
|
9
|
+
* Unknown slugs fall back to a capitalized slug on the vault's chain rather than
|
|
10
|
+
* being dropped, so a newly integrated protocol still shows up (unlabelled)
|
|
11
|
+
* instead of silently vanishing from the breakdown.
|
|
12
|
+
*/
|
|
13
|
+
exports.UNTANGLED_PROTOCOL_REGISTRY = {
|
|
14
|
+
blend: { name: 'Blend', chain: 'stellar' },
|
|
15
|
+
templar: { name: 'Templar (NEAR)', chain: 'near' },
|
|
16
|
+
aquarius: { name: 'Aquarius', chain: 'stellar' },
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Slugs that are not protocol positions: `stellar-wallet` is custody wallet
|
|
20
|
+
* cash and `upshift` is the vault's own idle buffer. Both are undeployed
|
|
21
|
+
* capital, which the exposure breakdown renders as wallet holdings — the same
|
|
22
|
+
* treatment EVM vaults get for funds sitting outside a protocol.
|
|
23
|
+
*/
|
|
24
|
+
const WALLET_PROTOCOL_IDS = new Set(['stellar-wallet', 'upshift']);
|
|
25
|
+
const DEFAULT_CHAIN = 'stellar';
|
|
26
|
+
/**
|
|
27
|
+
* Stellar's asset precision, carried only to satisfy the DeBank token shape.
|
|
28
|
+
* The synthesized tokens hold USD values (`price: 1`), so no consumer scales by
|
|
29
|
+
* this.
|
|
30
|
+
*/
|
|
31
|
+
const SYNTHETIC_TOKEN_DECIMALS = 7;
|
|
32
|
+
/**
|
|
33
|
+
* Build a DeBank-shaped token carrying a USD value.
|
|
34
|
+
*
|
|
35
|
+
* `parseVaultLevelDebank` computes USD as `price * amount`, so a value already
|
|
36
|
+
* denominated in dollars is expressed as `price: 1, amount: <usd>`.
|
|
37
|
+
*/
|
|
38
|
+
function toDebankToken(symbol, chain, valueUsd, exposureType, protocolId) {
|
|
39
|
+
return {
|
|
40
|
+
id: symbol,
|
|
41
|
+
chain,
|
|
42
|
+
name: symbol,
|
|
43
|
+
symbol,
|
|
44
|
+
optimized_symbol: symbol,
|
|
45
|
+
decimals: SYNTHETIC_TOKEN_DECIMALS,
|
|
46
|
+
logo_url: '',
|
|
47
|
+
amount: valueUsd,
|
|
48
|
+
price: 1,
|
|
49
|
+
protocol_id: protocolId ?? '',
|
|
50
|
+
supplying_exposure: exposureType === 'supply' ? 'true' : undefined,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The asset holding most of the vault's value.
|
|
55
|
+
*
|
|
56
|
+
* Untangled splits assets vault-wide rather than per protocol, so every
|
|
57
|
+
* synthesized position is tagged with this one symbol. For the Gami vaults it is
|
|
58
|
+
* an exact description (earnUSDC is ~100% USDC); an exact per-protocol split
|
|
59
|
+
* needs `byProtocol[].assets[]` from Untangled.
|
|
60
|
+
*/
|
|
61
|
+
function dominantAssetSymbol(exposure) {
|
|
62
|
+
const dominant = (exposure.byAsset || []).reduce((best, asset) => !best || Number(asset?.valueUsd || 0) > Number(best.valueUsd || 0)
|
|
63
|
+
? asset
|
|
64
|
+
: best, null);
|
|
65
|
+
return dominant?.symbol || 'UNKNOWN';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Transform an Untangled vault exposure report into the DeBank-normalized shape
|
|
69
|
+
* that `parseVaultLevelDebank` and `parseLoanLevelDebank` consume.
|
|
70
|
+
*
|
|
71
|
+
* This is the Stellar equivalent of `transformOctavfiToDebank`: a foreign
|
|
72
|
+
* portfolio shape is mapped onto the one normalized structure the vault
|
|
73
|
+
* allocation parser understands, so Stellar vaults populate the same
|
|
74
|
+
* `exposurePerCategory` / `protocolExposure` / `tokenExposure` outputs as EVM
|
|
75
|
+
* vaults with no parser changes.
|
|
76
|
+
*
|
|
77
|
+
* Mapping:
|
|
78
|
+
* - Each `byProtocol` entry becomes one position with a single supplying token,
|
|
79
|
+
* valued in USD (`price: 1`), on the chain from
|
|
80
|
+
* {@link UNTANGLED_PROTOCOL_REGISTRY}.
|
|
81
|
+
* - `stellar-wallet` and `upshift` are summed into one wallet token, because
|
|
82
|
+
* both are undeployed capital rather than protocol exposure.
|
|
83
|
+
* - Dust is left in place: `filterOutBySize` in the parser applies the same
|
|
84
|
+
* threshold Stellar and EVM vaults share.
|
|
85
|
+
*
|
|
86
|
+
* `locations`, `asOf`, `stale` and `tvlUsd` are not consumed — TVL already comes
|
|
87
|
+
* from `getVaultTvl`, and freshness is not yet surfaced on `IVaultAllocations`.
|
|
88
|
+
*
|
|
89
|
+
* @param exposure - A resolved Untangled report, or `null`/`undefined` when the
|
|
90
|
+
* fetch failed.
|
|
91
|
+
* @returns A DeBank-normalized response. Empty positions and tokens when
|
|
92
|
+
* `exposure` is absent, so callers can pass a failed fetch straight through.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const exposure = await fetchUntangledVaultExposure(vault);
|
|
97
|
+
* const normalized = transformUntangledToDebank(exposure);
|
|
98
|
+
* parseVaultLevelDebank(
|
|
99
|
+
* normalized, protocolExposure, tokenExposure, vault, exposurePerCategory, netValue,
|
|
100
|
+
* );
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
function transformUntangledToDebank(exposure) {
|
|
104
|
+
if (!exposure) {
|
|
105
|
+
return { subaccount: { positions: [], tokens: [] } };
|
|
106
|
+
}
|
|
107
|
+
const symbol = dominantAssetSymbol(exposure);
|
|
108
|
+
const vaultChain = exposure.vault?.chain || DEFAULT_CHAIN;
|
|
109
|
+
const positions = [];
|
|
110
|
+
let walletValueUsd = 0;
|
|
111
|
+
(exposure.byProtocol || []).forEach((entry) => {
|
|
112
|
+
if (!entry?.protocolId)
|
|
113
|
+
return;
|
|
114
|
+
const valueUsd = Number(entry.valueUsd) || 0;
|
|
115
|
+
if (WALLET_PROTOCOL_IDS.has(entry.protocolId)) {
|
|
116
|
+
walletValueUsd += valueUsd;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const metadata = exports.UNTANGLED_PROTOCOL_REGISTRY[entry.protocolId];
|
|
120
|
+
const chain = metadata?.chain || vaultChain;
|
|
121
|
+
const name = metadata?.name ||
|
|
122
|
+
entry.protocolId.charAt(0).toUpperCase() + entry.protocolId.slice(1);
|
|
123
|
+
positions.push({
|
|
124
|
+
id: entry.protocolId,
|
|
125
|
+
chain,
|
|
126
|
+
name,
|
|
127
|
+
logo_url: '',
|
|
128
|
+
site_url: '',
|
|
129
|
+
portfolio_item_list: [
|
|
130
|
+
{
|
|
131
|
+
name,
|
|
132
|
+
stats: {
|
|
133
|
+
asset_usd_value: valueUsd,
|
|
134
|
+
debt_usd_value: 0,
|
|
135
|
+
net_usd_value: valueUsd,
|
|
136
|
+
},
|
|
137
|
+
detail: {
|
|
138
|
+
supply_token_list: [
|
|
139
|
+
toDebankToken(symbol, chain, valueUsd, 'supply', entry.protocolId),
|
|
140
|
+
],
|
|
141
|
+
borrow_token_list: [],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
const tokens = [];
|
|
148
|
+
if (walletValueUsd > 0) {
|
|
149
|
+
tokens.push({
|
|
150
|
+
...toDebankToken(symbol, vaultChain, walletValueUsd, 'wallet'),
|
|
151
|
+
is_wallet: true,
|
|
152
|
+
is_core: true,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return { subaccount: { positions, tokens } };
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=utils.js.map
|