domain

package
v0.0.0-...-7608417 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const EmptyAddress = ""

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address = string

Address is the type for the participant's address

type Asset

type Asset = string

Asset is the type for the assets in the pair

type AssetAssuranceSigned

type AssetAssuranceSigned struct {
	Asset Asset    `json:"asset,omitempty"`
	Tx    SignedTx `json:"tx,omitempty"`
}

AssetAssuranceSigned is the event for signing the assurance transaction for the asset.

type AssetDeposited

type AssetDeposited struct {
	Asset  Asset  `json:"asset,omitempty"`
	TxHash TxHash `json:"tx_hash,omitempty"`
}

AssetDeposited is the event for signing the transfer transaction for the asset.

type LPDone

type LPDone struct {
	Asset    Asset     `json:"asset,omitempty"`
	TxHash   TxHash    `json:"tx_hash,omitempty"`
	Deadline time.Time `json:"deadline,omitempty"`
}

LPDone is the event for when the liquidity providing is done.

type MultiSigWalletSecurity

type MultiSigWalletSecurity string

MultiSigWalletSecurity is the type of security method used for threshold signature wallet In case of 2-2, both parties need to agree on signing the withdrawal transaction and in case of 2-3, a third-party signer is added as mediator.

const (
	MultiSigWalletSecurity2Of2 MultiSigWalletSecurity = "2-2"
)

type MultisigWallet

type MultisigWallet struct {
	PublicKeys    map[Asset]string  `json:"public_keys,omitempty"`
	Addresses     map[Asset]Address `json:"addresses,omitempty"`
	EncryptionKey string            `json:"encryption_key,omitempty"`
	HexChainCode  string            `json:"hex_chain_code,omitempty"`
}

MultisigWallet is the shared wallet for the pair of participants

func (*MultisigWallet) AreAddressesEqual

func (w *MultisigWallet) AreAddressesEqual(addresses map[Asset]Address) bool

type Pair

type Pair struct {
	eventsourcing.AggregateRoot
	Status                PairStatus             `json:"status,omitempty"`
	Assets                []Asset                `json:"assets,omitempty"`
	ParticipantsAddress   map[Asset]Address      `json:"participants_address,omitempty"`
	ShareValue            int                    `json:"share_value,omitempty"`
	InvestingPeriod       int                    `json:"investing_period,omitempty"`
	WalletSecurity        MultiSigWalletSecurity `json:"wallet_security,omitempty"`
	ProfitSharingStrategy ProfitSharingStrategy  `json:"profit_sharing_strategy,omitempty"`
	LossProtection        float64                `json:"loss_protection,omitempty"`
	Wallet                *MultisigWallet        `json:"wallet,omitempty"`
	Assurances            map[Asset][]SignedTx   `json:"assurances,omitempty"`
	Deposits              map[Asset]TxHash       `json:"deposits,omitempty"`
	WithdrawTx            *SignedTx              `json:"withdraw_tx,omitempty"`
	LP                    map[Asset]TxHash       `json:"lp,omitempty"`
	Deadline              time.Time              `json:"deadline,omitempty"`
	WithdrawnTx           *TxHash                `json:"withdrawn_tx,omitempty"`
}

Pair is the aggregate root for a pair of participates going through a liquidity providing process for a pair of crypto assets. We create a Pair for an individual participant for a plan with validated account address that has more than the required quantum of assets in $. After that the Pair is thrown in a queue or pool of Pairs with the ShareValue same as the quantum of the selected plan. The Pair is then matched with another participant who has interest in the same plan but with the counterpart asset. The participants then go through creating a shared wallet with the required security method and series of steps for the liquidity providing process.

func (Pair) AssetOfParticipant

func (p Pair) AssetOfParticipant(address Address) Asset

AssetOfParticipant returns the asset of the participant

func (Pair) HasAsset

func (p Pair) HasAsset(asset Asset) bool

HasAsset checks if the pair has the asset

func (Pair) HasAssurancesForAsset

func (p Pair) HasAssurancesForAsset(asset Asset) bool

HasAssurancesForAsset checks if the pair has assurances for the asset

func (Pair) HasDepositForAsset

func (p Pair) HasDepositForAsset(asset Asset) bool

HasDepositForAsset checks if the pair has deposits for the asset

func (Pair) HasLPForAsset

func (p Pair) HasLPForAsset(asset Asset) bool

HasLPForAsset checks if the pair has liquidity providing for the asset

func (Pair) HasParticipant

func (p Pair) HasParticipant(address Address) bool

HasParticipant checks if the pair has the participant

func (*Pair) Register

func (p *Pair) Register(r eventsourcing.RegisterFunc)

Register implements aggregate.Register

func (*Pair) Transition

func (p *Pair) Transition(event eventsourcing.Event)

Transition implements aggregate.Transition

type PairCreated

