Module SDK
Modules
Auto Saving Executor

Auto Saving Executor

The Auto Saving Executor module is a module that allows users users to automatically save a percentage of their received tokens to a vault.

You can find the source code for the module in the Core Modules repo (opens in a new tab) and the deployment address in the address book.

getInstallAutoSavingsExecutor

The getInstallAutoSavingsExecutor function is used to create an instance of the Auto Saving Executor module. This function returns a module object.

import { getInstallAutoSavingsExecutor } from "@rhinestone/module-sdk";
 
const params = {
  tokens: ['0x..'], // array of token addresses
  configs: [{
    percentage: 10, // percentage to save
    vault: '0x..', // vault address
    sqrtPriceLimitX96: 10n, // sqrt price limit
  }]
}
 
const autoSavingsExecutor = getInstallAutoSavingsExecutor(params);

getSetAutoSavingConfigAction

The getSetAutoSavingConfigAction function is used to set auto saving config to the executor. This function returns an execution object

import { getSetAutoSavingConfigAction } from "@rhinestone/module-sdk";
 
const params = {
  token: '0x..', // token addresses
  config: {
    percentage: 10, // percentage to save
    vault: '0x..', // vault address
    sqrtPriceLimitX96: 10n, // sqrt price limit
  },
}
 
const setAutoSavingConfigAction = getSetAutoSavingConfigAction(params);

getAutoSavingTokens

The getAutoSavingTokens function is used to get tokens that is auto saved by the executor. This function returns an array of token addresses.

import { getAutoSavingTokens } from "@rhinestone/module-sdk";
 
const autoSavingTokens = await getAutoSavingTokens(
  {
    client,
    account,
  }
);

getDeleteAutoSavingConfigAction

The getDeleteAutoSavingConfigAction function is used to delete an auto saving configuration. This function returns an execution object.

import { getDeleteAutoSavingConfigAction } from "@rhinestone/module-sdk";
 
const params = {
  account,
  client,
  token: '0x..' // token address
};
 
const deleteAutoSavingConfigAction = await getDeleteAutoSavingConfigAction(params);

getAutoSaveAction

The getAutoSaveAction function is used to execute auto save when a token receives some funds.

import { getAutoSaveAction } from "@rhinestone/module-sdk";
 
const params = {
  token: '0x...', // token address
  amountReceived: 10,
};
 
const autoSaveAction = getAutoSaveAction(params);

getAutoSavingAccountTokenConfig

The getAutoSavingAccountTokenConfig function is used to get auto saving config for a specific token.

import { getAutoSavingAccountTokenConfig } from "@rhinestone/module-sdk";
 
const params = {
  token: '0x...', // token address
  account,
  client,
};
 
const autoSavingAccountTokenConfig = await getAutoSavingAccountTokenConfig(params);

AUTO_SAVINGS_ADDRESS

The AUTO_SAVINGS_ADDRESS is a constant that represents the module address.