biz

package
v0.0.0-...-ed0dbbb Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package biz is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BacktestService

type BacktestService interface {
	// RunBacktest executes a backtest for a campaign within a specified time range.
	RunBacktest(c context.Context, campaign *Campaign, resultCh chan<- *model.Reward) error
}

BacktestService defines the domain logic for backtesting campaigns with historical data.

type Campaign

type Campaign struct {
	model.Campaign `bson:",inline"`
	// contains filtered or unexported fields
}

Campaign represents the aggregate root for campaigns.

func NewCampaign

func NewCampaign(name string, startAt time.Time, poolID string) (*Campaign, error)

NewCampaign creates a new Campaign aggregate.

func (*Campaign) AddTask

func (c *Campaign) AddTask(task *Task) error

AddTask adds a task to the campaign.

func (*Campaign) Complete

func (c *Campaign) Complete() error

Complete marks the campaign as completed.

func (*Campaign) GetSharePoolTaskReward

func (c *Campaign) GetSharePoolTaskReward() []*model.Reward

GetSharePoolTaskReward returns the rewards for the share pool task.

func (*Campaign) GetTaskByType

func (c *Campaign) GetTaskByType(taskType model.TaskType) *Task

GetTaskByType returns the task of the specified type.

func (*Campaign) HasCompletedOnboardingTask

func (c *Campaign) HasCompletedOnboardingTask(volume float64) bool

HasCompletedOnboardingTask checks if the user has completed the onboarding task.

func (*Campaign) MarshalBSON

func (c *Campaign) MarshalBSON() ([]byte, error)

func (*Campaign) OnSwapExecuted

func (c *Campaign) OnSwapExecuted(tx *Transaction) (*model.Reward, error)

OnSwapExecuted handles the swap executed event.

func (*Campaign) Start

func (c *Campaign) Start() error

Start marks the campaign as active.

func (*Campaign) Tasks

func (c *Campaign) Tasks() []*Task

Tasks returns the tasks associated with the campaign.

func (*Campaign) UnmarshalBSON

func (c *Campaign) UnmarshalBSON(bytes []byte) error

type CampaignService

type CampaignService interface {
	// CreateCampaign initializes a new campaign.
	CreateCampaign(
		c context.Context,
		name string,
		startAt time.Time,
		mode model.CampaignMode,
		targetPool string,
		minAmount float64,
	) (*Campaign, error)
}

CampaignService defines the domain logic for campaign management.

type MockBacktestService

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

MockBacktestService is a mock of BacktestService interface.

func NewMockBacktestService

func NewMockBacktestService(ctrl *gomock.Controller) *MockBacktestService

NewMockBacktestService creates a new mock instance.

func (*MockBacktestService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBacktestService) RunBacktest

func (m *MockBacktestService) RunBacktest(c context.Context, campaign *Campaign, resultCh chan<- *model.Reward) error

RunBacktest mocks base method.

type MockBacktestServiceMockRecorder

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

MockBacktestServiceMockRecorder is the mock recorder for MockBacktestService.

func (*MockBacktestServiceMockRecorder) RunBacktest

func (mr *MockBacktestServiceMockRecorder) RunBacktest(c, campaign, resultCh any) *gomock.Call

RunBacktest indicates an expected call of RunBacktest.

type MockCampaignService

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

MockCampaignService is a mock of CampaignService interface.

func NewMockCampaignService

func NewMockCampaignService(ctrl *gomock.Controller) *MockCampaignService

NewMockCampaignService creates a new mock instance.

func (*MockCampaignService) CreateCampaign

func (m *MockCampaignService) CreateCampaign(c context.Context, name string, startAt time.Time, mode model.CampaignMode, targetPool string, minAmount float64) (*Campaign, error)

CreateCampaign mocks base method.

