blockchain

package
v0.0.0-...-4d9bc2d Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Solana                      = "solana"
	SolanaMainChainId    uint64 = 1199999911
	SolanaTestnetChainId uint64 = 1188888811
	SolanaDevnetChainId  uint64 = 1177777711
)

Variables

View Source
var EthInstancesByChain = make(map[uint64]*EthClient, 0)
View Source
var SolanaInstancesByChain = make(map[uint64]*SolanaClient, 0)

Functions

func InitBlockChainClient

func InitBlockChainClient()

func IsSolana

func IsSolana(chainId uint64) bool

Types

type Blockchain

type Blockchain interface {
	WalletCount() (total uint64, err error)
	IsWalletValid(address string) (ok bool, err error)
	IsWalletAssignable(address string) (ok bool, err error)
	AssignWallet(walletAddress, holderAddress, pfTokenReceiverAddress string, payableAmount, validityTerm uint64) (address, txHash string, expireTime, blockNumber, blockTime, nonce uint64, err error)
	HandleWalletDeposit(address string) error
	RequestRedemption(redeemAmount uint64, redemptionWalletMap map[string]uint64) (claimableTime uint64, err error)
	Claim() (totalClaimAmount uint64, err error)
	RefundFromWallet(address string) (refundAmount string, err error)
	WithdrawRefundTokens(address string, amount string) error
	GetTVL() (amount uint64, err error)
	GetUserClaimableAmount(address string) (userClaimableAmount uint64, err error)
	GetPayTokenContractAddr() string
	GetPayTokenSymbol() string
	GetIsPaymentProcessedByWallet(address string) (isPaymentProcessed bool, err error)
	Rebase() error
	GetPayTokenDecimals() uint8
	GetBlockNumberIntervalSeconds() uint64
	LastRebaseTime() (lastRebaseTime uint64, err error)
	MinRebaseInterval() (minRebaseInterval uint64, err error)
	GetPayTokenBlockNumber() uint64
	GetPlpAddressPoolContractAddr() string
	GetOwnerAddress() string
	GetFundTokenReserve() (fundTokenReserve string, err error)
	GetSwapFeeBase() (liquidityTarget, maxFee, minFee string, err error)
	GetPercentageFactor() (factor string, err error)
}

func GetClientByChainId

func GetClientByChainId(chainId uint64) (client Blockchain, err error)

type EthClient

type EthClient struct {
	ChainId                    uint64
	Client                     *eth.Client
	PlpAddressPoolContractAddr common.Address
	PfTokenContractAddr        common.Address
	LiquidStakingContractAddr  common.Address
	PayTokenContractAddr       common.Address
	PayTokenSymbol             string
	PayTokenDecimals           uint8
	PayTokenBlockNumber        uint64
	OwnerPriKey                *eth.PrivateKey
	MerchantPriKey             *eth.PrivateKey
	PlpAddressPoolContract     *plp.Plp
	PfTokenContract            *token.Token
	LiquidStakingContract      *staking.Staking
	BlockNumberIntervalSeconds uint64
}

func GetEthClientByChainId

func GetEthClientByChainId(chainId uint64) (client *EthClient, err error)

func (*EthClient) AssignWallet

func (c *EthClient) AssignWallet(walletAddress, holderAddress, pfTokenReceiverAddress string,
	payableAmount, validityTerm uint64) (address, txHash string, expireTime, blockNumber, blockTime, nonce uint64, err error)

func (*EthClient) Claim

func (c *EthClient) Claim() (totalClaimAmount uint64, err error)

func (*EthClient) GetBlockNumberIntervalSeconds

func (c *EthClient) GetBlockNumberIntervalSeconds() uint64

func (*EthClient) GetFundTokenReserve

func (c *EthClient) GetFundTokenReserve() (fundTokenReserve string, err error)

func (*EthClient) GetIsPaymentProcessedByWallet

func (c *EthClient) GetIsPaymentProcessedByWallet(address string) (isPaymentProcessed bool, err error)

func (*EthClient) GetOwnerAddress

func (c *EthClient) GetOwnerAddress() string

func (*EthClient) GetPayTokenBlockNumber

func (c *EthClient) GetPayTokenBlockNumber() uint64

func (*EthClient) GetPayTokenContractAddr

func (c *EthClient) GetPayTokenContractAddr() string

func (*EthClient) GetPayTokenDecimals

func (c *EthClient) GetPayTokenDecimals() uint8

func (*EthClient) GetPayTokenSymbol

func (c *EthClient) GetPayTokenSymbol() string

func (*EthClient) GetPercentageFactor

func (c *EthClient) GetPercentageFactor() (factor string, err error)

func (*EthClient) GetPlpAddressPoolContractAddr

func (c *EthClient) GetPlpAddressPoolContractAddr() string

func (*EthClient) GetSwapFeeBase

func (c *EthClient) GetSwapFeeBase() (liquidityTarget, maxFee, minFee string, err error)

func (*EthClient) GetTVL

func (c *EthClient) GetTVL() (amount uint64, err error)

func (*EthClient) GetUserClaimableAmount

func (c *EthClient) GetUserClaimableAmount(address string) (userClaimableAmount uint64, err error)

func (*EthClient) HandleWalletDeposit

func (c *EthClient) HandleWalletDeposit(address string) (err error)

func (*EthClient) IsWalletAssignable

func (c *EthClient) IsWalletAssignable(address string) (ok bool, err error)

