Skip to Content
PluginsSpark

Spark

Spark is a decentralized lending protocol built as an Aave V3 fork within the Sky/Maker ecosystem. Users can supply assets to earn interest, borrow against collateral, and deposit DAI into the sDAI savings vault to earn the DAI Savings Rate (DSR). SparkLend uses the same Pool interface as Aave V3 for core lending operations.

Supported chains: Ethereum (all contracts) and Gnosis Chain (lending contracts only, no sDAI). Read-only actions work without credentials. Write actions require a connected wallet.

Actions

ActionTypeCredentialsDescription
Supply AssetWriteWalletSupply an asset to earn interest
Withdraw AssetWriteWalletWithdraw a supplied asset
Borrow AssetWriteWalletBorrow against supplied collateral
Repay DebtWriteWalletRepay a borrowed asset
Set Asset as CollateralWriteWalletEnable or disable a supplied asset as collateral
Deposit DAI to sDAIWriteWalletDeposit DAI into the sDAI vault (DSR)
Redeem sDAI for DAIWriteWalletRedeem sDAI shares for DAI
Get User Account DataReadNoGet overall account health and balances
Get User Reserve DataReadNoGet per-asset position data and rates
Get sDAI BalanceReadNoCheck sDAI balance of an address
Get sDAI Total AssetsReadNoGet total DAI locked in the sDAI vault
Convert sDAI to DAI ValueReadNoPreview sDAI to DAI conversion at current rate

Supply Asset

Supply an asset to the SparkLend lending pool to earn interest. The supplied asset automatically starts accruing interest. Requires prior ERC-20 approval for the Pool contract.

Inputs:

InputTypeDescription
assetaddressAsset Token Address
amountuint256Amount (wei)
onBehalfOfaddressOn Behalf Of Address
referralCodeuint16Referral Code (default: 0)

Outputs: success, transactionHash, transactionLink, error

When to use: Earn yield on idle tokens, automate deposits when conditions are met, build supply strategies based on rate changes.


Withdraw Asset

Withdraw a supplied asset from the SparkLend lending pool. Ensure the withdrawal does not bring the health factor below 1 if the asset is used as collateral.

Inputs:

InputTypeDescription
assetaddressAsset Token Address
amountuint256Amount (wei)
toaddressRecipient Address

Outputs: success, transactionHash, transactionLink, error

When to use: Withdraw funds when needed, automate withdrawals based on rate drops, rebalance collateral positions.


Borrow Asset

Borrow an asset from SparkLend against supplied collateral. Variable rate (mode 2) is the standard borrowing mode.

Inputs:

InputTypeDescription
assetaddressAsset Token Address
amountuint256Amount (wei)
interestRateModeuint256Interest Rate Mode (2=Variable, default: 2)
referralCodeuint16Referral Code (default: 0)
onBehalfOfaddressOn Behalf Of Address

Outputs: success, transactionHash, transactionLink, error

When to use: Borrow stablecoins against volatile assets, leverage positions, automate borrowing based on market conditions.


Repay Debt

Repay a borrowed asset to the SparkLend lending pool. Use type(uint256).max as amount to repay the entire debt.

Inputs:

InputTypeDescription
assetaddressAsset Token Address
amountuint256Amount (wei)
interestRateModeuint256Interest Rate Mode (2=Variable, default: 2)
onBehalfOfaddressOn Behalf Of Address

Outputs: success, transactionHash, transactionLink, error

When to use: Automate debt repayment when health factor drops, repay before liquidation, scheduled debt reduction.


Set Asset as Collateral

Enable or disable a supplied asset as collateral in SparkLend. This toggles the entire supplied balance of the asset — there is no partial collateral in Aave V3/Spark.

Inputs:

InputTypeDescription
assetaddressAsset Token Address
useAsCollateralboolUse as Collateral (toggles entire supplied balance)

Outputs: success, transactionHash, transactionLink, error

When to use: Enable collateral on a newly supplied asset before borrowing, disable collateral to protect an asset from liquidation, automate collateral management based on market conditions.


Deposit DAI to sDAI

Deposit DAI into the sDAI savings vault (ERC-4626) to earn the DAI Savings Rate. Requires prior DAI approval for the sDAI contract. The DSR yield accrues automatically via the exchange rate between sDAI and DAI.

Inputs:

InputTypeDescription
assetsuint256DAI Amount (wei)
receiveraddressReceiver Address

Outputs: success, transactionHash, transactionLink, error

When to use: Park idle DAI in the DSR for risk-free yield, automate DAI savings deposits, build yield farming pipelines.


Redeem sDAI for DAI

Redeem sDAI shares for DAI from the savings vault. The DAI received includes accrued DSR yield based on the current exchange rate.

Inputs:

InputTypeDescription
sharesuint256sDAI Shares (wei)
receiveraddressReceiver Address
owneraddressShare Owner Address

