- Supply wFiat and access yield: borrowers pay interest, and returns accrue in local currency stablecoins, depending on borrowing demand.
- Borrow wFiat against USDC, ETH or BTC: users receive wARS or wBRL without selling their collateral, and can off-ramp them to ARS or BRL with Ripio’s Ramps API.
Ripio doesn’t operate, administer or guarantee CapyFi. It is a third-party protocol with its own smart contracts, price oracle and risk parameters, which its administrators can change. Read the risks before you offer it to your users.
How it works
1
Suppliers deposit into a market
Each asset has a market, the caToken contract. Supplying wARS to the caWARS market mints caWARS to the supplier.
2
Borrowers post collateral and borrow
A borrower supplies an asset with a collateral factor, such as USDC, enables it as collateral, and borrows wARS up to their borrow limit. Interest on the debt accrues every block.
3
Borrower interest accrues to the market
caTokens don’t rebase: each caToken is redeemable for more of the underlying asset over time, as borrowers pay interest. Suppliers redeem their caTokens for the underlying, including accrued interest, subject to the market’s available liquidity.
4
Undercollateralized accounts get liquidated
If the value of a borrower’s debt rises above their borrow limit, liquidators can repay part of it and seize the borrower’s collateral at a discount.
wFiat markets have a collateral factor of 0: you can supply and borrow wARS and wBRL, but they don’t add to a user’s borrow limit. To borrow, users post USDC, ETH or BTC.
Markets
The underlying wARS and wBRL use the same address on every chain (see Contracts), with 18 decimals; caTokens have 8 decimals. The Comptrollers on Ethereum and Base also list wMXN and wCOP markets, and the World Chain wBRL market isn’t on CapyFi’s Networks page yet: all of them are listed on-chain. Read
getAllMarkets() on the Comptroller for the live list, and CapyFi’s Networks page for the other contracts.
At the time of writing, collateral factors for these assets range from 80% to 85%. Read each one with
markets(caToken) on the Comptroller instead of hardcoding it. The Ethereum Comptroller also lists a legacy caETH market (0xbaA6bc4E24686d710B9318B49b0Bb16ec7C46bFA) with supply and borrows paused: use 0x37DE57183491Fa9745d8Fa5DCd950f0c3a4645c9, and don’t pick markets from getAllMarkets() by symbol alone.
Choose your integration
Link out
Send users to the CapyFi app. No code, but users leave your product.
Direct contract calls
Call the caToken and Comptroller contracts from your app or backend. Full control; this recipe shows it with viem.
Recipe
The examples below use viem on Base, where gas costs are low. The same calls work on Ethereum and World Chain: change the chain, the Comptroller and the caToken addresses.0. Setup, constants and ABI
send checks both before it sends anything. The snippets in the next steps import from these files.
1. Get wFiat on Base
- Buy it: deliver wARS or wBRL to the user’s wallet on Base with Ramps, if Base is supported for that token (see Get Withdrawal Networks) (see the on/off-ramp recipe for Privy wallets) or Crypto as a Service.
- Swap it: from USDC or any other token, on any chain, with the LI.FI recipe.
- Bridge it: from any other supported chain to Base (chain id
8453) with the Ripio Bridge.
2. Show rates and available liquidity
Rates are per block, so convert them with the market’sblocksPerYear. Block times differ per chain: the rate models report 2,628,000 blocks per year on Ethereum and 15,768,000 on Base and World Chain.
market.ts
A caToken can also have a Whitelist contract: while its
isActive() returns true, only whitelisted addresses can supply, borrow or hold that caToken. The wFiat markets don’t set one today; read whitelist() on the caToken before you show a market.
Values are decimals: 0.05 means 5%. Rates move with utilization, so refresh them before every action and never present them as fixed.
3. Supply wFiat
The user approves the caToken on the wFiat token and callsmint. caTokens are minted to the caller.
supply.ts
mintTokens from the receipt, not an amount computed from the exchange rate before sending.
4. Borrow wFiat against USDC
The user supplies USDC, enables it as collateral withenterMarkets, and borrows wARS. The borrow limit is the sum of each collateral’s USD value times its collateral factor, and getAccountLiquidity returns what’s left of it in USD.
borrow.ts
mint() on the caETH market with value set, and enter that market. For BTC, use the caCBBTC market on Base or caWBTC on Ethereum and World Chain.
Cash out the loan. To turn the borrowed wARS into pesos in a bank account, send them to Ripio with an off-ramp. Check that the token is rampable from Base with Get Deposit Networks, or bridge it to a chain that is.
5. Track the position
position.ts
borrowLimitUsed assumes wARS is the account’s only debt: with several borrowed assets, add the USD value of each. A non-zero shortfall means the account can be liquidated now. Liquidators can repay up to the close factor of a debt (50% at the time of writing) and seize collateral worth that amount plus the liquidation incentive (8% at the time of writing). Read both from the Comptroller with closeFactorMantissa() and liquidationIncentiveMantissa().
A user who supplies wFiat and borrows in the same account puts that wFiat at risk too: a collateral factor of 0 means it doesn’t add to the borrow limit, but liquidators can still seize it once the account is in shortfall.
6. Repay
repay.ts
repayBorrowBehalf(borrower, amount) on the caToken to repay a debt from another address, for example from your treasury.
7. Withdraw
withdraw.ts
redeemUnderlying(amount) to withdraw an exact amount of wFiat instead. A withdrawal fails when:
- The market doesn’t have enough cash. Suppliers can only withdraw what isn’t lent out. When utilization is high, they wait for borrowers to repay or for rates to attract new supply.
- It would leave a debt undercollateralized. Collateral can only be withdrawn down to what the outstanding debt needs: repay first.
WhitelistAccess: not whitelisted if the market’s whitelist is active and the address isn’t on it.
Rewards
CapyFi runs incentive campaigns through Merkle-based distributions: entitlements are computed off-chain per campaign for the address that supplies or borrows, and claimed separately from the market contracts with a Merkle proof served by CapyFi. Today the RewardsDistributor is deployed only on Ethereum. See CapyFi’s Rewards page for how to claim. Label rewards as a temporary incentive, separate from the market’s supply rate.Risks to disclose to your users
- Issuer and peg risk. wARS and wBRL are issued by Ripio and depend on its reserves backing them. The protocol values them with its price oracle, which may not reflect their market price. A depeg can affect liquidations and the value of positions.
- Smart contract risk. Bugs in the caTokens, the Comptroller or the oracle can cause losses. CapyFi reports audits by OpenZeppelin and Coinspect, but audits don’t remove the risk.
- Bad debt risk. If collateral prices drop faster than liquidations execute, a market can accrue bad debt that its suppliers absorb, and they may not get back everything they supplied.
- Liquidation risk. Borrowers lose part of their collateral if their account goes into shortfall, for example because the collateral price drops or the local currency appreciates against the dollar.
- Oracle risk. Collateral and debt are valued with CapyFi’s price oracle, which the protocol’s administrators can replace. An incorrect price can trigger liquidations or let accounts borrow more than they should.
- Currency risk. wARS and wBRL track the ARS and BRL. Supply returns accrue in local currency stablecoins, so their value in USD moves with the exchange rate, and so does the value of a wFiat debt.
- Withdrawal liquidity. Suppliers can withdraw only the cash in the market. At high utilization, a withdrawal can have to wait until borrowers repay.
- Governance and pause risk. Administrators can change collateral factors, borrow caps, interest rate models and the oracle, can pause supply or borrows on a market, and can restrict a market to whitelisted addresses.
- Variable rates. Supply and borrow rates depend on utilization and can change every block. Incentive rewards are temporary.
Resources
- CapyFi docs: caTokens, Comptroller, Price Feed and Networks
- CompoundLens, to read every market or an account’s limits in one call
- wFiat contracts and networks
- Ripio Bridge developer guide
- Off-ramp integration guide