interest

package
v1.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecondsPerHour = 3_600
	SecondsPerDay  = 86_400
	SecondsPerYear = 31_536_000

	EulerPrecision = 17
)

Variables

This section is empty.

Functions

func CalculateAUMFee added in v1.1.0

func CalculateAUMFee(aum sdkmath.Int, bips uint32, duration int64) (fee sdkmath.Int, err error)

CalculateAUMFee computes the technology fee based on the vault's AUM and configured basis points.

Formula:

Fee = (AUM * (bips / 10000) * duration) / 31536000 (SecondsPerYear)

Returns the fee as a truncated sdkmath.Int.

func CalculateInterestEarned

func CalculateInterestEarned(principal sdk.Coin, rate string, periodSeconds int64) (amount sdkmath.Int, err error)

CalculateInterestEarned computes the continuously compounded interest for a given principal over a period.

It uses the formula `Interest = P * (e^(rt)) - P`, where:

  • P is the `principal`.
  • r is the annual `rate`.
  • t is the time in years, derived from (`periodSeconds` / 31_536_000).

This function returns the interest as a `cosmosmath.Int`, truncating any fractional part to ensure compatibility with coin amounts. It uses deterministic arithmetic via `cosmosmath.LegacyDec` and approximates e^x using a Maclaurin series (`utils.ExpDec`).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL