AGENT SKILL

snapshot-fx-rates-at-posting-time

Use when amounts cross currencies and a ledger must stay reproducible. Stores the FX rate used at the moment of posting and never restates a past conversion with a newer rate.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 81
Forks
17

01 前言 Front Matter

name
snapshot-fx-rates-at-posting-time
description
Use when amounts cross currencies and a ledger must stay reproducible. Stores the FX rate used at the moment of posting and never restates a past conversion with a newer rate.

02 资源文件 3

03 SKILL.md 正文

Snapshot FX rates at posting time

A foreign amount must be converted at the rate in effect when it was posted, then frozen. Recomputing last quarter's total with today's rate changes closed books — a restatement you did not intend.

Procedure

  1. At post time fetch the rate from a named source with a timestamp: {"pair":"EUR/USD","rate":1.0873,"as_of":"2026-10-08T14:00:00Z","source":"ecb"}.
  2. Store the rate and the source and timestamp on the row, alongside the source amount, so the conversion is reproducible without re-querying the feed.
  3. Store the rate as a scaled integer or exact decimal (say 8 dp), never a float: rate_e8 = 108_730_000. Reconstruct as value / 10**8 only for display.
  4. Convert with the snapshot: usd_minor = mulDiv(eur_minor, rate_e8, 10**8), rounded once, for the base-currency figure.
  5. Never join a past transaction to the current rate table; the rate table is a time series and you already captured the point.
  6. If a rate is unavailable, block the post rather than defaulting to a stale value silently; record the gap.
  7. For a base-currency report, sum the stored base amounts (each converted at its own row's rate), not the sum of foreign amounts times today's rate.
  8. Keep both the transaction amount and the base amount; an FX gain/loss report needs the pair.
  9. Store the precision the rate was published to, so a display layer never implies more precision than the source had.
  10. For a revaluation, compute the delta between the posting rate and the closing rate explicitly; a silent restate hides the gain or loss.
  11. Reject a rate of zero or a negative — both are feed errors, not prices.
  12. Version the feed; if a provider corrects history, record that you deliberately kept the original snapshot.

Pitfalls

  • Re-running a report with a live feed produces different totals each day; only the snapshot is authoritative.
  • A timezone-less as_of lets two systems pick different rates for the "same" moment; always store UTC.
  • Using the mid rate when the posting applied a bid/ask or a card-network rate invents a spread; store the rate that was actually applied.
  • A float rate multiplies a float into money; keep the rate exact and the product in integer arithmetic.
  • Round-tripping (EUR -> USD -> EUR) with a single-direction rate loses the spread and drifts; store direction pairs.
  • Fetching the rate inside a transaction that then rolls back can leave the stored snapshot orphaned; fetch, then post, then commit.

Verification

psql -c "SELECT COUNT(*) FROM txn WHERE rate_e8 IS NULL AND currency <> 'USD'"   # expect 0 for posted rows
python3 -c "print((100_00 * 108_730_000) // 10**8)"   # 1.0873 * 100.00 -> reproducible

Pass when every foreign posting carries a rate, source and UTC timestamp. Report the rate source and a reproduced conversion.

04 同仓库更多 Skills

jiayaoqijia
jiayaoqijia/cryptoskill

troves

Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say "Troves" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

trade

Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say "swap".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

staking

Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say "stake" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

send

Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say "pay 10 STRK to 0x...".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

portfolio

View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks "what do I have", "show me everything", "how much am I worth", "my positions", "my investments", "rebalance my portfolio", "I want 50% ETH", "optimize my holdings", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say "portfolio".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

multi-swap

Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions "two swaps", "three swaps", "swap X and Y at the same time", or wants to convert multiple tokens in a single call.

★ 81