Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/earn/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function formatApy(decimal: number, fractionDigits = 2): string {
export function formatCompactUsd(value: string | number): string {
const n = typeof value === "string" ? Number(value) : value
if (!Number.isFinite(n)) return "$0"
if (n === 0) return "$0"
return new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"lint": "eslint .",
"test": "vitest run",
"test:watch": "vitest",
"spend:gateway:arc": "node scripts/spend-arc-gateway-usdc.mjs",
"webhooks:register": "node scripts/register-gateway-webhooks.mjs",
"db:start": "supabase start",
"db:stop": "supabase stop",
Expand Down
67 changes: 67 additions & 0 deletions scripts/spend-arc-gateway-usdc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Copyright 2026 Circle Internet Group, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*/

import { AppKit } from "@circle-fin/app-kit"
import { createCircleWalletsAdapter } from "@circle-fin/adapter-circle-wallets"

export const CIRCLE_API_KEY = process.env.CIRCLE_API_KEY ?? ""
export const CIRCLE_ENTITY_SECRET = process.env.CIRCLE_ENTITY_SECRET ?? ""
export const ARC_SOURCE_ADDRESS =
process.env.ARC_SOURCE_ADDRESS ?? "0x1111111111111111111111111111111111111111"
export const ARC_DELEGATE_ADDRESS =
process.env.ARC_DELEGATE_ADDRESS ?? "0x2222222222222222222222222222222222222222"
export const ARC_RECIPIENT_ADDRESS =
process.env.ARC_RECIPIENT_ADDRESS ?? "0x3333333333333333333333333333333333333333"
export const ARC_SPEND_AMOUNT = process.env.ARC_SPEND_AMOUNT ?? "0.002"

const ARC_CHAIN = "Arc_Testnet"
const TOKEN = "USDC"

const kit = new AppKit()
const adapter = createCircleWalletsAdapter({
apiKey: CIRCLE_API_KEY,
entitySecret: CIRCLE_ENTITY_SECRET,
})

const addDelegateResult = await kit.unifiedBalance.addDelegate({
from: {
adapter,
address: ARC_SOURCE_ADDRESS,
chain: ARC_CHAIN,
},
delegateAddress: ARC_DELEGATE_ADDRESS,
})
console.log(addDelegateResult)

const balancesResult = await kit.unifiedBalance.getBalances({
token: TOKEN,
sources: { address: ARC_SOURCE_ADDRESS },
networkType: "testnet",
})
console.log(JSON.stringify(balancesResult, null, 2))

const spendResult = await kit.unifiedBalance.spend({
from: {
adapter,
address: ARC_DELEGATE_ADDRESS,
sourceAccount: ARC_SOURCE_ADDRESS,
allocations: [{ amount: ARC_SPEND_AMOUNT, chain: ARC_CHAIN }],
},
to: {
chain: ARC_CHAIN,
recipientAddress: ARC_RECIPIENT_ADDRESS,
useForwarder: true,
},
token: TOKEN,
amount: ARC_SPEND_AMOUNT,
})
console.log(spendResult)