Credit Accounts

A Credit Account is an isolated smart contract that holds both a user’s own funds and borrowed liquidity. This is where leverage is created and managed. Once a Credit Account is opened, all actions, positions, and assets flow through this account and remain stored within it.

You can think of a Credit Account as an automated, leveraged DeFi wallet. It not only holds your positions, but also allows you to execute complex DeFi strategies in a structured and controlled way. Each user has their own dedicated Credit Account, ensuring isolation between users and positions.

What You Can Do with a Credit Account

Funds held in a Credit Account act as collateral for borrowed funds. Users interact with their Credit Accounts by sending instructions to it, enabling activities such as:

  • Margin trading on decentralized exchanges like Uniswap or SushiSwap

  • Leveraged yield farming through protocols like Yearn

  • Arbitrage strategies on stable or pegged assets using Curve

  • Other advanced DeFi strategies as supported by the protocol

All of these operations are executed directly through the Credit Account.

Built-In Risk Controls

To protect both users and liquidity providers, Credit Accounts operate under two key safety policies:

Allowed Contracts List

Credit Accounts can only interact with approved smart contracts. This prevents funds from being sent to unsafe or malicious contracts and reduces the risk of smart contract exploits.

Allowed Tokens List

Only approved tokens can be used within Credit Accounts. This helps prevent risk scenarios such as:

  • Swapping into extremely volatile assets that could collapse before liquidation

  • Users creating fake or malicious ERC-20 tokens and draining protocol liquidity

Both lists are managed by governance and can expand over time as new assets and protocols are vetted and added.

Modular by Design

StackFi’s architecture is highly modular.

  • Different liquidity pools can exist for the same asset

  • Multiple Credit Managers can operate with different risk parameters

  • Each Credit Manager can have its own Allowed Token and Allowed Contract policies

This flexibility allows StackFi to support a wide range of strategies and user groups while keeping risk segmented. The explanation above is intended for product users; developers should refer to the StackFi developer documentation for technical implementation details.

Gas Efficiency & User Experience

Credit Accounts are designed to be gas efficient.

  • Each user operates through their own Credit Account rather than a shared pool with virtual balances

  • This avoids unnecessary overhead and reduces gas costs

Additionally, Credit Accounts are not deployed as new smart contracts for each user. Instead, they are “borrowed” from the protocol when needed and returned when closed, similar to using a shared resource. This design keeps deployment costs at zero for new users and improves overall efficiency.

How to Close Credit Account

Before you close a Credit Account (farming or margin trading), you must repay your loan and the accrued interest.

Option 1: Swap All Assets to Underlying and Repay the Debt

  • The protocol swaps your non-underlying assets to the underlying asset on DEXes.

  • It repays your debt, and you receive remaining funds in your wallet.

  • Set your slippage tolerance (top-right settings).

  • Click “Swap and Get Tokens.”

  • If price changes beyond the slippage limit, the transaction reverts.

Option 2: Repay the Debt and Keep All Assets

  • You repay the loan from your personal wallet.

  • After repayment, all Credit Account assets go to your wallet.

  • Only works if your wallet holds enough of the denominated debt asset.

Option 3: Keep a 0-Debt Credit Account

  • Great option if expecting airdrops to your Credit Account.

  • Pay off the debt and withdraw assets, but retain the Credit Account.

  • No ongoing fees. You stay liquid and airdrop-eligible.

In summary, Credit Accounts are the core mechanism that enables leverage in StackFi, providing users with a flexible, secure, and capital-efficient way to execute advanced DeFi strategies while maintaining strong risk controls.

Last updated