type PairCreated struct {
	ParticipantAsset      Asset                  `json:"participant_asset,omitempty"`
	ParticipantAddress    Address                `json:"participant_address,omitempty"`
	SecondaryAsset        Asset                  `json:"secondary_asset,omitempty"`
	ShareValue            int                    `json:"share_value,omitempty"`
	InvestingPeriod       int                    `json:"investing_period,omitempty"`
	WalletSecurity        MultiSigWalletSecurity `json:"wallet_security,omitempty"`
	ProfitSharingStrategy ProfitSharingStrategy  `json:"profit_sharing_strategy,omitempty"`
	LossProtection        float64                `json:"loss_protection,omitempty"`
}

PairCreated is the event for creating a new pair for the first time.

type PairMatched

type PairMatched struct {
	ParticipantAddress  Address `json:"participant_address,omitempty"`
	WalletEncryptionKey string  `json:"wallet_encryption_key,omitempty"`
	WalletHexChainCode  string  `json:"wallet_hex_chain_code,omitempty"`
}

PairMatched is the event for matching a pair with another participant.

type PairStatus

type PairStatus string

PairStatus is the type for the status of the pair

const (
	PairStatusWaiting            PairStatus = "waiting"
	PairStatusWalletConformation PairStatus = "wallet_conformation"
	PairStatusAssurance          PairStatus = "assurance"
	PairStatusDeposit            PairStatus = "deposit"
	PairStatusPreSignWithdrawal  PairStatus = "pre_sign_withdrawal"
	PairStatusLP                 PairStatus = "lp"
	PairStatusWithdrawn          PairStatus = "withdrawn"
	PairStatusInvalid            PairStatus = "invalid"
)

type PairStatusChanged

type PairStatusChanged struct {
	Status PairStatus `json:"status,omitempty"`
}

PairStatusChanged is the event for changing the status of the pair.

type Plan

type Plan struct {
	eventsourcing.AggregateRoot
	Assets          []Asset                `json:"assets,omitempty"`
	Security        MultiSigWalletSecurity `json:"security,omitempty"`
	Strategy        ProfitSharingStrategy  `json:"strategy,omitempty"`
	Quantum         int                    `json:"quantum,omitempty"`
	LossProtection  float64                `json:"loss_protection,omitempty"`
	InvestingPeriod int                    `json:"investing_period,omitempty"`
}

Plan is the aggregate root for a plan that bases around a pair of crypto assets for liquidity providing, a security method for shared wallet authority between the parties (2 of 2) or (2 of 3 including mediator), a strategy for profit splitting, quantum of each asset's share in $, agreed loss limit and a time frame (in weeks) for the plan.

func (*Plan) Register

func (p *Plan) Register(r eventsourcing.RegisterFunc)

Register implements aggregate.Register

func (*Plan) Transition

func (p *Plan) Transition(event eventsourcing.Event)

Transition implements aggregate.Transition

type PlanCreated

type PlanCreated struct {
	Assets          []Asset                `json:"assets,omitempty"`
	Security        MultiSigWalletSecurity `json:"security,omitempty"`
	Strategy        ProfitSharingStrategy  `json:"strategy,omitempty"`
	Quantum         int                    `json:"quantum,omitempty"`
	LossProtection  float64                `json:"loss_protection,omitempty"`
	InvestingPeriod int                    `json:"investing_period,omitempty"`
}

PlanCreated is the event for creating a new plan for the first time.

type ProfitSharingStrategy

type ProfitSharingStrategy string

ProfitSharingStrategy is the type of profit splitting strategy used for the plan PriceDependent is a strategy which splits the withdrawn assets based on how much assets price has changed at the withdrawal time compared to the time of deposit i.e. The participant who's assets dropped more gains less of the total share in $ value.

const (
	ProfitSharingStrategyEqualShare ProfitSharingStrategy = "equal_share"
)

type SignedTx

type SignedTx struct {
	Nonce     int    `json:"nonce"`
	Tx        []byte `json:"tx"`
	Signature []byte `json:"signature"`
}

SignedTx is the type for the transactions that are signed by the participants

type TxHash

type TxHash = string

TxHash is the type for the transaction hash

type WalletAddressConfirmed

type WalletAddressConfirmed struct {
	ParticipantAsset Asset             `json:"participant,omitempty"`
	PublicKey        string            `json:"public_key,omitempty"`
	WalletAddresses  map[Asset]Address `json:"addresses,omitempty"`
}

WalletAddressConfirmed is the event for confirming the shared wallet's addresses by the participants.

type WithdrawTxSigned

type WithdrawTxSigned struct {
	Tx SignedTx `json:"tx,omitempty"`
}

WithdrawTxSigned is the event for signing the withdrawal transaction.

type Withdrawn

type Withdrawn struct {
	TxHash TxHash `json:"tx_hash,omitempty"`
}

Withdrawn is the event for when the withdrawal is done.

Jump to

Keyboard shortcuts

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