Outputs: success, transactionHash, transactionLink, error

When to use: Exit the DSR to redeploy capital, automate redemptions based on rate changes, withdraw savings for operational use.


Get User Account Data

Get overall account health including total collateral, total debt, available borrow power, and health factor. Base currency values are denominated in USD with 8 decimal precision.

Inputs:

InputTypeDescription
useraddressUser Address

Outputs:

OutputTypeDescription
totalCollateralBaseuint256Total Collateral (base currency), 8 decimals
totalDebtBaseuint256Total Debt (base currency), 8 decimals
availableBorrowsBaseuint256Available Borrows (base currency), 8 decimals
currentLiquidationThresholduint256Liquidation Threshold (basis points)
ltvuint256Loan-to-Value (basis points)
healthFactoruint256Health Factor, 18 decimals (1e18 = 1.0)

When to use: Monitor account health factor for liquidation protection, check borrow capacity before opening new positions, track portfolio-level collateral and debt.


Get User Reserve Data

Get per-asset position data including supplied balance (spToken), stable and variable debt, borrow rates, and whether the asset is used as collateral. Uses the Pool Data Provider contract.

Inputs:

InputTypeDescription
assetaddressAsset Token Address
useraddressUser Address

Outputs:

OutputTypeDescription
currentATokenBalanceuint256Supplied Balance (spToken)
currentStableDebtTokenBalanceuint256Stable Debt Balance
currentVariableDebtTokenBalanceuint256Variable Debt Balance
principalStableDebtuint256Principal Stable Debt
scaledVariableDebtuint256Scaled Variable Debt
stableBorrowRateuint256Stable Borrow Rate (ray), 27 decimals
liquidityRateuint256Supply APY (ray), 27 decimals
stableRateLastUpdateduint40Stable Rate Last Updated (timestamp)
usageAsCollateralEnabledboolWhether asset is used as collateral

When to use: Check per-asset balances and debt, monitor supply APY for rate-based strategies, verify collateral status before borrowing.


Get sDAI Balance

Check the sDAI balance of an address. The sDAI balance represents shares in the savings vault. Use “Convert sDAI to DAI Value” to see the underlying DAI value.

Inputs:

InputTypeDescription
accountaddressWallet Address

Outputs:

OutputTypeDescription
balanceuint256sDAI Balance (wei), 18 decimals

When to use: Check savings position size, monitor sDAI holdings across wallets, trigger actions based on balance thresholds.


Get sDAI Total Assets

Get the total DAI held in the sDAI vault, representing the total value locked earning the DSR.

Inputs: None

Outputs:

OutputTypeDescription
totalAssetsuint256Total DAI in Vault (wei), 18 decimals

When to use: Monitor total DSR TVL, track protocol-level savings growth, compare against other yield sources.


Convert sDAI to DAI Value

Preview how much DAI a given amount of sDAI is worth at the current exchange rate. The rate increases over time as DSR yield accrues.

Inputs:

InputTypeDescription
sharesuint256sDAI Shares (wei)

Outputs:

OutputTypeDescription
assetsuint256DAI Value (wei), 18 decimals

When to use: Check the current value of sDAI holdings in DAI terms, calculate realized yield, price sDAI for swaps or portfolio tracking.


Example Workflows

Health Factor Monitor with Discord Alert

Schedule (every 5 min) -> Spark: Get User Account Data -> Code (healthFactor / 1e18) -> Condition (< 1.5) -> Discord: Send Message

Monitor your SparkLend health factor and send a Discord alert when it drops below 1.5, giving you time to act before liquidation.

Auto-Repay on Low Health Factor

Schedule (every 5 min) -> Spark: Get User Account Data -> Code (healthFactor / 1e18) -> Condition (< 1.2) -> Spark: Repay Debt

Automatically repay debt when health factor approaches the liquidation threshold. Requires wallet connection and token approval.

sDAI Savings Monitor

Schedule (daily) -> Spark: Get sDAI Balance -> Spark: Convert sDAI to DAI Value -> Code (compute yield) -> SendGrid: Send Email

Track your sDAI position value daily and receive an email summary showing balance, current DAI value, and accrued yield.

sDAI TVL Tracker with Webhook

Schedule (hourly) -> Spark: Get sDAI Total Assets -> Code (format TVL) -> Webhook: Send HTTP Request

Monitor the total DAI locked in the sDAI vault and send hourly updates to an external dashboard or analytics service.


Supported Chains

ChainContracts Available
Ethereum (1)SparkLend Pool, Pool Data Provider, sDAI
Gnosis (100)SparkLend Pool, Pool Data Provider

SparkLend uses the same Aave V3 Pool interface for supply, withdraw, borrow, and repay. The sDAI contract is an ERC-4626 vault wrapping DAI in the DAI Savings Rate and is available on Ethereum only (Gnosis uses sxDAI instead).