principal

package
v0.0.0-...-a9acf74 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Calculator

type Calculator struct {
	// contains filtered or unexported fields
}

func NewCalculator

func NewCalculator(assets assetManager, prices priceProvider, config *config.Config) *Calculator

func (*Calculator) BalanceFromPrincipal

func (c *Calculator) BalanceFromPrincipal(principal *big.Int, asset string) *big.Int

func (*Calculator) BalanceFromValue

func (c *Calculator) BalanceFromValue(balance *big.Int, asset string) *big.Int

func (*Calculator) PrincipalFromBalance

func (c *Calculator) PrincipalFromBalance(balance *big.Int, asset string) *big.Int

func (*Calculator) PrincipalFromValue

func (c *Calculator) PrincipalFromValue(value *big.Int, asset string) *big.Int

func (*Calculator) ValueFromBalance

func (c *Calculator) ValueFromBalance(value *big.Int, asset string) *big.Int

func (*Calculator) ValueFromPrincipal

func (c *Calculator) ValueFromPrincipal(principal *big.Int, asset string) *big.Int

type Health

type Health struct {
	GreatestCollateralValue *big.Int
	GreatestCollateralAsset *big.Int
	GreatestLoanValue       *big.Int
	GreatestLoanAsset       *big.Int
	TotalDebt               *big.Int
	TotalLimit              *big.Int
	TotalSupply             *big.Int
}

func (*Health) Factor

func (h *Health) Factor() float64

func (*Health) IsBadDebt

func (h *Health) IsBadDebt(liquidationBonus, liquidationBonusScale *big.Int) bool

func (*Health) IsLiquidatable

func (h *Health) IsLiquidatable() bool

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(config *config.Config) *Service

func (*Service) AggregatedBalances

func (s *Service) AggregatedBalances(user UserBalancer, assets assetManager, prices priceProvider) (*big.Int, *big.Int)

func (*Service) CalculateHealth

func (s *Service) CalculateHealth(user UserBalancer, assets assetManager, prices priceProvider) *Health

func (*Service) CalculateLiquidationData

func (s *Service) CalculateLiquidationData(user UserBalancer, assets assetManager, prices priceProvider) (health *Health, liquidationAmount, collateralAmount *big.Int, ok bool)

func (*Service) CalculateMaximumWithdrawAmount

func (s *Service) CalculateMaximumWithdrawAmount(user UserBalancer, assets assetManager, prices priceProvider, asset string) *big.Int

func (*Service) CalculateUserSCAddress

func (s *Service) CalculateUserSCAddress(userAddress *address.Address) (*address.Address, error)

func (*Service) GetAvailableToBorrow

func (s *Service) GetAvailableToBorrow(user UserBalancer, assets assetManager, prices priceProvider) *big.Int

func (*Service) PredictHealthFactor

func (s *Service) PredictHealthFactor(user UserBalancer, assets assetManager, prices priceProvider, asset string, amount *big.Int) float64

type UserBalancer

type UserBalancer interface {
	Principal(asset string) *big.Int
	Balance(asset string, assetData *asset.Data, applyDust bool, assetConfig *asset.Config) *big.Int
	ChangePrincipal(asset string, volume *big.Int) UserBalancer
	CheckNotInDebtAtAll() bool
}

type UserSC

type UserSC struct {
	// contains filtered or unexported fields
}

func NewUserSC

func NewUserSC(addr *address.Address) *UserSC

func (*UserSC) Address

func (u *UserSC) Address() *address.Address

func (*UserSC) BackupCell1

func (u *UserSC) BackupCell1() *cell.Cell

func (*UserSC) BackupCell2

func (u *UserSC) BackupCell2() *cell.Cell

func (*UserSC) Balance

func (u *UserSC) Balance(asset string, assetData *asset.Data, applyDust bool, assetConfig *asset.Config) *big.Int

func (*UserSC) ChangePrincipal

func (u *UserSC) ChangePrincipal(asset string, amount *big.Int) UserBalancer

func (*UserSC) CheckNotInDebtAtAll

func (u *UserSC) CheckNotInDebtAtAll() bool

func (*UserSC) CodeVersion

func (u *UserSC) CodeVersion() uint64

func (*UserSC) MasterAddress

func (u *UserSC) MasterAddress() *address.Address

func (*UserSC) Principal

func (u *UserSC) Principal(asset string) *big.Int

func (*UserSC) Principals

func (u *UserSC) Principals() map[string]*big.Int

func (*UserSC) Rewards

func (u *UserSC) Rewards() *cell.Dictionary

func (*UserSC) SetAccData

func (u *UserSC) SetAccData(userData *cell.Cell) (UserBalancer, error)

func (*UserSC) SetData

func (u *UserSC) SetData(userData *ton.ExecutionResult) (UserBalancer, error)

func (*UserSC) SetPrincipals

func (u *UserSC) SetPrincipals(principals map[string]*big.Int) UserBalancer

func (*UserSC) UserAddress

func (u *UserSC) UserAddress() *address.Address

func (*UserSC) UserState

func (u *UserSC) UserState() int64

Jump to

Keyboard shortcuts

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