@moonpay/cli 1.56.1 → 1.57.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/dist/{chunk-MJ6HU43F.js → chunk-5KV2OSFP.js} +2 -2
- package/dist/chunk-JFG43WLV.js +2 -0
- package/dist/chunk-S6L5J3Y6.js +58 -0
- package/dist/{chunk-UFFI3BH7.js → chunk-YSS3I7U7.js} +1 -1
- package/dist/{client-CIPU62V4.js → client-KFFWEIDS.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/{ledger-WRHJNFW4.js → ledger-J3NMOYDE.js} +2 -2
- package/dist/{mcp-4X36UTSX.js → mcp-2QY22U7G.js} +1 -1
- package/dist/{store-2YHXRFTX.js → store-JGO45XHQ.js} +1 -1
- package/package.json +1 -1
- package/skills/moonpay-fund-polymarket/SKILL.md +15 -15
- package/skills/moonpay-kalshi/SKILL.md +52 -90
- package/skills/moonpay-missions/SKILL.md +2 -2
- package/skills/moonpay-polymarket/SKILL.md +59 -62
- package/skills/moonpay-polymarket-feeds/SKILL.md +30 -29
- package/skills/moonpay-polymarket-strategy/SKILL.md +14 -14
- package/skills/moonpay-prediction-market/SKILL.md +12 -16
- package/dist/chunk-ROMVXUXZ.js +0 -58
- package/dist/chunk-YBHV433T.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
|
|
2
|
-
import{b as m,d as b}from"./chunk-LMDE72OE.js";var G={};b(G,{decrypt:()=>k,encrypt:()=>T,encryptedFileSchema:()=>O});import{randomBytes as A,scryptSync as v,createCipheriv as X,createDecipheriv as $}from"crypto";import{z as i}from"zod";function T(n,t){let r=A(32),o=v(t,r,D,{N:R,r:L,p:F,maxmem:K}),s=A(12),c=X("aes-256-gcm",o,s),_=Buffer.concat([c.update(n,"utf8"),c.final()]);return{encryption:{cipher:"aes-256-gcm",kdf:"scrypt",kdfparams:{n:R,r:L,p:F},salt:r.toString("base64"),iv:s.toString("base64"),tag:c.getAuthTag().toString("base64")},data:_.toString("base64")}}function k(n,t){let{salt:r,iv:o,tag:s,kdfparams:c}=n.encryption,_=v(t,Buffer.from(r,"base64"),D,{N:c.n,r:c.r,p:c.p,maxmem:K}),x=$("aes-256-gcm",_,Buffer.from(o,"base64"),{authTagLength:16});return x.setAuthTag(Buffer.from(s,"base64")),Buffer.concat([x.update(Buffer.from(n.data,"base64")),x.final()]).toString("utf8")}var R,L,F,D,K,O,P=m(()=>{"use strict";R=2**18,L=8,F=1,D=32,K=512*1024*1024,O=i.object({encryption:i.object({cipher:i.literal("aes-256-gcm"),kdf:i.literal("scrypt"),kdfparams:i.object({n:i.number(),r:i.number(),p:i.number()}),salt:i.string(),iv:i.string(),tag:i.string()}),data:i.string()})});import{readFileSync as W}from"fs";import{join as z}from"path";import{homedir as q}from"os";function en(){if(f!==void 0)return f;try{f=JSON.parse(W(z(q(),".config","moonpay","consent.json"),"utf-8")).agentId??null}catch{f=null}return f??null}function rn(){return process.env.OPENCLAW_SHELL?"openclaw":process.env.CLAUDECODE?"claude-code":process.env.CODEX_CI?"codex":process.env.GEMINI_CLI?"gemini-cli":"human"}function U(){let n={"Content-Type":"application/json",[Z]:Q,[tn]:rn()},t=en();return t&&(n[nn]=t),n}var Q,Z,nn,f,tn,j=m(()=>{"use strict";Q="1.
|
|
2
|
+
import{b as m,d as b}from"./chunk-LMDE72OE.js";var G={};b(G,{decrypt:()=>k,encrypt:()=>T,encryptedFileSchema:()=>O});import{randomBytes as A,scryptSync as v,createCipheriv as X,createDecipheriv as $}from"crypto";import{z as i}from"zod";function T(n,t){let r=A(32),o=v(t,r,D,{N:R,r:L,p:F,maxmem:K}),s=A(12),c=X("aes-256-gcm",o,s),_=Buffer.concat([c.update(n,"utf8"),c.final()]);return{encryption:{cipher:"aes-256-gcm",kdf:"scrypt",kdfparams:{n:R,r:L,p:F},salt:r.toString("base64"),iv:s.toString("base64"),tag:c.getAuthTag().toString("base64")},data:_.toString("base64")}}function k(n,t){let{salt:r,iv:o,tag:s,kdfparams:c}=n.encryption,_=v(t,Buffer.from(r,"base64"),D,{N:c.n,r:c.r,p:c.p,maxmem:K}),x=$("aes-256-gcm",_,Buffer.from(o,"base64"),{authTagLength:16});return x.setAuthTag(Buffer.from(s,"base64")),Buffer.concat([x.update(Buffer.from(n.data,"base64")),x.final()]).toString("utf8")}var R,L,F,D,K,O,P=m(()=>{"use strict";R=2**18,L=8,F=1,D=32,K=512*1024*1024,O=i.object({encryption:i.object({cipher:i.literal("aes-256-gcm"),kdf:i.literal("scrypt"),kdfparams:i.object({n:i.number(),r:i.number(),p:i.number()}),salt:i.string(),iv:i.string(),tag:i.string()}),data:i.string()})});import{readFileSync as W}from"fs";import{join as z}from"path";import{homedir as q}from"os";function en(){if(f!==void 0)return f;try{f=JSON.parse(W(z(q(),".config","moonpay","consent.json"),"utf-8")).agentId??null}catch{f=null}return f??null}function rn(){return process.env.OPENCLAW_SHELL?"openclaw":process.env.CLAUDECODE?"claude-code":process.env.CODEX_CI?"codex":process.env.GEMINI_CLI?"gemini-cli":"human"}function U(){let n={"Content-Type":"application/json",[Z]:Q,[tn]:rn()},t=en();return t&&(n[nn]=t),n}var Q,Z,nn,f,tn,j=m(()=>{"use strict";Q="1.57.0",Z="X-CLI-Version",nn="X-Agent-Id";tn="X-Agent"});import*as e from"fs";import*as Y from"os";import*as g from"path";function d(){e.existsSync(l)||e.mkdirSync(l,{recursive:!0,mode:448})}function H(n,t,r){let o=n+`.tmp.${process.pid}`;e.writeFileSync(o,t,{encoding:"utf-8",mode:r}),e.renameSync(o,n)}function sn(){d();try{let n=e.openSync(u,e.constants.O_CREAT|e.constants.O_EXCL|e.constants.O_WRONLY,384);e.writeSync(n,JSON.stringify({pid:process.pid,ts:Date.now()})),e.closeSync(n)}catch(n){if(n.code!=="EEXIST")throw n;try{let t=JSON.parse(e.readFileSync(u,"utf-8"));if(Date.now()-t.ts<on)return null}catch{}try{e.unlinkSync(u)}catch{}try{let t=e.openSync(u,e.constants.O_CREAT|e.constants.O_EXCL|e.constants.O_WRONLY,384);e.writeSync(t,JSON.stringify({pid:process.pid,ts:Date.now()})),e.closeSync(t)}catch{return null}}return()=>{try{e.unlinkSync(u)}catch{}}}function B(){if(!e.existsSync(w))return null;try{let n=JSON.parse(e.readFileSync(w,"utf-8"));return n.baseUrl?n:null}catch{return null}}function Pn(){let n=B();return n||(an(N),N)}function S(){if(!e.existsSync(p))return null;let n=h();if(!n)return null;try{let t=JSON.parse(e.readFileSync(p,"utf-8")),r=O.parse(t),o=k(r,n),s=JSON.parse(o);return!s.accessToken||!s.baseUrl?null:s}catch{return null}}function cn(n){let t=I(),r=T(JSON.stringify(n),t);d(),H(p,JSON.stringify(r,null,2),384)}function an(n){d(),H(w,JSON.stringify(n,null,2),384)}function Un(){e.existsSync(p)&&e.unlinkSync(p)}function jn(){let n=B(),t=S();return n?.baseUrl??t?.baseUrl??N.baseUrl}async function fn(n,t,r){let o=await fetch(`${n}/api/tools/${encodeURIComponent(t)}`,{method:"POST",signal:AbortSignal.timeout(15e3),headers:U(),body:JSON.stringify(r)}),s=await o.json();if(!o.ok){let c=s;throw new Error(c?.error??`${t} failed (${o.status})`)}return s}async function un(n){if(!n.refreshToken)throw new Error("No refresh token available");let t=sn();if(!t){await new Promise(o=>setTimeout(o,2e3));let r=S();if(r&&r.expiresAt>Date.now())return r;throw new Error("Token refresh failed (concurrent refresh in progress)")}try{let r=S();if(r&&r.expiresAt>Date.now()+6e4)return r;let o=await fn(n.baseUrl,"refresh",{refreshToken:n.refreshToken}),s={accessToken:o.accessToken,refreshToken:o.refreshToken,expiresAt:o.expiresAt*1e3,baseUrl:n.baseUrl};return cn(s),s}finally{t()}}async function Jn(){let n=S();if(!n)return null;if(Date.now()>=n.expiresAt-ln){if(n.refreshToken)try{return(await un(n)).accessToken}catch{return null}return null}return n.accessToken}var l,w,p,u,N,on,ln,V=m(()=>{"use strict";P();J();j();l=g.join(Y.homedir(),".config","moonpay"),w=g.join(l,"config.json"),p=g.join(l,"credentials.json"),u=g.join(l,".credentials.lock"),N={baseUrl:"https://agents.moonpay.com"};on=3e4;ln=300*1e3});var Nn={};b(Nn,{ensureEncryptionKey:()=>I,getEncryptionKey:()=>h});import{execFileSync as C,execSync as pn}from"child_process";import{randomBytes as gn}from"crypto";import{existsSync as dn,readFileSync as yn,writeFileSync as mn}from"fs";import{homedir as Sn,platform as M}from"os";import{join as hn}from"path";function Cn(n){try{C("security",["delete-generic-password","-s",a,"-a",y],{stdio:"ignore"})}catch{}C("security",["add-generic-password","-s",a,"-a",y,"-w",n],{stdio:"ignore"})}function En(){try{return C("security",["find-generic-password","-s",a,"-a",y,"-w"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}}function _n(n){pn(`printf '%s' | secret-tool store --label="${a}" service "${a}" account "${y}"`,{input:n,stdio:["pipe","ignore","ignore"]})}function xn(){try{return C("secret-tool",["lookup","service",a,"account",y],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}}function On(n){d(),mn(E,n,{encoding:"utf-8",mode:384})}function Tn(){try{return dn(E)&&yn(E,"utf-8").trim()||null}catch{return null}}function kn(n){try{let t=M();return t==="darwin"?(Cn(n),!0):t==="linux"?(_n(n),!0):!1}catch{return!1}}function wn(){let n=M();return n==="darwin"?En():n==="linux"?xn():null}function h(){let n=process.env.MOONPAY_ENCRYPTION_KEY;return n||(wn()??Tn())}function I(){let n=h();if(n)return n;let t=gn(32).toString("hex");return kn(t)||(On(t),process.stderr.write("Note: Keychain unavailable. Encryption key stored in "+E+`
|
|
3
3
|
`)),t}var a,y,E,J=m(()=>{"use strict";V();a="moonpay-cli",y="encryption-key",E=hn(Sn(),".config","moonpay",".encryption-key")});export{G as a,P as b,Nn as c,J as d,Q as e,U as f,j as g,d as h,Pn as i,S as j,cn as k,Un as l,jn as m,un as n,Jn as o,V as p};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
|
|
2
|
-
import{b as a,c as b}from"./chunk-
|
|
2
|
+
import{b as a,c as b}from"./chunk-JFG43WLV.js";import"./chunk-YSS3I7U7.js";import"./chunk-LMDE72OE.js";export{a as moonpay,b as resetClient};
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
|
|
3
|
-
import{a as J,b as K,c as R,d as C}from"./chunk-
|
|
3
|
+
import{a as J,b as K,c as R,d as C}from"./chunk-S6L5J3Y6.js";import{b as N}from"./chunk-JFG43WLV.js";import{m as A}from"./chunk-5KV2OSFP.js";import{e as v,g as H}from"./chunk-YSS3I7U7.js";import"./chunk-LMDE72OE.js";import{Command as se}from"commander";var W=!process.env.NO_COLOR&&process.stdout.isTTY===!0;function _(e){return n=>W?`${e}${n}\x1B[0m`:n}var d={bold:_("\x1B[1m"),dim:_("\x1B[2m"),green:_("\x1B[32m"),yellow:_("\x1B[33m"),cyan:_("\x1B[36m"),red:_("\x1B[31m")};function O(e){if(e==null)return!0;let n=typeof e;return n==="string"||n==="number"||n==="boolean"}function w(e){return e==null?"-":String(e)}function S(e,n=0){let t=" ".repeat(n);return O(e)?`${t}${w(e)}`:Array.isArray(e)?e.length===0?`${t}${d.dim("(empty)")}`:e.every(O)?e.map(s=>`${t}- ${w(s)}`).join(`
|
|
4
4
|
`):e.map(s=>{if(typeof s!="object"||s===null)return`${t}- ${w(s)}`;let r=Object.entries(s),c=[],[l,u]=r[0];O(u)?c.push(`${t}- ${d.bold(l)}: ${w(u)}`):(c.push(`${t}- ${d.bold(l)}:`),c.push(S(u,n+2)));for(let[p,g]of r.slice(1))O(g)?c.push(`${t} ${d.bold(p)}: ${w(g)}`):(c.push(`${t} ${d.bold(p)}:`),c.push(S(g,n+2)));return c.join(`
|
|
5
5
|
`)}).join(`
|
|
6
6
|
|
|
@@ -14,5 +14,5 @@ ${S(c,n+1)}`).join(`
|
|
|
14
14
|
|
|
15
15
|
Run \`mp skill install\` to install AI skills for Claude Code.
|
|
16
16
|
|
|
17
|
-
`+K).version(v).option("--json","Output as JSON instead of YAML");function ae(){return h.opts().json?"json":"yaml"}function U(e){console.log(F(e,ae()))}function M(){let e=ie();e&&process.stderr.write(e)}h.command("mcp").description("Start MCP server over stdio (for Claude Desktop, Claude Code, etc.)").action(async()=>{let{startMcpServer:e}=await import("./mcp-
|
|
17
|
+
`+K).version(v).option("--json","Output as JSON instead of YAML");function ae(){return h.opts().json?"json":"yaml"}function U(e){console.log(F(e,ae()))}function M(){let e=ie();e&&process.stderr.write(e)}h.command("mcp").description("Start MCP server over stdio (for Claude Desktop, Claude Code, etc.)").action(async()=>{let{startMcpServer:e}=await import("./mcp-2QY22U7G.js");await e()});function q(e,n){let t=e;for(let s of n){let r=t.commands.find(c=>c.name()===s);r||(r=t.command(s)),t=r}return t}function z(e,n=""){let t=[];for(let[s,r]of Object.entries(e)){let c=n?`${n}-${s}`:s,l=r;for(;l._def.typeName==="ZodEffects";)l=l._def.schema;let u=l;u._def.typeName==="ZodNullable"&&(u=u._def.innerType),u._def.typeName==="ZodObject"&&u.shape?t.push(...z(u.shape,c)):t.push({flatKey:c,field:r,path:c.split("-")})}return t}function ce(e,n){let t={};for(let{flatKey:s,path:r}of n){let c=s.replace(/-([a-z])/g,(u,p)=>p.toUpperCase()),l=c in e?e[c]:e[s];if(r.length===1)t[r[0]]=l;else{let u=t;for(let p=0;p<r.length-1;p++)(!u[r[p]]||typeof u[r[p]]!="object")&&(u[r[p]]={}),u=u[r[p]];u[r[r.length-1]]=l}}return t}function le(e,n){for(let t of n){let s=t.schema.name.split("_"),r=s.pop(),l=q(e,s).command(r).description(t.schema.description),u=t.schema.input.shape??{},p=z(u),g=[],b=[],k=[],$=[];for(let{flatKey:f,field:i}of p){let o=i.description??f,a=i;for(;a._def.typeName==="ZodEffects";)a=a._def.schema;let y=a._def.typeName,m=a;m._def.typeName==="ZodNullable"&&(m=m._def.innerType),m._def.typeName==="ZodNumber"&&b.push(f),m._def.typeName==="ZodRecord"&&k.push(f),m._def.typeName==="ZodBoolean"&&$.push(f),y==="ZodBoolean"?l.option(`--${f} [${f}]`,o,!1):y==="ZodNullable"?(l.option(`--${f} <${f}>`,o),g.push(f)):l.requiredOption(`--${f} <${f}>`,o)}l.action(async f=>{t.schema.name.startsWith("consent_")||await R.handler({});for(let o of g){let a=o.replace(/-([a-z])/g,(y,m)=>m.toUpperCase());f[a]===void 0&&(f[a]=null)}for(let o of b){let a=o.replace(/-([a-z])/g,(y,m)=>m.toUpperCase());f[a]!=null&&typeof f[a]=="string"&&(f[a]=Number(f[a]))}for(let o of $){let a=o.replace(/-([a-z])/g,(m,j)=>j.toUpperCase()),y=f[a];if(typeof y=="string"){let m=y.toLowerCase();m==="true"||m==="1"?f[a]=!0:(m==="false"||m==="0")&&(f[a]=!1)}}for(let o of k){let a=o.replace(/-([a-z])/g,(y,m)=>m.toUpperCase());if(typeof f[a]=="string")try{f[a]=JSON.parse(f[a])}catch{console.error(`Invalid JSON for --${o}`),process.exit(1)}}let i=ce(f,p);try{let o=await t.handler(i);U(o)}catch(o){console.error(Z(o)),process.exit(1)}})}}function fe(e){if(e.$ref&&e.definitions){let n=e.$ref.replace("#/definitions/","");return e.definitions[n]}return e}function ue(e){return Array.isArray(e.type)?e.type.includes("null"):e.anyOf?e.anyOf.some(n=>n.type==="null"):!1}function me(e){return Array.isArray(e.type)?e.type.includes("object"):e.anyOf?e.anyOf.some(n=>n.type==="object"):e.type==="object"}function pe(e){return Array.isArray(e.type)?e.type.some(n=>n==="number"||n==="integer"):e.anyOf?e.anyOf.some(n=>n.type==="number"||n.type==="integer"):e.type==="number"||e.type==="integer"}function de(e){return Array.isArray(e.type)?e.type.includes("boolean"):e.anyOf?e.anyOf.some(n=>n.type==="boolean"):e.type==="boolean"}var Y=new Set(["swaps_transaction_build","transaction_register","virtual-account_offramp_initiate","prediction-market_position_buy","prediction-market_position_sell","prediction-market_position_redeem","commerce_cart_update","commerce_checkout_start","commerce_checkout_pay","card_delegation_approve_transaction_build","card_delegation_revoke_transaction_build","card_delegation_token_retrieve","card_wallet_link","card_wallet_unlink"]);function ye(e,n){for(let t of n){if(Y.has(t.name))continue;let s=t.name.split("_"),r=s.pop(),c=q(e,s);if(c.commands.find(i=>i.name()===r))continue;let l=c.command(r).description(t.description),u=fe(t.inputSchema),p=u.properties??{},g=new Set(u.required??[]),b=[],k=[],$=[],f=[];for(let[i,o]of Object.entries(p)){let a=o.description??i,y=ue(o),m=me(o),j=pe(o),B=de(o);j&&k.push(i),B&&f.push(i),m?($.push(i),g.has(i)&&!y?l.requiredOption(`--${i} <json>`,`${a} (as JSON)`):(l.option(`--${i} <json>`,`${a} (as JSON)`),b.push(i))):y||!g.has(i)?(l.option(`--${i} <${i}>`,a),b.push(i)):l.requiredOption(`--${i} <${i}>`,a)}l.action(async i=>{await R.handler({});for(let o of b)i[o]===void 0&&(i[o]=null);for(let o of k)i[o]!=null&&typeof i[o]=="string"&&(i[o]=Number(i[o]));for(let o of f)if(typeof i[o]=="string"){let a=i[o].toLowerCase();a==="true"||a==="1"?i[o]=!0:(a==="false"||a==="0")&&(i[o]=!1)}for(let o of $)if(typeof i[o]=="string")try{i[o]=JSON.parse(i[o])}catch{console.error(`Invalid JSON for --${o}`),process.exit(1)}try{await I(i);let o=await N._call(t.name,i);U(o),M()}catch(o){console.error(Z(o)),process.exit(1)}})}}le(h,C);ye(h,J);h.command("tools").description("List available tools").action(()=>{let e=[...C.map(t=>({name:t.schema.name,description:t.schema.description})),...J.filter(t=>!C.some(s=>s.schema.name===t.name)&&!Y.has(t.name)).map(t=>({name:t.name,description:t.description}))].sort((t,s)=>t.name.localeCompare(s.name)),n=[];for(let t of e){let s=t.name.replace(/_/g," ");n.push(` ${d.green(s.padEnd(28))} ${d.dim(t.description)}`)}n.push(""),n.push(d.dim(`${e.length} tools`)),console.log(n.join(`
|
|
18
18
|
`)),M()});h.parse();
|
|
@@ -7,6 +7,6 @@ Run: npm i -g @moonpay/cli --include=optional`;function y(){try{let e=S("@ledger
|
|
|
7
7
|
`),p}async function U(){if(!p)return null;try{let e=y(),i=f().getDeviceSessionState({sessionId:p}),s=await e.firstValueFrom(i.pipe(e.take(1),e.timeout(3e3)));return s.sessionStateType>=1?s.currentApp?.name??null:null}catch{return null}}var M={evm:"Ethereum",solana:"Solana"};function _(e){let n=String(e);return n.includes("6807")||n.includes("6a15")||n.includes("UnknownDeviceExchangeError")}async function C(e){process.stderr.write(`Installing ${e} app on your Ledger...
|
|
8
8
|
`);let{OpenAppWithDependenciesDeviceAction:n}=y(),i=new n({input:{appName:e}}),t=f().executeDeviceAction({sessionId:E(),deviceAction:i});await m(t,`Install ${e}`,18e4),process.stderr.write(`Installed ${e} app
|
|
9
9
|
`)}async function R(e){let n=M[e];if(!n||await U()===n)return;process.stderr.write(`Opening ${n} app on your Ledger...
|
|
10
|
-
`);let{OpenAppDeviceAction:s}=y(),t=new s({input:{appName:n}}),u=f().executeDeviceAction({sessionId:E(),deviceAction:t});try{await m(u,`Open ${n}`)}catch(c){if(_(c)){await D(),await C(n),await D();return}if(!String(c).includes("isconnect"))throw c}await D()}async function D(){try{await f().disconnect({sessionId:p})}catch{}p=null,await new Promise(e=>setTimeout(e,500)),await P()}function $(e,n=0){switch(e){case"evm":return`44'/60'/${n}'/0/0`;case"solana":return`44'/501'/${n}'/0'`;default:throw new Error(`${e} derivation via Ledger is not supported.`)}}function k(e){return e.startsWith("0x")?e.slice(2):e}function T(e){return e.startsWith("0x")?e:`0x${e}`}async function x(e){let{moonpay:n}=await import("./client-
|
|
10
|
+
`);let{OpenAppDeviceAction:s}=y(),t=new s({input:{appName:n}}),u=f().executeDeviceAction({sessionId:E(),deviceAction:t});try{await m(u,`Open ${n}`)}catch(c){if(_(c)){await D(),await C(n),await D();return}if(!String(c).includes("isconnect"))throw c}await D()}async function D(){try{await f().disconnect({sessionId:p})}catch{}p=null,await new Promise(e=>setTimeout(e,500)),await P()}function $(e,n=0){switch(e){case"evm":return`44'/60'/${n}'/0/0`;case"solana":return`44'/501'/${n}'/0'`;default:throw new Error(`${e} derivation via Ledger is not supported.`)}}function k(e){return e.startsWith("0x")?e.slice(2):e}function T(e){return e.startsWith("0x")?e:`0x${e}`}async function x(e){let{moonpay:n}=await import("./client-KFFWEIDS.js"),s=(await n.chain.retrieve({chain:e})).keyFamily;if(s==="bitcoin")throw new Error("Bitcoin address derivation via Ledger is not yet supported.");if(s==="tron")throw new Error("Tron address derivation via Ledger is not supported. The Ethereum signer cannot interact with the Tron Ledger app.");await R(s);let t=$(s),a=E(),u=f();switch(s){case"evm":{let{SignerEthBuilder:c}=I(),l=new c({dmk:u,sessionId:a}).build().getAddress(t,{skipOpenApp:!1});return(await m(l,"Get Ethereum address")).address}case"solana":{let{SignerSolanaBuilder:c}=L(),l=new c({dmk:u,sessionId:a}).build().getAddress(t,{skipOpenApp:!1});return await m(l,"Get Solana address")}default:throw new Error(`Ledger address derivation not supported for ${s}`)}}async function F(){let e={};try{e.ethereum=await x("ethereum")}catch(n){process.stderr.write(`Failed to get Ethereum address: ${n}
|
|
11
11
|
`)}try{e.solana=await x("solana")}catch(n){process.stderr.write(`Failed to get Solana address: ${n}
|
|
12
|
-
`)}if(!e.ethereum&&!e.solana)throw new Error("Could not derive any addresses from Ledger device");return e}async function H(e,n){let{moonpay:i}=await import("./client-
|
|
12
|
+
`)}if(!e.ethereum&&!e.solana)throw new Error("Could not derive any addresses from Ledger device");return e}async function H(e,n){let{moonpay:i}=await import("./client-KFFWEIDS.js"),t=(await i.chain.retrieve({chain:e})).keyFamily;if(t==="bitcoin")throw new Error("Bitcoin transaction signing via Ledger is not yet supported. Use a software wallet for Bitcoin transactions.");if(t==="tron")throw new Error("Tron transaction signing via Ledger is not supported. Use a software wallet for Tron transactions.");await R(t);let a=$(t),u=E(),c=f();switch(t){case"evm":{let{SignerEthBuilder:d}=I(),l=new d({dmk:c,sessionId:u}).build(),w=T(n.startsWith("0x")?n:Buffer.from(n,"base64").toString("hex")),o=Uint8Array.from(Buffer.from(k(w),"hex")),r=l.signTransaction(a,o,{skipOpenApp:!1}),g=await m(r,"Sign transaction"),{parseTransaction:v,serializeTransaction:A}=await import("viem"),B=v(w);return{transaction:A(B,{r:T(k(g.r)),s:T(k(g.s)),v:BigInt(g.v)})}}case"solana":{let{SignerSolanaBuilder:d}=L(),l=new d({dmk:c,sessionId:u}).build(),{VersionedTransaction:w}=await import("@solana/web3.js"),o=Uint8Array.from(Buffer.from(n,"base64")),r=w.deserialize(o),g=r.message.serialize(),v=l.signTransaction(a,g,{skipOpenApp:!1}),A=await m(v,"Sign Solana transaction");return r.signatures[0]=A,{transaction:Buffer.from(r.serialize()).toString("base64")}}default:throw new Error(`Ledger transaction signing not supported for ${t}`)}}async function V(e,n){let{moonpay:i}=await import("./client-KFFWEIDS.js"),t=(await i.chain.retrieve({chain:e})).keyFamily;if(t==="bitcoin")throw new Error("Bitcoin message signing via Ledger is not yet supported. Use a software wallet for Bitcoin message signing.");if(t==="tron")throw new Error("Tron message signing via Ledger is not supported. Use a software wallet for Tron message signing.");await R(t);let a=$(t),u=E(),c=f();switch(t){case"evm":{let{SignerEthBuilder:d}=I(),w=new d({dmk:c,sessionId:u}).build().signMessage(a,n,{skipOpenApp:!1}),o=await m(w,"Sign message"),r=k(o.r),g=k(o.s),v=o.v.toString(16).padStart(2,"0");return{signature:`0x${r}${g}${v}`}}case"solana":{let{SignerSolanaBuilder:d}=L(),l=new d({dmk:c,sessionId:u}).build(),w=Buffer.from(n,"utf8").toString("hex"),o=l.signMessage(a,w,{skipOpenApp:!1}),r=await m(o,"Sign Solana message");return{signature:(await import("bs58")).default.encode(r)}}default:throw new Error(`Ledger message signing not supported for ${t}`)}}async function q(){if(p){try{await f().disconnect({sessionId:p})}catch{}p=null}if(h){try{h.close()}catch{}h=null}}export{P as connectLedger,q as disconnectLedger,x as ledgerGetAddress,F as ledgerGetAllAddresses,V as ledgerSignMessage,H as ledgerSignTransaction};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
|
|
2
|
-
import{a as f,d as u}from"./chunk-
|
|
2
|
+
import{a as f,d as u}from"./chunk-S6L5J3Y6.js";import{b as d}from"./chunk-JFG43WLV.js";import"./chunk-5KV2OSFP.js";import{e as l,g as R}from"./chunk-YSS3I7U7.js";import"./chunk-LMDE72OE.js";import{Server as N}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as O}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as T,ListToolsRequestSchema as x}from"@modelcontextprotocol/sdk/types.js";import{zodToJsonSchema as k}from"zod-to-json-schema";R();var y=new Map(u.map(s=>[s.schema.name,s]));function q(s){let n=s.inputSchema;if(n.$ref&&n.definitions){let c=n.$ref.replace("#/definitions/","");return n.definitions[c]??n}return n}async function P(){let s=new N({name:"moonpay",version:l},{capabilities:{tools:{listChanged:!0}}}),n=u.map(e=>({name:e.schema.name,description:e.schema.description,inputSchema:k(e.schema.input)})),c=new Map;for(let e of f){if(y.has(e.name))continue;let t=q(e);c.set(e.name,t.properties??{}),n.push({name:e.name,description:e.description,inputSchema:{type:"object",properties:t.properties??{},...t.required?{required:t.required}:{},...t.additionalProperties!==void 0?{additionalProperties:t.additionalProperties}:{}}})}let h=new Map(n.map(e=>[e.name,e]));s.setRequestHandler(x,async()=>({tools:n.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema}))})),s.setRequestHandler(T,async e=>{let{name:t,arguments:o={}}=e.params;if(!h.has(t))return{content:[{type:"text",text:`Unknown tool: ${t}`}],isError:!0};try{let i=y.get(t);if(i){let p=i.schema.input.shape??{};for(let[m,a]of Object.entries(p))o[m]===void 0&&a._def.typeName==="ZodNullable"&&(o[m]=null);let r=await i.handler(o);return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}let S=c.get(t)??{};for(let[p,r]of Object.entries(S))o[p]===void 0&&(Array.isArray(r.type)?r.type.includes("null"):r.anyOf?.some(w=>w.type==="null"))&&(o[p]=null),(r.type==="number"||r.type==="integer"||Array.isArray(r.type)&&r.type.some(a=>a==="number"||a==="integer")||r.anyOf?.some(a=>a.type==="number"||a.type==="integer"))&&typeof o[p]=="string"&&(o[p]=Number(o[p]));let b=await d._call(t,o);return{content:[{type:"text",text:JSON.stringify(b,null,2)}]}}catch(i){return{content:[{type:"text",text:i instanceof Error?i.message:String(i)}],isError:!0}}});let g=new O;await s.connect(g)}export{P as startMcpServer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
|
|
2
|
-
import{A as v,B as w,f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l,r as m,s as n,t as o,u as p,v as q,w as r,x as s,y as t,z as u}from"./chunk-
|
|
2
|
+
import{A as v,B as w,f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l,r as m,s as n,t as o,u as p,v as q,w as r,x as s,y as t,z as u}from"./chunk-5KV2OSFP.js";import"./chunk-YSS3I7U7.js";import"./chunk-LMDE72OE.js";export{m as addHardwareWallet,u as addWallet,d as createWallet,j as deleteWallet,l as exportSecret,h as findWallet,i as findWalletOrThrow,a as getVaultPath,e as importMnemonic,f as importPrivateKey,g as listWallets,s as loadWallets,c as migrateWallets,w as mutateWallets,p as owsSignMessage,o as owsSignTransaction,q as owsSignTypedData,n as refreshHardwareAddresses,t as removeWallet,k as renameWallet,b as requireMigrationCheck,r as resolveSigningKey,v as saveWallets};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: moonpay-fund-polymarket
|
|
3
|
-
description: Install the Polymarket CLI and fund its wallet with
|
|
3
|
+
description: Install the Polymarket CLI and fund its wallet with pUSD and POL on Polygon via MoonPay.
|
|
4
4
|
tags: [trading, setup, polymarket, polygon]
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -8,18 +8,21 @@ tags: [trading, setup, polymarket, polygon]
|
|
|
8
8
|
|
|
9
9
|
## Goal
|
|
10
10
|
|
|
11
|
-
Install the Polymarket CLI and fund its wallet with POL (gas) and
|
|
11
|
+
Install the Polymarket CLI and fund its wallet with POL (gas) and pUSD (trading) via MoonPay so it's ready to trade on Polymarket.
|
|
12
12
|
|
|
13
13
|
Polymarket runs on Polygon. To trade, the user needs:
|
|
14
14
|
- **POL** — native gas token for transaction fees
|
|
15
|
-
- **
|
|
15
|
+
- **pUSD** (`0xc011a7e12a19f7b1f670d46f03b03f3342e82dfb`) — Polymarket USD. Polymarket-issued ERC-20, 1:1 USDC-backed. The token Polymarket uses for bets and the token `withdrawToEoa` looks for in proxy wallets.
|
|
16
|
+
|
|
17
|
+
> **Note**: Polymarket migrated off USDC.e in 2026. Old USDC.e balances in proxy wallets are effectively stranded — there's no automated USDC.e → pUSD sweep tool. Fund fresh wallets with pUSD directly.
|
|
16
18
|
|
|
17
19
|
## Key addresses
|
|
18
20
|
|
|
19
21
|
| Token | Chain | Address |
|
|
20
22
|
|-------|-------|---------|
|
|
21
23
|
| POL (native) | Polygon | `0x0000000000000000000000000000000000000000` |
|
|
22
|
-
|
|
|
24
|
+
| pUSD | Polygon | `0xc011a7e12a19f7b1f670d46f03b03f3342e82dfb` |
|
|
25
|
+
| USDC (native) | Ethereum | `0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48` |
|
|
23
26
|
| ETH (native) | Ethereum | `0x0000000000000000000000000000000000000000` |
|
|
24
27
|
|
|
25
28
|
## Workflow
|
|
@@ -70,7 +73,7 @@ Use this address as the `--wallet` for all MoonPay funding commands below. EVM a
|
|
|
70
73
|
mp token balance list --wallet <polymarket-address> --chain polygon
|
|
71
74
|
```
|
|
72
75
|
|
|
73
|
-
If the wallet already has POL and
|
|
76
|
+
If the wallet already has POL and pUSD, they're set.
|
|
74
77
|
|
|
75
78
|
### 4. Get POL for gas
|
|
76
79
|
|
|
@@ -93,9 +96,9 @@ mp token bridge \
|
|
|
93
96
|
|
|
94
97
|
~$2-5 worth of POL covers hundreds of transactions.
|
|
95
98
|
|
|
96
|
-
### 5. Get
|
|
99
|
+
### 5. Get pUSD for trading
|
|
97
100
|
|
|
98
|
-
Bridge ETH on Ethereum to
|
|
101
|
+
Bridge ETH on Ethereum to pUSD on Polygon in one step:
|
|
99
102
|
|
|
100
103
|
```bash
|
|
101
104
|
mp token bridge \
|
|
@@ -103,7 +106,7 @@ mp token bridge \
|
|
|
103
106
|
--from-token 0x0000000000000000000000000000000000000000 \
|
|
104
107
|
--from-amount 0.005 \
|
|
105
108
|
--to-chain polygon \
|
|
106
|
-
--to-token
|
|
109
|
+
--to-token 0xc011a7e12a19f7b1f670d46f03b03f3342e82dfb
|
|
107
110
|
```
|
|
108
111
|
|
|
109
112
|
Alternatively, if the user already has USDC on Ethereum, bridge it directly:
|
|
@@ -114,7 +117,7 @@ mp token bridge \
|
|
|
114
117
|
--from-token 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 \
|
|
115
118
|
--from-amount 10 \
|
|
116
119
|
--to-chain polygon \
|
|
117
|
-
--to-token
|
|
120
|
+
--to-token 0xc011a7e12a19f7b1f670d46f03b03f3342e82dfb
|
|
118
121
|
```
|
|
119
122
|
|
|
120
123
|
### 6. Verify
|
|
@@ -123,7 +126,7 @@ mp token bridge \
|
|
|
123
126
|
mp token balance list --wallet <polymarket-address> --chain polygon
|
|
124
127
|
```
|
|
125
128
|
|
|
126
|
-
Confirm both POL and
|
|
129
|
+
Confirm both POL and pUSD are present.
|
|
127
130
|
|
|
128
131
|
### 7. Trade on Polymarket
|
|
129
132
|
|
|
@@ -134,19 +137,15 @@ Once funded, trade directly via MoonPay CLI:
|
|
|
134
137
|
mp prediction-market market search --provider polymarket --query "bitcoin"
|
|
135
138
|
|
|
136
139
|
# Get trending markets
|
|
137
|
-
mp prediction-market market trending list --provider polymarket
|
|
138
|
-
|
|
139
140
|
# Register wallet (one-time)
|
|
140
|
-
mp prediction-market user create --provider polymarket --wallet <evm-address>
|
|
141
141
|
|
|
142
|
-
# Buy shares
|
|
142
|
+
# Buy shares — price is a max ceiling (FAK, not a resting limit), $1 minimum order
|
|
143
143
|
mp prediction-market position buy --wallet main --provider polymarket --tokenId <token-id> --price 0.65 --size 100
|
|
144
144
|
|
|
145
145
|
# Check positions
|
|
146
146
|
mp prediction-market position list --provider polymarket --wallet <evm-address>
|
|
147
147
|
|
|
148
148
|
# Check PnL
|
|
149
|
-
mp prediction-market pnl retrieve --provider polymarket --wallet <evm-address>
|
|
150
149
|
```
|
|
151
150
|
|
|
152
151
|
Or use the Polymarket CLI for advanced order types:
|
|
@@ -165,6 +164,7 @@ polymarket clob balance # check trading balance
|
|
|
165
164
|
- Bridge times from Ethereum → Polygon are typically 5-20 seconds
|
|
166
165
|
- POL is very cheap for gas — a few dollars covers hundreds of transactions
|
|
167
166
|
- The fiat buy option (`mp buy`) is the fastest path if the user has no crypto yet
|
|
167
|
+
- pUSD is the new Polymarket collateral — don't fund with USDC.e (would be stranded) or regular USDC on Polygon (different mint)
|
|
168
168
|
|
|
169
169
|
## Related skills
|
|
170
170
|
|
|
@@ -11,167 +11,129 @@ US-regulated prediction-market venue. Settles on Solana in regular USDC (no brid
|
|
|
11
11
|
## Prerequisites
|
|
12
12
|
|
|
13
13
|
1. Authenticate: `mp login --email <email>` then `mp verify --email <email> --code <code>`
|
|
14
|
-
2. Solana wallet: `mp wallet list` (or
|
|
15
|
-
3. **Kalshi KYC** — see the next section.
|
|
16
|
-
4.
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
mp prediction-market user create --provider kalshi --wallet <solana-address>
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
5. Fund with USDC on Solana — the same USDC mint the user uses everywhere else (`EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`). No bridging required.
|
|
14
|
+
2. Solana wallet: `mp wallet list` (or `mp wallet create --name "main"`)
|
|
15
|
+
3. **Kalshi KYC** — see the next section. The #1 reason a Kalshi flow fails live; handle it up front.
|
|
16
|
+
4. Fund with USDC on Solana (`EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`). No bridging required.
|
|
23
17
|
|
|
24
18
|
## Kalshi KYC — read this BEFORE the user gets excited
|
|
25
19
|
|
|
26
|
-
Kalshi is a US-regulated, CFTC-licensed exchange. Every user needs identity verification before their wallet can place orders.
|
|
20
|
+
Kalshi is a US-regulated, CFTC-licensed exchange. Every user needs identity verification before their wallet can place orders.
|
|
27
21
|
|
|
28
22
|
**What KYC typically requires:**
|
|
29
23
|
- US residency (some states are blocked or have extra rules)
|
|
30
24
|
- Legal name + DOB matching a govt ID
|
|
31
25
|
- SSN (last 4 or full, depending on tier)
|
|
32
26
|
- Photo of govt ID + selfie
|
|
33
|
-
-
|
|
34
|
-
- 18+ (21+ in some states for sports markets specifically)
|
|
27
|
+
- 18+ (21+ in some states for sports markets)
|
|
35
28
|
|
|
36
|
-
|
|
29
|
+
KYC is handled by MoonPay's identity flow — not via a `prediction-market` tool. A user KYC'd for fiat onramps is NOT automatically KYC'd for Kalshi; different identity tier.
|
|
37
30
|
|
|
38
|
-
|
|
39
|
-
mp prediction-market user create --provider kalshi --wallet <solana-address>
|
|
40
|
-
```
|
|
31
|
+
**Be honest with the user:**
|
|
41
32
|
|
|
42
|
-
|
|
33
|
+
> "Quick heads-up: Kalshi needs ID verification because it's US-regulated — takes about 5 minutes. Polymarket doesn't have that step but doesn't have NBA markets. For your ask, Kalshi is the right venue."
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
|---|---|---|
|
|
46
|
-
| Success / no error | KYC done, wallet registered | Proceed to trading |
|
|
47
|
-
| `pending` | Submitted, under review | Wait — usually minutes to hours, sometimes a day |
|
|
48
|
-
| `requires_action` | Missing doc (extra ID, address proof, etc.) | Open the link from the response |
|
|
49
|
-
| `rejected` | Application declined | Surface the reason; don't loop |
|
|
50
|
-
| Region blocked | User outside US, or in a blocked state | Don't push — route them to **moonpay-polymarket** instead |
|
|
51
|
-
|
|
52
|
-
**Be honest with the user.** Kalshi's friction is the price of US regulation. Explain it once at the top:
|
|
53
|
-
|
|
54
|
-
> "Quick heads-up: Kalshi needs ID verification because it's US-regulated — takes about 5 minutes. Polymarket doesn't have that step, but it lives on Polygon and doesn't have this NBA market. For your ask specifically, Kalshi is the right venue. Want me to walk you through?"
|
|
55
|
-
|
|
56
|
-
**Watch out for:**
|
|
57
|
-
- A user KYC'd with MoonPay for fiat onramps is **NOT automatically** KYC'd for Kalshi. Different identity tier. Don't assume "I bought crypto with my card, I'm fine."
|
|
58
|
-
- Sports markets have age restrictions in some states (21+ vs 18+).
|
|
59
|
-
- A non-US user who just wants prediction markets shouldn't be sent through Kalshi KYC. Polymarket is the answer there, full stop.
|
|
35
|
+
Non-US users → route to **moonpay-polymarket** instead.
|
|
60
36
|
|
|
61
37
|
## Browse and research
|
|
62
38
|
|
|
63
39
|
```bash
|
|
64
|
-
# Search by keyword
|
|
65
|
-
mp prediction-market
|
|
66
|
-
|
|
67
|
-
# Trending
|
|
68
|
-
mp prediction-market market trending list --provider kalshi --limit 10
|
|
69
|
-
|
|
70
|
-
# Tags
|
|
71
|
-
mp prediction-market market tag list --provider kalshi
|
|
40
|
+
# Search events by keyword
|
|
41
|
+
mp prediction-market event search --provider kalshi --query "NBA" --limit 10
|
|
72
42
|
|
|
73
|
-
# Full event details
|
|
74
|
-
mp prediction-market
|
|
43
|
+
# Full event details — markets + outcomes with current bid/ask/price/volume inline
|
|
44
|
+
mp prediction-market event retrieve --provider kalshi --slug <event-slug>
|
|
75
45
|
|
|
76
|
-
#
|
|
77
|
-
mp prediction-market market
|
|
78
|
-
|
|
79
|
-
# Price history
|
|
80
|
-
mp prediction-market market price-history list --provider kalshi --tokenId <token-id> --interval 1w
|
|
46
|
+
# Price history (OHLCV)
|
|
47
|
+
mp prediction-market market ohlcv list --provider kalshi --tokenId <outcome-id> --interval 1w
|
|
81
48
|
```
|
|
82
49
|
|
|
50
|
+
Current prices and bid/ask live on `event_retrieve.markets[].outcomes[]` — no separate `price retrieve` call.
|
|
51
|
+
|
|
83
52
|
### How Kalshi names things
|
|
84
53
|
|
|
85
|
-
- Kalshi groups markets into a **series**
|
|
86
|
-
-
|
|
87
|
-
-
|
|
54
|
+
- Kalshi groups markets into a **series** like `KXNBA-26` ("Pro Basketball Champion — 2026"). Each series has many sub-markets (one per team / candidate).
|
|
55
|
+
- `outcomes[].id` is the SPL mint of the outcome token (YES mint or NO mint).
|
|
56
|
+
- Status: `"open"` markets accept orders; `"closed"` and `"resolved"` don't.
|
|
88
57
|
|
|
89
58
|
## Buy / sell
|
|
90
59
|
|
|
60
|
+
Kalshi flow is symmetric: sell + redeem both return an unsigned Solana tx that the CLI signs + broadcasts. No EIP-712 step (that's Polymarket-only).
|
|
61
|
+
|
|
91
62
|
```bash
|
|
92
63
|
# Buy YES shares
|
|
93
64
|
mp prediction-market position buy \
|
|
94
65
|
--provider kalshi \
|
|
95
66
|
--wallet main \
|
|
96
|
-
--tokenId <outcome-
|
|
67
|
+
--tokenId <outcome-id> \
|
|
97
68
|
--price 0.42 \
|
|
98
69
|
--size 50
|
|
99
70
|
|
|
100
|
-
# Sell
|
|
71
|
+
# Sell — uses the symmetric marketId + outcomeId pair from position_list
|
|
101
72
|
mp prediction-market position sell \
|
|
102
73
|
--provider kalshi \
|
|
103
74
|
--wallet main \
|
|
104
|
-
--
|
|
105
|
-
--
|
|
75
|
+
--marketId <market-ticker> \
|
|
76
|
+
--outcomeId <outcome-id> \
|
|
106
77
|
--size 50
|
|
107
78
|
```
|
|
108
79
|
|
|
109
80
|
**Concepts:**
|
|
110
|
-
- `
|
|
111
|
-
- `
|
|
81
|
+
- `outcomeId` is the SPL mint of the outcome (YES or NO). Comes from `event_retrieve.markets[].outcomes[].id` or `position_list[].outcomeId`.
|
|
82
|
+
- `marketId` is the Kalshi market ticker (e.g. `KXNBA-26-OKC`). Comes from `position_list[].marketId`.
|
|
83
|
+
- `price` is 0–1 (0.42 = 42¢ per share, implies 42% probability).
|
|
112
84
|
- `size` is the share count. **`size × price` must be ≥ $1** (Kalshi's minimum order value).
|
|
113
|
-
- Cost = `price × size` USDC.
|
|
114
85
|
- If YES resolves, each share pays $1 → profit = (1 − price) × size.
|
|
115
|
-
- No POL or bridging — Kalshi settles in plain USDC on Solana.
|
|
116
86
|
|
|
117
|
-
## Track +
|
|
87
|
+
## Track + redeem positions
|
|
118
88
|
|
|
119
89
|
```bash
|
|
120
90
|
mp prediction-market position list --provider kalshi --wallet <address>
|
|
121
91
|
mp prediction-market position list --provider kalshi --wallet <address> --status closed
|
|
122
|
-
mp prediction-market pnl retrieve --provider kalshi --wallet <address>
|
|
123
|
-
mp prediction-market trade list --provider kalshi --wallet <address>
|
|
124
|
-
mp prediction-market activity list --provider kalshi --wallet <address>
|
|
125
92
|
|
|
126
93
|
# Redeem winning shares after a market resolves
|
|
127
|
-
mp prediction-market position redeem
|
|
94
|
+
mp prediction-market position redeem \
|
|
95
|
+
--provider kalshi \
|
|
96
|
+
--wallet main \
|
|
97
|
+
--marketId <market-ticker> \
|
|
98
|
+
--outcomeId <outcome-id>
|
|
128
99
|
```
|
|
129
100
|
|
|
101
|
+
Position status is `"open" | "redeemable" | "redeemed"`. Derived on-chain from the market's `status` + the account's `redemptionStatus` — no separate API needed.
|
|
102
|
+
|
|
130
103
|
## Example flow — NBA championship
|
|
131
104
|
|
|
132
105
|
```bash
|
|
133
106
|
# 1. Find the NBA championship series
|
|
134
|
-
mp prediction-market
|
|
107
|
+
mp prediction-market event search --provider kalshi --query "NBA"
|
|
135
108
|
# → look for KXNBA-26 ("Pro Basketball Champion — 2026")
|
|
136
109
|
|
|
137
|
-
# 2. Drill in
|
|
138
|
-
mp prediction-market
|
|
139
|
-
# → list of sub-markets (one per team), each with bestAsk + acceptingOrders
|
|
110
|
+
# 2. Drill in — current bid/ask + volume per market
|
|
111
|
+
mp prediction-market event retrieve --provider kalshi --slug <slug-from-search>
|
|
140
112
|
|
|
141
|
-
# 3.
|
|
142
|
-
mp prediction-market market price retrieve --provider kalshi --tokenId <yes-token-id>
|
|
143
|
-
|
|
144
|
-
# 4. Buy 10 shares of OKC at 38¢ ($3.80 cost — meets the $1 minimum)
|
|
113
|
+
# 3. Buy 10 shares of OKC at 38¢ ($3.80 cost — meets the $1 minimum)
|
|
145
114
|
mp prediction-market position buy \
|
|
146
|
-
--provider kalshi \
|
|
147
|
-
--
|
|
148
|
-
--tokenId <yes-token-id> \
|
|
149
|
-
--price 0.38 \
|
|
150
|
-
--size 10
|
|
115
|
+
--provider kalshi --wallet funded-sol \
|
|
116
|
+
--tokenId <yes-outcome-id> --price 0.38 --size 10
|
|
151
117
|
|
|
152
|
-
#
|
|
118
|
+
# 4. Watch
|
|
153
119
|
mp prediction-market position list --provider kalshi --wallet <solana-address>
|
|
154
120
|
|
|
155
|
-
#
|
|
156
|
-
mp prediction-market position sell
|
|
157
|
-
--
|
|
121
|
+
# 5. Exit
|
|
122
|
+
mp prediction-market position sell \
|
|
123
|
+
--provider kalshi --wallet funded-sol \
|
|
124
|
+
--marketId <market-ticker> --outcomeId <yes-outcome-id> --size 10
|
|
158
125
|
```
|
|
159
126
|
|
|
160
127
|
## Tips
|
|
161
128
|
|
|
162
129
|
- `--json` is a global flag, BEFORE the subcommand: `mp --json prediction-market ...`.
|
|
163
|
-
-
|
|
164
|
-
- The
|
|
165
|
-
- Kalshi resolves
|
|
166
|
-
|
|
167
|
-
## When to choose Kalshi vs Polymarket
|
|
168
|
-
|
|
169
|
-
- **Kalshi** — sports (NBA / NFL / MLB), macro indicators (CPI, Fed rate decisions), US-regulated. No bridging, no Polygon.
|
|
170
|
-
- **Polymarket** — politics, crypto, world events, news. Largest catalog and deepest liquidity, but lives on Polygon (USDC.e).
|
|
130
|
+
- Sports markets fill cleanly during games — liquidity tightens close to resolution.
|
|
131
|
+
- The $1 minimum catches new users out — `size × price` must clear $1.
|
|
132
|
+
- Kalshi resolves via the official scoring body (e.g., NBA's published winner). Most sports markets settle within minutes of the final.
|
|
171
133
|
|
|
172
134
|
## Related skills
|
|
173
135
|
|
|
174
|
-
- **moonpay-
|
|
136
|
+
- **moonpay-prediction-market** — venue chooser (Kalshi vs Polymarket)
|
|
175
137
|
- **moonpay-check-wallet** — check Solana USDC balance
|
|
176
138
|
- **moonpay-buy-crypto** — onramp into USDC on Solana (zero-fee for stablecoins)
|
|
177
139
|
- **moonpay-trading-automation** — automate prediction-market strategies
|
|
@@ -169,7 +169,7 @@ Step 1 — Search:
|
|
|
169
169
|
mp prediction-market market search --provider kalshi --query "NBA"
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
-
Step 2 — Look at the `KXNBA-26` series ("Pro Basketball Champion — 2026"). Find sub-markets with `
|
|
172
|
+
Step 2 — Look at the `KXNBA-26` series ("Pro Basketball Champion — 2026"). Find sub-markets with `status === "open"` and real `outcomes[].ask` prices. Pick one with a story — a heavy favorite (OKC, Boston) for clean execution, or a value underdog if the spread looks juicy.
|
|
173
173
|
|
|
174
174
|
Step 3 — Quick take on the market — implied probability, whether the price looks fair.
|
|
175
175
|
|
|
@@ -179,7 +179,7 @@ Step 4 — Then: "Want me to grab some shares?"
|
|
|
179
179
|
mp prediction-market position buy \
|
|
180
180
|
--provider kalshi \
|
|
181
181
|
--tokenId <yes-tokenId> \
|
|
182
|
-
--price <
|
|
182
|
+
--price <outcomes[].ask> \
|
|
183
183
|
--size <shares> \
|
|
184
184
|
--wallet funded-sol
|
|
185
185
|
```
|