@gvnrdao/dh-mcp 0.5.15 → 0.5.16
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/dist/boundary.js +123 -29
- package/dist/connector-embed.js +139 -37
- package/dist/connector.js +139 -37
- package/dist/index.js +139 -37
- package/package.json +1 -1
package/dist/boundary.js
CHANGED
|
@@ -78438,18 +78438,12 @@ function listPositionsQuery(f) {
|
|
|
78438
78438
|
return { document: LIST_POSITIONS, variables: { first, skip } };
|
|
78439
78439
|
}
|
|
78440
78440
|
var SUPPORTED_STABLECOINS = `
|
|
78441
|
-
query
|
|
78441
|
+
query GetSupportedStablecoins {
|
|
78442
78442
|
supportedStablecoins(where: { isSupported: true }, orderBy: addedAt, orderDirection: desc) {
|
|
78443
|
-
id
|
|
78444
|
-
|
|
78445
|
-
isSupported
|
|
78446
|
-
decimals
|
|
78447
|
-
entryFee
|
|
78448
|
-
exitFee
|
|
78449
|
-
reserves
|
|
78443
|
+
id address isSupported exchangeRate entryFee exitFee reserves decimals
|
|
78444
|
+
totalSwapVolume totalRedeemVolume swapCount redeemCount addedAt lastUpdated
|
|
78450
78445
|
}
|
|
78451
|
-
}
|
|
78452
|
-
`;
|
|
78446
|
+
}`;
|
|
78453
78447
|
|
|
78454
78448
|
// src/boundary/upstream/real/psm-calls.ts
|
|
78455
78449
|
var import_ethers31 = require("ethers");
|
|
@@ -79418,7 +79412,7 @@ function buildWriteOps(deps) {
|
|
|
79418
79412
|
const tokenAddress = isSwap ? addr.stablecoin : addr.ucdToken;
|
|
79419
79413
|
const spenderAddress = isSwap ? addr.psm : addr.ucdController;
|
|
79420
79414
|
const spenderContract = isSwap ? "SimplePSMV2" : "UCDController";
|
|
79421
|
-
const tokenSymbol = isSwap ?
|
|
79415
|
+
const tokenSymbol = isSwap ? calls.symbol() : "UCD";
|
|
79422
79416
|
const quoteR = isSwap ? await calls.swapQuote(p.amountIn) : await calls.redemptionQuote(p.amountIn);
|
|
79423
79417
|
if (!quoteR.ok) return upFail(quoteR.failure);
|
|
79424
79418
|
const broadcast = async (leg, action, tx2) => {
|
|
@@ -79458,7 +79452,7 @@ function buildWriteOps(deps) {
|
|
|
79458
79452
|
} catch (e) {
|
|
79459
79453
|
return upFail({ kind: "rejected", source: SOURCE5, message: `PSM ${p.direction} tx failed the whitelist: ${e.message} \u2014 ${residualNote}` });
|
|
79460
79454
|
}
|
|
79461
|
-
const execCard = `${p.direction} ${p.amountIn} ${isSwap ?
|
|
79455
|
+
const execCard = `${p.direction} ${p.amountIn} ${isSwap ? `${tokenSymbol} smallest units` : "UCD wei"} via the PSM: quote ${quoteR.value.amountOut} out (fee ${quoteR.value.feeAmount}), floor ${p.minOut} \u2014 output to ${p.borrower}`;
|
|
79462
79456
|
const execHashR = await broadcast(`psmSwap (${p.direction})`, isSwap ? "psm-swap" : "psm-redeem", execTx);
|
|
79463
79457
|
if (!execHashR.ok) {
|
|
79464
79458
|
const f = execHashR.failure;
|
|
@@ -80009,25 +80003,16 @@ var RealUpstreamPlugin = class {
|
|
|
80009
80003
|
// PSM reads (plan 08 Part B Phase R): on-chain views ONLY, through the dedicated
|
|
80010
80004
|
// wrapper (NOT chainRead) so custom-error refusals decode WITH their figures.
|
|
80011
80005
|
listPsmStablecoins: async () => {
|
|
80012
|
-
const
|
|
80013
|
-
if (!
|
|
80014
|
-
|
|
80015
|
-
listed.rows.map(async (row) => {
|
|
80016
|
-
const built = await this.psmCallsFor(row.address);
|
|
80017
|
-
return built.ok ? { address: row.address, symbol: built.calls.symbol(), decimals: row.decimals } : null;
|
|
80018
|
-
})
|
|
80019
|
-
);
|
|
80020
|
-
return upOk(
|
|
80021
|
-
rows.filter((r) => r !== null),
|
|
80022
|
-
this.src("subgraph")
|
|
80023
|
-
);
|
|
80006
|
+
const verified = await this.verifiedStablecoins();
|
|
80007
|
+
if (!verified.ok) return upFail(verified.failure);
|
|
80008
|
+
return upOk(verified.rows, this.src("subgraph"));
|
|
80024
80009
|
},
|
|
80025
80010
|
getPsmStatus: async (p) => {
|
|
80026
|
-
const r = await this.
|
|
80011
|
+
const r = await this.psmCallsForChoice(p.stablecoin);
|
|
80027
80012
|
return r.ok ? r.calls.status() : upFail(r.failure);
|
|
80028
80013
|
},
|
|
80029
80014
|
getPsmQuote: async (p) => {
|
|
80030
|
-
const r = await this.
|
|
80015
|
+
const r = await this.psmCallsForChoice(p.stablecoin);
|
|
80031
80016
|
if (!r.ok) return upFail(r.failure);
|
|
80032
80017
|
return p.direction === "swap" ? r.calls.swapQuote(p.amountIn) : r.calls.redemptionQuote(p.amountIn);
|
|
80033
80018
|
}
|
|
@@ -80219,7 +80204,7 @@ var RealUpstreamPlugin = class {
|
|
|
80219
80204
|
session,
|
|
80220
80205
|
getWriteSdk: () => this.sdkCache.get(key) ?? null,
|
|
80221
80206
|
readDetails: (id) => this.readPositionDetails(id),
|
|
80222
|
-
psm: (stablecoin) => this.
|
|
80207
|
+
psm: (stablecoin) => this.psmCallsForChoice(stablecoin),
|
|
80223
80208
|
assertValidatorConfigured: () => this.assertValidatorConfigured()
|
|
80224
80209
|
});
|
|
80225
80210
|
}
|
|
@@ -80353,7 +80338,7 @@ var RealUpstreamPlugin = class {
|
|
|
80353
80338
|
session,
|
|
80354
80339
|
getWriteSdk: () => this.sdkCache.get(key) ?? null,
|
|
80355
80340
|
readDetails: (id) => this.readPositionDetails(id),
|
|
80356
|
-
psm: (stablecoin) => this.
|
|
80341
|
+
psm: (stablecoin) => this.psmCallsForChoice(stablecoin),
|
|
80357
80342
|
assertValidatorConfigured: () => this.assertValidatorConfigured()
|
|
80358
80343
|
});
|
|
80359
80344
|
this.opsGatewayCache.set(key, gateway);
|
|
@@ -80517,12 +80502,118 @@ var RealUpstreamPlugin = class {
|
|
|
80517
80502
|
{}
|
|
80518
80503
|
);
|
|
80519
80504
|
if (!r.ok) return r;
|
|
80520
|
-
const
|
|
80505
|
+
const raw = r.value.data.supportedStablecoins ?? [];
|
|
80506
|
+
const bad = raw.find((x) => !import_ethers38.ethers.isAddress(String(x.address)) || !Number.isFinite(Number(x.decimals)));
|
|
80507
|
+
if (bad) {
|
|
80508
|
+
return {
|
|
80509
|
+
ok: false,
|
|
80510
|
+
failure: {
|
|
80511
|
+
kind: "malformed",
|
|
80512
|
+
source: "subgraph",
|
|
80513
|
+
message: `the indexer returned a PSM stablecoin row this build cannot read (address '${String(bad.address)}', decimals '${String(bad.decimals)}')`
|
|
80514
|
+
}
|
|
80515
|
+
};
|
|
80516
|
+
}
|
|
80517
|
+
const rows = raw.map((x) => ({
|
|
80521
80518
|
address: String(x.address).toLowerCase(),
|
|
80522
80519
|
decimals: Number(x.decimals)
|
|
80523
80520
|
}));
|
|
80521
|
+
if (rows.length === 0) {
|
|
80522
|
+
return {
|
|
80523
|
+
ok: false,
|
|
80524
|
+
failure: {
|
|
80525
|
+
kind: "unavailable",
|
|
80526
|
+
source: "subgraph",
|
|
80527
|
+
message: `the indexer lists NO supported stablecoins for the PSM on ${this.config.network}. Either the subgraph has not indexed the StablecoinAdded events yet (check its start block against the block the coins were added at), or governance has removed every coin. PSM exchange is unavailable here until one of those is resolved \u2014 this is NOT "the PSM supports nothing".`
|
|
80528
|
+
}
|
|
80529
|
+
};
|
|
80530
|
+
}
|
|
80524
80531
|
return { ok: true, rows };
|
|
80525
80532
|
}
|
|
80533
|
+
/**
|
|
80534
|
+
* The supported set, verified — index rows each re-checked on-chain, carrying the symbol
|
|
80535
|
+
* read from the token itself. This is what `protocol://psm` lists and what a caller's
|
|
80536
|
+
* SYMBOL is resolved against.
|
|
80537
|
+
*
|
|
80538
|
+
* Rows are dropped ONLY for the one reason a drop is honest: the index still lists a coin
|
|
80539
|
+
* the chain no longer supports (index lag behind a governance removal). Any OTHER failure
|
|
80540
|
+
* — an RPC outage mid-loop — propagates, because a list that silently shrinks when the
|
|
80541
|
+
* chain is unreachable is the same silent-failure shape as the empty list above. If
|
|
80542
|
+
* nothing survives verification, that is a refusal too, and it says which side disagreed.
|
|
80543
|
+
*/
|
|
80544
|
+
async verifiedStablecoins() {
|
|
80545
|
+
const listed = await this.listSupportedStablecoins();
|
|
80546
|
+
if (!listed.ok) return listed;
|
|
80547
|
+
const checked = await Promise.all(
|
|
80548
|
+
listed.rows.map(async (row) => ({ row, built: await this.psmCallsFor(row.address) }))
|
|
80549
|
+
);
|
|
80550
|
+
const transport = checked.find((c) => !c.built.ok && c.built.failure.kind !== "rejected");
|
|
80551
|
+
if (transport && !transport.built.ok) return { ok: false, failure: transport.built.failure };
|
|
80552
|
+
const rows = checked.flatMap(
|
|
80553
|
+
({ row, built }) => built.ok ? [{ address: row.address, symbol: built.calls.symbol(), decimals: row.decimals }] : []
|
|
80554
|
+
);
|
|
80555
|
+
if (rows.length === 0) {
|
|
80556
|
+
return {
|
|
80557
|
+
ok: false,
|
|
80558
|
+
failure: {
|
|
80559
|
+
kind: "unavailable",
|
|
80560
|
+
source: "chain-rpc",
|
|
80561
|
+
message: `the indexer lists ${listed.rows.length} PSM stablecoin(s) on ${this.config.network}, and the PSM contract confirms none of them. The index is behind a governance removal, or it is indexing a different PSM than the one in this build's deployment table \u2014 verify before exchanging anything.`
|
|
80562
|
+
}
|
|
80563
|
+
};
|
|
80564
|
+
}
|
|
80565
|
+
return { ok: true, rows };
|
|
80566
|
+
}
|
|
80567
|
+
/**
|
|
80568
|
+
* Resolve what the CALLER named — a symbol or a 0x address — to a verified address.
|
|
80569
|
+
*
|
|
80570
|
+
* The tool schemas have always said "by SYMBOL (e.g. 'USDC', 'USDT') or by 0x address",
|
|
80571
|
+
* and the mock world accepts exactly that. The real adapter accepted only the address:
|
|
80572
|
+
* a symbol went straight into an address-typed `ethers.Contract`, which threw, and the
|
|
80573
|
+
* throw was caught as `kind: "unavailable"` → `UPSTREAM_UNAVAILABLE` — a code the guide
|
|
80574
|
+
* tells the model is "usually transient; retry once". So the documented input produced a
|
|
80575
|
+
* retry loop on the one deployment that moves real money, and a developer practising
|
|
80576
|
+
* against the mock never met it. Both halves are fixed here: the symbol resolves, and a
|
|
80577
|
+
* name that cannot resolve is `rejected` (the caller's input) rather than `unavailable`
|
|
80578
|
+
* (our upstream).
|
|
80579
|
+
*/
|
|
80580
|
+
async psmCallsForChoice(chosen) {
|
|
80581
|
+
const raw = chosen.trim();
|
|
80582
|
+
if (raw.length === 0) {
|
|
80583
|
+
return {
|
|
80584
|
+
ok: false,
|
|
80585
|
+
failure: { kind: "rejected", source: "chain-rpc", message: "no stablecoin named \u2014 name one by symbol (e.g. 'USDC') or by 0x address; there is no default coin." }
|
|
80586
|
+
};
|
|
80587
|
+
}
|
|
80588
|
+
const symbol = raw.toLowerCase();
|
|
80589
|
+
if (import_ethers38.ethers.isAddress(raw)) return this.psmCallsFor(symbol);
|
|
80590
|
+
const verified = await this.verifiedStablecoins();
|
|
80591
|
+
if (!verified.ok) return { ok: false, failure: verified.failure };
|
|
80592
|
+
const hits = verified.rows.filter((r) => r.symbol.toLowerCase() === symbol);
|
|
80593
|
+
if (hits.length > 1) {
|
|
80594
|
+
return {
|
|
80595
|
+
ok: false,
|
|
80596
|
+
failure: {
|
|
80597
|
+
kind: "rejected",
|
|
80598
|
+
source: "chain-rpc",
|
|
80599
|
+
message: `'${raw}' names ${hits.length} different coins this PSM supports \u2014 ${hits.map((r) => r.address).join(", ")}. Symbols are self-declared and not unique, so this one cannot be resolved for you: name the 0x address of the one you mean.`
|
|
80600
|
+
}
|
|
80601
|
+
};
|
|
80602
|
+
}
|
|
80603
|
+
const hit = hits[0];
|
|
80604
|
+
if (!hit) {
|
|
80605
|
+
const names = verified.rows.map((r) => `${r.symbol} (${r.address})`).join(", ");
|
|
80606
|
+
return {
|
|
80607
|
+
ok: false,
|
|
80608
|
+
failure: {
|
|
80609
|
+
kind: "rejected",
|
|
80610
|
+
source: "chain-rpc",
|
|
80611
|
+
message: `'${raw}' is not a coin this PSM supports on ${this.config.network} \u2014 it supports ${names}. Name one of those by symbol or address. \`protocol://psm\` carries each one's fees, limits and reserves.`
|
|
80612
|
+
}
|
|
80613
|
+
};
|
|
80614
|
+
}
|
|
80615
|
+
return this.psmCallsFor(hit.address);
|
|
80616
|
+
}
|
|
80526
80617
|
/**
|
|
80527
80618
|
* Build the PSM wrapper for ONE caller-chosen stablecoin.
|
|
80528
80619
|
*
|
|
@@ -80533,6 +80624,9 @@ var RealUpstreamPlugin = class {
|
|
|
80533
80624
|
* chain, then sign.
|
|
80534
80625
|
*/
|
|
80535
80626
|
async psmCallsFor(stablecoinAddress) {
|
|
80627
|
+
if (!import_ethers38.ethers.isAddress(stablecoinAddress)) {
|
|
80628
|
+
throw new Error(`psmCallsFor requires a resolved 0x address, got '${stablecoinAddress}' \u2014 resolve through psmCallsForChoice`);
|
|
80629
|
+
}
|
|
80536
80630
|
const key = stablecoinAddress.toLowerCase();
|
|
80537
80631
|
const cached = this.psmWrappers.get(key);
|
|
80538
80632
|
if (cached) return { ok: true, calls: cached };
|
package/dist/connector-embed.js
CHANGED
|
@@ -41038,7 +41038,7 @@ function htmlPageSecurityHeaders(extra) {
|
|
|
41038
41038
|
}
|
|
41039
41039
|
|
|
41040
41040
|
// src/version.ts
|
|
41041
|
-
var SERVER_VERSION = "0.5.
|
|
41041
|
+
var SERVER_VERSION = "0.5.16";
|
|
41042
41042
|
|
|
41043
41043
|
// src/connector/siwe-oauth.ts
|
|
41044
41044
|
var import_node_crypto2 = require("crypto");
|
|
@@ -79577,18 +79577,12 @@ function listPositionsQuery(f) {
|
|
|
79577
79577
|
return { document: LIST_POSITIONS, variables: { first, skip } };
|
|
79578
79578
|
}
|
|
79579
79579
|
var SUPPORTED_STABLECOINS = `
|
|
79580
|
-
query
|
|
79580
|
+
query GetSupportedStablecoins {
|
|
79581
79581
|
supportedStablecoins(where: { isSupported: true }, orderBy: addedAt, orderDirection: desc) {
|
|
79582
|
-
id
|
|
79583
|
-
|
|
79584
|
-
isSupported
|
|
79585
|
-
decimals
|
|
79586
|
-
entryFee
|
|
79587
|
-
exitFee
|
|
79588
|
-
reserves
|
|
79582
|
+
id address isSupported exchangeRate entryFee exitFee reserves decimals
|
|
79583
|
+
totalSwapVolume totalRedeemVolume swapCount redeemCount addedAt lastUpdated
|
|
79589
79584
|
}
|
|
79590
|
-
}
|
|
79591
|
-
`;
|
|
79585
|
+
}`;
|
|
79592
79586
|
|
|
79593
79587
|
// src/boundary/upstream/real/psm-calls.ts
|
|
79594
79588
|
var import_ethers32 = require("ethers");
|
|
@@ -80557,7 +80551,7 @@ function buildWriteOps(deps) {
|
|
|
80557
80551
|
const tokenAddress = isSwap ? addr.stablecoin : addr.ucdToken;
|
|
80558
80552
|
const spenderAddress = isSwap ? addr.psm : addr.ucdController;
|
|
80559
80553
|
const spenderContract = isSwap ? "SimplePSMV2" : "UCDController";
|
|
80560
|
-
const tokenSymbol = isSwap ?
|
|
80554
|
+
const tokenSymbol = isSwap ? calls.symbol() : "UCD";
|
|
80561
80555
|
const quoteR = isSwap ? await calls.swapQuote(p.amountIn) : await calls.redemptionQuote(p.amountIn);
|
|
80562
80556
|
if (!quoteR.ok) return upFail(quoteR.failure);
|
|
80563
80557
|
const broadcast = async (leg, action, tx2) => {
|
|
@@ -80597,7 +80591,7 @@ function buildWriteOps(deps) {
|
|
|
80597
80591
|
} catch (e) {
|
|
80598
80592
|
return upFail({ kind: "rejected", source: SOURCE5, message: `PSM ${p.direction} tx failed the whitelist: ${e.message} \u2014 ${residualNote}` });
|
|
80599
80593
|
}
|
|
80600
|
-
const execCard = `${p.direction} ${p.amountIn} ${isSwap ?
|
|
80594
|
+
const execCard = `${p.direction} ${p.amountIn} ${isSwap ? `${tokenSymbol} smallest units` : "UCD wei"} via the PSM: quote ${quoteR.value.amountOut} out (fee ${quoteR.value.feeAmount}), floor ${p.minOut} \u2014 output to ${p.borrower}`;
|
|
80601
80595
|
const execHashR = await broadcast(`psmSwap (${p.direction})`, isSwap ? "psm-swap" : "psm-redeem", execTx);
|
|
80602
80596
|
if (!execHashR.ok) {
|
|
80603
80597
|
const f = execHashR.failure;
|
|
@@ -81148,25 +81142,16 @@ var RealUpstreamPlugin = class {
|
|
|
81148
81142
|
// PSM reads (plan 08 Part B Phase R): on-chain views ONLY, through the dedicated
|
|
81149
81143
|
// wrapper (NOT chainRead) so custom-error refusals decode WITH their figures.
|
|
81150
81144
|
listPsmStablecoins: async () => {
|
|
81151
|
-
const
|
|
81152
|
-
if (!
|
|
81153
|
-
|
|
81154
|
-
listed.rows.map(async (row) => {
|
|
81155
|
-
const built = await this.psmCallsFor(row.address);
|
|
81156
|
-
return built.ok ? { address: row.address, symbol: built.calls.symbol(), decimals: row.decimals } : null;
|
|
81157
|
-
})
|
|
81158
|
-
);
|
|
81159
|
-
return upOk(
|
|
81160
|
-
rows.filter((r) => r !== null),
|
|
81161
|
-
this.src("subgraph")
|
|
81162
|
-
);
|
|
81145
|
+
const verified = await this.verifiedStablecoins();
|
|
81146
|
+
if (!verified.ok) return upFail(verified.failure);
|
|
81147
|
+
return upOk(verified.rows, this.src("subgraph"));
|
|
81163
81148
|
},
|
|
81164
81149
|
getPsmStatus: async (p) => {
|
|
81165
|
-
const r = await this.
|
|
81150
|
+
const r = await this.psmCallsForChoice(p.stablecoin);
|
|
81166
81151
|
return r.ok ? r.calls.status() : upFail(r.failure);
|
|
81167
81152
|
},
|
|
81168
81153
|
getPsmQuote: async (p) => {
|
|
81169
|
-
const r = await this.
|
|
81154
|
+
const r = await this.psmCallsForChoice(p.stablecoin);
|
|
81170
81155
|
if (!r.ok) return upFail(r.failure);
|
|
81171
81156
|
return p.direction === "swap" ? r.calls.swapQuote(p.amountIn) : r.calls.redemptionQuote(p.amountIn);
|
|
81172
81157
|
}
|
|
@@ -81358,7 +81343,7 @@ var RealUpstreamPlugin = class {
|
|
|
81358
81343
|
session,
|
|
81359
81344
|
getWriteSdk: () => this.sdkCache.get(key) ?? null,
|
|
81360
81345
|
readDetails: (id) => this.readPositionDetails(id),
|
|
81361
|
-
psm: (stablecoin) => this.
|
|
81346
|
+
psm: (stablecoin) => this.psmCallsForChoice(stablecoin),
|
|
81362
81347
|
assertValidatorConfigured: () => this.assertValidatorConfigured()
|
|
81363
81348
|
});
|
|
81364
81349
|
}
|
|
@@ -81492,7 +81477,7 @@ var RealUpstreamPlugin = class {
|
|
|
81492
81477
|
session,
|
|
81493
81478
|
getWriteSdk: () => this.sdkCache.get(key) ?? null,
|
|
81494
81479
|
readDetails: (id) => this.readPositionDetails(id),
|
|
81495
|
-
psm: (stablecoin) => this.
|
|
81480
|
+
psm: (stablecoin) => this.psmCallsForChoice(stablecoin),
|
|
81496
81481
|
assertValidatorConfigured: () => this.assertValidatorConfigured()
|
|
81497
81482
|
});
|
|
81498
81483
|
this.opsGatewayCache.set(key, gateway);
|
|
@@ -81656,12 +81641,118 @@ var RealUpstreamPlugin = class {
|
|
|
81656
81641
|
{}
|
|
81657
81642
|
);
|
|
81658
81643
|
if (!r.ok) return r;
|
|
81659
|
-
const
|
|
81644
|
+
const raw = r.value.data.supportedStablecoins ?? [];
|
|
81645
|
+
const bad = raw.find((x) => !import_ethers39.ethers.isAddress(String(x.address)) || !Number.isFinite(Number(x.decimals)));
|
|
81646
|
+
if (bad) {
|
|
81647
|
+
return {
|
|
81648
|
+
ok: false,
|
|
81649
|
+
failure: {
|
|
81650
|
+
kind: "malformed",
|
|
81651
|
+
source: "subgraph",
|
|
81652
|
+
message: `the indexer returned a PSM stablecoin row this build cannot read (address '${String(bad.address)}', decimals '${String(bad.decimals)}')`
|
|
81653
|
+
}
|
|
81654
|
+
};
|
|
81655
|
+
}
|
|
81656
|
+
const rows = raw.map((x) => ({
|
|
81660
81657
|
address: String(x.address).toLowerCase(),
|
|
81661
81658
|
decimals: Number(x.decimals)
|
|
81662
81659
|
}));
|
|
81660
|
+
if (rows.length === 0) {
|
|
81661
|
+
return {
|
|
81662
|
+
ok: false,
|
|
81663
|
+
failure: {
|
|
81664
|
+
kind: "unavailable",
|
|
81665
|
+
source: "subgraph",
|
|
81666
|
+
message: `the indexer lists NO supported stablecoins for the PSM on ${this.config.network}. Either the subgraph has not indexed the StablecoinAdded events yet (check its start block against the block the coins were added at), or governance has removed every coin. PSM exchange is unavailable here until one of those is resolved \u2014 this is NOT "the PSM supports nothing".`
|
|
81667
|
+
}
|
|
81668
|
+
};
|
|
81669
|
+
}
|
|
81670
|
+
return { ok: true, rows };
|
|
81671
|
+
}
|
|
81672
|
+
/**
|
|
81673
|
+
* The supported set, verified — index rows each re-checked on-chain, carrying the symbol
|
|
81674
|
+
* read from the token itself. This is what `protocol://psm` lists and what a caller's
|
|
81675
|
+
* SYMBOL is resolved against.
|
|
81676
|
+
*
|
|
81677
|
+
* Rows are dropped ONLY for the one reason a drop is honest: the index still lists a coin
|
|
81678
|
+
* the chain no longer supports (index lag behind a governance removal). Any OTHER failure
|
|
81679
|
+
* — an RPC outage mid-loop — propagates, because a list that silently shrinks when the
|
|
81680
|
+
* chain is unreachable is the same silent-failure shape as the empty list above. If
|
|
81681
|
+
* nothing survives verification, that is a refusal too, and it says which side disagreed.
|
|
81682
|
+
*/
|
|
81683
|
+
async verifiedStablecoins() {
|
|
81684
|
+
const listed = await this.listSupportedStablecoins();
|
|
81685
|
+
if (!listed.ok) return listed;
|
|
81686
|
+
const checked = await Promise.all(
|
|
81687
|
+
listed.rows.map(async (row) => ({ row, built: await this.psmCallsFor(row.address) }))
|
|
81688
|
+
);
|
|
81689
|
+
const transport = checked.find((c) => !c.built.ok && c.built.failure.kind !== "rejected");
|
|
81690
|
+
if (transport && !transport.built.ok) return { ok: false, failure: transport.built.failure };
|
|
81691
|
+
const rows = checked.flatMap(
|
|
81692
|
+
({ row, built }) => built.ok ? [{ address: row.address, symbol: built.calls.symbol(), decimals: row.decimals }] : []
|
|
81693
|
+
);
|
|
81694
|
+
if (rows.length === 0) {
|
|
81695
|
+
return {
|
|
81696
|
+
ok: false,
|
|
81697
|
+
failure: {
|
|
81698
|
+
kind: "unavailable",
|
|
81699
|
+
source: "chain-rpc",
|
|
81700
|
+
message: `the indexer lists ${listed.rows.length} PSM stablecoin(s) on ${this.config.network}, and the PSM contract confirms none of them. The index is behind a governance removal, or it is indexing a different PSM than the one in this build's deployment table \u2014 verify before exchanging anything.`
|
|
81701
|
+
}
|
|
81702
|
+
};
|
|
81703
|
+
}
|
|
81663
81704
|
return { ok: true, rows };
|
|
81664
81705
|
}
|
|
81706
|
+
/**
|
|
81707
|
+
* Resolve what the CALLER named — a symbol or a 0x address — to a verified address.
|
|
81708
|
+
*
|
|
81709
|
+
* The tool schemas have always said "by SYMBOL (e.g. 'USDC', 'USDT') or by 0x address",
|
|
81710
|
+
* and the mock world accepts exactly that. The real adapter accepted only the address:
|
|
81711
|
+
* a symbol went straight into an address-typed `ethers.Contract`, which threw, and the
|
|
81712
|
+
* throw was caught as `kind: "unavailable"` → `UPSTREAM_UNAVAILABLE` — a code the guide
|
|
81713
|
+
* tells the model is "usually transient; retry once". So the documented input produced a
|
|
81714
|
+
* retry loop on the one deployment that moves real money, and a developer practising
|
|
81715
|
+
* against the mock never met it. Both halves are fixed here: the symbol resolves, and a
|
|
81716
|
+
* name that cannot resolve is `rejected` (the caller's input) rather than `unavailable`
|
|
81717
|
+
* (our upstream).
|
|
81718
|
+
*/
|
|
81719
|
+
async psmCallsForChoice(chosen) {
|
|
81720
|
+
const raw = chosen.trim();
|
|
81721
|
+
if (raw.length === 0) {
|
|
81722
|
+
return {
|
|
81723
|
+
ok: false,
|
|
81724
|
+
failure: { kind: "rejected", source: "chain-rpc", message: "no stablecoin named \u2014 name one by symbol (e.g. 'USDC') or by 0x address; there is no default coin." }
|
|
81725
|
+
};
|
|
81726
|
+
}
|
|
81727
|
+
const symbol = raw.toLowerCase();
|
|
81728
|
+
if (import_ethers39.ethers.isAddress(raw)) return this.psmCallsFor(symbol);
|
|
81729
|
+
const verified = await this.verifiedStablecoins();
|
|
81730
|
+
if (!verified.ok) return { ok: false, failure: verified.failure };
|
|
81731
|
+
const hits = verified.rows.filter((r) => r.symbol.toLowerCase() === symbol);
|
|
81732
|
+
if (hits.length > 1) {
|
|
81733
|
+
return {
|
|
81734
|
+
ok: false,
|
|
81735
|
+
failure: {
|
|
81736
|
+
kind: "rejected",
|
|
81737
|
+
source: "chain-rpc",
|
|
81738
|
+
message: `'${raw}' names ${hits.length} different coins this PSM supports \u2014 ${hits.map((r) => r.address).join(", ")}. Symbols are self-declared and not unique, so this one cannot be resolved for you: name the 0x address of the one you mean.`
|
|
81739
|
+
}
|
|
81740
|
+
};
|
|
81741
|
+
}
|
|
81742
|
+
const hit = hits[0];
|
|
81743
|
+
if (!hit) {
|
|
81744
|
+
const names = verified.rows.map((r) => `${r.symbol} (${r.address})`).join(", ");
|
|
81745
|
+
return {
|
|
81746
|
+
ok: false,
|
|
81747
|
+
failure: {
|
|
81748
|
+
kind: "rejected",
|
|
81749
|
+
source: "chain-rpc",
|
|
81750
|
+
message: `'${raw}' is not a coin this PSM supports on ${this.config.network} \u2014 it supports ${names}. Name one of those by symbol or address. \`protocol://psm\` carries each one's fees, limits and reserves.`
|
|
81751
|
+
}
|
|
81752
|
+
};
|
|
81753
|
+
}
|
|
81754
|
+
return this.psmCallsFor(hit.address);
|
|
81755
|
+
}
|
|
81665
81756
|
/**
|
|
81666
81757
|
* Build the PSM wrapper for ONE caller-chosen stablecoin.
|
|
81667
81758
|
*
|
|
@@ -81672,6 +81763,9 @@ var RealUpstreamPlugin = class {
|
|
|
81672
81763
|
* chain, then sign.
|
|
81673
81764
|
*/
|
|
81674
81765
|
async psmCallsFor(stablecoinAddress) {
|
|
81766
|
+
if (!import_ethers39.ethers.isAddress(stablecoinAddress)) {
|
|
81767
|
+
throw new Error(`psmCallsFor requires a resolved 0x address, got '${stablecoinAddress}' \u2014 resolve through psmCallsForChoice`);
|
|
81768
|
+
}
|
|
81675
81769
|
const key = stablecoinAddress.toLowerCase();
|
|
81676
81770
|
const cached = this.psmWrappers.get(key);
|
|
81677
81771
|
if (cached) return { ok: true, calls: cached };
|
|
@@ -83694,6 +83788,17 @@ function signerModeSourceClause(d) {
|
|
|
83694
83788
|
function phoneWalletOffer(d) {
|
|
83695
83789
|
return d.walletConnect ? "or scan the WalletConnect QR (or paste the pairing code) to approve on a phone wallet" : "This deployment does NOT offer the WalletConnect phone-wallet leg \u2014 there is no QR to scan and `/wc-pairing` answers 404; a browser-extension wallet is the only path here";
|
|
83696
83790
|
}
|
|
83791
|
+
function worldAxes(d) {
|
|
83792
|
+
const axes = [];
|
|
83793
|
+
axes.push(
|
|
83794
|
+
offers(d, "mock-simulated") ? "practice (mock) or real adapter" : "the REAL adapter \u2014 there is no practice (mock) world on this deployment"
|
|
83795
|
+
);
|
|
83796
|
+
axes.push(
|
|
83797
|
+
d.networks.length > 1 ? "sepolia (practice money) or mainnet (real money)" : d.networks.includes("mainnet") ? "MAINNET only, so every fund movement here is real money" : "sepolia only, so the ceremonies are real and the money is practice"
|
|
83798
|
+
);
|
|
83799
|
+
axes.push("that writes are enabled, and what actually gates one is whether a signing identity is connected");
|
|
83800
|
+
return axes.join("; ");
|
|
83801
|
+
}
|
|
83697
83802
|
function moneyTruth(d) {
|
|
83698
83803
|
const practice = offers(d, "mock-simulated");
|
|
83699
83804
|
const sepolia = d.networks.includes("sepolia");
|
|
@@ -83876,8 +83981,7 @@ have to guess whether the money is real.`;
|
|
|
83876
83981
|
function authorizationModeBullets(d) {
|
|
83877
83982
|
const bullets = [];
|
|
83878
83983
|
if (offers(d, "external")) {
|
|
83879
|
-
bullets.push(` - \`external\` \u2014 the user approves in their OWN wallet (browser popup, or WalletConnect
|
|
83880
|
-
mobile via QR/paste-code). Real adapter and mock. For TRANSACTIONS the approval card
|
|
83984
|
+
bullets.push(` - \`external\` \u2014 the user approves in their OWN wallet (browser popup${d.walletConnect ? ", or WalletConnect\n mobile via QR/paste-code" : " \u2014 this build has no WalletConnect\n mobile leg"}). Real adapter and mock. For TRANSACTIONS the approval card
|
|
83881
83985
|
is decoded from the exact bytes being signed \u2014 what the user reads IS what executes.
|
|
83882
83986
|
The ONE exception is the BTC withdrawal's EXECUTE phase: an opaque 32-byte hash the
|
|
83883
83987
|
approval page states plainly it CANNOT decode. Never extend the card promise over
|
|
@@ -83940,8 +84044,7 @@ install matrix. ${connectorInstallNote(d)}
|
|
|
83940
84044
|
Nothing needs a config file. Three steps:
|
|
83941
84045
|
|
|
83942
84046
|
**1. Know your world.** Read \`boundary://info\` (its \`capabilities\` block) and
|
|
83943
|
-
\`protocol_status\`, then tell the user
|
|
83944
|
-
(practice money) or mainnet (real money); whether writes are enabled here and which
|
|
84047
|
+
\`protocol_status\`, then tell the user what THIS deployment is: ${worldAxes(d)}; which
|
|
83945
84048
|
signer modes exist; current terms (\`protocol_terms\`).
|
|
83946
84049
|
|
|
83947
84050
|
**2. Choose HOW to authorize operations** (the user's choice, made by talking):
|
|
@@ -84050,8 +84153,7 @@ on the real adapter and the mock.
|
|
|
84050
84153
|
10 UCD.
|
|
84051
84154
|
|
|
84052
84155
|
**Disconnecting \u2014 "log out / sign out / forget my wallet" (\`signer_setup\` action
|
|
84053
|
-
\`disconnect\`):** the FULL wallet flush. It ends every approval-page session and any
|
|
84054
|
-
WalletConnect session (pending approvals are cancelled loudly), discards the login
|
|
84156
|
+
\`disconnect\`):** the FULL wallet flush. It ends every approval-page session${d.walletConnect ? " and any\nWalletConnect session" : ""} (pending approvals are cancelled loudly), discards the login
|
|
84055
84157
|
token from server memory AND revokes it at the service, and unbinds the borrower
|
|
84056
84158
|
identity. Reconnecting afterwards ALWAYS requires opening the approval page again and
|
|
84057
84159
|
a fresh wallet signature \u2014 a disconnect can never silently reconnect. Two truths to
|
|
@@ -84509,7 +84611,7 @@ function renderGuideIndex(deployment) {
|
|
|
84509
84611
|
|
|
84510
84612
|
- getting-started \u2014 what this product is, practice-vs-real-money honesty (three cases)
|
|
84511
84613
|
- first-setup \u2014 zero to ready by conversation (authorization choice included)
|
|
84512
|
-
- connect-wallet \u2014 external-wallet walkthrough: approval page, extension or WalletConnect QR, popup cadence, login honesty, disconnect/log-out
|
|
84614
|
+
- connect-wallet \u2014 external-wallet walkthrough: approval page, ${deployment.walletConnect ? "extension or WalletConnect QR" : "browser extension (no WalletConnect leg here)"}, popup cadence, login honesty, disconnect/log-out
|
|
84513
84615
|
- lifecycle \u2014 the exact calls, create \u2192 deposit \u2192 mint \u2192 pay \u2192 extend \u2192 withdraw
|
|
84514
84616
|
- fees \u2014 the two fee models, plainly
|
|
84515
84617
|
- psm \u2014 exchanging UCD \u2194 USDC: both directions, the two fees WITH their tokens, limits, why a floor exists
|
package/dist/connector.js
CHANGED
|
@@ -41032,7 +41032,7 @@ function htmlPageSecurityHeaders(extra) {
|
|
|
41032
41032
|
}
|
|
41033
41033
|
|
|
41034
41034
|
// src/version.ts
|
|
41035
|
-
var SERVER_VERSION = "0.5.
|
|
41035
|
+
var SERVER_VERSION = "0.5.16";
|
|
41036
41036
|
|
|
41037
41037
|
// src/connector/siwe-oauth.ts
|
|
41038
41038
|
var import_node_crypto2 = require("crypto");
|
|
@@ -79571,18 +79571,12 @@ function listPositionsQuery(f) {
|
|
|
79571
79571
|
return { document: LIST_POSITIONS, variables: { first, skip } };
|
|
79572
79572
|
}
|
|
79573
79573
|
var SUPPORTED_STABLECOINS = `
|
|
79574
|
-
query
|
|
79574
|
+
query GetSupportedStablecoins {
|
|
79575
79575
|
supportedStablecoins(where: { isSupported: true }, orderBy: addedAt, orderDirection: desc) {
|
|
79576
|
-
id
|
|
79577
|
-
|
|
79578
|
-
isSupported
|
|
79579
|
-
decimals
|
|
79580
|
-
entryFee
|
|
79581
|
-
exitFee
|
|
79582
|
-
reserves
|
|
79576
|
+
id address isSupported exchangeRate entryFee exitFee reserves decimals
|
|
79577
|
+
totalSwapVolume totalRedeemVolume swapCount redeemCount addedAt lastUpdated
|
|
79583
79578
|
}
|
|
79584
|
-
}
|
|
79585
|
-
`;
|
|
79579
|
+
}`;
|
|
79586
79580
|
|
|
79587
79581
|
// src/boundary/upstream/real/psm-calls.ts
|
|
79588
79582
|
var import_ethers32 = require("ethers");
|
|
@@ -80551,7 +80545,7 @@ function buildWriteOps(deps) {
|
|
|
80551
80545
|
const tokenAddress = isSwap ? addr.stablecoin : addr.ucdToken;
|
|
80552
80546
|
const spenderAddress = isSwap ? addr.psm : addr.ucdController;
|
|
80553
80547
|
const spenderContract = isSwap ? "SimplePSMV2" : "UCDController";
|
|
80554
|
-
const tokenSymbol = isSwap ?
|
|
80548
|
+
const tokenSymbol = isSwap ? calls.symbol() : "UCD";
|
|
80555
80549
|
const quoteR = isSwap ? await calls.swapQuote(p.amountIn) : await calls.redemptionQuote(p.amountIn);
|
|
80556
80550
|
if (!quoteR.ok) return upFail(quoteR.failure);
|
|
80557
80551
|
const broadcast = async (leg, action, tx2) => {
|
|
@@ -80591,7 +80585,7 @@ function buildWriteOps(deps) {
|
|
|
80591
80585
|
} catch (e) {
|
|
80592
80586
|
return upFail({ kind: "rejected", source: SOURCE5, message: `PSM ${p.direction} tx failed the whitelist: ${e.message} \u2014 ${residualNote}` });
|
|
80593
80587
|
}
|
|
80594
|
-
const execCard = `${p.direction} ${p.amountIn} ${isSwap ?
|
|
80588
|
+
const execCard = `${p.direction} ${p.amountIn} ${isSwap ? `${tokenSymbol} smallest units` : "UCD wei"} via the PSM: quote ${quoteR.value.amountOut} out (fee ${quoteR.value.feeAmount}), floor ${p.minOut} \u2014 output to ${p.borrower}`;
|
|
80595
80589
|
const execHashR = await broadcast(`psmSwap (${p.direction})`, isSwap ? "psm-swap" : "psm-redeem", execTx);
|
|
80596
80590
|
if (!execHashR.ok) {
|
|
80597
80591
|
const f = execHashR.failure;
|
|
@@ -81142,25 +81136,16 @@ var RealUpstreamPlugin = class {
|
|
|
81142
81136
|
// PSM reads (plan 08 Part B Phase R): on-chain views ONLY, through the dedicated
|
|
81143
81137
|
// wrapper (NOT chainRead) so custom-error refusals decode WITH their figures.
|
|
81144
81138
|
listPsmStablecoins: async () => {
|
|
81145
|
-
const
|
|
81146
|
-
if (!
|
|
81147
|
-
|
|
81148
|
-
listed.rows.map(async (row) => {
|
|
81149
|
-
const built = await this.psmCallsFor(row.address);
|
|
81150
|
-
return built.ok ? { address: row.address, symbol: built.calls.symbol(), decimals: row.decimals } : null;
|
|
81151
|
-
})
|
|
81152
|
-
);
|
|
81153
|
-
return upOk(
|
|
81154
|
-
rows.filter((r) => r !== null),
|
|
81155
|
-
this.src("subgraph")
|
|
81156
|
-
);
|
|
81139
|
+
const verified = await this.verifiedStablecoins();
|
|
81140
|
+
if (!verified.ok) return upFail(verified.failure);
|
|
81141
|
+
return upOk(verified.rows, this.src("subgraph"));
|
|
81157
81142
|
},
|
|
81158
81143
|
getPsmStatus: async (p) => {
|
|
81159
|
-
const r = await this.
|
|
81144
|
+
const r = await this.psmCallsForChoice(p.stablecoin);
|
|
81160
81145
|
return r.ok ? r.calls.status() : upFail(r.failure);
|
|
81161
81146
|
},
|
|
81162
81147
|
getPsmQuote: async (p) => {
|
|
81163
|
-
const r = await this.
|
|
81148
|
+
const r = await this.psmCallsForChoice(p.stablecoin);
|
|
81164
81149
|
if (!r.ok) return upFail(r.failure);
|
|
81165
81150
|
return p.direction === "swap" ? r.calls.swapQuote(p.amountIn) : r.calls.redemptionQuote(p.amountIn);
|
|
81166
81151
|
}
|
|
@@ -81352,7 +81337,7 @@ var RealUpstreamPlugin = class {
|
|
|
81352
81337
|
session,
|
|
81353
81338
|
getWriteSdk: () => this.sdkCache.get(key) ?? null,
|
|
81354
81339
|
readDetails: (id) => this.readPositionDetails(id),
|
|
81355
|
-
psm: (stablecoin) => this.
|
|
81340
|
+
psm: (stablecoin) => this.psmCallsForChoice(stablecoin),
|
|
81356
81341
|
assertValidatorConfigured: () => this.assertValidatorConfigured()
|
|
81357
81342
|
});
|
|
81358
81343
|
}
|
|
@@ -81486,7 +81471,7 @@ var RealUpstreamPlugin = class {
|
|
|
81486
81471
|
session,
|
|
81487
81472
|
getWriteSdk: () => this.sdkCache.get(key) ?? null,
|
|
81488
81473
|
readDetails: (id) => this.readPositionDetails(id),
|
|
81489
|
-
psm: (stablecoin) => this.
|
|
81474
|
+
psm: (stablecoin) => this.psmCallsForChoice(stablecoin),
|
|
81490
81475
|
assertValidatorConfigured: () => this.assertValidatorConfigured()
|
|
81491
81476
|
});
|
|
81492
81477
|
this.opsGatewayCache.set(key, gateway);
|
|
@@ -81650,12 +81635,118 @@ var RealUpstreamPlugin = class {
|
|
|
81650
81635
|
{}
|
|
81651
81636
|
);
|
|
81652
81637
|
if (!r.ok) return r;
|
|
81653
|
-
const
|
|
81638
|
+
const raw = r.value.data.supportedStablecoins ?? [];
|
|
81639
|
+
const bad = raw.find((x) => !import_ethers39.ethers.isAddress(String(x.address)) || !Number.isFinite(Number(x.decimals)));
|
|
81640
|
+
if (bad) {
|
|
81641
|
+
return {
|
|
81642
|
+
ok: false,
|
|
81643
|
+
failure: {
|
|
81644
|
+
kind: "malformed",
|
|
81645
|
+
source: "subgraph",
|
|
81646
|
+
message: `the indexer returned a PSM stablecoin row this build cannot read (address '${String(bad.address)}', decimals '${String(bad.decimals)}')`
|
|
81647
|
+
}
|
|
81648
|
+
};
|
|
81649
|
+
}
|
|
81650
|
+
const rows = raw.map((x) => ({
|
|
81654
81651
|
address: String(x.address).toLowerCase(),
|
|
81655
81652
|
decimals: Number(x.decimals)
|
|
81656
81653
|
}));
|
|
81654
|
+
if (rows.length === 0) {
|
|
81655
|
+
return {
|
|
81656
|
+
ok: false,
|
|
81657
|
+
failure: {
|
|
81658
|
+
kind: "unavailable",
|
|
81659
|
+
source: "subgraph",
|
|
81660
|
+
message: `the indexer lists NO supported stablecoins for the PSM on ${this.config.network}. Either the subgraph has not indexed the StablecoinAdded events yet (check its start block against the block the coins were added at), or governance has removed every coin. PSM exchange is unavailable here until one of those is resolved \u2014 this is NOT "the PSM supports nothing".`
|
|
81661
|
+
}
|
|
81662
|
+
};
|
|
81663
|
+
}
|
|
81664
|
+
return { ok: true, rows };
|
|
81665
|
+
}
|
|
81666
|
+
/**
|
|
81667
|
+
* The supported set, verified — index rows each re-checked on-chain, carrying the symbol
|
|
81668
|
+
* read from the token itself. This is what `protocol://psm` lists and what a caller's
|
|
81669
|
+
* SYMBOL is resolved against.
|
|
81670
|
+
*
|
|
81671
|
+
* Rows are dropped ONLY for the one reason a drop is honest: the index still lists a coin
|
|
81672
|
+
* the chain no longer supports (index lag behind a governance removal). Any OTHER failure
|
|
81673
|
+
* — an RPC outage mid-loop — propagates, because a list that silently shrinks when the
|
|
81674
|
+
* chain is unreachable is the same silent-failure shape as the empty list above. If
|
|
81675
|
+
* nothing survives verification, that is a refusal too, and it says which side disagreed.
|
|
81676
|
+
*/
|
|
81677
|
+
async verifiedStablecoins() {
|
|
81678
|
+
const listed = await this.listSupportedStablecoins();
|
|
81679
|
+
if (!listed.ok) return listed;
|
|
81680
|
+
const checked = await Promise.all(
|
|
81681
|
+
listed.rows.map(async (row) => ({ row, built: await this.psmCallsFor(row.address) }))
|
|
81682
|
+
);
|
|
81683
|
+
const transport = checked.find((c) => !c.built.ok && c.built.failure.kind !== "rejected");
|
|
81684
|
+
if (transport && !transport.built.ok) return { ok: false, failure: transport.built.failure };
|
|
81685
|
+
const rows = checked.flatMap(
|
|
81686
|
+
({ row, built }) => built.ok ? [{ address: row.address, symbol: built.calls.symbol(), decimals: row.decimals }] : []
|
|
81687
|
+
);
|
|
81688
|
+
if (rows.length === 0) {
|
|
81689
|
+
return {
|
|
81690
|
+
ok: false,
|
|
81691
|
+
failure: {
|
|
81692
|
+
kind: "unavailable",
|
|
81693
|
+
source: "chain-rpc",
|
|
81694
|
+
message: `the indexer lists ${listed.rows.length} PSM stablecoin(s) on ${this.config.network}, and the PSM contract confirms none of them. The index is behind a governance removal, or it is indexing a different PSM than the one in this build's deployment table \u2014 verify before exchanging anything.`
|
|
81695
|
+
}
|
|
81696
|
+
};
|
|
81697
|
+
}
|
|
81657
81698
|
return { ok: true, rows };
|
|
81658
81699
|
}
|
|
81700
|
+
/**
|
|
81701
|
+
* Resolve what the CALLER named — a symbol or a 0x address — to a verified address.
|
|
81702
|
+
*
|
|
81703
|
+
* The tool schemas have always said "by SYMBOL (e.g. 'USDC', 'USDT') or by 0x address",
|
|
81704
|
+
* and the mock world accepts exactly that. The real adapter accepted only the address:
|
|
81705
|
+
* a symbol went straight into an address-typed `ethers.Contract`, which threw, and the
|
|
81706
|
+
* throw was caught as `kind: "unavailable"` → `UPSTREAM_UNAVAILABLE` — a code the guide
|
|
81707
|
+
* tells the model is "usually transient; retry once". So the documented input produced a
|
|
81708
|
+
* retry loop on the one deployment that moves real money, and a developer practising
|
|
81709
|
+
* against the mock never met it. Both halves are fixed here: the symbol resolves, and a
|
|
81710
|
+
* name that cannot resolve is `rejected` (the caller's input) rather than `unavailable`
|
|
81711
|
+
* (our upstream).
|
|
81712
|
+
*/
|
|
81713
|
+
async psmCallsForChoice(chosen) {
|
|
81714
|
+
const raw = chosen.trim();
|
|
81715
|
+
if (raw.length === 0) {
|
|
81716
|
+
return {
|
|
81717
|
+
ok: false,
|
|
81718
|
+
failure: { kind: "rejected", source: "chain-rpc", message: "no stablecoin named \u2014 name one by symbol (e.g. 'USDC') or by 0x address; there is no default coin." }
|
|
81719
|
+
};
|
|
81720
|
+
}
|
|
81721
|
+
const symbol = raw.toLowerCase();
|
|
81722
|
+
if (import_ethers39.ethers.isAddress(raw)) return this.psmCallsFor(symbol);
|
|
81723
|
+
const verified = await this.verifiedStablecoins();
|
|
81724
|
+
if (!verified.ok) return { ok: false, failure: verified.failure };
|
|
81725
|
+
const hits = verified.rows.filter((r) => r.symbol.toLowerCase() === symbol);
|
|
81726
|
+
if (hits.length > 1) {
|
|
81727
|
+
return {
|
|
81728
|
+
ok: false,
|
|
81729
|
+
failure: {
|
|
81730
|
+
kind: "rejected",
|
|
81731
|
+
source: "chain-rpc",
|
|
81732
|
+
message: `'${raw}' names ${hits.length} different coins this PSM supports \u2014 ${hits.map((r) => r.address).join(", ")}. Symbols are self-declared and not unique, so this one cannot be resolved for you: name the 0x address of the one you mean.`
|
|
81733
|
+
}
|
|
81734
|
+
};
|
|
81735
|
+
}
|
|
81736
|
+
const hit = hits[0];
|
|
81737
|
+
if (!hit) {
|
|
81738
|
+
const names = verified.rows.map((r) => `${r.symbol} (${r.address})`).join(", ");
|
|
81739
|
+
return {
|
|
81740
|
+
ok: false,
|
|
81741
|
+
failure: {
|
|
81742
|
+
kind: "rejected",
|
|
81743
|
+
source: "chain-rpc",
|
|
81744
|
+
message: `'${raw}' is not a coin this PSM supports on ${this.config.network} \u2014 it supports ${names}. Name one of those by symbol or address. \`protocol://psm\` carries each one's fees, limits and reserves.`
|
|
81745
|
+
}
|
|
81746
|
+
};
|
|
81747
|
+
}
|
|
81748
|
+
return this.psmCallsFor(hit.address);
|
|
81749
|
+
}
|
|
81659
81750
|
/**
|
|
81660
81751
|
* Build the PSM wrapper for ONE caller-chosen stablecoin.
|
|
81661
81752
|
*
|
|
@@ -81666,6 +81757,9 @@ var RealUpstreamPlugin = class {
|
|
|
81666
81757
|
* chain, then sign.
|
|
81667
81758
|
*/
|
|
81668
81759
|
async psmCallsFor(stablecoinAddress) {
|
|
81760
|
+
if (!import_ethers39.ethers.isAddress(stablecoinAddress)) {
|
|
81761
|
+
throw new Error(`psmCallsFor requires a resolved 0x address, got '${stablecoinAddress}' \u2014 resolve through psmCallsForChoice`);
|
|
81762
|
+
}
|
|
81669
81763
|
const key = stablecoinAddress.toLowerCase();
|
|
81670
81764
|
const cached = this.psmWrappers.get(key);
|
|
81671
81765
|
if (cached) return { ok: true, calls: cached };
|
|
@@ -83688,6 +83782,17 @@ function signerModeSourceClause(d) {
|
|
|
83688
83782
|
function phoneWalletOffer(d) {
|
|
83689
83783
|
return d.walletConnect ? "or scan the WalletConnect QR (or paste the pairing code) to approve on a phone wallet" : "This deployment does NOT offer the WalletConnect phone-wallet leg \u2014 there is no QR to scan and `/wc-pairing` answers 404; a browser-extension wallet is the only path here";
|
|
83690
83784
|
}
|
|
83785
|
+
function worldAxes(d) {
|
|
83786
|
+
const axes = [];
|
|
83787
|
+
axes.push(
|
|
83788
|
+
offers(d, "mock-simulated") ? "practice (mock) or real adapter" : "the REAL adapter \u2014 there is no practice (mock) world on this deployment"
|
|
83789
|
+
);
|
|
83790
|
+
axes.push(
|
|
83791
|
+
d.networks.length > 1 ? "sepolia (practice money) or mainnet (real money)" : d.networks.includes("mainnet") ? "MAINNET only, so every fund movement here is real money" : "sepolia only, so the ceremonies are real and the money is practice"
|
|
83792
|
+
);
|
|
83793
|
+
axes.push("that writes are enabled, and what actually gates one is whether a signing identity is connected");
|
|
83794
|
+
return axes.join("; ");
|
|
83795
|
+
}
|
|
83691
83796
|
function moneyTruth(d) {
|
|
83692
83797
|
const practice = offers(d, "mock-simulated");
|
|
83693
83798
|
const sepolia = d.networks.includes("sepolia");
|
|
@@ -83870,8 +83975,7 @@ have to guess whether the money is real.`;
|
|
|
83870
83975
|
function authorizationModeBullets(d) {
|
|
83871
83976
|
const bullets = [];
|
|
83872
83977
|
if (offers(d, "external")) {
|
|
83873
|
-
bullets.push(` - \`external\` \u2014 the user approves in their OWN wallet (browser popup, or WalletConnect
|
|
83874
|
-
mobile via QR/paste-code). Real adapter and mock. For TRANSACTIONS the approval card
|
|
83978
|
+
bullets.push(` - \`external\` \u2014 the user approves in their OWN wallet (browser popup${d.walletConnect ? ", or WalletConnect\n mobile via QR/paste-code" : " \u2014 this build has no WalletConnect\n mobile leg"}). Real adapter and mock. For TRANSACTIONS the approval card
|
|
83875
83979
|
is decoded from the exact bytes being signed \u2014 what the user reads IS what executes.
|
|
83876
83980
|
The ONE exception is the BTC withdrawal's EXECUTE phase: an opaque 32-byte hash the
|
|
83877
83981
|
approval page states plainly it CANNOT decode. Never extend the card promise over
|
|
@@ -83934,8 +84038,7 @@ install matrix. ${connectorInstallNote(d)}
|
|
|
83934
84038
|
Nothing needs a config file. Three steps:
|
|
83935
84039
|
|
|
83936
84040
|
**1. Know your world.** Read \`boundary://info\` (its \`capabilities\` block) and
|
|
83937
|
-
\`protocol_status\`, then tell the user
|
|
83938
|
-
(practice money) or mainnet (real money); whether writes are enabled here and which
|
|
84041
|
+
\`protocol_status\`, then tell the user what THIS deployment is: ${worldAxes(d)}; which
|
|
83939
84042
|
signer modes exist; current terms (\`protocol_terms\`).
|
|
83940
84043
|
|
|
83941
84044
|
**2. Choose HOW to authorize operations** (the user's choice, made by talking):
|
|
@@ -84044,8 +84147,7 @@ on the real adapter and the mock.
|
|
|
84044
84147
|
10 UCD.
|
|
84045
84148
|
|
|
84046
84149
|
**Disconnecting \u2014 "log out / sign out / forget my wallet" (\`signer_setup\` action
|
|
84047
|
-
\`disconnect\`):** the FULL wallet flush. It ends every approval-page session and any
|
|
84048
|
-
WalletConnect session (pending approvals are cancelled loudly), discards the login
|
|
84150
|
+
\`disconnect\`):** the FULL wallet flush. It ends every approval-page session${d.walletConnect ? " and any\nWalletConnect session" : ""} (pending approvals are cancelled loudly), discards the login
|
|
84049
84151
|
token from server memory AND revokes it at the service, and unbinds the borrower
|
|
84050
84152
|
identity. Reconnecting afterwards ALWAYS requires opening the approval page again and
|
|
84051
84153
|
a fresh wallet signature \u2014 a disconnect can never silently reconnect. Two truths to
|
|
@@ -84503,7 +84605,7 @@ function renderGuideIndex(deployment) {
|
|
|
84503
84605
|
|
|
84504
84606
|
- getting-started \u2014 what this product is, practice-vs-real-money honesty (three cases)
|
|
84505
84607
|
- first-setup \u2014 zero to ready by conversation (authorization choice included)
|
|
84506
|
-
- connect-wallet \u2014 external-wallet walkthrough: approval page, extension or WalletConnect QR, popup cadence, login honesty, disconnect/log-out
|
|
84608
|
+
- connect-wallet \u2014 external-wallet walkthrough: approval page, ${deployment.walletConnect ? "extension or WalletConnect QR" : "browser extension (no WalletConnect leg here)"}, popup cadence, login honesty, disconnect/log-out
|
|
84507
84609
|
- lifecycle \u2014 the exact calls, create \u2192 deposit \u2192 mint \u2192 pay \u2192 extend \u2192 withdraw
|
|
84508
84610
|
- fees \u2014 the two fee models, plainly
|
|
84509
84611
|
- psm \u2014 exchanging UCD \u2194 USDC: both directions, the two fees WITH their tokens, limits, why a floor exists
|
package/dist/index.js
CHANGED
|
@@ -78659,18 +78659,12 @@ function listPositionsQuery(f) {
|
|
|
78659
78659
|
return { document: LIST_POSITIONS, variables: { first, skip } };
|
|
78660
78660
|
}
|
|
78661
78661
|
var SUPPORTED_STABLECOINS = `
|
|
78662
|
-
query
|
|
78662
|
+
query GetSupportedStablecoins {
|
|
78663
78663
|
supportedStablecoins(where: { isSupported: true }, orderBy: addedAt, orderDirection: desc) {
|
|
78664
|
-
id
|
|
78665
|
-
|
|
78666
|
-
isSupported
|
|
78667
|
-
decimals
|
|
78668
|
-
entryFee
|
|
78669
|
-
exitFee
|
|
78670
|
-
reserves
|
|
78664
|
+
id address isSupported exchangeRate entryFee exitFee reserves decimals
|
|
78665
|
+
totalSwapVolume totalRedeemVolume swapCount redeemCount addedAt lastUpdated
|
|
78671
78666
|
}
|
|
78672
|
-
}
|
|
78673
|
-
`;
|
|
78667
|
+
}`;
|
|
78674
78668
|
|
|
78675
78669
|
// src/boundary/upstream/real/psm-calls.ts
|
|
78676
78670
|
var import_ethers31 = require("ethers");
|
|
@@ -79639,7 +79633,7 @@ function buildWriteOps(deps) {
|
|
|
79639
79633
|
const tokenAddress = isSwap ? addr.stablecoin : addr.ucdToken;
|
|
79640
79634
|
const spenderAddress = isSwap ? addr.psm : addr.ucdController;
|
|
79641
79635
|
const spenderContract = isSwap ? "SimplePSMV2" : "UCDController";
|
|
79642
|
-
const tokenSymbol = isSwap ?
|
|
79636
|
+
const tokenSymbol = isSwap ? calls.symbol() : "UCD";
|
|
79643
79637
|
const quoteR = isSwap ? await calls.swapQuote(p.amountIn) : await calls.redemptionQuote(p.amountIn);
|
|
79644
79638
|
if (!quoteR.ok) return upFail(quoteR.failure);
|
|
79645
79639
|
const broadcast = async (leg, action, tx2) => {
|
|
@@ -79679,7 +79673,7 @@ function buildWriteOps(deps) {
|
|
|
79679
79673
|
} catch (e) {
|
|
79680
79674
|
return upFail({ kind: "rejected", source: SOURCE5, message: `PSM ${p.direction} tx failed the whitelist: ${e.message} \u2014 ${residualNote}` });
|
|
79681
79675
|
}
|
|
79682
|
-
const execCard = `${p.direction} ${p.amountIn} ${isSwap ?
|
|
79676
|
+
const execCard = `${p.direction} ${p.amountIn} ${isSwap ? `${tokenSymbol} smallest units` : "UCD wei"} via the PSM: quote ${quoteR.value.amountOut} out (fee ${quoteR.value.feeAmount}), floor ${p.minOut} \u2014 output to ${p.borrower}`;
|
|
79683
79677
|
const execHashR = await broadcast(`psmSwap (${p.direction})`, isSwap ? "psm-swap" : "psm-redeem", execTx);
|
|
79684
79678
|
if (!execHashR.ok) {
|
|
79685
79679
|
const f = execHashR.failure;
|
|
@@ -80230,25 +80224,16 @@ var RealUpstreamPlugin = class {
|
|
|
80230
80224
|
// PSM reads (plan 08 Part B Phase R): on-chain views ONLY, through the dedicated
|
|
80231
80225
|
// wrapper (NOT chainRead) so custom-error refusals decode WITH their figures.
|
|
80232
80226
|
listPsmStablecoins: async () => {
|
|
80233
|
-
const
|
|
80234
|
-
if (!
|
|
80235
|
-
|
|
80236
|
-
listed.rows.map(async (row) => {
|
|
80237
|
-
const built = await this.psmCallsFor(row.address);
|
|
80238
|
-
return built.ok ? { address: row.address, symbol: built.calls.symbol(), decimals: row.decimals } : null;
|
|
80239
|
-
})
|
|
80240
|
-
);
|
|
80241
|
-
return upOk(
|
|
80242
|
-
rows.filter((r) => r !== null),
|
|
80243
|
-
this.src("subgraph")
|
|
80244
|
-
);
|
|
80227
|
+
const verified = await this.verifiedStablecoins();
|
|
80228
|
+
if (!verified.ok) return upFail(verified.failure);
|
|
80229
|
+
return upOk(verified.rows, this.src("subgraph"));
|
|
80245
80230
|
},
|
|
80246
80231
|
getPsmStatus: async (p) => {
|
|
80247
|
-
const r = await this.
|
|
80232
|
+
const r = await this.psmCallsForChoice(p.stablecoin);
|
|
80248
80233
|
return r.ok ? r.calls.status() : upFail(r.failure);
|
|
80249
80234
|
},
|
|
80250
80235
|
getPsmQuote: async (p) => {
|
|
80251
|
-
const r = await this.
|
|
80236
|
+
const r = await this.psmCallsForChoice(p.stablecoin);
|
|
80252
80237
|
if (!r.ok) return upFail(r.failure);
|
|
80253
80238
|
return p.direction === "swap" ? r.calls.swapQuote(p.amountIn) : r.calls.redemptionQuote(p.amountIn);
|
|
80254
80239
|
}
|
|
@@ -80440,7 +80425,7 @@ var RealUpstreamPlugin = class {
|
|
|
80440
80425
|
session,
|
|
80441
80426
|
getWriteSdk: () => this.sdkCache.get(key) ?? null,
|
|
80442
80427
|
readDetails: (id) => this.readPositionDetails(id),
|
|
80443
|
-
psm: (stablecoin) => this.
|
|
80428
|
+
psm: (stablecoin) => this.psmCallsForChoice(stablecoin),
|
|
80444
80429
|
assertValidatorConfigured: () => this.assertValidatorConfigured()
|
|
80445
80430
|
});
|
|
80446
80431
|
}
|
|
@@ -80574,7 +80559,7 @@ var RealUpstreamPlugin = class {
|
|
|
80574
80559
|
session,
|
|
80575
80560
|
getWriteSdk: () => this.sdkCache.get(key) ?? null,
|
|
80576
80561
|
readDetails: (id) => this.readPositionDetails(id),
|
|
80577
|
-
psm: (stablecoin) => this.
|
|
80562
|
+
psm: (stablecoin) => this.psmCallsForChoice(stablecoin),
|
|
80578
80563
|
assertValidatorConfigured: () => this.assertValidatorConfigured()
|
|
80579
80564
|
});
|
|
80580
80565
|
this.opsGatewayCache.set(key, gateway);
|
|
@@ -80738,12 +80723,118 @@ var RealUpstreamPlugin = class {
|
|
|
80738
80723
|
{}
|
|
80739
80724
|
);
|
|
80740
80725
|
if (!r.ok) return r;
|
|
80741
|
-
const
|
|
80726
|
+
const raw = r.value.data.supportedStablecoins ?? [];
|
|
80727
|
+
const bad = raw.find((x) => !import_ethers38.ethers.isAddress(String(x.address)) || !Number.isFinite(Number(x.decimals)));
|
|
80728
|
+
if (bad) {
|
|
80729
|
+
return {
|
|
80730
|
+
ok: false,
|
|
80731
|
+
failure: {
|
|
80732
|
+
kind: "malformed",
|
|
80733
|
+
source: "subgraph",
|
|
80734
|
+
message: `the indexer returned a PSM stablecoin row this build cannot read (address '${String(bad.address)}', decimals '${String(bad.decimals)}')`
|
|
80735
|
+
}
|
|
80736
|
+
};
|
|
80737
|
+
}
|
|
80738
|
+
const rows = raw.map((x) => ({
|
|
80742
80739
|
address: String(x.address).toLowerCase(),
|
|
80743
80740
|
decimals: Number(x.decimals)
|
|
80744
80741
|
}));
|
|
80742
|
+
if (rows.length === 0) {
|
|
80743
|
+
return {
|
|
80744
|
+
ok: false,
|
|
80745
|
+
failure: {
|
|
80746
|
+
kind: "unavailable",
|
|
80747
|
+
source: "subgraph",
|
|
80748
|
+
message: `the indexer lists NO supported stablecoins for the PSM on ${this.config.network}. Either the subgraph has not indexed the StablecoinAdded events yet (check its start block against the block the coins were added at), or governance has removed every coin. PSM exchange is unavailable here until one of those is resolved \u2014 this is NOT "the PSM supports nothing".`
|
|
80749
|
+
}
|
|
80750
|
+
};
|
|
80751
|
+
}
|
|
80752
|
+
return { ok: true, rows };
|
|
80753
|
+
}
|
|
80754
|
+
/**
|
|
80755
|
+
* The supported set, verified — index rows each re-checked on-chain, carrying the symbol
|
|
80756
|
+
* read from the token itself. This is what `protocol://psm` lists and what a caller's
|
|
80757
|
+
* SYMBOL is resolved against.
|
|
80758
|
+
*
|
|
80759
|
+
* Rows are dropped ONLY for the one reason a drop is honest: the index still lists a coin
|
|
80760
|
+
* the chain no longer supports (index lag behind a governance removal). Any OTHER failure
|
|
80761
|
+
* — an RPC outage mid-loop — propagates, because a list that silently shrinks when the
|
|
80762
|
+
* chain is unreachable is the same silent-failure shape as the empty list above. If
|
|
80763
|
+
* nothing survives verification, that is a refusal too, and it says which side disagreed.
|
|
80764
|
+
*/
|
|
80765
|
+
async verifiedStablecoins() {
|
|
80766
|
+
const listed = await this.listSupportedStablecoins();
|
|
80767
|
+
if (!listed.ok) return listed;
|
|
80768
|
+
const checked = await Promise.all(
|
|
80769
|
+
listed.rows.map(async (row) => ({ row, built: await this.psmCallsFor(row.address) }))
|
|
80770
|
+
);
|
|
80771
|
+
const transport = checked.find((c) => !c.built.ok && c.built.failure.kind !== "rejected");
|
|
80772
|
+
if (transport && !transport.built.ok) return { ok: false, failure: transport.built.failure };
|
|
80773
|
+
const rows = checked.flatMap(
|
|
80774
|
+
({ row, built }) => built.ok ? [{ address: row.address, symbol: built.calls.symbol(), decimals: row.decimals }] : []
|
|
80775
|
+
);
|
|
80776
|
+
if (rows.length === 0) {
|
|
80777
|
+
return {
|
|
80778
|
+
ok: false,
|
|
80779
|
+
failure: {
|
|
80780
|
+
kind: "unavailable",
|
|
80781
|
+
source: "chain-rpc",
|
|
80782
|
+
message: `the indexer lists ${listed.rows.length} PSM stablecoin(s) on ${this.config.network}, and the PSM contract confirms none of them. The index is behind a governance removal, or it is indexing a different PSM than the one in this build's deployment table \u2014 verify before exchanging anything.`
|
|
80783
|
+
}
|
|
80784
|
+
};
|
|
80785
|
+
}
|
|
80745
80786
|
return { ok: true, rows };
|
|
80746
80787
|
}
|
|
80788
|
+
/**
|
|
80789
|
+
* Resolve what the CALLER named — a symbol or a 0x address — to a verified address.
|
|
80790
|
+
*
|
|
80791
|
+
* The tool schemas have always said "by SYMBOL (e.g. 'USDC', 'USDT') or by 0x address",
|
|
80792
|
+
* and the mock world accepts exactly that. The real adapter accepted only the address:
|
|
80793
|
+
* a symbol went straight into an address-typed `ethers.Contract`, which threw, and the
|
|
80794
|
+
* throw was caught as `kind: "unavailable"` → `UPSTREAM_UNAVAILABLE` — a code the guide
|
|
80795
|
+
* tells the model is "usually transient; retry once". So the documented input produced a
|
|
80796
|
+
* retry loop on the one deployment that moves real money, and a developer practising
|
|
80797
|
+
* against the mock never met it. Both halves are fixed here: the symbol resolves, and a
|
|
80798
|
+
* name that cannot resolve is `rejected` (the caller's input) rather than `unavailable`
|
|
80799
|
+
* (our upstream).
|
|
80800
|
+
*/
|
|
80801
|
+
async psmCallsForChoice(chosen) {
|
|
80802
|
+
const raw = chosen.trim();
|
|
80803
|
+
if (raw.length === 0) {
|
|
80804
|
+
return {
|
|
80805
|
+
ok: false,
|
|
80806
|
+
failure: { kind: "rejected", source: "chain-rpc", message: "no stablecoin named \u2014 name one by symbol (e.g. 'USDC') or by 0x address; there is no default coin." }
|
|
80807
|
+
};
|
|
80808
|
+
}
|
|
80809
|
+
const symbol = raw.toLowerCase();
|
|
80810
|
+
if (import_ethers38.ethers.isAddress(raw)) return this.psmCallsFor(symbol);
|
|
80811
|
+
const verified = await this.verifiedStablecoins();
|
|
80812
|
+
if (!verified.ok) return { ok: false, failure: verified.failure };
|
|
80813
|
+
const hits = verified.rows.filter((r) => r.symbol.toLowerCase() === symbol);
|
|
80814
|
+
if (hits.length > 1) {
|
|
80815
|
+
return {
|
|
80816
|
+
ok: false,
|
|
80817
|
+
failure: {
|
|
80818
|
+
kind: "rejected",
|
|
80819
|
+
source: "chain-rpc",
|
|
80820
|
+
message: `'${raw}' names ${hits.length} different coins this PSM supports \u2014 ${hits.map((r) => r.address).join(", ")}. Symbols are self-declared and not unique, so this one cannot be resolved for you: name the 0x address of the one you mean.`
|
|
80821
|
+
}
|
|
80822
|
+
};
|
|
80823
|
+
}
|
|
80824
|
+
const hit = hits[0];
|
|
80825
|
+
if (!hit) {
|
|
80826
|
+
const names = verified.rows.map((r) => `${r.symbol} (${r.address})`).join(", ");
|
|
80827
|
+
return {
|
|
80828
|
+
ok: false,
|
|
80829
|
+
failure: {
|
|
80830
|
+
kind: "rejected",
|
|
80831
|
+
source: "chain-rpc",
|
|
80832
|
+
message: `'${raw}' is not a coin this PSM supports on ${this.config.network} \u2014 it supports ${names}. Name one of those by symbol or address. \`protocol://psm\` carries each one's fees, limits and reserves.`
|
|
80833
|
+
}
|
|
80834
|
+
};
|
|
80835
|
+
}
|
|
80836
|
+
return this.psmCallsFor(hit.address);
|
|
80837
|
+
}
|
|
80747
80838
|
/**
|
|
80748
80839
|
* Build the PSM wrapper for ONE caller-chosen stablecoin.
|
|
80749
80840
|
*
|
|
@@ -80754,6 +80845,9 @@ var RealUpstreamPlugin = class {
|
|
|
80754
80845
|
* chain, then sign.
|
|
80755
80846
|
*/
|
|
80756
80847
|
async psmCallsFor(stablecoinAddress) {
|
|
80848
|
+
if (!import_ethers38.ethers.isAddress(stablecoinAddress)) {
|
|
80849
|
+
throw new Error(`psmCallsFor requires a resolved 0x address, got '${stablecoinAddress}' \u2014 resolve through psmCallsForChoice`);
|
|
80850
|
+
}
|
|
80757
80851
|
const key = stablecoinAddress.toLowerCase();
|
|
80758
80852
|
const cached = this.psmWrappers.get(key);
|
|
80759
80853
|
if (cached) return { ok: true, calls: cached };
|
|
@@ -82804,6 +82898,17 @@ function signerModeSourceClause(d) {
|
|
|
82804
82898
|
function phoneWalletOffer(d) {
|
|
82805
82899
|
return d.walletConnect ? "or scan the WalletConnect QR (or paste the pairing code) to approve on a phone wallet" : "This deployment does NOT offer the WalletConnect phone-wallet leg \u2014 there is no QR to scan and `/wc-pairing` answers 404; a browser-extension wallet is the only path here";
|
|
82806
82900
|
}
|
|
82901
|
+
function worldAxes(d) {
|
|
82902
|
+
const axes = [];
|
|
82903
|
+
axes.push(
|
|
82904
|
+
offers(d, "mock-simulated") ? "practice (mock) or real adapter" : "the REAL adapter \u2014 there is no practice (mock) world on this deployment"
|
|
82905
|
+
);
|
|
82906
|
+
axes.push(
|
|
82907
|
+
d.networks.length > 1 ? "sepolia (practice money) or mainnet (real money)" : d.networks.includes("mainnet") ? "MAINNET only, so every fund movement here is real money" : "sepolia only, so the ceremonies are real and the money is practice"
|
|
82908
|
+
);
|
|
82909
|
+
axes.push("that writes are enabled, and what actually gates one is whether a signing identity is connected");
|
|
82910
|
+
return axes.join("; ");
|
|
82911
|
+
}
|
|
82807
82912
|
function moneyTruth(d) {
|
|
82808
82913
|
const practice = offers(d, "mock-simulated");
|
|
82809
82914
|
const sepolia = d.networks.includes("sepolia");
|
|
@@ -82986,8 +83091,7 @@ have to guess whether the money is real.`;
|
|
|
82986
83091
|
function authorizationModeBullets(d) {
|
|
82987
83092
|
const bullets = [];
|
|
82988
83093
|
if (offers(d, "external")) {
|
|
82989
|
-
bullets.push(` - \`external\` \u2014 the user approves in their OWN wallet (browser popup, or WalletConnect
|
|
82990
|
-
mobile via QR/paste-code). Real adapter and mock. For TRANSACTIONS the approval card
|
|
83094
|
+
bullets.push(` - \`external\` \u2014 the user approves in their OWN wallet (browser popup${d.walletConnect ? ", or WalletConnect\n mobile via QR/paste-code" : " \u2014 this build has no WalletConnect\n mobile leg"}). Real adapter and mock. For TRANSACTIONS the approval card
|
|
82991
83095
|
is decoded from the exact bytes being signed \u2014 what the user reads IS what executes.
|
|
82992
83096
|
The ONE exception is the BTC withdrawal's EXECUTE phase: an opaque 32-byte hash the
|
|
82993
83097
|
approval page states plainly it CANNOT decode. Never extend the card promise over
|
|
@@ -83050,8 +83154,7 @@ install matrix. ${connectorInstallNote(d)}
|
|
|
83050
83154
|
Nothing needs a config file. Three steps:
|
|
83051
83155
|
|
|
83052
83156
|
**1. Know your world.** Read \`boundary://info\` (its \`capabilities\` block) and
|
|
83053
|
-
\`protocol_status\`, then tell the user
|
|
83054
|
-
(practice money) or mainnet (real money); whether writes are enabled here and which
|
|
83157
|
+
\`protocol_status\`, then tell the user what THIS deployment is: ${worldAxes(d)}; which
|
|
83055
83158
|
signer modes exist; current terms (\`protocol_terms\`).
|
|
83056
83159
|
|
|
83057
83160
|
**2. Choose HOW to authorize operations** (the user's choice, made by talking):
|
|
@@ -83160,8 +83263,7 @@ on the real adapter and the mock.
|
|
|
83160
83263
|
10 UCD.
|
|
83161
83264
|
|
|
83162
83265
|
**Disconnecting \u2014 "log out / sign out / forget my wallet" (\`signer_setup\` action
|
|
83163
|
-
\`disconnect\`):** the FULL wallet flush. It ends every approval-page session and any
|
|
83164
|
-
WalletConnect session (pending approvals are cancelled loudly), discards the login
|
|
83266
|
+
\`disconnect\`):** the FULL wallet flush. It ends every approval-page session${d.walletConnect ? " and any\nWalletConnect session" : ""} (pending approvals are cancelled loudly), discards the login
|
|
83165
83267
|
token from server memory AND revokes it at the service, and unbinds the borrower
|
|
83166
83268
|
identity. Reconnecting afterwards ALWAYS requires opening the approval page again and
|
|
83167
83269
|
a fresh wallet signature \u2014 a disconnect can never silently reconnect. Two truths to
|
|
@@ -83619,7 +83721,7 @@ function renderGuideIndex(deployment) {
|
|
|
83619
83721
|
|
|
83620
83722
|
- getting-started \u2014 what this product is, practice-vs-real-money honesty (three cases)
|
|
83621
83723
|
- first-setup \u2014 zero to ready by conversation (authorization choice included)
|
|
83622
|
-
- connect-wallet \u2014 external-wallet walkthrough: approval page, extension or WalletConnect QR, popup cadence, login honesty, disconnect/log-out
|
|
83724
|
+
- connect-wallet \u2014 external-wallet walkthrough: approval page, ${deployment.walletConnect ? "extension or WalletConnect QR" : "browser extension (no WalletConnect leg here)"}, popup cadence, login honesty, disconnect/log-out
|
|
83623
83725
|
- lifecycle \u2014 the exact calls, create \u2192 deposit \u2192 mint \u2192 pay \u2192 extend \u2192 withdraw
|
|
83624
83726
|
- fees \u2014 the two fee models, plainly
|
|
83625
83727
|
- psm \u2014 exchanging UCD \u2194 USDC: both directions, the two fees WITH their tokens, limits, why a floor exists
|
|
@@ -85027,7 +85129,7 @@ function registerBoundaryInfoResource(server, getB) {
|
|
|
85027
85129
|
}
|
|
85028
85130
|
|
|
85029
85131
|
// src/version.ts
|
|
85030
|
-
var SERVER_VERSION = "0.5.
|
|
85132
|
+
var SERVER_VERSION = "0.5.16";
|
|
85031
85133
|
|
|
85032
85134
|
// src/server.ts
|
|
85033
85135
|
var SERVER_INSTRUCTIONS = "Diamond Hands MCP \u2014 Bitcoin-collateralized borrowing. Before promising ANY flow, read the boundary://info resource and honor its `capabilities` block: it states which network this server is on, whether money is real (practiceWorld), whether writes are enabled (and the true reason when they are not), and which signer modes this build actually offers \u2014 never describe a flow outside it. State the network and whether funds are real when the user first acts. Authorization is chosen by conversation via the signer_setup tool (when listed); writes always require confirmed:true after showing the human-readable card. For walkthroughs consult the guide tool / guide:// resources instead of inventing steps; when a tool refuses, relay its stated reason and remedy \u2014 do not improvise alternatives. When a network_switch tool is listed, the network can change mid-session \u2014 after ANY switch, re-read boundary://info and state the new network and money reality to the user before doing anything else. When the user asks to disconnect / log out / sign out / forget or remove their wallet, call signer_setup action 'disconnect' (the full flush) \u2014 never treat 'reset-borrower' as a disconnect; it only swaps identity. READING DATA: a payload's fields and notes are authoritative \u2014 state what they say, never speculate past them, and when the data does not carry something, say 'the data does not carry X'. Field meanings live in guide topic 'reading-data'; `reading` notes inside a result are interpretation instructions for that exact payload \u2014 follow them over any prior assumption.";
|