user_actions

package
v0.0.0-...-07d62d3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UserActionSwap, with the swap of a token into (or out of) a Fluid Asset
	UserActionSwap = `swap`

	// UserActionSend to another user from this user
	UserActionSend = `send`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatedUserTransaction

type AggregatedUserTransaction struct {
	TokenShortName string `json:"token_short_name"`

	Network network.BlockchainNetwork `json:"network"`

	Time time.Time `json:"time"`

	TransactionHash string `json:"transaction_hash"`

	// SenderAddress is the owner of the ATA that sent this transaction on Solana
	// and the normal sender address on other networks
	SenderAddress string `json:"sender_address"`

	// RecipientAddress is the owner of the ATA that received this transaction on Solana
	// and the normal sender address on other networks
	RecipientAddress string `json:"recipient_address"`

	// scaled to usd
	Amount float64 `json:"amount"`

	Application string `json:"application"`

	WinningAddress string `json:"winning_address"`

	WinningAmount float64 `json:"winning_amount"`

	RewardHash string `json:"reward_hash"`

	// Type of the user action, currently either a swap or a send
	Type string `json:"type"`

	// SwapIn or swap out from a Fluid Asset. If true, then that would indicate
	// that the transfer went from USDT to fUSDT for example.
	SwapIn bool `json:"swap_in"`

	// scaled to usd
	UtilityAmount float64 `json:"utility_amount"`

	UtilityName applications.UtilityName `json:"utility_name"`
}

unique on tx hash, aggregates all log indexes stored literally as it should be returned, so amount is rounded etc

func AggregatedTransactionFromPendingWinner

func AggregatedTransactionFromPendingWinner(pendingWinner winners.PendingWinner) AggregatedUserTransaction

AggregatedTransactionFromPendingWinner to create a partially aggregated transaction from a pending winner

func AggregatedTransactionFromUserAction

func AggregatedTransactionFromUserAction(userAction UserAction) AggregatedUserTransaction

AggregatedTransactionFromUserAction to create a partially aggregated transaction from a user action

type BufferedUserAction

type BufferedUserAction struct {
	UserActions          []UserAction `json:"user_actions"`
	SecondsSinceLastSlot uint64       `json:"seconds_since_last_slot"`
}

type UserAction

type UserAction struct {
	// EventNumber of this UserAction. May be useful to get more information
	// about an event. Set by the database!
	EventNumber uint64 `json:"event_number"`

	// Network that this event took place on
	Network network.BlockchainNetwork `json:"network"`

	// Type of the user action, currently either a swap or a send
	Type string `json:"type"`

	// TransactionHash to find the transaction that generated this user action
	TransactionHash string `json:"transaction_hash"`

	// LogIndex for the index of the log in the block
	// For Sui, this is the index of the action in a PTB
	LogIndex misc.BigInt `json:"log_index"`

	// SwapIn or swap out from a Fluid Asset. If true, then that would indicate
	// that the transfer went from USDT to fUSDT for example.
	SwapIn bool `json:"swap_in"`

	// Creator of the user action (their address)
	SenderAddress string `json:"sender_address"`

	// Account that owns the sender ATA for solana, empty string otherwise
	SolanaSenderOwnerAddress string `json:"solana_sender_owner_address"`

	// Recipient of the user action, if the user action was a send
	RecipientAddress string `json:"recipient_address"`

	// Account that owns the receiver ATA for solana, empty string otherwise
	SolanaRecipientOwnerAddress string `json:"solana_recipient_owner_address"`

	// Fee adjusted based on compute units used
	AdjustedFee *big.Rat

	// Amount that was swapped or sent
	Amount misc.BigInt `json:"amount"`

	// AmountStr is the string representation of Amount
	// Used to accurately store digits in database
	AmountStr string `json:"amount_str"`

	// TokenDetails to include information on the token's name and the number
	// of decimal places contained within it
	TokenDetails token_details.TokenDetails `json:"token_details"`

	// Time of this user action
	Time time.Time `json:"time"`

	// this is the stringified result of either an ethereum.Application or solana.Application
	Application string `json:"application"`
}

func NewSendEthereum

func NewSendEthereum(network_ network.BlockchainNetwork, senderAddress, recipientAddress ethereum.Address, transactionHash ethereum.Hash, amount misc.BigInt, tokenShortName string, tokenDecimals int, logIndex misc.BigInt, application applications.Application) UserAction

NewSendEthereum of a Fluid Asset, from the sender to the recipient with the transaction hash with the amount. The current time is set within the function.

func NewSendSolana

func NewSendSolana(senderAddress, recipientAddress, transactionHash string, amount misc.BigInt, tokenShortName string, tokenDecimals int, applications []solApplications.Application) UserAction

func NewSendSui

func NewSendSui(network_ network.BlockchainNetwork, senderAddress, recipientAddress, transactionHash string, amount, txIndex misc.BigInt, fee *big.Rat, application *string, tokenShortName string, tokenDecimals int) UserAction

func NewSwapEthereum

func NewSwapEthereum(network_ network.BlockchainNetwork, senderAddress ethereum.Address, transactionHash ethereum.Hash, amount misc.BigInt, swapIn bool, tokenShortName string, tokenDecimals int) UserAction

NewSwapEthereum made by the user, either swapping in (swapIn) to a Fluid Asset from an underlying asset or swapping out. Sets the time to time.Now().

func NewSwapSolana

func NewSwapSolana(senderAddress, transactionHash string, amount misc.BigInt, swapIn bool, tokenShortName string, tokenDecimals int) UserAction

NewSwapSolana made by the user, either swapping in (swapIn) to a Fluid Asset from an underlying asset or swapping out. Sets the time to time.Now(). Solana ATA owner addresses should be set outside of the function.

func NewSwapSui

func NewSwapSui(network_ network.BlockchainNetwork, senderAddress, transactionHash string, amount misc.BigInt, swapIn bool, tokenShortName string, tokenDecimals int) UserAction

func (UserAction) IsSend

func (userAction UserAction) IsSend() bool

IsSend type of user action (was this a send?)

func (UserAction) IsSwap

func (userAction UserAction) IsSwap() bool

IsSwap type of user action (was this a swap?)

Jump to

Keyboard shortcuts

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