escrow

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DistributionV2 uses legacy v2.x distribution
	DistributionV2 = "grid2"
	// DistributionV3 uses new v3.0 distribution
	DistributionV3 = "grid3"
	// DistributionCertifiedSales uses distribution if capacity is sold over
	// certified sales channel
	DistributionCertifiedSales = "certified-sales"
	// DistributionFamerSales uses distribution if farmer is re-buying or selling
	// his own capacity
	DistributionFamerSales = "farmer-sales"
)
View Source
const (
	// CuPriceDollarMonth CU price per month in dollar
	CuPriceDollarMonth = 10
	// SuPriceDollarMonth SU price per month in dollar
	SuPriceDollarMonth = 8
	// IP4uPriceDollarMonth IPv4U price per month in dollar
	IP4uPriceDollarMonth = 6

	// TftPriceMill tft price in millies
	TftPriceMill = 100 // 0.01 * 1000 (1mill = 1/1000 of a dollar)

)

Price for 1 CU or SU for 1 month is 10$ TFT price is fixed at 0.05 CU and SU price per second is CU -> (10 / 0.15) / (3600 *24*30) = 257.2 SU -> (8 / 0.15) / (3600 *24*30) = 257.2

View Source
const (

	// WisdomWallet as defined in https://wiki.threefold.io/#/threefold_foundation_wallets
	WisdomWallet = "GAI4C2BGOA3YHVQZZW7OW4FHOGGYWTUBEVNHB6MW4ZAFG7ZAA7D5IPC3"
)

Variables

View Source
var (
	// ErrNoCurrencySupported indicates a reservation was offered but none of the currencies
	// the farmer wants to pay in are currently supported
	ErrNoCurrencySupported = errors.New("none of the offered currencies are currently supported")
	// ErrNoCurrencyShared indicates that none of the currencies offered in the reservation
	// is supported by all farmers used
	ErrNoCurrencyShared = errors.New("none of the provided currencies is supported by all farmers")
)

AssetDistributions map

Functions

This section is empty.

Types

type Escrow

type Escrow interface {
	Run(ctx context.Context) error
	CapacityReservation(reservation capacitytypes.Reservation, supportedCurrencies []string) (types.CustomerCapacityEscrowInformation, error)
	PaidCapacity() <-chan schema.ID
}

Escrow are responsible for the payment flow of a reservation

type FarmAPI

type FarmAPI interface {
	// GetByID get a farm from the database using its ID
	GetByID(ctx context.Context, db *mongo.Database, id int64) (directorytypes.Farm, error)
	GetFarmCustomPriceForThreebot(ctx context.Context, db *mongo.Database, farmID, threebotID int64) (directorytypes.FarmThreebotPrice, error)
}

FarmAPI operations on farm database

type Free

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

Free implements the Escrow interface in a way that makes all reservation free

func NewFree

func NewFree(db *mongo.Database) *Free

NewFree creates a new EscrowFree object

func (*Free) CapacityReservation

func (e *Free) CapacityReservation(reservation capacitytypes.Reservation, _ []string) (detail types.CustomerCapacityEscrowInformation, err error)

CapacityReservation implements the escrow interface

func (*Free) PaidCapacity

func (e *Free) PaidCapacity() <-chan schema.ID

PaidCapacity implements the escrow interface

func (*Free) Run

func (e *Free) Run(ctx context.Context) error

Run implements the escrow interface

type GatewayAPI added in v0.4.9

type GatewayAPI interface {
	// Get a gateway from the database using its ID
	Get(ctx context.Context, db *mongo.Database, id string) (directorytypes.Gateway, error)
}

GatewayAPI operations for gateway database

type NodeAPI

type NodeAPI interface {
	// Get a node from the database using its ID
	Get(ctx context.Context, db *mongo.Database, id string, proofs bool) (directorytypes.Node, error)
}

NodeAPI operations on node database

type PaymentDestination added in v0.6.0

type PaymentDestination uint8

PaymentDestination type

const (
	// FarmerDestination destination
	FarmerDestination PaymentDestination = 0
	// BurnedDestination destination
	BurnedDestination PaymentDestination = 1
	// FoundationDestination destination
	FoundationDestination PaymentDestination = 2
	// SalesDestination destination
	SalesDestination PaymentDestination = 3
	// WisdomDestination destination
	WisdomDestination PaymentDestination = 4
)

type PaymentDistribution added in v0.6.0

type PaymentDistribution map[PaymentDestination]uint8

PaymentDistribution type is map from destination to a percent

func (PaymentDistribution) Valid added in v0.6.0

func (p PaymentDistribution) Valid() error

Valid checks if distribution is valid

type Payout added in v0.6.0

type Payout struct {
	Destination  PaymentDestination
	Distribution uint8
	Address      string
}

Payout structure

func (*Payout) Valid added in v0.6.0

func (p *Payout) Valid() error

Valid checks if payout is valid,

type Stellar

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

Stellar service manages a dedicate wallet for payments for reservations.

func NewStellar

func NewStellar(wallet stellar.Wallet, db *mongo.Database, foundationAddress string, gridNetwork gridnetworks.GridNetwork) *Stellar

NewStellar creates a new escrow object and fetches all addresses for the escrow wallet

func (*Stellar) CapacityReservation

func (e *Stellar) CapacityReservation(reservation capacitytypes.Reservation, supportedCurrencies []string) (types.CustomerCapacityEscrowInformation, error)

CapacityReservation implements Escrow

func (*Stellar) PaidCapacity

func (e *Stellar) PaidCapacity() <-chan schema.ID

PaidCapacity implements Escrow

func (*Stellar) Run

func (e *Stellar) Run(ctx context.Context) error

Run the escrow until the context is done

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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