func (*MockCampaignService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockCampaignServiceMockRecorder

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

MockCampaignServiceMockRecorder is the mock recorder for MockCampaignService.

func (*MockCampaignServiceMockRecorder) CreateCampaign

func (mr *MockCampaignServiceMockRecorder) CreateCampaign(c, name, startAt, mode, targetPool, minAmount any) *gomock.Call

CreateCampaign indicates an expected call of CreateCampaign.

type MockRewardService

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

MockRewardService is a mock of RewardService interface.

func NewMockRewardService

func NewMockRewardService(ctrl *gomock.Controller) *MockRewardService

NewMockRewardService creates a new mock instance.

func (*MockRewardService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockRewardServiceMockRecorder

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

MockRewardServiceMockRecorder is the mock recorder for MockRewardService.

type MockTaskService

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

MockTaskService is a mock of TaskService interface.

func NewMockTaskService

func NewMockTaskService(ctrl *gomock.Controller) *MockTaskService

NewMockTaskService creates a new mock instance.

func (*MockTaskService) CreateTask

func (m *MockTaskService) CreateTask(c context.Context, campaign *Campaign, name, description string, taskType model.TaskType, minAmount float64, poolID string) (*Task, error)

CreateTask mocks base method.

func (*MockTaskService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockTaskServiceMockRecorder

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

MockTaskServiceMockRecorder is the mock recorder for MockTaskService.

func (*MockTaskServiceMockRecorder) CreateTask

func (mr *MockTaskServiceMockRecorder) CreateTask(c, campaign, name, description, taskType, minAmount, poolID any) *gomock.Call

CreateTask indicates an expected call of CreateTask.

type MockTransactionService

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

MockTransactionService is a mock of TransactionService interface.

func NewMockTransactionService

func NewMockTransactionService(ctrl *gomock.Controller) *MockTransactionService

NewMockTransactionService creates a new mock instance.

func (*MockTransactionService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTransactionService) ProcessTransaction

func (m *MockTransactionService) ProcessTransaction(ctx context.Context, transaction *Transaction, user *User, task *Task) error

ProcessTransaction mocks base method.

type MockTransactionServiceMockRecorder

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

MockTransactionServiceMockRecorder is the mock recorder for MockTransactionService.

func (*MockTransactionServiceMockRecorder) ProcessTransaction

func (mr *MockTransactionServiceMockRecorder) ProcessTransaction(ctx, transaction, user, task any) *gomock.Call

ProcessTransaction indicates an expected call of ProcessTransaction.

type MockUserService

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

MockUserService is a mock of UserService interface.

func NewMockUserService

func NewMockUserService(ctrl *gomock.Controller) *MockUserService

NewMockUserService creates a new mock instance.

func (*MockUserService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockUserService) GetUserTaskListByAddress

func (m *MockUserService) GetUserTaskListByAddress(c context.Context, address string) (*User, error)

GetUserTaskListByAddress mocks base method.

type MockUserServiceMockRecorder

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

MockUserServiceMockRecorder is the mock recorder for MockUserService.

func (*MockUserServiceMockRecorder) GetUserTaskListByAddress

func (mr *MockUserServiceMockRecorder) GetUserTaskListByAddress(c, address any) *gomock.Call

GetUserTaskListByAddress indicates an expected call of GetUserTaskListByAddress.

type Reward

type Reward struct {
	model.Reward
}

Reward is the reward aggregate.

func NewReward

func NewReward(points int64, campaignID string, toAddress string) *Reward

NewReward is used to create a new Reward.

type RewardRedeemedEvent

type RewardRedeemedEvent struct {
}

RewardRedeemedEvent is the event for reward redeemed.

type RewardService

type RewardService interface {
}

RewardService defines the domain logic for rewards and point allocation.

type SwapExecutedEvent

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

SwapExecutedEvent is the event for swap executed.

func NewSwapExecutedEvent

func NewSwapExecutedEvent(occurredAt time.Time, payload SwapExecutedPayload) *SwapExecutedEvent

NewSwapExecutedEvent creates a new SwapExecutedEvent instance.

func (*SwapExecutedEvent) GetID

func (e *SwapExecutedEvent) GetID() string

func (*SwapExecutedEvent) GetName

func (e *SwapExecutedEvent) GetName() string

func (*SwapExecutedEvent) GetOccurredAt

func (e *SwapExecutedEvent) GetOccurredAt() time.Time

func (*SwapExecutedEvent) GetPayload

func (e *SwapExecutedEvent) GetPayload() interface{}

type SwapExecutedPayload

type SwapExecutedPayload struct {
	TxID string
}

SwapExecutedPayload is the payload for swap executed.

type Task

type Task struct {
	model.Task `bson:",inline"`

	CampaignID string `bson:"campaign_id"`
	Progress   int    `bson:"progress"`
}

Task is an aggregate root that represents the task.

func NewTask

func NewTask(
	name, description string,
	taskType model.TaskType,
	minAmount float64,
	poolID string,
) (*Task, error)

NewTask creates a new Task aggregate.

func NewTaskOfOnboarding

func NewTaskOfOnboarding(name, description string, minAmount float64, poolID string) (*Task, error)

NewTaskOfOnboarding creates a new Task aggregate for onboarding.

func NewTaskOfSharePool

func NewTaskOfSharePool(name, description string, poolID string) (*Task, error)

NewTaskOfSharePool creates a new Task aggregate for sharing a pool.

func (*Task) CalculateProgress

func (t *Task) CalculateProgress(amount float64) int

CalculateProgress calculates the progress of a task based on the given amount.

func (*Task) Deactivate

func (t *Task) Deactivate()

Deactivate marks the task as inactive.

type TaskService

type TaskService interface {

	// CreateTask creates a new task in the system.
	CreateTask(
		c context.Context,
		campaign *Campaign,
		name, description string,
		taskType model.TaskType,
		minAmount float64,
		poolID string,
	) (*Task, error)
}

TaskService provides operations related to task management.

type Transaction

type Transaction struct {
	SwapDetail *model.SwapDetail
	// contains filtered or unexported fields
}

Transaction is an aggregate root that represents the transaction.

func NewTransaction

func NewTransaction(txHash, from, to string, blockNumber int64, ts time.Time) *Transaction

NewTransaction is used to create a new transaction.

func (*Transaction) GetSwapAmountByTokenAddress

func (x *Transaction) GetSwapAmountByTokenAddress(tokenAddress string) string

GetSwapAmountByTokenAddress is used to get the swap amount by token address.

func (*Transaction) GetSwapForPool

func (x *Transaction) GetSwapForPool(poolAddress common.Address, swapEventHash common.Hash) (*model.SwapDetail, error)

GetSwapForPool is used to get the swap for the pool.

func (*Transaction) GetTransaction

func (x *Transaction) GetTransaction() *model.Transaction

GetTransaction is used to get the transaction.

func (*Transaction) IsSwapType

func (x *Transaction) IsSwapType() bool

IsSwapType is used to check if the transaction is swap executed.

func (*Transaction) SwapUSDCAmount

func (x *Transaction) SwapUSDCAmount() string

SwapUSDCAmount is used to get the swap usdc amount.

func (*Transaction) Timestamp

func (x *Transaction) Timestamp() time.Time

Timestamp is used to get the timestamp.

func (*Transaction) TxHash

func (x *Transaction) TxHash() string

TxHash is used to get the transaction hash.

func (*Transaction) WithReceipt

func (x *Transaction) WithReceipt(receipt *types.Receipt) *Transaction

WithReceipt is used to set the receipt.

func (*Transaction) WithStatus

func (x *Transaction) WithStatus(status model.TransactionStatus) *Transaction

WithStatus is used to set the status.

type TransactionList

type TransactionList []*Transaction

TransactionList is a list of transactions.

type TransactionService

type TransactionService interface {
	// ProcessTransaction processes a transaction and updates the user's progress.
	ProcessTransaction(ctx context.Context, transaction *Transaction, user *User, task *Task) error
}

TransactionService defines the domain logic for processing transactions.

type User

type User struct {
	model.User

	Tasks        []*Task         `json:"tasks,omitempty"`
	Rewards      []*Reward       `json:"rewards,omitempty"`
	Transactions TransactionList `json:"transactions,omitempty"`
	// contains filtered or unexported fields
}

User is an aggregate root that represents the user.

func NewUser

func NewUser(address string) (*User, error)

NewUser creates a new User aggregate.

func (*User) OnSwapExecuted

func (x *User) OnSwapExecuted(ctx contextx.Contextx, tx *Transaction) error

OnSwapExecuted is called when a swap transaction is executed.

type UserService

type UserService interface {
	GetUserTaskListByAddress(c context.Context, address, campaignID string) (*User, error)
}

UserService defines the domain logic for user management.

Jump to

Keyboard shortcuts

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