divy-sdk 0.1.0 → 0.1.1

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/index.cjs CHANGED
@@ -175,7 +175,11 @@ function parseAgentLaunch(l) {
175
175
  pairToken: l.pairToken,
176
176
  graduated: l.graduated,
177
177
  launchedAt: l.launchedAt,
178
- recorded: l.recorded
178
+ recorded: l.recorded,
179
+ retention: l.retention ?? null,
180
+ retentionProvisional: l.retentionProvisional ?? false,
181
+ earlyHolders: l.earlyHolders ?? null,
182
+ retained: l.retained ?? null
179
183
  };
180
184
  }
181
185
  function parseAgentRecord(j) {
@@ -183,7 +187,7 @@ function parseAgentRecord(j) {
183
187
  agent: j.agent,
184
188
  split: j.split,
185
189
  registered: j.registered,
186
- record: { launches: big(j.record.launches), graduated: big(j.record.graduated), score: j.record.score },
190
+ record: { launches: big(j.record.launches), graduated: big(j.record.graduated), score: j.record.score, graduationRate: j.record.graduationRate ?? j.record.score },
187
191
  fees: { agentEth: big(j.fees.agentEth), divyEth: big(j.fees.divyEth), pendingEscrowEth: big(j.fees.pendingEscrowEth) },
188
192
  launches: j.launches.map(parseAgentLaunch),
189
193
  ...j.balanceEth !== void 0 ? { balanceEth: j.balanceEth } : {},
@@ -192,7 +196,16 @@ function parseAgentRecord(j) {
192
196
  };
193
197
  }
194
198
  function parseLeaderboard(j) {
195
- return j.map((r) => ({ agent: r.agent, launches: r.launches, graduated: r.graduated, score: r.score, feesEth: big(r.feesEth) }));
199
+ return j.map((r) => ({
200
+ agent: r.agent,
201
+ launches: r.launches,
202
+ graduated: r.graduated,
203
+ score: r.score,
204
+ graduationRate: r.graduationRate ?? r.score,
205
+ retention: r.retention ?? null,
206
+ retentionProvisional: r.retentionProvisional ?? false,
207
+ feesEth: big(r.feesEth)
208
+ }));
196
209
  }
197
210
  function parseLaunches(j) {
198
211
  return j.map((r) => ({
@@ -206,7 +219,11 @@ function parseLaunches(j) {
206
219
  launchedBlock: r.launchedBlock,
207
220
  launchedAt: r.launchedAt,
208
221
  recorded: r.recorded,
209
- graduated: r.graduated
222
+ graduated: r.graduated,
223
+ retention: r.retention ?? null,
224
+ retentionProvisional: r.retentionProvisional ?? false,
225
+ earlyHolders: r.earlyHolders ?? null,
226
+ retained: r.retained ?? null
210
227
  }));
211
228
  }
212
229
  function parseHealth(j) {
@@ -321,6 +338,14 @@ var Divy = class {
321
338
  async health() {
322
339
  return parseHealth(await apiRequest(this.apiUrl, "/health"));
323
340
  }
341
+ // Creates a fresh hosted wallet on the API. Needs no credential, so an agent can bootstrap
342
+ // itself from a read-only client, then continue with createDivy({ apiKey }).
343
+ async createHostedAgent(params = {}) {
344
+ const body = {};
345
+ if (params.payout) body.payout = params.payout;
346
+ if (params.label) body.label = params.label;
347
+ return apiRequest(this.apiUrl, "/agents", { body });
348
+ }
324
349
  async register() {
325
350
  this.requireSigner("register");
326
351
  if (this.mode === "hosted") {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/chain.ts","../src/abi.ts","../src/errors.ts","../src/http.ts","../src/parse.ts"],"sourcesContent":["export { createDivy, Divy } from './client.js';\nexport { DivyError } from './errors.js';\nexport { addresses, defineDivyChain, explorerAddress, explorerTx, CHAIN_ID, DEFAULT_API_URL, DEFAULT_RPC_URL } from './chain.js';\nexport type {\n Address, Hex, Tx,\n CreateDivyOptions, CreateDivySelfCustody, CreateDivyHosted, CreateDivyReadOnly, DivyMode,\n InfoResult, FeePolicy, AgentRecord, AgentLaunch, LeaderboardEntry, LaunchListItem, HealthResult,\n QuoteParams, QuoteResult, RegisterResult, LaunchParams, LaunchResult, RecordResult,\n TradeParams, BuyParams, SellParams, TradeResult, HarvestResult, WaitForRecordOptions,\n} from './types.js';\n","import {\n createPublicClient, createWalletClient, http, encodeFunctionData, decodeEventLog, zeroAddress,\n} from 'viem';\nimport type { Address, Hex } from 'viem';\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { addresses, defineDivyChain } from './chain.js';\nimport { curveAbi, factoryTokenLaunchedAbi } from './abi.js';\nimport { DivyError } from './errors.js';\nimport { apiRequest } from './http.js';\nimport {\n parseAgentRecord, parseHealth, parseInfo, parseLaunches, parseLeaderboard, parseQuote,\n} from './parse.js';\nimport type {\n AgentRecord, BuyParams, CreateDivyOptions, DivyMode, HarvestResult, HealthResult, InfoResult,\n LaunchListItem, LaunchParams, LaunchResult, LeaderboardEntry, QuoteParams, QuoteResult, RecordResult,\n RegisterResult, SellParams, TradeResult, Tx, WaitForRecordOptions,\n} from './types.js';\n\nconst PRIVATE_KEY_RE = /^0x[0-9a-fA-F]{64}$/;\nconst BPS_DENOM = 10000n;\n\nfunction readAmount(amount: bigint | string): bigint {\n return typeof amount === 'bigint' ? amount : BigInt(amount);\n}\n\nexport class Divy {\n readonly mode: DivyMode;\n readonly apiUrl: string;\n\n private readonly apiKey?: string;\n private readonly account?: ReturnType<typeof privateKeyToAccount>;\n // viem's client generics resist a clean stored type across the three constructor branches;\n // both are only ever touched through sendLocal(), which fixes the call shape in one place.\n private readonly wallet?: any;\n private readonly pub?: any;\n private readonly chain?: ReturnType<typeof defineDivyChain>;\n\n constructor(options: CreateDivyOptions) {\n const hasPrivateKey = 'privateKey' in options && options.privateKey !== undefined;\n const hasApiKey = 'apiKey' in options && options.apiKey !== undefined;\n if (hasPrivateKey && hasApiKey) {\n throw new Error('pass either privateKey or apiKey to createDivy, not both');\n }\n\n this.apiUrl = options.apiUrl ?? addresses.apiUrl;\n\n if (hasPrivateKey) {\n const { privateKey, rpcUrl } = options as { privateKey: Hex; rpcUrl?: string };\n if (!PRIVATE_KEY_RE.test(privateKey)) {\n throw new Error('privateKey must be a 0x-prefixed 32-byte hex string');\n }\n this.mode = 'self-custody';\n this.account = privateKeyToAccount(privateKey);\n this.chain = defineDivyChain(rpcUrl ?? addresses.rpcUrl);\n const transport = http(rpcUrl ?? addresses.rpcUrl);\n this.wallet = createWalletClient({ account: this.account, chain: this.chain, transport });\n this.pub = createPublicClient({ chain: this.chain, transport });\n } else if (hasApiKey) {\n const { apiKey } = options as { apiKey: string };\n if (typeof apiKey !== 'string' || apiKey.length === 0) {\n throw new Error('apiKey must be a non-empty string');\n }\n this.mode = 'hosted';\n this.apiKey = apiKey;\n } else {\n this.mode = 'read-only';\n }\n }\n\n private requireSigner(action: string): void {\n if (this.mode === 'read-only') {\n throw new Error(`${action} requires a privateKey (self-custody) or apiKey (hosted) — this client is read-only`);\n }\n }\n\n private async sendLocal(tx: Tx) {\n if (!this.wallet || !this.pub || !this.account) throw new Error('self-custody wallet is not configured');\n const hash = await this.wallet.sendTransaction({\n account: this.account, chain: this.chain, to: tx.to, data: tx.data, value: tx.value,\n });\n const receipt = await this.pub.waitForTransactionReceipt({ hash });\n if (receipt.status !== 'success') throw new Error(`transaction reverted on-chain: ${hash}`);\n return receipt;\n }\n\n async buildTx<T = Record<string, unknown>>(path: string, body?: object): Promise<T> {\n return apiRequest<T>(this.apiUrl, path, { body: body ?? {} });\n }\n\n async info(): Promise<InfoResult> {\n return parseInfo(await apiRequest(this.apiUrl, '/'));\n }\n\n async agent(address?: Address): Promise<AgentRecord> {\n if (!address) {\n if (this.mode === 'hosted') {\n return parseAgentRecord(await apiRequest(this.apiUrl, '/me', { apiKey: this.apiKey }));\n }\n if (this.mode === 'self-custody' && this.account) {\n address = this.account.address;\n } else {\n throw new Error('agent() requires an address in read-only mode');\n }\n }\n return parseAgentRecord(await apiRequest(this.apiUrl, `/agents/${address}`));\n }\n\n async leaderboard(): Promise<LeaderboardEntry[]> {\n return parseLeaderboard(await apiRequest(this.apiUrl, '/leaderboard'));\n }\n\n async launches(options: { limit?: number } = {}): Promise<LaunchListItem[]> {\n const qs = options.limit ? `?limit=${options.limit}` : '';\n return parseLaunches(await apiRequest(this.apiUrl, `/launches${qs}`));\n }\n\n async health(): Promise<HealthResult> {\n return parseHealth(await apiRequest(this.apiUrl, '/health'));\n }\n\n async register(): Promise<RegisterResult> {\n this.requireSigner('register');\n\n if (this.mode === 'hosted') {\n const me = await apiRequest<{ registered: boolean; split: Address | null }>(this.apiUrl, '/me', { apiKey: this.apiKey });\n if (me.registered) return { registered: true, split: me.split };\n return { registered: false, split: null };\n }\n\n const address = this.account!.address;\n const first = await apiRequest<{ registered: boolean; split: Address; tx?: Tx }>(this.apiUrl, '/agents', {\n body: { address },\n });\n if (first.registered) return { registered: true, split: first.split };\n\n const receipt = await this.sendLocal({ to: first.tx!.to, data: first.tx!.data, value: BigInt(first.tx!.value ?? 0) });\n const after = await apiRequest<{ registered: boolean; split: Address }>(this.apiUrl, '/agents', { body: { address } });\n return { registered: after.registered, split: after.split, txHash: receipt.transactionHash };\n }\n\n async quote(params: QuoteParams): Promise<QuoteResult> {\n let recipient = params.recipient;\n if (!recipient && this.mode === 'self-custody' && this.account) recipient = this.account.address;\n return parseQuote(\n await apiRequest(this.apiUrl, '/quote', {\n body: {\n curve: params.curve, token: params.token, side: params.side,\n amount: readAmount(params.amount).toString(), recipient: recipient ?? zeroAddress,\n },\n }),\n );\n }\n\n async launch(params: LaunchParams): Promise<LaunchResult> {\n this.requireSigner('launch');\n\n if (this.mode === 'hosted') {\n const out = await apiRequest<{ token: Address; curve: Address; txHash: Hex }>(this.apiUrl, '/launch', {\n apiKey: this.apiKey, body: params,\n });\n return { token: out.token, curve: out.curve, txHash: out.txHash };\n }\n\n const address = this.account!.address;\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/launch', { body: { ...params, agent: address } });\n const receipt = await this.sendLocal(built.tx);\n\n let launched: { token: Address; curve: Address } | undefined;\n for (const log of receipt.logs) {\n try {\n const ev = decodeEventLog({ abi: factoryTokenLaunchedAbi, data: log.data, topics: log.topics });\n if (ev.eventName === 'TokenLaunched') { launched = ev.args as { token: Address; curve: Address }; break; }\n } catch { /* not a TokenLaunched log */ }\n }\n if (!launched) throw new Error(`launch mined (${receipt.transactionHash}) but no TokenLaunched event was found`);\n\n const result: LaunchResult = { token: launched.token, curve: launched.curve, txHash: receipt.transactionHash };\n try {\n const recorded = await this.record(launched.token);\n result.recordTxHash = recorded.txHash;\n } catch (e) {\n result.recordError = e instanceof Error ? e.message : String(e);\n }\n return result;\n }\n\n async record(token: Address): Promise<RecordResult> {\n if (this.mode !== 'self-custody') {\n throw new Error(\n 'record() requires self-custody (a privateKey): hosted and read-only launches are recorded '\n + 'automatically by Divy\\'s keeper within about a minute — use waitForRecord() to wait for it',\n );\n }\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/record', { body: { token } });\n const receipt = await this.sendLocal(built.tx);\n return { txHash: receipt.transactionHash };\n }\n\n async buy(params: BuyParams): Promise<TradeResult> {\n return this.trade('buy', readAmount(params.amountWei), params);\n }\n\n async sell(params: SellParams): Promise<TradeResult> {\n return this.trade('sell', readAmount(params.amountTokens), params);\n }\n\n private async trade(side: 'buy' | 'sell', amount: bigint, params: BuyParams | SellParams): Promise<TradeResult> {\n this.requireSigner(side);\n const slippageBps = params.slippageBps ?? 100;\n\n if (this.mode === 'hosted') {\n if (slippageBps !== 100) {\n throw new Error('slippageBps is not configurable in hosted mode: /trade hardcodes a 1% (100bps) slippage floor');\n }\n const out = await apiRequest<{ txHash: Hex; amountOut: string }>(this.apiUrl, '/trade', {\n apiKey: this.apiKey, body: { curve: params.curve, token: params.token, side, amount: amount.toString() },\n });\n return { txHash: out.txHash, amountOut: BigInt(out.amountOut) };\n }\n\n const address = this.account!.address;\n const q = await this.quote({ curve: params.curve, token: params.token, side, amount, recipient: address });\n\n let tradeTx = q.tx;\n if (slippageBps !== 100) {\n const minOut = (q.amountOut * (BPS_DENOM - BigInt(slippageBps))) / BPS_DENOM;\n const data = encodeFunctionData({ abi: curveAbi, functionName: side, args: [q.amountIn, minOut, address] });\n tradeTx = { ...q.tx, data };\n }\n\n if (q.approveTx) await this.sendLocal(q.approveTx);\n const receipt = await this.sendLocal(tradeTx);\n return { txHash: receipt.transactionHash, amountOut: q.amountOut };\n }\n\n async harvest(): Promise<HarvestResult> {\n this.requireSigner('harvest');\n\n if (this.mode === 'hosted') {\n const out = await apiRequest<{ txHash: Hex }>(this.apiUrl, '/harvest', { apiKey: this.apiKey, body: {} });\n return { txHash: out.txHash };\n }\n\n const address = this.account!.address;\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/harvest', { body: { agent: address } });\n const receipt = await this.sendLocal(built.tx);\n return { txHash: receipt.transactionHash };\n }\n\n async waitForRecord(token: Address, options: WaitForRecordOptions = {}): Promise<LaunchListItem> {\n const timeoutMs = options.timeoutMs ?? 60_000;\n const intervalMs = options.intervalMs ?? 3_000;\n const deadline = Date.now() + timeoutMs;\n const wanted = token.toLowerCase();\n\n for (;;) {\n const rows = await this.launches({ limit: 200 });\n const row = rows.find((r) => r.token.toLowerCase() === wanted);\n if (row?.recorded) return row;\n if (Date.now() >= deadline) {\n throw new DivyError(`timed out waiting for ${token} to be recorded`, 408);\n }\n await new Promise((resolve) => setTimeout(resolve, intervalMs));\n }\n }\n}\n\nexport function createDivy(options: CreateDivyOptions = {}): Divy {\n return new Divy(options);\n}\n","import { defineChain } from 'viem';\nimport type { Address } from 'viem';\n\nexport const CHAIN_ID = 4663;\nexport const DEFAULT_RPC_URL = 'https://rpc.mainnet.chain.robinhood.com';\nexport const DEFAULT_API_URL = 'https://divy-api-j8di.onrender.com';\nexport const EXPLORER_URL = 'https://robinhoodchain.blockscout.com';\n\nexport const addresses = {\n chainId: CHAIN_ID,\n registry: '0x0fEf638d8C88e6eD38eDcD9aB21BF39D083c8B1b' as Address,\n factory: '0x7eD598BcEf8bd9Edd8C97A195C6d13f40801EC7e' as Address,\n escrow: '0xd3AFEB2a57f70eF218Aa82451c51B2fb0416Ac9e' as Address,\n rpcUrl: DEFAULT_RPC_URL,\n apiUrl: DEFAULT_API_URL,\n explorerUrl: EXPLORER_URL,\n} as const;\n\nexport function defineDivyChain(rpcUrl: string = DEFAULT_RPC_URL) {\n return defineChain({\n id: CHAIN_ID,\n name: 'robinhood-chain',\n nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },\n rpcUrls: { default: { http: [rpcUrl] } },\n blockExplorers: { default: { name: 'Blockscout', url: EXPLORER_URL } },\n });\n}\n\nexport function explorerTx(hash: string): string {\n return `${EXPLORER_URL}/tx/${hash}`;\n}\n\nexport function explorerAddress(address: string): string {\n return `${EXPLORER_URL}/address/${address}`;\n}\n","// Minimal ABIs: the API returns pre-encoded {to, data, value} for every write, so the SDK\n// only needs to encode locally when overriding the API's default 1% slippage floor, and to\n// decode the TokenLaunched event off a launch receipt.\n\nexport const curveAbi = [\n {\n type: 'function',\n name: 'buy',\n stateMutability: 'payable',\n inputs: [\n { name: 'quoteIn', type: 'uint256' },\n { name: 'minTokensOut', type: 'uint256' },\n { name: 'recipient', type: 'address' },\n ],\n outputs: [{ name: 'tokensOut', type: 'uint256' }],\n },\n {\n type: 'function',\n name: 'sell',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'tokensIn', type: 'uint256' },\n { name: 'minQuoteOut', type: 'uint256' },\n { name: 'recipient', type: 'address' },\n ],\n outputs: [{ name: 'quoteOut', type: 'uint256' }],\n },\n] as const;\n\nexport const factoryTokenLaunchedAbi = [\n {\n type: 'event',\n name: 'TokenLaunched',\n inputs: [\n { indexed: true, name: 'token', type: 'address' },\n { indexed: true, name: 'curve', type: 'address' },\n { indexed: true, name: 'deployer', type: 'address' },\n { indexed: false, name: 'pairToken', type: 'address' },\n { indexed: false, name: 'launchConfigId', type: 'uint256' },\n { indexed: false, name: 'graduationThreshold', type: 'uint256' },\n ],\n },\n] as const;\n","export class DivyError extends Error {\n readonly status: number;\n\n constructor(message: string, status: number) {\n super(message);\n this.name = 'DivyError';\n this.status = status;\n }\n}\n","import { DivyError } from './errors.js';\n\nconst stringify = (body: unknown): string =>\n JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value));\n\nexport interface RequestOptions {\n method?: 'GET' | 'POST' | 'PATCH';\n body?: unknown;\n apiKey?: string;\n}\n\nexport async function apiRequest<T = unknown>(apiUrl: string, path: string, options: RequestOptions = {}): Promise<T> {\n const headers: Record<string, string> = {};\n if (options.body !== undefined) headers['content-type'] = 'application/json';\n if (options.apiKey) headers.authorization = `Bearer ${options.apiKey}`;\n\n const res = await fetch(`${apiUrl}${path}`, {\n method: options.method ?? (options.body !== undefined ? 'POST' : 'GET'),\n headers,\n body: options.body !== undefined ? stringify(options.body) : undefined,\n });\n\n const text = await res.text();\n let json: any;\n try {\n json = text ? JSON.parse(text) : {};\n } catch {\n // A gateway or proxy in front of the API (Render, Cloudflare, ...) can return an HTML\n // error page instead of JSON, typically on a 502/504 while the API is cold-starting or down.\n throw new DivyError(`${apiUrl} returned a non-JSON response (HTTP ${res.status} ${res.statusText}): the API may be down or restarting`, res.status);\n }\n if (!res.ok) {\n throw new DivyError(typeof json.error === 'string' ? json.error : res.statusText, res.status);\n }\n return json as T;\n}\n","import type {\n AgentLaunch, AgentRecord, HealthResult, InfoResult, LaunchListItem, LeaderboardEntry, QuoteResult, Tx,\n} from './types.js';\n\nconst big = (v: unknown): bigint => BigInt(v as string);\nconst bigOrNull = (v: unknown): bigint | null => (v === null || v === undefined ? null : big(v));\n\nexport function parseInfo(j: any): InfoResult {\n return {\n chain: j.chain,\n registry: j.registry,\n factory: j.factory,\n escrow: j.escrow,\n hostedWallets: j.hostedWallets,\n feePolicy: {\n treasury: j.feePolicy.treasury,\n divyBps: j.feePolicy.divyBps === null || j.feePolicy.divyBps === undefined ? null : Number(j.feePolicy.divyBps),\n agentShareOfBaseFee: j.feePolicy.agentShareOfBaseFee,\n ponsShare: j.feePolicy.ponsShare,\n divyShare: j.feePolicy.divyShare,\n },\n launchFee: { wei: big(j.launchFee.wei), eth: j.launchFee.eth },\n maxCreatorTaxBps: j.maxCreatorTaxBps,\n economics: j.economics,\n indexedBlock: bigOrNull(j.indexedBlock),\n keeper: j.keeper,\n };\n}\n\nfunction parseAgentLaunch(l: any): AgentLaunch {\n return {\n token: l.token,\n symbol: l.symbol,\n name: l.name,\n curve: l.curve,\n pairToken: l.pairToken,\n graduated: l.graduated,\n launchedAt: l.launchedAt,\n recorded: l.recorded,\n };\n}\n\nexport function parseAgentRecord(j: any): AgentRecord {\n return {\n agent: j.agent,\n split: j.split,\n registered: j.registered,\n record: { launches: big(j.record.launches), graduated: big(j.record.graduated), score: j.record.score },\n fees: { agentEth: big(j.fees.agentEth), divyEth: big(j.fees.divyEth), pendingEscrowEth: big(j.fees.pendingEscrowEth) },\n launches: j.launches.map(parseAgentLaunch),\n ...(j.balanceEth !== undefined ? { balanceEth: j.balanceEth } : {}),\n ...(j.payout !== undefined ? { payout: j.payout } : {}),\n ...(j.label !== undefined ? { label: j.label } : {}),\n };\n}\n\nexport function parseLeaderboard(j: any[]): LeaderboardEntry[] {\n return j.map((r) => ({ agent: r.agent, launches: r.launches, graduated: r.graduated, score: r.score, feesEth: big(r.feesEth) }));\n}\n\nexport function parseLaunches(j: any[]): LaunchListItem[] {\n return j.map((r) => ({\n token: r.token, agent: r.agent, split: r.split, curve: r.curve, pairToken: r.pairToken,\n name: r.name, symbol: r.symbol, launchedBlock: r.launchedBlock, launchedAt: r.launchedAt,\n recorded: r.recorded, graduated: r.graduated,\n }));\n}\n\nexport function parseHealth(j: any): HealthResult {\n return { ok: j.ok, indexedBlock: bigOrNull(j.indexedBlock), head: big(j.head), lag: bigOrNull(j.lag) };\n}\n\nfunction parseTx(t: any): Tx {\n return { to: t.to, data: t.data, value: big(t.value) };\n}\n\nexport function parseQuote(j: any): QuoteResult {\n return {\n curve: j.curve,\n amountIn: big(j.amountIn),\n amountOut: big(j.amountOut),\n minOut: big(j.minOut),\n feeBps: j.feeBps,\n creatorTaxBps: j.creatorTaxBps,\n snipeTaxBps: j.snipeTaxBps,\n tx: parseTx(j.tx),\n approveTx: j.approveTx ? parseTx(j.approveTx) : null,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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WAA4B,KAAK,QAAQ,YAAY,EAAE,QAAQ,KAAK,QAAQ,MAAM,CAAC,EAAE,CAAC;AACxG,aAAO,EAAE,QAAQ,IAAI,OAAO;AAAA,IAC9B;AAEA,UAAM,UAAU,KAAK,QAAS;AAC9B,UAAM,QAAQ,MAAM,WAAuB,KAAK,QAAQ,YAAY,EAAE,MAAM,EAAE,OAAO,QAAQ,EAAE,CAAC;AAChG,UAAM,UAAU,MAAM,KAAK,UAAU,MAAM,EAAE;AAC7C,WAAO,EAAE,QAAQ,QAAQ,gBAAgB;AAAA,EAC3C;AAAA,EAEA,MAAM,cAAc,OAAgB,UAAgC,CAAC,GAA4B;AAC/F,UAAM,YAAY,QAAQ,aAAa;AACvC,UAAM,aAAa,QAAQ,cAAc;AACzC,UAAM,WAAW,KAAK,IAAI,IAAI;AAC9B,UAAM,SAAS,MAAM,YAAY;AAEjC,eAAS;AACP,YAAM,OAAO,MAAM,KAAK,SAAS,EAAE,OAAO,IAAI,CAAC;AAC/C,YAAM,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,MAAM,YAAY,MAAM,MAAM;AAC7D,UAAI,KAAK,SAAU,QAAO;AAC1B,UAAI,KAAK,IAAI,KAAK,UAAU;AAC1B,cAAM,IAAI,UAAU,yBAAyB,KAAK,mBAAmB,GAAG;AAAA,MAC1E;AACA,YAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,UAAU,CAAC;AAAA,IAChE;AAAA,EACF;AACF;AAEO,SAAS,WAAW,UAA6B,CAAC,GAAS;AAChE,SAAO,IAAI,KAAK,OAAO;AACzB;","names":["import_viem"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/chain.ts","../src/abi.ts","../src/errors.ts","../src/http.ts","../src/parse.ts"],"sourcesContent":["export { createDivy, Divy } from './client.js';\nexport { DivyError } from './errors.js';\nexport { addresses, defineDivyChain, explorerAddress, explorerTx, CHAIN_ID, DEFAULT_API_URL, DEFAULT_RPC_URL } from './chain.js';\nexport type {\n Address, Hex, Tx,\n CreateDivyOptions, CreateDivySelfCustody, CreateDivyHosted, CreateDivyReadOnly, DivyMode,\n CreateHostedAgentParams, CreateHostedAgentResult,\n InfoResult, FeePolicy, AgentRecord, AgentLaunch, LeaderboardEntry, LaunchListItem, HealthResult,\n QuoteParams, QuoteResult, RegisterResult, LaunchParams, LaunchResult, RecordResult,\n TradeParams, BuyParams, SellParams, TradeResult, HarvestResult, WaitForRecordOptions,\n} from './types.js';\n","import {\n createPublicClient, createWalletClient, http, encodeFunctionData, decodeEventLog, zeroAddress,\n} from 'viem';\nimport type { Address, Hex } from 'viem';\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { addresses, defineDivyChain } from './chain.js';\nimport { curveAbi, factoryTokenLaunchedAbi } from './abi.js';\nimport { DivyError } from './errors.js';\nimport { apiRequest } from './http.js';\nimport {\n parseAgentRecord, parseHealth, parseInfo, parseLaunches, parseLeaderboard, parseQuote,\n} from './parse.js';\nimport type {\n AgentRecord, BuyParams, CreateDivyOptions, CreateHostedAgentParams, CreateHostedAgentResult, DivyMode, HarvestResult, HealthResult, InfoResult,\n LaunchListItem, LaunchParams, LaunchResult, LeaderboardEntry, QuoteParams, QuoteResult, RecordResult,\n RegisterResult, SellParams, TradeResult, Tx, WaitForRecordOptions,\n} from './types.js';\n\nconst PRIVATE_KEY_RE = /^0x[0-9a-fA-F]{64}$/;\nconst BPS_DENOM = 10000n;\n\nfunction readAmount(amount: bigint | string): bigint {\n return typeof amount === 'bigint' ? amount : BigInt(amount);\n}\n\nexport class Divy {\n readonly mode: DivyMode;\n readonly apiUrl: string;\n\n private readonly apiKey?: string;\n private readonly account?: ReturnType<typeof privateKeyToAccount>;\n // viem's client generics resist a clean stored type across the three constructor branches;\n // both are only ever touched through sendLocal(), which fixes the call shape in one place.\n private readonly wallet?: any;\n private readonly pub?: any;\n private readonly chain?: ReturnType<typeof defineDivyChain>;\n\n constructor(options: CreateDivyOptions) {\n const hasPrivateKey = 'privateKey' in options && options.privateKey !== undefined;\n const hasApiKey = 'apiKey' in options && options.apiKey !== undefined;\n if (hasPrivateKey && hasApiKey) {\n throw new Error('pass either privateKey or apiKey to createDivy, not both');\n }\n\n this.apiUrl = options.apiUrl ?? addresses.apiUrl;\n\n if (hasPrivateKey) {\n const { privateKey, rpcUrl } = options as { privateKey: Hex; rpcUrl?: string };\n if (!PRIVATE_KEY_RE.test(privateKey)) {\n throw new Error('privateKey must be a 0x-prefixed 32-byte hex string');\n }\n this.mode = 'self-custody';\n this.account = privateKeyToAccount(privateKey);\n this.chain = defineDivyChain(rpcUrl ?? addresses.rpcUrl);\n const transport = http(rpcUrl ?? addresses.rpcUrl);\n this.wallet = createWalletClient({ account: this.account, chain: this.chain, transport });\n this.pub = createPublicClient({ chain: this.chain, transport });\n } else if (hasApiKey) {\n const { apiKey } = options as { apiKey: string };\n if (typeof apiKey !== 'string' || apiKey.length === 0) {\n throw new Error('apiKey must be a non-empty string');\n }\n this.mode = 'hosted';\n this.apiKey = apiKey;\n } else {\n this.mode = 'read-only';\n }\n }\n\n private requireSigner(action: string): void {\n if (this.mode === 'read-only') {\n throw new Error(`${action} requires a privateKey (self-custody) or apiKey (hosted) — this client is read-only`);\n }\n }\n\n private async sendLocal(tx: Tx) {\n if (!this.wallet || !this.pub || !this.account) throw new Error('self-custody wallet is not configured');\n const hash = await this.wallet.sendTransaction({\n account: this.account, chain: this.chain, to: tx.to, data: tx.data, value: tx.value,\n });\n const receipt = await this.pub.waitForTransactionReceipt({ hash });\n if (receipt.status !== 'success') throw new Error(`transaction reverted on-chain: ${hash}`);\n return receipt;\n }\n\n async buildTx<T = Record<string, unknown>>(path: string, body?: object): Promise<T> {\n return apiRequest<T>(this.apiUrl, path, { body: body ?? {} });\n }\n\n async info(): Promise<InfoResult> {\n return parseInfo(await apiRequest(this.apiUrl, '/'));\n }\n\n async agent(address?: Address): Promise<AgentRecord> {\n if (!address) {\n if (this.mode === 'hosted') {\n return parseAgentRecord(await apiRequest(this.apiUrl, '/me', { apiKey: this.apiKey }));\n }\n if (this.mode === 'self-custody' && this.account) {\n address = this.account.address;\n } else {\n throw new Error('agent() requires an address in read-only mode');\n }\n }\n return parseAgentRecord(await apiRequest(this.apiUrl, `/agents/${address}`));\n }\n\n async leaderboard(): Promise<LeaderboardEntry[]> {\n return parseLeaderboard(await apiRequest(this.apiUrl, '/leaderboard'));\n }\n\n async launches(options: { limit?: number } = {}): Promise<LaunchListItem[]> {\n const qs = options.limit ? `?limit=${options.limit}` : '';\n return parseLaunches(await apiRequest(this.apiUrl, `/launches${qs}`));\n }\n\n async health(): Promise<HealthResult> {\n return parseHealth(await apiRequest(this.apiUrl, '/health'));\n }\n\n // Creates a fresh hosted wallet on the API. Needs no credential, so an agent can bootstrap\n // itself from a read-only client, then continue with createDivy({ apiKey }).\n async createHostedAgent(params: CreateHostedAgentParams = {}): Promise<CreateHostedAgentResult> {\n const body: Record<string, unknown> = {};\n if (params.payout) body.payout = params.payout;\n if (params.label) body.label = params.label;\n return apiRequest<CreateHostedAgentResult>(this.apiUrl, '/agents', { body });\n }\n\n async register(): Promise<RegisterResult> {\n this.requireSigner('register');\n\n if (this.mode === 'hosted') {\n const me = await apiRequest<{ registered: boolean; split: Address | null }>(this.apiUrl, '/me', { apiKey: this.apiKey });\n if (me.registered) return { registered: true, split: me.split };\n return { registered: false, split: null };\n }\n\n const address = this.account!.address;\n const first = await apiRequest<{ registered: boolean; split: Address; tx?: Tx }>(this.apiUrl, '/agents', {\n body: { address },\n });\n if (first.registered) return { registered: true, split: first.split };\n\n const receipt = await this.sendLocal({ to: first.tx!.to, data: first.tx!.data, value: BigInt(first.tx!.value ?? 0) });\n const after = await apiRequest<{ registered: boolean; split: Address }>(this.apiUrl, '/agents', { body: { address } });\n return { registered: after.registered, split: after.split, txHash: receipt.transactionHash };\n }\n\n async quote(params: QuoteParams): Promise<QuoteResult> {\n let recipient = params.recipient;\n if (!recipient && this.mode === 'self-custody' && this.account) recipient = this.account.address;\n return parseQuote(\n await apiRequest(this.apiUrl, '/quote', {\n body: {\n curve: params.curve, token: params.token, side: params.side,\n amount: readAmount(params.amount).toString(), recipient: recipient ?? zeroAddress,\n },\n }),\n );\n }\n\n async launch(params: LaunchParams): Promise<LaunchResult> {\n this.requireSigner('launch');\n\n if (this.mode === 'hosted') {\n const out = await apiRequest<{ token: Address; curve: Address; txHash: Hex }>(this.apiUrl, '/launch', {\n apiKey: this.apiKey, body: params,\n });\n return { token: out.token, curve: out.curve, txHash: out.txHash };\n }\n\n const address = this.account!.address;\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/launch', { body: { ...params, agent: address } });\n const receipt = await this.sendLocal(built.tx);\n\n let launched: { token: Address; curve: Address } | undefined;\n for (const log of receipt.logs) {\n try {\n const ev = decodeEventLog({ abi: factoryTokenLaunchedAbi, data: log.data, topics: log.topics });\n if (ev.eventName === 'TokenLaunched') { launched = ev.args as { token: Address; curve: Address }; break; }\n } catch { /* not a TokenLaunched log */ }\n }\n if (!launched) throw new Error(`launch mined (${receipt.transactionHash}) but no TokenLaunched event was found`);\n\n const result: LaunchResult = { token: launched.token, curve: launched.curve, txHash: receipt.transactionHash };\n try {\n const recorded = await this.record(launched.token);\n result.recordTxHash = recorded.txHash;\n } catch (e) {\n result.recordError = e instanceof Error ? e.message : String(e);\n }\n return result;\n }\n\n async record(token: Address): Promise<RecordResult> {\n if (this.mode !== 'self-custody') {\n throw new Error(\n 'record() requires self-custody (a privateKey): hosted and read-only launches are recorded '\n + 'automatically by Divy\\'s keeper within about a minute — use waitForRecord() to wait for it',\n );\n }\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/record', { body: { token } });\n const receipt = await this.sendLocal(built.tx);\n return { txHash: receipt.transactionHash };\n }\n\n async buy(params: BuyParams): Promise<TradeResult> {\n return this.trade('buy', readAmount(params.amountWei), params);\n }\n\n async sell(params: SellParams): Promise<TradeResult> {\n return this.trade('sell', readAmount(params.amountTokens), params);\n }\n\n private async trade(side: 'buy' | 'sell', amount: bigint, params: BuyParams | SellParams): Promise<TradeResult> {\n this.requireSigner(side);\n const slippageBps = params.slippageBps ?? 100;\n\n if (this.mode === 'hosted') {\n if (slippageBps !== 100) {\n throw new Error('slippageBps is not configurable in hosted mode: /trade hardcodes a 1% (100bps) slippage floor');\n }\n const out = await apiRequest<{ txHash: Hex; amountOut: string }>(this.apiUrl, '/trade', {\n apiKey: this.apiKey, body: { curve: params.curve, token: params.token, side, amount: amount.toString() },\n });\n return { txHash: out.txHash, amountOut: BigInt(out.amountOut) };\n }\n\n const address = this.account!.address;\n const q = await this.quote({ curve: params.curve, token: params.token, side, amount, recipient: address });\n\n let tradeTx = q.tx;\n if (slippageBps !== 100) {\n const minOut = (q.amountOut * (BPS_DENOM - BigInt(slippageBps))) / BPS_DENOM;\n const data = encodeFunctionData({ abi: curveAbi, functionName: side, args: [q.amountIn, minOut, address] });\n tradeTx = { ...q.tx, data };\n }\n\n if (q.approveTx) await this.sendLocal(q.approveTx);\n const receipt = await this.sendLocal(tradeTx);\n return { txHash: receipt.transactionHash, amountOut: q.amountOut };\n }\n\n async harvest(): Promise<HarvestResult> {\n this.requireSigner('harvest');\n\n if (this.mode === 'hosted') {\n const out = await apiRequest<{ txHash: Hex }>(this.apiUrl, '/harvest', { apiKey: this.apiKey, body: {} });\n return { txHash: out.txHash };\n }\n\n const address = this.account!.address;\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/harvest', { body: { agent: address } });\n const receipt = await this.sendLocal(built.tx);\n return { txHash: receipt.transactionHash };\n }\n\n async waitForRecord(token: Address, options: WaitForRecordOptions = {}): Promise<LaunchListItem> {\n const timeoutMs = options.timeoutMs ?? 60_000;\n const intervalMs = options.intervalMs ?? 3_000;\n const deadline = Date.now() + timeoutMs;\n const wanted = token.toLowerCase();\n\n for (;;) {\n const rows = await this.launches({ limit: 200 });\n const row = rows.find((r) => r.token.toLowerCase() === wanted);\n if (row?.recorded) return row;\n if (Date.now() >= deadline) {\n throw new DivyError(`timed out waiting for ${token} to be recorded`, 408);\n }\n await new Promise((resolve) => setTimeout(resolve, intervalMs));\n }\n }\n}\n\nexport function createDivy(options: CreateDivyOptions = {}): Divy {\n return new Divy(options);\n}\n","import { defineChain } from 'viem';\nimport type { Address } from 'viem';\n\nexport const CHAIN_ID = 4663;\nexport const DEFAULT_RPC_URL = 'https://rpc.mainnet.chain.robinhood.com';\nexport const DEFAULT_API_URL = 'https://divy-api-j8di.onrender.com';\nexport const EXPLORER_URL = 'https://robinhoodchain.blockscout.com';\n\nexport const addresses = {\n chainId: CHAIN_ID,\n registry: '0x0fEf638d8C88e6eD38eDcD9aB21BF39D083c8B1b' as Address,\n factory: '0x7eD598BcEf8bd9Edd8C97A195C6d13f40801EC7e' as Address,\n escrow: '0xd3AFEB2a57f70eF218Aa82451c51B2fb0416Ac9e' as Address,\n rpcUrl: DEFAULT_RPC_URL,\n apiUrl: DEFAULT_API_URL,\n explorerUrl: EXPLORER_URL,\n} as const;\n\nexport function defineDivyChain(rpcUrl: string = DEFAULT_RPC_URL) {\n return defineChain({\n id: CHAIN_ID,\n name: 'robinhood-chain',\n nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },\n rpcUrls: { default: { http: [rpcUrl] } },\n blockExplorers: { default: { name: 'Blockscout', url: EXPLORER_URL } },\n });\n}\n\nexport function explorerTx(hash: string): string {\n return `${EXPLORER_URL}/tx/${hash}`;\n}\n\nexport function explorerAddress(address: string): string {\n return `${EXPLORER_URL}/address/${address}`;\n}\n","// Minimal ABIs: the API returns pre-encoded {to, data, value} for every write, so the SDK\n// only needs to encode locally when overriding the API's default 1% slippage floor, and to\n// decode the TokenLaunched event off a launch receipt.\n\nexport const curveAbi = [\n {\n type: 'function',\n name: 'buy',\n stateMutability: 'payable',\n inputs: [\n { name: 'quoteIn', type: 'uint256' },\n { name: 'minTokensOut', type: 'uint256' },\n { name: 'recipient', type: 'address' },\n ],\n outputs: [{ name: 'tokensOut', type: 'uint256' }],\n },\n {\n type: 'function',\n name: 'sell',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'tokensIn', type: 'uint256' },\n { name: 'minQuoteOut', type: 'uint256' },\n { name: 'recipient', type: 'address' },\n ],\n outputs: [{ name: 'quoteOut', type: 'uint256' }],\n },\n] as const;\n\nexport const factoryTokenLaunchedAbi = [\n {\n type: 'event',\n name: 'TokenLaunched',\n inputs: [\n { indexed: true, name: 'token', type: 'address' },\n { indexed: true, name: 'curve', type: 'address' },\n { indexed: true, name: 'deployer', type: 'address' },\n { indexed: false, name: 'pairToken', type: 'address' },\n { indexed: false, name: 'launchConfigId', type: 'uint256' },\n { indexed: false, name: 'graduationThreshold', type: 'uint256' },\n ],\n },\n] as const;\n","export class DivyError extends Error {\n readonly status: number;\n\n constructor(message: string, status: number) {\n super(message);\n this.name = 'DivyError';\n this.status = status;\n }\n}\n","import { DivyError } from './errors.js';\n\nconst stringify = (body: unknown): string =>\n JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value));\n\nexport interface RequestOptions {\n method?: 'GET' | 'POST' | 'PATCH';\n body?: unknown;\n apiKey?: string;\n}\n\nexport async function apiRequest<T = unknown>(apiUrl: string, path: string, options: RequestOptions = {}): Promise<T> {\n const headers: Record<string, string> = {};\n if (options.body !== undefined) headers['content-type'] = 'application/json';\n if (options.apiKey) headers.authorization = `Bearer ${options.apiKey}`;\n\n const res = await fetch(`${apiUrl}${path}`, {\n method: options.method ?? (options.body !== undefined ? 'POST' : 'GET'),\n headers,\n body: options.body !== undefined ? stringify(options.body) : undefined,\n });\n\n const text = await res.text();\n let json: any;\n try {\n json = text ? JSON.parse(text) : {};\n } catch {\n // A gateway or proxy in front of the API (Render, Cloudflare, ...) can return an HTML\n // error page instead of JSON, typically on a 502/504 while the API is cold-starting or down.\n throw new DivyError(`${apiUrl} returned a non-JSON response (HTTP ${res.status} ${res.statusText}): the API may be down or restarting`, res.status);\n }\n if (!res.ok) {\n throw new DivyError(typeof json.error === 'string' ? json.error : res.statusText, res.status);\n }\n return json as T;\n}\n","import type {\n AgentLaunch, AgentRecord, HealthResult, InfoResult, LaunchListItem, LeaderboardEntry, QuoteResult, Tx,\n} from './types.js';\n\nconst big = (v: unknown): bigint => BigInt(v as string);\nconst bigOrNull = (v: unknown): bigint | null => (v === null || v === undefined ? null : big(v));\n\nexport function parseInfo(j: any): InfoResult {\n return {\n chain: j.chain,\n registry: j.registry,\n factory: j.factory,\n escrow: j.escrow,\n hostedWallets: j.hostedWallets,\n feePolicy: {\n treasury: j.feePolicy.treasury,\n divyBps: j.feePolicy.divyBps === null || j.feePolicy.divyBps === undefined ? null : Number(j.feePolicy.divyBps),\n agentShareOfBaseFee: j.feePolicy.agentShareOfBaseFee,\n ponsShare: j.feePolicy.ponsShare,\n divyShare: j.feePolicy.divyShare,\n },\n launchFee: { wei: big(j.launchFee.wei), eth: j.launchFee.eth },\n maxCreatorTaxBps: j.maxCreatorTaxBps,\n economics: j.economics,\n indexedBlock: bigOrNull(j.indexedBlock),\n keeper: j.keeper,\n };\n}\n\nfunction parseAgentLaunch(l: any): AgentLaunch {\n return {\n token: l.token,\n symbol: l.symbol,\n name: l.name,\n curve: l.curve,\n pairToken: l.pairToken,\n graduated: l.graduated,\n launchedAt: l.launchedAt,\n recorded: l.recorded,\n retention: l.retention ?? null, retentionProvisional: l.retentionProvisional ?? false,\n earlyHolders: l.earlyHolders ?? null, retained: l.retained ?? null,\n };\n}\n\nexport function parseAgentRecord(j: any): AgentRecord {\n return {\n agent: j.agent,\n split: j.split,\n registered: j.registered,\n record: { launches: big(j.record.launches), graduated: big(j.record.graduated), score: j.record.score, graduationRate: j.record.graduationRate ?? j.record.score },\n fees: { agentEth: big(j.fees.agentEth), divyEth: big(j.fees.divyEth), pendingEscrowEth: big(j.fees.pendingEscrowEth) },\n launches: j.launches.map(parseAgentLaunch),\n ...(j.balanceEth !== undefined ? { balanceEth: j.balanceEth } : {}),\n ...(j.payout !== undefined ? { payout: j.payout } : {}),\n ...(j.label !== undefined ? { label: j.label } : {}),\n };\n}\n\nexport function parseLeaderboard(j: any[]): LeaderboardEntry[] {\n return j.map((r) => ({\n agent: r.agent, launches: r.launches, graduated: r.graduated, score: r.score,\n graduationRate: r.graduationRate ?? r.score, retention: r.retention ?? null,\n retentionProvisional: r.retentionProvisional ?? false, feesEth: big(r.feesEth),\n }));\n}\n\nexport function parseLaunches(j: any[]): LaunchListItem[] {\n return j.map((r) => ({\n token: r.token, agent: r.agent, split: r.split, curve: r.curve, pairToken: r.pairToken,\n name: r.name, symbol: r.symbol, launchedBlock: r.launchedBlock, launchedAt: r.launchedAt,\n recorded: r.recorded, graduated: r.graduated,\n retention: r.retention ?? null, retentionProvisional: r.retentionProvisional ?? false,\n earlyHolders: r.earlyHolders ?? null, retained: r.retained ?? null,\n }));\n}\n\nexport function parseHealth(j: any): HealthResult {\n return { ok: j.ok, indexedBlock: bigOrNull(j.indexedBlock), head: big(j.head), lag: bigOrNull(j.lag) };\n}\n\nfunction parseTx(t: any): Tx {\n return { to: t.to, data: t.data, value: big(t.value) };\n}\n\nexport function parseQuote(j: any): QuoteResult {\n return {\n curve: j.curve,\n amountIn: big(j.amountIn),\n amountOut: big(j.amountOut),\n minOut: big(j.minOut),\n feeBps: j.feeBps,\n creatorTaxBps: j.creatorTaxBps,\n snipeTaxBps: j.snipeTaxBps,\n tx: parseTx(j.tx),\n approveTx: j.approveTx ? parseTx(j.approveTx) : null,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAEO;AAEP,sBAAoC;;;ACJpC,kBAA4B;AAGrB,IAAM,WAAW;AACjB,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AACxB,IAAM,eAAe;AAErB,IAAM,YAAY;AAAA,EACvB,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EAC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mBAAmB,GAAG;AAAA,MAC1E;AACA,YAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,UAAU,CAAC;AAAA,IAChE;AAAA,EACF;AACF;AAEO,SAAS,WAAW,UAA6B,CAAC,GAAS;AAChE,SAAO,IAAI,KAAK,OAAO;AACzB;","names":["import_viem"]}
package/dist/index.d.cts CHANGED
@@ -22,6 +22,24 @@ interface CreateDivyReadOnly {
22
22
  }
23
23
  type CreateDivyOptions = CreateDivySelfCustody | CreateDivyHosted | CreateDivyReadOnly;
24
24
  type DivyMode = 'self-custody' | 'hosted' | 'read-only';
25
+ interface CreateHostedAgentParams {
26
+ /** Wallet that harvested fees are swept to. Defaults to the hosted wallet itself. */
27
+ payout?: Address;
28
+ label?: string;
29
+ }
30
+ interface CreateHostedAgentResult {
31
+ /** Shown once. Persist it: it is the only credential for this wallet. */
32
+ apiKey: string;
33
+ address: Address;
34
+ payout: Address | null;
35
+ fund: {
36
+ to: Address;
37
+ chainId: number;
38
+ minEth: string;
39
+ note: string;
40
+ };
41
+ next: string;
42
+ }
25
43
  interface FeePolicy {
26
44
  treasury: Address | null;
27
45
  divyBps: number | null;
@@ -55,15 +73,23 @@ interface AgentLaunch {
55
73
  graduated: boolean;
56
74
  launchedAt: number;
57
75
  recorded: boolean;
76
+ /** Share of early holders (wallets holding one day after launch) still holding at the measurement point; null until the launch is a day old. */
77
+ retention: number | null;
78
+ /** True while measured against the chain head because the launch is younger than 30 days. */
79
+ retentionProvisional: boolean;
80
+ earlyHolders: number | null;
81
+ retained: number | null;
58
82
  }
59
83
  interface AgentRecord {
60
84
  agent: Address;
61
85
  split: Address | null;
62
86
  registered: boolean;
87
+ /** score = sum(graduated_i * retention_i) / launches; graduationRate is the unweighted graduated / launches. */
63
88
  record: {
64
89
  launches: bigint;
65
90
  graduated: bigint;
66
91
  score: number;
92
+ graduationRate: number;
67
93
  };
68
94
  fees: {
69
95
  agentEth: bigint;
@@ -80,7 +106,12 @@ interface LeaderboardEntry {
80
106
  agent: Address;
81
107
  launches: number;
82
108
  graduated: number;
109
+ /** Graduation rate weighted by holder retention. */
83
110
  score: number;
111
+ graduationRate: number;
112
+ /** Mean retention over launches that have a measurement; null if none do. */
113
+ retention: number | null;
114
+ retentionProvisional: boolean;
84
115
  feesEth: bigint;
85
116
  }
86
117
  interface LaunchListItem {
@@ -95,6 +126,12 @@ interface LaunchListItem {
95
126
  launchedAt: number;
96
127
  recorded: boolean;
97
128
  graduated: boolean;
129
+ /** Share of early holders (wallets holding one day after launch) still holding at the measurement point; null until the launch is a day old. */
130
+ retention: number | null;
131
+ /** True while measured against the chain head because the launch is younger than 30 days. */
132
+ retentionProvisional: boolean;
133
+ earlyHolders: number | null;
134
+ retained: number | null;
98
135
  }
99
136
  interface HealthResult {
100
137
  ok: boolean;
@@ -196,6 +233,7 @@ declare class Divy {
196
233
  limit?: number;
197
234
  }): Promise<LaunchListItem[]>;
198
235
  health(): Promise<HealthResult>;
236
+ createHostedAgent(params?: CreateHostedAgentParams): Promise<CreateHostedAgentResult>;
199
237
  register(): Promise<RegisterResult>;
200
238
  quote(params: QuoteParams): Promise<QuoteResult>;
201
239
  launch(params: LaunchParams): Promise<LaunchResult>;
@@ -278,4 +316,4 @@ declare function defineDivyChain(rpcUrl?: string): {
278
316
  declare function explorerTx(hash: string): string;
279
317
  declare function explorerAddress(address: string): string;
280
318
 
281
- export { type AgentLaunch, type AgentRecord, type BuyParams, CHAIN_ID, type CreateDivyHosted, type CreateDivyOptions, type CreateDivyReadOnly, type CreateDivySelfCustody, DEFAULT_API_URL, DEFAULT_RPC_URL, Divy, DivyError, type DivyMode, type FeePolicy, type HarvestResult, type HealthResult, type InfoResult, type LaunchListItem, type LaunchParams, type LaunchResult, type LeaderboardEntry, type QuoteParams, type QuoteResult, type RecordResult, type RegisterResult, type SellParams, type TradeParams, type TradeResult, type Tx, type WaitForRecordOptions, addresses, createDivy, defineDivyChain, explorerAddress, explorerTx };
319
+ export { type AgentLaunch, type AgentRecord, type BuyParams, CHAIN_ID, type CreateDivyHosted, type CreateDivyOptions, type CreateDivyReadOnly, type CreateDivySelfCustody, type CreateHostedAgentParams, type CreateHostedAgentResult, DEFAULT_API_URL, DEFAULT_RPC_URL, Divy, DivyError, type DivyMode, type FeePolicy, type HarvestResult, type HealthResult, type InfoResult, type LaunchListItem, type LaunchParams, type LaunchResult, type LeaderboardEntry, type QuoteParams, type QuoteResult, type RecordResult, type RegisterResult, type SellParams, type TradeParams, type TradeResult, type Tx, type WaitForRecordOptions, addresses, createDivy, defineDivyChain, explorerAddress, explorerTx };
package/dist/index.d.ts CHANGED
@@ -22,6 +22,24 @@ interface CreateDivyReadOnly {
22
22
  }
23
23
  type CreateDivyOptions = CreateDivySelfCustody | CreateDivyHosted | CreateDivyReadOnly;
24
24
  type DivyMode = 'self-custody' | 'hosted' | 'read-only';
25
+ interface CreateHostedAgentParams {
26
+ /** Wallet that harvested fees are swept to. Defaults to the hosted wallet itself. */
27
+ payout?: Address;
28
+ label?: string;
29
+ }
30
+ interface CreateHostedAgentResult {
31
+ /** Shown once. Persist it: it is the only credential for this wallet. */
32
+ apiKey: string;
33
+ address: Address;
34
+ payout: Address | null;
35
+ fund: {
36
+ to: Address;
37
+ chainId: number;
38
+ minEth: string;
39
+ note: string;
40
+ };
41
+ next: string;
42
+ }
25
43
  interface FeePolicy {
26
44
  treasury: Address | null;
27
45
  divyBps: number | null;
@@ -55,15 +73,23 @@ interface AgentLaunch {
55
73
  graduated: boolean;
56
74
  launchedAt: number;
57
75
  recorded: boolean;
76
+ /** Share of early holders (wallets holding one day after launch) still holding at the measurement point; null until the launch is a day old. */
77
+ retention: number | null;
78
+ /** True while measured against the chain head because the launch is younger than 30 days. */
79
+ retentionProvisional: boolean;
80
+ earlyHolders: number | null;
81
+ retained: number | null;
58
82
  }
59
83
  interface AgentRecord {
60
84
  agent: Address;
61
85
  split: Address | null;
62
86
  registered: boolean;
87
+ /** score = sum(graduated_i * retention_i) / launches; graduationRate is the unweighted graduated / launches. */
63
88
  record: {
64
89
  launches: bigint;
65
90
  graduated: bigint;
66
91
  score: number;
92
+ graduationRate: number;
67
93
  };
68
94
  fees: {
69
95
  agentEth: bigint;
@@ -80,7 +106,12 @@ interface LeaderboardEntry {
80
106
  agent: Address;
81
107
  launches: number;
82
108
  graduated: number;
109
+ /** Graduation rate weighted by holder retention. */
83
110
  score: number;
111
+ graduationRate: number;
112
+ /** Mean retention over launches that have a measurement; null if none do. */
113
+ retention: number | null;
114
+ retentionProvisional: boolean;
84
115
  feesEth: bigint;
85
116
  }
86
117
  interface LaunchListItem {
@@ -95,6 +126,12 @@ interface LaunchListItem {
95
126
  launchedAt: number;
96
127
  recorded: boolean;
97
128
  graduated: boolean;
129
+ /** Share of early holders (wallets holding one day after launch) still holding at the measurement point; null until the launch is a day old. */
130
+ retention: number | null;
131
+ /** True while measured against the chain head because the launch is younger than 30 days. */
132
+ retentionProvisional: boolean;
133
+ earlyHolders: number | null;
134
+ retained: number | null;
98
135
  }
99
136
  interface HealthResult {
100
137
  ok: boolean;
@@ -196,6 +233,7 @@ declare class Divy {
196
233
  limit?: number;
197
234
  }): Promise<LaunchListItem[]>;
198
235
  health(): Promise<HealthResult>;
236
+ createHostedAgent(params?: CreateHostedAgentParams): Promise<CreateHostedAgentResult>;
199
237
  register(): Promise<RegisterResult>;
200
238
  quote(params: QuoteParams): Promise<QuoteResult>;
201
239
  launch(params: LaunchParams): Promise<LaunchResult>;
@@ -278,4 +316,4 @@ declare function defineDivyChain(rpcUrl?: string): {
278
316
  declare function explorerTx(hash: string): string;
279
317
  declare function explorerAddress(address: string): string;
280
318
 
281
- export { type AgentLaunch, type AgentRecord, type BuyParams, CHAIN_ID, type CreateDivyHosted, type CreateDivyOptions, type CreateDivyReadOnly, type CreateDivySelfCustody, DEFAULT_API_URL, DEFAULT_RPC_URL, Divy, DivyError, type DivyMode, type FeePolicy, type HarvestResult, type HealthResult, type InfoResult, type LaunchListItem, type LaunchParams, type LaunchResult, type LeaderboardEntry, type QuoteParams, type QuoteResult, type RecordResult, type RegisterResult, type SellParams, type TradeParams, type TradeResult, type Tx, type WaitForRecordOptions, addresses, createDivy, defineDivyChain, explorerAddress, explorerTx };
319
+ export { type AgentLaunch, type AgentRecord, type BuyParams, CHAIN_ID, type CreateDivyHosted, type CreateDivyOptions, type CreateDivyReadOnly, type CreateDivySelfCustody, type CreateHostedAgentParams, type CreateHostedAgentResult, DEFAULT_API_URL, DEFAULT_RPC_URL, Divy, DivyError, type DivyMode, type FeePolicy, type HarvestResult, type HealthResult, type InfoResult, type LaunchListItem, type LaunchParams, type LaunchResult, type LeaderboardEntry, type QuoteParams, type QuoteResult, type RecordResult, type RegisterResult, type SellParams, type TradeParams, type TradeResult, type Tx, type WaitForRecordOptions, addresses, createDivy, defineDivyChain, explorerAddress, explorerTx };
package/dist/index.js CHANGED
@@ -147,7 +147,11 @@ function parseAgentLaunch(l) {
147
147
  pairToken: l.pairToken,
148
148
  graduated: l.graduated,
149
149
  launchedAt: l.launchedAt,
150
- recorded: l.recorded
150
+ recorded: l.recorded,
151
+ retention: l.retention ?? null,
152
+ retentionProvisional: l.retentionProvisional ?? false,
153
+ earlyHolders: l.earlyHolders ?? null,
154
+ retained: l.retained ?? null
151
155
  };
152
156
  }
153
157
  function parseAgentRecord(j) {
@@ -155,7 +159,7 @@ function parseAgentRecord(j) {
155
159
  agent: j.agent,
156
160
  split: j.split,
157
161
  registered: j.registered,
158
- record: { launches: big(j.record.launches), graduated: big(j.record.graduated), score: j.record.score },
162
+ record: { launches: big(j.record.launches), graduated: big(j.record.graduated), score: j.record.score, graduationRate: j.record.graduationRate ?? j.record.score },
159
163
  fees: { agentEth: big(j.fees.agentEth), divyEth: big(j.fees.divyEth), pendingEscrowEth: big(j.fees.pendingEscrowEth) },
160
164
  launches: j.launches.map(parseAgentLaunch),
161
165
  ...j.balanceEth !== void 0 ? { balanceEth: j.balanceEth } : {},
@@ -164,7 +168,16 @@ function parseAgentRecord(j) {
164
168
  };
165
169
  }
166
170
  function parseLeaderboard(j) {
167
- return j.map((r) => ({ agent: r.agent, launches: r.launches, graduated: r.graduated, score: r.score, feesEth: big(r.feesEth) }));
171
+ return j.map((r) => ({
172
+ agent: r.agent,
173
+ launches: r.launches,
174
+ graduated: r.graduated,
175
+ score: r.score,
176
+ graduationRate: r.graduationRate ?? r.score,
177
+ retention: r.retention ?? null,
178
+ retentionProvisional: r.retentionProvisional ?? false,
179
+ feesEth: big(r.feesEth)
180
+ }));
168
181
  }
169
182
  function parseLaunches(j) {
170
183
  return j.map((r) => ({
@@ -178,7 +191,11 @@ function parseLaunches(j) {
178
191
  launchedBlock: r.launchedBlock,
179
192
  launchedAt: r.launchedAt,
180
193
  recorded: r.recorded,
181
- graduated: r.graduated
194
+ graduated: r.graduated,
195
+ retention: r.retention ?? null,
196
+ retentionProvisional: r.retentionProvisional ?? false,
197
+ earlyHolders: r.earlyHolders ?? null,
198
+ retained: r.retained ?? null
182
199
  }));
183
200
  }
184
201
  function parseHealth(j) {
@@ -293,6 +310,14 @@ var Divy = class {
293
310
  async health() {
294
311
  return parseHealth(await apiRequest(this.apiUrl, "/health"));
295
312
  }
313
+ // Creates a fresh hosted wallet on the API. Needs no credential, so an agent can bootstrap
314
+ // itself from a read-only client, then continue with createDivy({ apiKey }).
315
+ async createHostedAgent(params = {}) {
316
+ const body = {};
317
+ if (params.payout) body.payout = params.payout;
318
+ if (params.label) body.label = params.label;
319
+ return apiRequest(this.apiUrl, "/agents", { body });
320
+ }
296
321
  async register() {
297
322
  this.requireSigner("register");
298
323
  if (this.mode === "hosted") {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/chain.ts","../src/abi.ts","../src/errors.ts","../src/http.ts","../src/parse.ts"],"sourcesContent":["import {\n createPublicClient, createWalletClient, http, encodeFunctionData, decodeEventLog, zeroAddress,\n} from 'viem';\nimport type { Address, Hex } from 'viem';\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { addresses, defineDivyChain } from './chain.js';\nimport { curveAbi, factoryTokenLaunchedAbi } from './abi.js';\nimport { DivyError } from './errors.js';\nimport { apiRequest } from './http.js';\nimport {\n parseAgentRecord, parseHealth, parseInfo, parseLaunches, parseLeaderboard, parseQuote,\n} from './parse.js';\nimport type {\n AgentRecord, BuyParams, CreateDivyOptions, DivyMode, HarvestResult, HealthResult, InfoResult,\n LaunchListItem, LaunchParams, LaunchResult, LeaderboardEntry, QuoteParams, QuoteResult, RecordResult,\n RegisterResult, SellParams, TradeResult, Tx, WaitForRecordOptions,\n} from './types.js';\n\nconst PRIVATE_KEY_RE = /^0x[0-9a-fA-F]{64}$/;\nconst BPS_DENOM = 10000n;\n\nfunction readAmount(amount: bigint | string): bigint {\n return typeof amount === 'bigint' ? amount : BigInt(amount);\n}\n\nexport class Divy {\n readonly mode: DivyMode;\n readonly apiUrl: string;\n\n private readonly apiKey?: string;\n private readonly account?: ReturnType<typeof privateKeyToAccount>;\n // viem's client generics resist a clean stored type across the three constructor branches;\n // both are only ever touched through sendLocal(), which fixes the call shape in one place.\n private readonly wallet?: any;\n private readonly pub?: any;\n private readonly chain?: ReturnType<typeof defineDivyChain>;\n\n constructor(options: CreateDivyOptions) {\n const hasPrivateKey = 'privateKey' in options && options.privateKey !== undefined;\n const hasApiKey = 'apiKey' in options && options.apiKey !== undefined;\n if (hasPrivateKey && hasApiKey) {\n throw new Error('pass either privateKey or apiKey to createDivy, not both');\n }\n\n this.apiUrl = options.apiUrl ?? addresses.apiUrl;\n\n if (hasPrivateKey) {\n const { privateKey, rpcUrl } = options as { privateKey: Hex; rpcUrl?: string };\n if (!PRIVATE_KEY_RE.test(privateKey)) {\n throw new Error('privateKey must be a 0x-prefixed 32-byte hex string');\n }\n this.mode = 'self-custody';\n this.account = privateKeyToAccount(privateKey);\n this.chain = defineDivyChain(rpcUrl ?? addresses.rpcUrl);\n const transport = http(rpcUrl ?? addresses.rpcUrl);\n this.wallet = createWalletClient({ account: this.account, chain: this.chain, transport });\n this.pub = createPublicClient({ chain: this.chain, transport });\n } else if (hasApiKey) {\n const { apiKey } = options as { apiKey: string };\n if (typeof apiKey !== 'string' || apiKey.length === 0) {\n throw new Error('apiKey must be a non-empty string');\n }\n this.mode = 'hosted';\n this.apiKey = apiKey;\n } else {\n this.mode = 'read-only';\n }\n }\n\n private requireSigner(action: string): void {\n if (this.mode === 'read-only') {\n throw new Error(`${action} requires a privateKey (self-custody) or apiKey (hosted) — this client is read-only`);\n }\n }\n\n private async sendLocal(tx: Tx) {\n if (!this.wallet || !this.pub || !this.account) throw new Error('self-custody wallet is not configured');\n const hash = await this.wallet.sendTransaction({\n account: this.account, chain: this.chain, to: tx.to, data: tx.data, value: tx.value,\n });\n const receipt = await this.pub.waitForTransactionReceipt({ hash });\n if (receipt.status !== 'success') throw new Error(`transaction reverted on-chain: ${hash}`);\n return receipt;\n }\n\n async buildTx<T = Record<string, unknown>>(path: string, body?: object): Promise<T> {\n return apiRequest<T>(this.apiUrl, path, { body: body ?? {} });\n }\n\n async info(): Promise<InfoResult> {\n return parseInfo(await apiRequest(this.apiUrl, '/'));\n }\n\n async agent(address?: Address): Promise<AgentRecord> {\n if (!address) {\n if (this.mode === 'hosted') {\n return parseAgentRecord(await apiRequest(this.apiUrl, '/me', { apiKey: this.apiKey }));\n }\n if (this.mode === 'self-custody' && this.account) {\n address = this.account.address;\n } else {\n throw new Error('agent() requires an address in read-only mode');\n }\n }\n return parseAgentRecord(await apiRequest(this.apiUrl, `/agents/${address}`));\n }\n\n async leaderboard(): Promise<LeaderboardEntry[]> {\n return parseLeaderboard(await apiRequest(this.apiUrl, '/leaderboard'));\n }\n\n async launches(options: { limit?: number } = {}): Promise<LaunchListItem[]> {\n const qs = options.limit ? `?limit=${options.limit}` : '';\n return parseLaunches(await apiRequest(this.apiUrl, `/launches${qs}`));\n }\n\n async health(): Promise<HealthResult> {\n return parseHealth(await apiRequest(this.apiUrl, '/health'));\n }\n\n async register(): Promise<RegisterResult> {\n this.requireSigner('register');\n\n if (this.mode === 'hosted') {\n const me = await apiRequest<{ registered: boolean; split: Address | null }>(this.apiUrl, '/me', { apiKey: this.apiKey });\n if (me.registered) return { registered: true, split: me.split };\n return { registered: false, split: null };\n }\n\n const address = this.account!.address;\n const first = await apiRequest<{ registered: boolean; split: Address; tx?: Tx }>(this.apiUrl, '/agents', {\n body: { address },\n });\n if (first.registered) return { registered: true, split: first.split };\n\n const receipt = await this.sendLocal({ to: first.tx!.to, data: first.tx!.data, value: BigInt(first.tx!.value ?? 0) });\n const after = await apiRequest<{ registered: boolean; split: Address }>(this.apiUrl, '/agents', { body: { address } });\n return { registered: after.registered, split: after.split, txHash: receipt.transactionHash };\n }\n\n async quote(params: QuoteParams): Promise<QuoteResult> {\n let recipient = params.recipient;\n if (!recipient && this.mode === 'self-custody' && this.account) recipient = this.account.address;\n return parseQuote(\n await apiRequest(this.apiUrl, '/quote', {\n body: {\n curve: params.curve, token: params.token, side: params.side,\n amount: readAmount(params.amount).toString(), recipient: recipient ?? zeroAddress,\n },\n }),\n );\n }\n\n async launch(params: LaunchParams): Promise<LaunchResult> {\n this.requireSigner('launch');\n\n if (this.mode === 'hosted') {\n const out = await apiRequest<{ token: Address; curve: Address; txHash: Hex }>(this.apiUrl, '/launch', {\n apiKey: this.apiKey, body: params,\n });\n return { token: out.token, curve: out.curve, txHash: out.txHash };\n }\n\n const address = this.account!.address;\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/launch', { body: { ...params, agent: address } });\n const receipt = await this.sendLocal(built.tx);\n\n let launched: { token: Address; curve: Address } | undefined;\n for (const log of receipt.logs) {\n try {\n const ev = decodeEventLog({ abi: factoryTokenLaunchedAbi, data: log.data, topics: log.topics });\n if (ev.eventName === 'TokenLaunched') { launched = ev.args as { token: Address; curve: Address }; break; }\n } catch { /* not a TokenLaunched log */ }\n }\n if (!launched) throw new Error(`launch mined (${receipt.transactionHash}) but no TokenLaunched event was found`);\n\n const result: LaunchResult = { token: launched.token, curve: launched.curve, txHash: receipt.transactionHash };\n try {\n const recorded = await this.record(launched.token);\n result.recordTxHash = recorded.txHash;\n } catch (e) {\n result.recordError = e instanceof Error ? e.message : String(e);\n }\n return result;\n }\n\n async record(token: Address): Promise<RecordResult> {\n if (this.mode !== 'self-custody') {\n throw new Error(\n 'record() requires self-custody (a privateKey): hosted and read-only launches are recorded '\n + 'automatically by Divy\\'s keeper within about a minute — use waitForRecord() to wait for it',\n );\n }\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/record', { body: { token } });\n const receipt = await this.sendLocal(built.tx);\n return { txHash: receipt.transactionHash };\n }\n\n async buy(params: BuyParams): Promise<TradeResult> {\n return this.trade('buy', readAmount(params.amountWei), params);\n }\n\n async sell(params: SellParams): Promise<TradeResult> {\n return this.trade('sell', readAmount(params.amountTokens), params);\n }\n\n private async trade(side: 'buy' | 'sell', amount: bigint, params: BuyParams | SellParams): Promise<TradeResult> {\n this.requireSigner(side);\n const slippageBps = params.slippageBps ?? 100;\n\n if (this.mode === 'hosted') {\n if (slippageBps !== 100) {\n throw new Error('slippageBps is not configurable in hosted mode: /trade hardcodes a 1% (100bps) slippage floor');\n }\n const out = await apiRequest<{ txHash: Hex; amountOut: string }>(this.apiUrl, '/trade', {\n apiKey: this.apiKey, body: { curve: params.curve, token: params.token, side, amount: amount.toString() },\n });\n return { txHash: out.txHash, amountOut: BigInt(out.amountOut) };\n }\n\n const address = this.account!.address;\n const q = await this.quote({ curve: params.curve, token: params.token, side, amount, recipient: address });\n\n let tradeTx = q.tx;\n if (slippageBps !== 100) {\n const minOut = (q.amountOut * (BPS_DENOM - BigInt(slippageBps))) / BPS_DENOM;\n const data = encodeFunctionData({ abi: curveAbi, functionName: side, args: [q.amountIn, minOut, address] });\n tradeTx = { ...q.tx, data };\n }\n\n if (q.approveTx) await this.sendLocal(q.approveTx);\n const receipt = await this.sendLocal(tradeTx);\n return { txHash: receipt.transactionHash, amountOut: q.amountOut };\n }\n\n async harvest(): Promise<HarvestResult> {\n this.requireSigner('harvest');\n\n if (this.mode === 'hosted') {\n const out = await apiRequest<{ txHash: Hex }>(this.apiUrl, '/harvest', { apiKey: this.apiKey, body: {} });\n return { txHash: out.txHash };\n }\n\n const address = this.account!.address;\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/harvest', { body: { agent: address } });\n const receipt = await this.sendLocal(built.tx);\n return { txHash: receipt.transactionHash };\n }\n\n async waitForRecord(token: Address, options: WaitForRecordOptions = {}): Promise<LaunchListItem> {\n const timeoutMs = options.timeoutMs ?? 60_000;\n const intervalMs = options.intervalMs ?? 3_000;\n const deadline = Date.now() + timeoutMs;\n const wanted = token.toLowerCase();\n\n for (;;) {\n const rows = await this.launches({ limit: 200 });\n const row = rows.find((r) => r.token.toLowerCase() === wanted);\n if (row?.recorded) return row;\n if (Date.now() >= deadline) {\n throw new DivyError(`timed out waiting for ${token} to be recorded`, 408);\n }\n await new Promise((resolve) => setTimeout(resolve, intervalMs));\n }\n }\n}\n\nexport function createDivy(options: CreateDivyOptions = {}): Divy {\n return new Divy(options);\n}\n","import { defineChain } from 'viem';\nimport type { Address } from 'viem';\n\nexport const CHAIN_ID = 4663;\nexport const DEFAULT_RPC_URL = 'https://rpc.mainnet.chain.robinhood.com';\nexport const DEFAULT_API_URL = 'https://divy-api-j8di.onrender.com';\nexport const EXPLORER_URL = 'https://robinhoodchain.blockscout.com';\n\nexport const addresses = {\n chainId: CHAIN_ID,\n registry: '0x0fEf638d8C88e6eD38eDcD9aB21BF39D083c8B1b' as Address,\n factory: '0x7eD598BcEf8bd9Edd8C97A195C6d13f40801EC7e' as Address,\n escrow: '0xd3AFEB2a57f70eF218Aa82451c51B2fb0416Ac9e' as Address,\n rpcUrl: DEFAULT_RPC_URL,\n apiUrl: DEFAULT_API_URL,\n explorerUrl: EXPLORER_URL,\n} as const;\n\nexport function defineDivyChain(rpcUrl: string = DEFAULT_RPC_URL) {\n return defineChain({\n id: CHAIN_ID,\n name: 'robinhood-chain',\n nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },\n rpcUrls: { default: { http: [rpcUrl] } },\n blockExplorers: { default: { name: 'Blockscout', url: EXPLORER_URL } },\n });\n}\n\nexport function explorerTx(hash: string): string {\n return `${EXPLORER_URL}/tx/${hash}`;\n}\n\nexport function explorerAddress(address: string): string {\n return `${EXPLORER_URL}/address/${address}`;\n}\n","// Minimal ABIs: the API returns pre-encoded {to, data, value} for every write, so the SDK\n// only needs to encode locally when overriding the API's default 1% slippage floor, and to\n// decode the TokenLaunched event off a launch receipt.\n\nexport const curveAbi = [\n {\n type: 'function',\n name: 'buy',\n stateMutability: 'payable',\n inputs: [\n { name: 'quoteIn', type: 'uint256' },\n { name: 'minTokensOut', type: 'uint256' },\n { name: 'recipient', type: 'address' },\n ],\n outputs: [{ name: 'tokensOut', type: 'uint256' }],\n },\n {\n type: 'function',\n name: 'sell',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'tokensIn', type: 'uint256' },\n { name: 'minQuoteOut', type: 'uint256' },\n { name: 'recipient', type: 'address' },\n ],\n outputs: [{ name: 'quoteOut', type: 'uint256' }],\n },\n] as const;\n\nexport const factoryTokenLaunchedAbi = [\n {\n type: 'event',\n name: 'TokenLaunched',\n inputs: [\n { indexed: true, name: 'token', type: 'address' },\n { indexed: true, name: 'curve', type: 'address' },\n { indexed: true, name: 'deployer', type: 'address' },\n { indexed: false, name: 'pairToken', type: 'address' },\n { indexed: false, name: 'launchConfigId', type: 'uint256' },\n { indexed: false, name: 'graduationThreshold', type: 'uint256' },\n ],\n },\n] as const;\n","export class DivyError extends Error {\n readonly status: number;\n\n constructor(message: string, status: number) {\n super(message);\n this.name = 'DivyError';\n this.status = status;\n }\n}\n","import { DivyError } from './errors.js';\n\nconst stringify = (body: unknown): string =>\n JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value));\n\nexport interface RequestOptions {\n method?: 'GET' | 'POST' | 'PATCH';\n body?: unknown;\n apiKey?: string;\n}\n\nexport async function apiRequest<T = unknown>(apiUrl: string, path: string, options: RequestOptions = {}): Promise<T> {\n const headers: Record<string, string> = {};\n if (options.body !== undefined) headers['content-type'] = 'application/json';\n if (options.apiKey) headers.authorization = `Bearer ${options.apiKey}`;\n\n const res = await fetch(`${apiUrl}${path}`, {\n method: options.method ?? (options.body !== undefined ? 'POST' : 'GET'),\n headers,\n body: options.body !== undefined ? stringify(options.body) : undefined,\n });\n\n const text = await res.text();\n let json: any;\n try {\n json = text ? JSON.parse(text) : {};\n } catch {\n // A gateway or proxy in front of the API (Render, Cloudflare, ...) can return an HTML\n // error page instead of JSON, typically on a 502/504 while the API is cold-starting or down.\n throw new DivyError(`${apiUrl} returned a non-JSON response (HTTP ${res.status} ${res.statusText}): the API may be down or restarting`, res.status);\n }\n if (!res.ok) {\n throw new DivyError(typeof json.error === 'string' ? json.error : res.statusText, res.status);\n }\n return json as T;\n}\n","import type {\n AgentLaunch, AgentRecord, HealthResult, InfoResult, LaunchListItem, LeaderboardEntry, QuoteResult, Tx,\n} from './types.js';\n\nconst big = (v: unknown): bigint => BigInt(v as string);\nconst bigOrNull = (v: unknown): bigint | null => (v === null || v === undefined ? null : big(v));\n\nexport function parseInfo(j: any): InfoResult {\n return {\n chain: j.chain,\n registry: j.registry,\n factory: j.factory,\n escrow: j.escrow,\n hostedWallets: j.hostedWallets,\n feePolicy: {\n treasury: j.feePolicy.treasury,\n divyBps: j.feePolicy.divyBps === null || j.feePolicy.divyBps === undefined ? null : Number(j.feePolicy.divyBps),\n agentShareOfBaseFee: j.feePolicy.agentShareOfBaseFee,\n ponsShare: j.feePolicy.ponsShare,\n divyShare: j.feePolicy.divyShare,\n },\n launchFee: { wei: big(j.launchFee.wei), eth: j.launchFee.eth },\n maxCreatorTaxBps: j.maxCreatorTaxBps,\n economics: j.economics,\n indexedBlock: bigOrNull(j.indexedBlock),\n keeper: j.keeper,\n };\n}\n\nfunction parseAgentLaunch(l: any): AgentLaunch {\n return {\n token: l.token,\n symbol: l.symbol,\n name: l.name,\n curve: l.curve,\n pairToken: l.pairToken,\n graduated: l.graduated,\n launchedAt: l.launchedAt,\n recorded: l.recorded,\n };\n}\n\nexport function parseAgentRecord(j: any): AgentRecord {\n return {\n agent: j.agent,\n split: j.split,\n registered: j.registered,\n record: { launches: big(j.record.launches), graduated: big(j.record.graduated), score: j.record.score },\n fees: { agentEth: big(j.fees.agentEth), divyEth: big(j.fees.divyEth), pendingEscrowEth: big(j.fees.pendingEscrowEth) },\n launches: j.launches.map(parseAgentLaunch),\n ...(j.balanceEth !== undefined ? { balanceEth: j.balanceEth } : {}),\n ...(j.payout !== undefined ? { payout: j.payout } : {}),\n ...(j.label !== undefined ? { label: j.label } : {}),\n };\n}\n\nexport function parseLeaderboard(j: any[]): LeaderboardEntry[] {\n return j.map((r) => ({ agent: r.agent, launches: r.launches, graduated: r.graduated, score: r.score, feesEth: big(r.feesEth) }));\n}\n\nexport function parseLaunches(j: any[]): LaunchListItem[] {\n return j.map((r) => ({\n token: r.token, agent: r.agent, split: r.split, curve: r.curve, pairToken: r.pairToken,\n name: r.name, symbol: r.symbol, launchedBlock: r.launchedBlock, launchedAt: r.launchedAt,\n recorded: r.recorded, graduated: r.graduated,\n }));\n}\n\nexport function parseHealth(j: any): HealthResult {\n return { ok: j.ok, indexedBlock: bigOrNull(j.indexedBlock), head: big(j.head), lag: bigOrNull(j.lag) };\n}\n\nfunction parseTx(t: any): Tx {\n return { to: t.to, data: t.data, value: big(t.value) };\n}\n\nexport function parseQuote(j: any): QuoteResult {\n return {\n curve: j.curve,\n amountIn: big(j.amountIn),\n amountOut: big(j.amountOut),\n minOut: big(j.minOut),\n feeBps: j.feeBps,\n creatorTaxBps: j.creatorTaxBps,\n snipeTaxBps: j.snipeTaxBps,\n tx: parseTx(j.tx),\n approveTx: j.approveTx ? parseTx(j.approveTx) : null,\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAAoB;AAAA,EAAoB;AAAA,EAAM;AAAA,EAAoB;AAAA,EAAgB;AAAA,OAC7E;AAE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AAY,EAAE,QAAQ,KAAK,QAAQ,MAAM,CAAC,EAAE,CAAC;AACxG,aAAO,EAAE,QAAQ,IAAI,OAAO;AAAA,IAC9B;AAEA,UAAM,UAAU,KAAK,QAAS;AAC9B,UAAM,QAAQ,MAAM,WAAuB,KAAK,QAAQ,YAAY,EAAE,MAAM,EAAE,OAAO,QAAQ,EAAE,CAAC;AAChG,UAAM,UAAU,MAAM,KAAK,UAAU,MAAM,EAAE;AAC7C,WAAO,EAAE,QAAQ,QAAQ,gBAAgB;AAAA,EAC3C;AAAA,EAEA,MAAM,cAAc,OAAgB,UAAgC,CAAC,GAA4B;AAC/F,UAAM,YAAY,QAAQ,aAAa;AACvC,UAAM,aAAa,QAAQ,cAAc;AACzC,UAAM,WAAW,KAAK,IAAI,IAAI;AAC9B,UAAM,SAAS,MAAM,YAAY;AAEjC,eAAS;AACP,YAAM,OAAO,MAAM,KAAK,SAAS,EAAE,OAAO,IAAI,CAAC;AAC/C,YAAM,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,MAAM,YAAY,MAAM,MAAM;AAC7D,UAAI,KAAK,SAAU,QAAO;AAC1B,UAAI,KAAK,IAAI,KAAK,UAAU;AAC1B,cAAM,IAAI,UAAU,yBAAyB,KAAK,mBAAmB,GAAG;AAAA,MAC1E;AACA,YAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,UAAU,CAAC;AAAA,IAChE;AAAA,EACF;AACF;AAEO,SAAS,WAAW,UAA6B,CAAC,GAAS;AAChE,SAAO,IAAI,KAAK,OAAO;AACzB;","names":[]}
1
+ {"version":3,"sources":["../src/client.ts","../src/chain.ts","../src/abi.ts","../src/errors.ts","../src/http.ts","../src/parse.ts"],"sourcesContent":["import {\n createPublicClient, createWalletClient, http, encodeFunctionData, decodeEventLog, zeroAddress,\n} from 'viem';\nimport type { Address, Hex } from 'viem';\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { addresses, defineDivyChain } from './chain.js';\nimport { curveAbi, factoryTokenLaunchedAbi } from './abi.js';\nimport { DivyError } from './errors.js';\nimport { apiRequest } from './http.js';\nimport {\n parseAgentRecord, parseHealth, parseInfo, parseLaunches, parseLeaderboard, parseQuote,\n} from './parse.js';\nimport type {\n AgentRecord, BuyParams, CreateDivyOptions, CreateHostedAgentParams, CreateHostedAgentResult, DivyMode, HarvestResult, HealthResult, InfoResult,\n LaunchListItem, LaunchParams, LaunchResult, LeaderboardEntry, QuoteParams, QuoteResult, RecordResult,\n RegisterResult, SellParams, TradeResult, Tx, WaitForRecordOptions,\n} from './types.js';\n\nconst PRIVATE_KEY_RE = /^0x[0-9a-fA-F]{64}$/;\nconst BPS_DENOM = 10000n;\n\nfunction readAmount(amount: bigint | string): bigint {\n return typeof amount === 'bigint' ? amount : BigInt(amount);\n}\n\nexport class Divy {\n readonly mode: DivyMode;\n readonly apiUrl: string;\n\n private readonly apiKey?: string;\n private readonly account?: ReturnType<typeof privateKeyToAccount>;\n // viem's client generics resist a clean stored type across the three constructor branches;\n // both are only ever touched through sendLocal(), which fixes the call shape in one place.\n private readonly wallet?: any;\n private readonly pub?: any;\n private readonly chain?: ReturnType<typeof defineDivyChain>;\n\n constructor(options: CreateDivyOptions) {\n const hasPrivateKey = 'privateKey' in options && options.privateKey !== undefined;\n const hasApiKey = 'apiKey' in options && options.apiKey !== undefined;\n if (hasPrivateKey && hasApiKey) {\n throw new Error('pass either privateKey or apiKey to createDivy, not both');\n }\n\n this.apiUrl = options.apiUrl ?? addresses.apiUrl;\n\n if (hasPrivateKey) {\n const { privateKey, rpcUrl } = options as { privateKey: Hex; rpcUrl?: string };\n if (!PRIVATE_KEY_RE.test(privateKey)) {\n throw new Error('privateKey must be a 0x-prefixed 32-byte hex string');\n }\n this.mode = 'self-custody';\n this.account = privateKeyToAccount(privateKey);\n this.chain = defineDivyChain(rpcUrl ?? addresses.rpcUrl);\n const transport = http(rpcUrl ?? addresses.rpcUrl);\n this.wallet = createWalletClient({ account: this.account, chain: this.chain, transport });\n this.pub = createPublicClient({ chain: this.chain, transport });\n } else if (hasApiKey) {\n const { apiKey } = options as { apiKey: string };\n if (typeof apiKey !== 'string' || apiKey.length === 0) {\n throw new Error('apiKey must be a non-empty string');\n }\n this.mode = 'hosted';\n this.apiKey = apiKey;\n } else {\n this.mode = 'read-only';\n }\n }\n\n private requireSigner(action: string): void {\n if (this.mode === 'read-only') {\n throw new Error(`${action} requires a privateKey (self-custody) or apiKey (hosted) — this client is read-only`);\n }\n }\n\n private async sendLocal(tx: Tx) {\n if (!this.wallet || !this.pub || !this.account) throw new Error('self-custody wallet is not configured');\n const hash = await this.wallet.sendTransaction({\n account: this.account, chain: this.chain, to: tx.to, data: tx.data, value: tx.value,\n });\n const receipt = await this.pub.waitForTransactionReceipt({ hash });\n if (receipt.status !== 'success') throw new Error(`transaction reverted on-chain: ${hash}`);\n return receipt;\n }\n\n async buildTx<T = Record<string, unknown>>(path: string, body?: object): Promise<T> {\n return apiRequest<T>(this.apiUrl, path, { body: body ?? {} });\n }\n\n async info(): Promise<InfoResult> {\n return parseInfo(await apiRequest(this.apiUrl, '/'));\n }\n\n async agent(address?: Address): Promise<AgentRecord> {\n if (!address) {\n if (this.mode === 'hosted') {\n return parseAgentRecord(await apiRequest(this.apiUrl, '/me', { apiKey: this.apiKey }));\n }\n if (this.mode === 'self-custody' && this.account) {\n address = this.account.address;\n } else {\n throw new Error('agent() requires an address in read-only mode');\n }\n }\n return parseAgentRecord(await apiRequest(this.apiUrl, `/agents/${address}`));\n }\n\n async leaderboard(): Promise<LeaderboardEntry[]> {\n return parseLeaderboard(await apiRequest(this.apiUrl, '/leaderboard'));\n }\n\n async launches(options: { limit?: number } = {}): Promise<LaunchListItem[]> {\n const qs = options.limit ? `?limit=${options.limit}` : '';\n return parseLaunches(await apiRequest(this.apiUrl, `/launches${qs}`));\n }\n\n async health(): Promise<HealthResult> {\n return parseHealth(await apiRequest(this.apiUrl, '/health'));\n }\n\n // Creates a fresh hosted wallet on the API. Needs no credential, so an agent can bootstrap\n // itself from a read-only client, then continue with createDivy({ apiKey }).\n async createHostedAgent(params: CreateHostedAgentParams = {}): Promise<CreateHostedAgentResult> {\n const body: Record<string, unknown> = {};\n if (params.payout) body.payout = params.payout;\n if (params.label) body.label = params.label;\n return apiRequest<CreateHostedAgentResult>(this.apiUrl, '/agents', { body });\n }\n\n async register(): Promise<RegisterResult> {\n this.requireSigner('register');\n\n if (this.mode === 'hosted') {\n const me = await apiRequest<{ registered: boolean; split: Address | null }>(this.apiUrl, '/me', { apiKey: this.apiKey });\n if (me.registered) return { registered: true, split: me.split };\n return { registered: false, split: null };\n }\n\n const address = this.account!.address;\n const first = await apiRequest<{ registered: boolean; split: Address; tx?: Tx }>(this.apiUrl, '/agents', {\n body: { address },\n });\n if (first.registered) return { registered: true, split: first.split };\n\n const receipt = await this.sendLocal({ to: first.tx!.to, data: first.tx!.data, value: BigInt(first.tx!.value ?? 0) });\n const after = await apiRequest<{ registered: boolean; split: Address }>(this.apiUrl, '/agents', { body: { address } });\n return { registered: after.registered, split: after.split, txHash: receipt.transactionHash };\n }\n\n async quote(params: QuoteParams): Promise<QuoteResult> {\n let recipient = params.recipient;\n if (!recipient && this.mode === 'self-custody' && this.account) recipient = this.account.address;\n return parseQuote(\n await apiRequest(this.apiUrl, '/quote', {\n body: {\n curve: params.curve, token: params.token, side: params.side,\n amount: readAmount(params.amount).toString(), recipient: recipient ?? zeroAddress,\n },\n }),\n );\n }\n\n async launch(params: LaunchParams): Promise<LaunchResult> {\n this.requireSigner('launch');\n\n if (this.mode === 'hosted') {\n const out = await apiRequest<{ token: Address; curve: Address; txHash: Hex }>(this.apiUrl, '/launch', {\n apiKey: this.apiKey, body: params,\n });\n return { token: out.token, curve: out.curve, txHash: out.txHash };\n }\n\n const address = this.account!.address;\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/launch', { body: { ...params, agent: address } });\n const receipt = await this.sendLocal(built.tx);\n\n let launched: { token: Address; curve: Address } | undefined;\n for (const log of receipt.logs) {\n try {\n const ev = decodeEventLog({ abi: factoryTokenLaunchedAbi, data: log.data, topics: log.topics });\n if (ev.eventName === 'TokenLaunched') { launched = ev.args as { token: Address; curve: Address }; break; }\n } catch { /* not a TokenLaunched log */ }\n }\n if (!launched) throw new Error(`launch mined (${receipt.transactionHash}) but no TokenLaunched event was found`);\n\n const result: LaunchResult = { token: launched.token, curve: launched.curve, txHash: receipt.transactionHash };\n try {\n const recorded = await this.record(launched.token);\n result.recordTxHash = recorded.txHash;\n } catch (e) {\n result.recordError = e instanceof Error ? e.message : String(e);\n }\n return result;\n }\n\n async record(token: Address): Promise<RecordResult> {\n if (this.mode !== 'self-custody') {\n throw new Error(\n 'record() requires self-custody (a privateKey): hosted and read-only launches are recorded '\n + 'automatically by Divy\\'s keeper within about a minute — use waitForRecord() to wait for it',\n );\n }\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/record', { body: { token } });\n const receipt = await this.sendLocal(built.tx);\n return { txHash: receipt.transactionHash };\n }\n\n async buy(params: BuyParams): Promise<TradeResult> {\n return this.trade('buy', readAmount(params.amountWei), params);\n }\n\n async sell(params: SellParams): Promise<TradeResult> {\n return this.trade('sell', readAmount(params.amountTokens), params);\n }\n\n private async trade(side: 'buy' | 'sell', amount: bigint, params: BuyParams | SellParams): Promise<TradeResult> {\n this.requireSigner(side);\n const slippageBps = params.slippageBps ?? 100;\n\n if (this.mode === 'hosted') {\n if (slippageBps !== 100) {\n throw new Error('slippageBps is not configurable in hosted mode: /trade hardcodes a 1% (100bps) slippage floor');\n }\n const out = await apiRequest<{ txHash: Hex; amountOut: string }>(this.apiUrl, '/trade', {\n apiKey: this.apiKey, body: { curve: params.curve, token: params.token, side, amount: amount.toString() },\n });\n return { txHash: out.txHash, amountOut: BigInt(out.amountOut) };\n }\n\n const address = this.account!.address;\n const q = await this.quote({ curve: params.curve, token: params.token, side, amount, recipient: address });\n\n let tradeTx = q.tx;\n if (slippageBps !== 100) {\n const minOut = (q.amountOut * (BPS_DENOM - BigInt(slippageBps))) / BPS_DENOM;\n const data = encodeFunctionData({ abi: curveAbi, functionName: side, args: [q.amountIn, minOut, address] });\n tradeTx = { ...q.tx, data };\n }\n\n if (q.approveTx) await this.sendLocal(q.approveTx);\n const receipt = await this.sendLocal(tradeTx);\n return { txHash: receipt.transactionHash, amountOut: q.amountOut };\n }\n\n async harvest(): Promise<HarvestResult> {\n this.requireSigner('harvest');\n\n if (this.mode === 'hosted') {\n const out = await apiRequest<{ txHash: Hex }>(this.apiUrl, '/harvest', { apiKey: this.apiKey, body: {} });\n return { txHash: out.txHash };\n }\n\n const address = this.account!.address;\n const built = await apiRequest<{ tx: Tx }>(this.apiUrl, '/harvest', { body: { agent: address } });\n const receipt = await this.sendLocal(built.tx);\n return { txHash: receipt.transactionHash };\n }\n\n async waitForRecord(token: Address, options: WaitForRecordOptions = {}): Promise<LaunchListItem> {\n const timeoutMs = options.timeoutMs ?? 60_000;\n const intervalMs = options.intervalMs ?? 3_000;\n const deadline = Date.now() + timeoutMs;\n const wanted = token.toLowerCase();\n\n for (;;) {\n const rows = await this.launches({ limit: 200 });\n const row = rows.find((r) => r.token.toLowerCase() === wanted);\n if (row?.recorded) return row;\n if (Date.now() >= deadline) {\n throw new DivyError(`timed out waiting for ${token} to be recorded`, 408);\n }\n await new Promise((resolve) => setTimeout(resolve, intervalMs));\n }\n }\n}\n\nexport function createDivy(options: CreateDivyOptions = {}): Divy {\n return new Divy(options);\n}\n","import { defineChain } from 'viem';\nimport type { Address } from 'viem';\n\nexport const CHAIN_ID = 4663;\nexport const DEFAULT_RPC_URL = 'https://rpc.mainnet.chain.robinhood.com';\nexport const DEFAULT_API_URL = 'https://divy-api-j8di.onrender.com';\nexport const EXPLORER_URL = 'https://robinhoodchain.blockscout.com';\n\nexport const addresses = {\n chainId: CHAIN_ID,\n registry: '0x0fEf638d8C88e6eD38eDcD9aB21BF39D083c8B1b' as Address,\n factory: '0x7eD598BcEf8bd9Edd8C97A195C6d13f40801EC7e' as Address,\n escrow: '0xd3AFEB2a57f70eF218Aa82451c51B2fb0416Ac9e' as Address,\n rpcUrl: DEFAULT_RPC_URL,\n apiUrl: DEFAULT_API_URL,\n explorerUrl: EXPLORER_URL,\n} as const;\n\nexport function defineDivyChain(rpcUrl: string = DEFAULT_RPC_URL) {\n return defineChain({\n id: CHAIN_ID,\n name: 'robinhood-chain',\n nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },\n rpcUrls: { default: { http: [rpcUrl] } },\n blockExplorers: { default: { name: 'Blockscout', url: EXPLORER_URL } },\n });\n}\n\nexport function explorerTx(hash: string): string {\n return `${EXPLORER_URL}/tx/${hash}`;\n}\n\nexport function explorerAddress(address: string): string {\n return `${EXPLORER_URL}/address/${address}`;\n}\n","// Minimal ABIs: the API returns pre-encoded {to, data, value} for every write, so the SDK\n// only needs to encode locally when overriding the API's default 1% slippage floor, and to\n// decode the TokenLaunched event off a launch receipt.\n\nexport const curveAbi = [\n {\n type: 'function',\n name: 'buy',\n stateMutability: 'payable',\n inputs: [\n { name: 'quoteIn', type: 'uint256' },\n { name: 'minTokensOut', type: 'uint256' },\n { name: 'recipient', type: 'address' },\n ],\n outputs: [{ name: 'tokensOut', type: 'uint256' }],\n },\n {\n type: 'function',\n name: 'sell',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'tokensIn', type: 'uint256' },\n { name: 'minQuoteOut', type: 'uint256' },\n { name: 'recipient', type: 'address' },\n ],\n outputs: [{ name: 'quoteOut', type: 'uint256' }],\n },\n] as const;\n\nexport const factoryTokenLaunchedAbi = [\n {\n type: 'event',\n name: 'TokenLaunched',\n inputs: [\n { indexed: true, name: 'token', type: 'address' },\n { indexed: true, name: 'curve', type: 'address' },\n { indexed: true, name: 'deployer', type: 'address' },\n { indexed: false, name: 'pairToken', type: 'address' },\n { indexed: false, name: 'launchConfigId', type: 'uint256' },\n { indexed: false, name: 'graduationThreshold', type: 'uint256' },\n ],\n },\n] as const;\n","export class DivyError extends Error {\n readonly status: number;\n\n constructor(message: string, status: number) {\n super(message);\n this.name = 'DivyError';\n this.status = status;\n }\n}\n","import { DivyError } from './errors.js';\n\nconst stringify = (body: unknown): string =>\n JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value));\n\nexport interface RequestOptions {\n method?: 'GET' | 'POST' | 'PATCH';\n body?: unknown;\n apiKey?: string;\n}\n\nexport async function apiRequest<T = unknown>(apiUrl: string, path: string, options: RequestOptions = {}): Promise<T> {\n const headers: Record<string, string> = {};\n if (options.body !== undefined) headers['content-type'] = 'application/json';\n if (options.apiKey) headers.authorization = `Bearer ${options.apiKey}`;\n\n const res = await fetch(`${apiUrl}${path}`, {\n method: options.method ?? (options.body !== undefined ? 'POST' : 'GET'),\n headers,\n body: options.body !== undefined ? stringify(options.body) : undefined,\n });\n\n const text = await res.text();\n let json: any;\n try {\n json = text ? JSON.parse(text) : {};\n } catch {\n // A gateway or proxy in front of the API (Render, Cloudflare, ...) can return an HTML\n // error page instead of JSON, typically on a 502/504 while the API is cold-starting or down.\n throw new DivyError(`${apiUrl} returned a non-JSON response (HTTP ${res.status} ${res.statusText}): the API may be down or restarting`, res.status);\n }\n if (!res.ok) {\n throw new DivyError(typeof json.error === 'string' ? json.error : res.statusText, res.status);\n }\n return json as T;\n}\n","import type {\n AgentLaunch, AgentRecord, HealthResult, InfoResult, LaunchListItem, LeaderboardEntry, QuoteResult, Tx,\n} from './types.js';\n\nconst big = (v: unknown): bigint => BigInt(v as string);\nconst bigOrNull = (v: unknown): bigint | null => (v === null || v === undefined ? null : big(v));\n\nexport function parseInfo(j: any): InfoResult {\n return {\n chain: j.chain,\n registry: j.registry,\n factory: j.factory,\n escrow: j.escrow,\n hostedWallets: j.hostedWallets,\n feePolicy: {\n treasury: j.feePolicy.treasury,\n divyBps: j.feePolicy.divyBps === null || j.feePolicy.divyBps === undefined ? null : Number(j.feePolicy.divyBps),\n agentShareOfBaseFee: j.feePolicy.agentShareOfBaseFee,\n ponsShare: j.feePolicy.ponsShare,\n divyShare: j.feePolicy.divyShare,\n },\n launchFee: { wei: big(j.launchFee.wei), eth: j.launchFee.eth },\n maxCreatorTaxBps: j.maxCreatorTaxBps,\n economics: j.economics,\n indexedBlock: bigOrNull(j.indexedBlock),\n keeper: j.keeper,\n };\n}\n\nfunction parseAgentLaunch(l: any): AgentLaunch {\n return {\n token: l.token,\n symbol: l.symbol,\n name: l.name,\n curve: l.curve,\n pairToken: l.pairToken,\n graduated: l.graduated,\n launchedAt: l.launchedAt,\n recorded: l.recorded,\n retention: l.retention ?? null, retentionProvisional: l.retentionProvisional ?? false,\n earlyHolders: l.earlyHolders ?? null, retained: l.retained ?? null,\n };\n}\n\nexport function parseAgentRecord(j: any): AgentRecord {\n return {\n agent: j.agent,\n split: j.split,\n registered: j.registered,\n record: { launches: big(j.record.launches), graduated: big(j.record.graduated), score: j.record.score, graduationRate: j.record.graduationRate ?? j.record.score },\n fees: { agentEth: big(j.fees.agentEth), divyEth: big(j.fees.divyEth), pendingEscrowEth: big(j.fees.pendingEscrowEth) },\n launches: j.launches.map(parseAgentLaunch),\n ...(j.balanceEth !== undefined ? { balanceEth: j.balanceEth } : {}),\n ...(j.payout !== undefined ? { payout: j.payout } : {}),\n ...(j.label !== undefined ? { label: j.label } : {}),\n };\n}\n\nexport function parseLeaderboard(j: any[]): LeaderboardEntry[] {\n return j.map((r) => ({\n agent: r.agent, launches: r.launches, graduated: r.graduated, score: r.score,\n graduationRate: r.graduationRate ?? r.score, retention: r.retention ?? null,\n retentionProvisional: r.retentionProvisional ?? false, feesEth: big(r.feesEth),\n }));\n}\n\nexport function parseLaunches(j: any[]): LaunchListItem[] {\n return j.map((r) => ({\n token: r.token, agent: r.agent, split: r.split, curve: r.curve, pairToken: r.pairToken,\n name: r.name, symbol: r.symbol, launchedBlock: r.launchedBlock, launchedAt: r.launchedAt,\n recorded: r.recorded, graduated: r.graduated,\n retention: r.retention ?? null, retentionProvisional: r.retentionProvisional ?? false,\n earlyHolders: r.earlyHolders ?? null, retained: r.retained ?? null,\n }));\n}\n\nexport function parseHealth(j: any): HealthResult {\n return { ok: j.ok, indexedBlock: bigOrNull(j.indexedBlock), head: big(j.head), lag: bigOrNull(j.lag) };\n}\n\nfunction parseTx(t: any): Tx {\n return { to: t.to, data: t.data, value: big(t.value) };\n}\n\nexport function parseQuote(j: any): QuoteResult {\n return {\n curve: j.curve,\n amountIn: big(j.amountIn),\n amountOut: big(j.amountOut),\n minOut: big(j.minOut),\n feeBps: j.feeBps,\n creatorTaxBps: j.creatorTaxBps,\n snipeTaxBps: j.snipeTaxBps,\n tx: parseTx(j.tx),\n approveTx: j.approveTx ? parseTx(j.approveTx) : null,\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAAoB;AAAA,EAAoB;AAAA,EAAM;AAAA,EAAoB;AAAA,EAAgB;AAAA,OAC7E;AAEP,SAAS,2BAA2B;;;ACJpC,SAAS,mBAAmB;AAGrB,IAAM,WAAW;AACjB,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AACxB,IAAM,eAAe;AAErB,IAAM,YAAY;AAAA,EACvB,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,aAAa;AACf;AAEO,SAAS,gBAAgB,SAAiB,iBAAiB;AAChE,SAAO,YAAY;AAAA,IACjB,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,gBAAgB,EAAE,MAAM,SAAS,QAAQ,OAAO,UAAU,GAAG;AAAA,IAC7D,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE;AAAA,IACvC,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,KAAK,aAAa,EAAE;AAAA,EACvE,CAAC;AACH;AAEO,SAAS,WAAW,MAAsB;AAC/C,SAAO,GAAG,YAAY,OAAO,IAAI;AACnC;AAEO,SAAS,gBAAgB,SAAyB;AACvD,SAAO,GAAG,YAAY,YAAY,OAAO;AAC3C;;;A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MAAM,CAAC,EAAE,CAAC;AACxG,aAAO,EAAE,QAAQ,IAAI,OAAO;AAAA,IAC9B;AAEA,UAAM,UAAU,KAAK,QAAS;AAC9B,UAAM,QAAQ,MAAM,WAAuB,KAAK,QAAQ,YAAY,EAAE,MAAM,EAAE,OAAO,QAAQ,EAAE,CAAC;AAChG,UAAM,UAAU,MAAM,KAAK,UAAU,MAAM,EAAE;AAC7C,WAAO,EAAE,QAAQ,QAAQ,gBAAgB;AAAA,EAC3C;AAAA,EAEA,MAAM,cAAc,OAAgB,UAAgC,CAAC,GAA4B;AAC/F,UAAM,YAAY,QAAQ,aAAa;AACvC,UAAM,aAAa,QAAQ,cAAc;AACzC,UAAM,WAAW,KAAK,IAAI,IAAI;AAC9B,UAAM,SAAS,MAAM,YAAY;AAEjC,eAAS;AACP,YAAM,OAAO,MAAM,KAAK,SAAS,EAAE,OAAO,IAAI,CAAC;AAC/C,YAAM,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,MAAM,YAAY,MAAM,MAAM;AAC7D,UAAI,KAAK,SAAU,QAAO;AAC1B,UAAI,KAAK,IAAI,KAAK,UAAU;AAC1B,cAAM,IAAI,UAAU,yBAAyB,KAAK,mBAAmB,GAAG;AAAA,MAC1E;AACA,YAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,UAAU,CAAC;AAAA,IAChE;AAAA,EACF;AACF;AAEO,SAAS,WAAW,UAA6B,CAAC,GAAS;AAChE,SAAO,IAAI,KAAK,OAAO;AACzB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "divy-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Typed TypeScript SDK for Divy: register agents, launch tokens on Pons, trade, and harvest fees on Robinhood Chain.",
5
5
  "license": "MIT",
6
6
  "type": "module",