@mysten-incubation/sui-agent-pass 0.1.2 → 0.1.3

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/plugin.js CHANGED
@@ -20,7 +20,7 @@ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/
20
20
  import { Transaction } from '@mysten/sui/transactions';
21
21
  import { fromBase64, normalizeSuiAddress } from '@mysten/sui/utils';
22
22
  import { z } from 'zod';
23
- import { clientFor, deepbookSizes, readStatus, withMarketFacts } from './chain.js';
23
+ import { clientFor, deepbookSizes, quoteSwap, readStatus, withMarketFacts } from './chain.js';
24
24
  import { describePolicy, describeSetup, renderRows } from './describe.js';
25
25
  import { address, coinBySymbol, coinInfo, DAY_MS, defaultGasDaily, DeploymentSchema, display, poolsFor, priceUnits, recipientName, sameCoin, SetupSchema, showCoin, units, VenueSchema, } from './domain.js';
26
26
  import { passesByAgent } from './explorer.js';
@@ -236,7 +236,7 @@ const rulesInput = {
236
236
  .describe('pool object ids for a pair the deployment does not list (a DeepBook or Cetus pool holding exactly these two coins); verified on chain'),
237
237
  perTrade: decimal.describe('sold coin per trade'),
238
238
  daily: decimal.describe('sold coin per UTC day'),
239
- minPrice: decimal.describe('lowest price accepted, in bought coin per one sold coin; required, above 0'),
239
+ minPrice: decimal.describe("lowest price accepted, in bought coin per one sold coin; required, above 0. When the owner names no floor, 1% under the pool's current price (list_passes shows it) and say so"),
240
240
  })
241
241
  .strict())
242
242
  .default([])
@@ -416,13 +416,25 @@ export function createPluginMcp(registry) {
416
416
  annotations: { readOnlyHint: true },
417
417
  }, async () => {
418
418
  const path = registry.deploymentPath();
419
+ // The pool's own price for ten units of coinA, so a floor can be sized from the market
420
+ // before any pass exists; ten clears DeepBook's minimum order where one may not.
421
+ const price = async (d, p) => {
422
+ const a = coinInfo(d, p.coinA), b = coinInfo(d, p.coinB);
423
+ const amountIn = (10n * 10n ** BigInt(a.decimals)).toString();
424
+ const q = await quoteSwap(clientFor(d), d, p, p.coinA, amountIn).catch(() => null);
425
+ if (!q || q.amountOut === '0')
426
+ return {};
427
+ const perUnit = (BigInt(q.amountOut) * 10n ** BigInt(a.decimals)) / BigInt(q.amountIn);
428
+ return { price: `${display(perUnit.toString(), b.decimals)} ${b.symbol} per ${a.symbol}` };
429
+ };
419
430
  const markets = async (d) => ({
420
431
  network: d.network,
421
432
  coins: d.coins,
422
- pools: d.pools.map((p) => ({
433
+ pools: await Promise.all(d.pools.map(async (p) => ({
423
434
  venue: p.venue,
424
435
  pair: `${coinInfo(d, p.coinA).symbol}/${coinInfo(d, p.coinB).symbol}`,
425
- })),
436
+ ...(await price(d, p)),
437
+ }))),
426
438
  lending: Object.keys(d.protocols.navi.reserves).map((c) => coinInfo(d, c).symbol),
427
439
  ...(d.pools.length || Object.keys(d.protocols.navi.reserves).length
428
440
  ? {}
package/docs/PLAYBOOK.md CHANGED
@@ -34,8 +34,10 @@ its type so the owner can tell a look-alike from the real one. Lending stays wit
34
34
  network lists as NAVI reserves. About the sum of daily limits:
35
35
  the chain checks the lifetime cap before the daily meter, so a cap equal to one day's limits
36
36
  turns the owner's "daily limit" refusal into a "lifetime cap" one. Coins are named by symbol; `list_passes` shows
37
- each network's coins, pools (which pairs trade where) and lendable coins. One rule per coin,
38
- pair direction or lending coin; a coin without a rule cannot be touched.
37
+ each network's coins, pools (which pairs trade where, with the pool's current price) and
38
+ lendable coins. One rule per coin, pair direction or lending coin; a coin without a rule cannot
39
+ be touched. A swap rule's `minPrice` is the owner's floor: when they name none, set it 1% under
40
+ the pool's current price and say so; a wider margin is theirs to ask for, not yours to assume.
39
41
 
40
42
  | Rule set | Fields (each entry one rule) | What the chain enforces |
41
43
  | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten-incubation/sui-agent-pass",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "AI builds transactions. A session signer signs. Your pass enforces the rules.",
6
6
  "repository": {