Query editor
/* [Sumcap] NEOBANKING - Ethena Pay weekly P&L (CAC vs LTV), v4.3 2026-11-01One query per card, standard layout (PROJECTS/NEOBANKING/03_DATA/CAC_LTV_PLAN.md).Decisions: PROJECTS/NEOBANKING/03_DATA/CARDS/ETHENA_PAY.md.v4.3 (2026-11-01, Sumcap): Earn+ vault 0x6aab14c5 (Ethena TokenizedVault, receipt pUSDe0xcb5c7b86, launched 2026-10-28) is part of the app. USDe moved between app accounts and thevault no longer counts as external flow, so AUM keeps Earn+ principal (before, about $4.2M ofdeposits in the week of 26 Oct would have read as money leaving). New columns at the end:earn_deposits_usd, earn_withdrawals_usd, avg_earn_aum_usd. Earn+ yield is paid by the vault'sstrategy, not by Ethena Pay's payers, so it is not a cost here. Weeks before 2026-09-22 areidentical to v4.2; 22 Sep to 19 Oct move by under 2% of AUM.v4.2 (2026-10-10, Sumcap): the window end is no longer hardcoded. It runs from 2026-06-01to the last full Monday to Sunday week before the day of the run (end, exclusive =date_trunc('week', current_date)). Weeks up to 2026-09-21 are identical to v4.1.v4 (audit, Noa OK'd fixes): second USDe payer 0xab2b06ef (Safe, weekly batches, likely theUSDe base rate) added to yield paid; USDe sent by 0xd0ec8cc7 to anything other than appaccounts (the Merkl feeRecipient via wrapper 0x9adb63ad) counted as a separate cost.Revenue stays sUSDe APY, now labelled an UPPER BOUND (Ethena earns less on unstaked USDe).v4.1: Merkl fee read from a payer-filtered transfer read (v4 re-read the tagged set andtimed out).v3 (Noa): no inputs, window hardcoded 2026-06-01 to 2026-09-27 (full weeks; first account2026-06-10); CAC columns NEGATIVE so they chart below zero.v2 (Noa): cashback counts as CAC; yield rate from sUSDe onchain instead of a parameter.LTV side:revenue (upper bound) = end-of-day AUM x sUSDe 7-day APY / 365. sUSDe share price per day= sum(assets) / sum(shares) over StakedUSDeV2 Deposit + Withdraw events (Ethereum);APY = (price / price 7 days earlier)^(365/7) - 1.yield paid = USDe sent to app accounts by 0xd0ec8cc7 (boost, Merkl-fed) and 0xab2b06ef(base rate), negative. Merkl fee = USDe from 0xd0ec8cc7 to non-account addresses.CAC side (negative): AVAX cashback (payers 0x37dea6fe, 0xfdc9d265, native AVAX via traces,daily WAVAX price) + card issuance $0.10 per new spender (virtual card, Stripe reference).The $30 AVAX referral and $30 waitlist bonus are not identified yet (referral pays within30 days, so likely from October); payouts_29_31 columns flag candidates.Not included: gas sponsorship (ERC-4337), offchain ATM / late / transfer fees.AUM = running sum of external USDe flows into app accounts from 2026-06-01 (yield payoutsincluded: that USDe sits in accounts and backs Ethena's yield). Since v4.3 this includesUSDe held in Earn+ (principal moved in, less principal moved out).Users: spender = app account debiting USDe into RainCollateral proxy 0x6070848b.returning = spent this week and in an earlier week inside the window.Interchange excluded by rule.Logic reused from team queries 8615969, 8615977, 8645782 (not modified). */with proxies as (select addressfrom avalanche_c.creation_traceswhere block_month >= date '2026-05-01'and bytearray_position(code, 0xc831ea25deb7654679a438c78c4c5d1c313c8448) > 0),xfer as (select evt_block_time as ts, "from" as f, "to" as t, cast(value as double) / 1e18 as amtfrom erc20_avalanche_c.evt_transferwhere contract_address = 0x5d3a1ff2b6bab83b63cd9ad0787074081a52ef34and evt_block_date >= date '2026-06-01'and evt_block_date < date_trunc('week', current_date)),tagged as (select x.ts, x.f, x.t, x.amt,x.t in (select address from proxies) as to_pay,x.f in (select address from proxies) as from_payfrom xfer x),flows as (select * from tagged where to_pay or from_pay),