Smart contract interactions
Last updated
Last updated
Kiln DeFi smart contracts integrate the Chainalysis Oracle for sanctions screening on all chains where it's available. The oracle actively monitors and screens addresses against up-to-date sanctions lists, ensuring that any sanctioned addresses are automatically restricted from interacting with Kiln DeFi vaults.
Kiln DeFi Vault smart contracts adhere to the ERC4626 standard, making integration straightforward. When users deposit tokens, they receive shares representing their position. For a better user experience, we recommend abstracting any asset-to-share conversions and always displaying asset amounts on the UI instead of share amounts.
Here is the ABI of the Vault contract:
Before depositing 'x' assets, ensure the user has approved the vault to spend 'x' on their behalf via the asset contract.
Check Allowance: Call the allowance(address owner, address spender) → uint256
function on the ERC20 asset contract.
Increase Allowance: Use the approve(address spender, uint256 amount) → bool
function on the ERC20 asset contract to increase the allowance to the desired deposit amount.
Before depositing X assets, you must make sure the user approved the vault to spend X on its behalf on the asset contract.
Note: Only have the user approve the exact amount they intend to deposit into the vault.
To deposit an amount of the vault's ERC20, the transaction sender must call the deposit(uint256 assets, address receiver)
function, where assets
is the amount of ERC20 to deposit in the strategy, and receiver
is the address that should own the deposited position.
(Optional) If you need to compute the amount of shares the user will receive before making a deposit, you can preview the amount by calling previewDeposit(uint256 assets)
, where assets
is the amount of ERC20 to deposit.
In this case, we expect the user to input the amount of ERC20 they want to withdraw and then call the withdraw(uint256 assets, address receiver, address owner)
function. Here:
assets
is the amount of ERC20 to withdraw.
receiver
is the address that will receive the redeemed ERC20.
owner
is the address of the position owner (the same as the transaction sender).
To exit the entire position, the best approach is to determine the user's share amount and redeem it. Follow these steps:
Retrieve the share amount of the user's position using the balanceOf(address owner)
function, where owner
is the address of the position owner.
Redeem the shares by calling the redeem(uint256 shares, address receiver, address owner)
function, where:
shares
is the amount of shares to redeem.
receiver
is the address that will receive the redeemed ERC20.
owner
is the address of the position owner (the same as the transaction sender).
Using the withdraw
function instead of the redeem
function may prevent the user from fully exiting their position, as the shares-to-assets rate might change between the input and the actual block when the transaction is included.