func (*EthClient) IsWalletValid

func (c *EthClient) IsWalletValid(address string) (ok bool, err error)

func (*EthClient) LastRebaseTime

func (c *EthClient) LastRebaseTime() (lastRebaseTime uint64, err error)

func (*EthClient) MinRebaseInterval

func (c *EthClient) MinRebaseInterval() (minRebaseInterval uint64, err error)

func (*EthClient) Rebase

func (c *EthClient) Rebase() (err error)

func (*EthClient) RefundFromWallet

func (c *EthClient) RefundFromWallet(address string) (refundAmount string, err error)

func (*EthClient) RequestRedemption

func (c *EthClient) RequestRedemption(redeemAmount uint64, redemptionWalletMap map[string]uint64) (claimableTime uint64, err error)

func (*EthClient) SwapForFundToken

func (c *EthClient) SwapForFundToken(_pftokenAmount *big.Int, toAddr string) (sender common.Address, fundTokenAmount, fee *big.Int, txReceipt *types.Receipt, txTime time.Time, err error)

func (*EthClient) WalletCount

func (c *EthClient) WalletCount() (total uint64, err error)

func (*EthClient) WithdrawRefundTokens

func (c *EthClient) WithdrawRefundTokens(address, amount string) error

type SolanaClient

type SolanaClient struct {
	ChainId                    uint64
	Client                     *solana.Client
	PlpAddressPoolContractAddr solanaGo.PublicKey
	PfTokenContractAddr        solanaGo.PublicKey
	LiquidStakingContractAddr  solanaGo.PublicKey
	PayTokenContractAddr       solanaGo.PublicKey
	PayTokenSymbol             string
	PayTokenDecimals           uint8
	PayTokenBlockNumber        uint64
	OwnerPriKey                solanaGo.PrivateKey
	BlockNumberIntervalSeconds uint64
}

func (*SolanaClient) AssignWallet

func (c *SolanaClient) AssignWallet(walletAddress, holderAddress, pfTokenReceiverAddress string,
	payableAmount, validityTerm uint64) (address, txHash string, expireTime, blockNumber, blockTime, nonce uint64, err error)

func (*SolanaClient) Claim

func (c *SolanaClient) Claim() (totalClaimAmount uint64, err error)

func (*SolanaClient) GetBlockNumberIntervalSeconds

func (c *SolanaClient) GetBlockNumberIntervalSeconds() uint64

func (*SolanaClient) GetFundTokenReserve

func (c *SolanaClient) GetFundTokenReserve() (fundTokenReserve string, err error)

func (*SolanaClient) GetIsPaymentProcessedByWallet

func (c *SolanaClient) GetIsPaymentProcessedByWallet(address string) (isPaymentProcessed bool, err error)

func (*SolanaClient) GetOwnerAddress

func (c *SolanaClient) GetOwnerAddress() string

func (*SolanaClient) GetPayTokenBlockNumber

func (c *SolanaClient) GetPayTokenBlockNumber() uint64

func (*SolanaClient) GetPayTokenContractAddr

func (c *SolanaClient) GetPayTokenContractAddr() string

func (*SolanaClient) GetPayTokenDecimals

func (c *SolanaClient) GetPayTokenDecimals() uint8

func (*SolanaClient) GetPayTokenSymbol

func (c *SolanaClient) GetPayTokenSymbol() string

func (*SolanaClient) GetPercentageFactor

func (c *SolanaClient) GetPercentageFactor() (factor string, err error)

func (*SolanaClient) GetPlpAddressPoolContractAddr

func (c *SolanaClient) GetPlpAddressPoolContractAddr() string

func (*SolanaClient) GetSwapFeeBase

func (c *SolanaClient) GetSwapFeeBase() (liquidityTarget, maxFee, minFee string, err error)

func (*SolanaClient) GetTVL

func (c *SolanaClient) GetTVL() (amount uint64, err error)

func (*SolanaClient) GetUserClaimableAmount

func (c *SolanaClient) GetUserClaimableAmount(address string) (userClaimableAmount uint64, err error)

func (*SolanaClient) HandleWalletDeposit

func (c *SolanaClient) HandleWalletDeposit(address string) error

func (*SolanaClient) IsWalletAssignable

func (c *SolanaClient) IsWalletAssignable(address string) (ok bool, err error)

func (*SolanaClient) IsWalletValid

func (c *SolanaClient) IsWalletValid(address string) (ok bool, err error)

func (*SolanaClient) LastRebaseTime

func (c *SolanaClient) LastRebaseTime() (lastRebaseTime uint64, err error)

func (*SolanaClient) MinRebaseInterval

func (c *SolanaClient) MinRebaseInterval() (minRebaseInterval uint64, err error)

func (*SolanaClient) Rebase

func (c *SolanaClient) Rebase() (err error)

func (*SolanaClient) RefundFromWallet

func (c *SolanaClient) RefundFromWallet(address string) (refundAmount string, err error)

func (*SolanaClient) RequestRedemption

func (c *SolanaClient) RequestRedemption(redeemAmount uint64, redemptionWalletMap map[string]uint64) (claimableTime uint64, err error)

func (*SolanaClient) WalletCount

func (c *SolanaClient) WalletCount() (total uint64, err error)

func (*SolanaClient) WithdrawRefundTokens

func (c *SolanaClient) WithdrawRefundTokens(address, amount string) error

Directories

Path Synopsis
eth

Jump to

Keyboard shortcuts

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