Documentation ¶
Index ¶
- Constants
- Variables
- func MockAmount() model.Amount
- func MockCampaigns() []model.LiquidityCampaign
- func MockDelay(f features.F)
- func MockGetPool(address string) (pool *seawater.Pool)
- func MockGetPoolPositions(address types.Address) (positions model.SeawaterPositions)
- func MockGetPosition(id int) (position *seawater.Position)
- func MockLiquidity(fusdc, token types.Address) (liquidity []model.SeawaterLiquidity)
- func MockPriceOverTime(period int, fusdc, token types.Address) (history []string, average string, max string, err error)
- func MockSeawaterPools() (pools []seawater.Pool)
- func MockSwaps(fusdc types.Address, amount int, pool types.Address) model.SeawaterSwaps
- func MockToken(address string) (model.Token, error)
- func MockVolumeOverTime(period int, fusdc, token types.Address) (history []model.PairAmount, average *model.PairAmount, ...)
- func NewExecutableSchema(cfg Config) graphql.ExecutableSchema
- type AmountResolver
- type ComplexityRoot
- type Config
- type DirectiveRoot
- type LiquidityCampaignResolver
- type QueryResolver
- type Resolver
- func (r *Resolver) Amount() AmountResolver
- func (r *Resolver) LiquidityCampaign() LiquidityCampaignResolver
- func (r *Resolver) Query() QueryResolver
- func (r *Resolver) SeawaterConfig() SeawaterConfigResolver
- func (r *Resolver) SeawaterLiquidity() SeawaterLiquidityResolver
- func (r *Resolver) SeawaterPool() SeawaterPoolResolver
- func (r *Resolver) SeawaterPosition() SeawaterPositionResolver
- func (r *Resolver) SeawaterPositionsGlobal() SeawaterPositionsGlobalResolver
- func (r *Resolver) SeawaterPositionsUser() SeawaterPositionsUserResolver
- func (r *Resolver) SeawaterSwap() SeawaterSwapResolver
- func (r *Resolver) SeawaterSwaps() SeawaterSwapsResolver
- func (r *Resolver) Token() TokenResolver
- func (r *Resolver) Wallet() WalletResolver
- type ResolverRoot
- type SeawaterConfigResolver
- type SeawaterLiquidityResolver
- type SeawaterPoolResolver
- type SeawaterPositionResolver
- type SeawaterPositionsGlobalResolver
- type SeawaterPositionsUserResolver
- type SeawaterSwapResolver
- type SeawaterSwapsResolver
- type TokenResolver
- type WalletResolver
Constants ¶
const ( PoolPositionsPageSize = 50 SwapPositionsPageSize = 10 )
const LiquidityGroupsLimit = 20
Variables ¶
var (
// MaxMockedVolume for the random mocking of the volume/yield over time
MaxMockedVolume, _ = new(big.Int).SetString("10000000000000000000000000000", 10)
// MaxMockedPrice for the random mocking of the price/tvl/earned, divided by 1e5 for decimals
MaxMockedPrice = new(big.Int).SetInt64(10000000000)
// MinTick supported by the tick system of concentrated liquidity.
MinTick = -887272
// MaxTick of the inverted form of MinTick.
MaxTick = -MinTick
)
var ( Tokens = map[string]model.Token{ "0x65dfe41220c438bf069bbce9eb66b087fe65db36": {erc20.Erc20{ Address: types.AddressFromString("0x65dfe41220c438bf069bbce9eb66b087fe65db36"), Name: "NEW_TOKEN_2", TotalSupply: mustUnscaled("10000000001000040000"), Decimals: 18, Symbol: "NEW_TOKEN_2", }}, } Pools = map[string]seawater.Pool{ "0x65dfe41220c438bf069bbce9eb66b087fe65db36": { TransactionHash: "", BlockNumber: types.Number{}, Token: types.AddressFromString("0x65dfe41220c438bf069bbce9eb66b087fe65db36"), Fee: types.NumberFromBig(new(big.Int).SetInt64(0)), }, } Positions = map[string][]seawater.Position{ "0x65dfe41220c438bf069bbce9eb66b087fe65db36": {{ TransactionHash: "", BlockNumber: types.Number{}, Id: 0, Owner: types.AddressFromString("0xdca670597bcc35e11200fe07d9191a33a73850b9"), Pool: types.AddressFromString("0x65dfe41220c438bf069bbce9eb66b087fe65db36"), Lower: types.EmptyNumber(), Upper: types.EmptyNumber(), }}, } )
var Five = new(big.Int).SetInt64(5)
Five to reuse for the max integer
var FiveThousand = new(big.Int).SetInt64(500)
var Ten = new(big.Int).SetInt64(10)
Functions ¶
func MockAmount ¶
func MockCampaigns ¶
func MockCampaigns() []model.LiquidityCampaign
func MockGetPool ¶
func MockGetPoolPositions ¶
func MockGetPoolPositions(address types.Address) (positions model.SeawaterPositions)
func MockGetPosition ¶
func MockLiquidity ¶
func MockLiquidity(fusdc, token types.Address) (liquidity []model.SeawaterLiquidity)
func MockPriceOverTime ¶
func MockSeawaterPools ¶
func MockVolumeOverTime ¶
func MockVolumeOverTime(period int, fusdc, token types.Address) (history []model.PairAmount, average *model.PairAmount, maximum *model.PairAmount, err error)
func NewExecutableSchema ¶
func NewExecutableSchema(cfg Config) graphql.ExecutableSchema
NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.
Types ¶
type AmountResolver ¶
type AmountResolver interface { Token(ctx context.Context, obj *model.Amount) (model.Token, error) ValueUnscaled(ctx context.Context, obj *model.Amount) (string, error) ValueScaled(ctx context.Context, obj *model.Amount) (string, error) ValueUsd(ctx context.Context, obj *model.Amount) (string, error) }
type ComplexityRoot ¶
type ComplexityRoot struct { Amount struct { Decimals func(childComplexity int) int Timestamp func(childComplexity int) int Token func(childComplexity int) int ValueScaled func(childComplexity int) int ValueUnscaled func(childComplexity int) int ValueUsd func(childComplexity int) int } GetSwaps struct { Data func(childComplexity int) int } GetSwapsForUser struct { Data func(childComplexity int) int } LiquidityCampaign struct { CampaignID func(childComplexity int) int EndTimestamp func(childComplexity int) int FromTimestamp func(childComplexity int) int MaximumAmount func(childComplexity int) int Owner func(childComplexity int) int PerSecond func(childComplexity int) int Pool func(childComplexity int) int TickLower func(childComplexity int) int TickUpper func(childComplexity int) int } LiquidityOverTime struct { Daily func(childComplexity int) int Monthly func(childComplexity int) int } Note struct { Content func(childComplexity int) int Placement func(childComplexity int) int } PairAmount struct { Fusdc func(childComplexity int) int Timestamp func(childComplexity int) int Token1 func(childComplexity int) int } PriceOverTime struct { Daily func(childComplexity int) int Monthly func(childComplexity int) int } Query struct { ActiveLiquidityCampaigns func(childComplexity int) int Fusdc func(childComplexity int) int GetPool func(childComplexity int, token string) int GetPoolPositions func(childComplexity int, pool string, first *int, after *int) int GetPosition func(childComplexity int, id int) int GetPositions func(childComplexity int, wallet string, first *int, after *int) int GetSmartAccount func(childComplexity int, wallet string) int GetSwaps func(childComplexity int, pool string, first *int, after *int) int GetSwapsForUser func(childComplexity int, wallet string, first *int, after *int) int GetWallet func(childComplexity int, address string) int Notes func(childComplexity int, wallet string) int Pools func(childComplexity int) int Served func(childComplexity int) int UpcomingLiquidityCampaigns func(childComplexity int) int } SeawaterConfig struct { Classification func(childComplexity int) int Displayed func(childComplexity int) int ID func(childComplexity int) int Pool func(childComplexity int) int } SeawaterLiquidity struct { ID func(childComplexity int) int Liquidity func(childComplexity int) int Price func(childComplexity int) int TickLower func(childComplexity int) int TickUpper func(childComplexity int) int } SeawaterPool struct { Address func(childComplexity int) int Amounts func(childComplexity int) int Config func(childComplexity int) int EarnedFeesAPRToken1 func(childComplexity int) int EarnedFeesAprfusdc func(childComplexity int) int Fee func(childComplexity int) int ID func(childComplexity int) int Liquidity func(childComplexity int) int LiquidityCampaigns func(childComplexity int) int LiquidityOverTime func(childComplexity int) int Positions func(childComplexity int, first *int, after *int) int PositionsForUser func(childComplexity int, wallet string, first *int, after *int) int Price func(childComplexity int) int PriceOverTime func(childComplexity int) int Served func(childComplexity int) int Swaps func(childComplexity int, first *int, after *int) int TickSpacing func(childComplexity int) int Token func(childComplexity int) int TvlOverTime func(childComplexity int) int VolumeOverTime func(childComplexity int) int YieldOverTime func(childComplexity int) int } SeawaterPosition struct { Created func(childComplexity int) int ID func(childComplexity int) int IsVested func(childComplexity int) int Liquidity func(childComplexity int) int Lower func(childComplexity int) int Owner func(childComplexity int) int Pool func(childComplexity int) int PositionID func(childComplexity int) int Served func(childComplexity int) int Upper func(childComplexity int) int } SeawaterPositionsGlobal struct { ID func(childComplexity int) int Next func(childComplexity int, first *int) int Positions func(childComplexity int) int Sum func(childComplexity int) int } SeawaterPositionsUser struct { ID func(childComplexity int) int Next func(childComplexity int, first *int) int Positions func(childComplexity int) int Sum func(childComplexity int) int } SeawaterSwap struct { AmountIn func(childComplexity int) int AmountOut func(childComplexity int) int Pool func(childComplexity int) int Sender func(childComplexity int) int Served func(childComplexity int) int Timestamp func(childComplexity int) int TransactionHash func(childComplexity int) int } SeawaterSwaps struct { Next func(childComplexity int, first *int) int Sum func(childComplexity int) int Swaps func(childComplexity int) int } Served struct { Timestamp func(childComplexity int) int } Token struct { Address func(childComplexity int) int Decimals func(childComplexity int) int ID func(childComplexity int) int Image func(childComplexity int) int Name func(childComplexity int) int Symbol func(childComplexity int) int TotalSupply func(childComplexity int) int } TvlOverTime struct { Daily func(childComplexity int) int Monthly func(childComplexity int) int } VolumeOverTime struct { Daily func(childComplexity int) int Monthly func(childComplexity int) int } Wallet struct { Address func(childComplexity int) int Balances func(childComplexity int) int ID func(childComplexity int) int Positions func(childComplexity int, first *int, after *int) int } YieldOverTime struct { Daily func(childComplexity int) int Monthly func(childComplexity int) int } }
type Config ¶
type Config struct { Schema *ast.Schema Resolvers ResolverRoot Directives DirectiveRoot Complexity ComplexityRoot }
type DirectiveRoot ¶
type DirectiveRoot struct { }
type LiquidityCampaignResolver ¶
type LiquidityCampaignResolver interface { CampaignID(ctx context.Context, obj *model.LiquidityCampaign) (string, error) Owner(ctx context.Context, obj *model.LiquidityCampaign) (model.SeawaterPositionsUser, error) PerSecond(ctx context.Context, obj *model.LiquidityCampaign) (model.Amount, error) MaximumAmount(ctx context.Context, obj *model.LiquidityCampaign) (model.Amount, error) FromTimestamp(ctx context.Context, obj *model.LiquidityCampaign) (int, error) EndTimestamp(ctx context.Context, obj *model.LiquidityCampaign) (int, error) Pool(ctx context.Context, obj *model.LiquidityCampaign) (seawater.Pool, error) }
type QueryResolver ¶
type QueryResolver interface { Served(ctx context.Context) (model.Served, error) Fusdc(ctx context.Context) (model.Token, error) Pools(ctx context.Context) ([]seawater.Pool, error) ActiveLiquidityCampaigns(ctx context.Context) ([]model.LiquidityCampaign, error) UpcomingLiquidityCampaigns(ctx context.Context) ([]model.LiquidityCampaign, error) Notes(ctx context.Context, wallet string) ([]model.Note, error) GetPool(ctx context.Context, token string) (*seawater.Pool, error) GetPoolPositions(ctx context.Context, pool string, first *int, after *int) (model.SeawaterPositionsGlobal, error) GetPosition(ctx context.Context, id int) (*seawater.Position, error) GetPositions(ctx context.Context, wallet string, first *int, after *int) (model.SeawaterPositionsUser, error) GetWallet(ctx context.Context, address string) (*model.Wallet, error) GetSwaps(ctx context.Context, pool string, first *int, after *int) (model.GetSwaps, error) GetSwapsForUser(ctx context.Context, wallet string, first *int, after *int) (model.GetSwapsForUser, error) GetSmartAccount(ctx context.Context, wallet string) ([]model.Wallet, error) }
type Resolver ¶
type Resolver struct { DB *gorm.DB // db used to look up any fields that are missing from a request. F features.F // features to have enabled when requested Geth *ethclient.Client // needed to do lookups with geth C config.C // config for connecting to the right endpoints PoolsConfig map[types.Address]config.Pool // config for pools deployed only the backend knows. }
func (*Resolver) Amount ¶
func (r *Resolver) Amount() AmountResolver
Amount returns AmountResolver implementation.
func (*Resolver) LiquidityCampaign ¶
func (r *Resolver) LiquidityCampaign() LiquidityCampaignResolver
LiquidityCampaign returns LiquidityCampaignResolver implementation.
func (*Resolver) Query ¶
func (r *Resolver) Query() QueryResolver
Query returns QueryResolver implementation.
func (*Resolver) SeawaterConfig ¶
func (r *Resolver) SeawaterConfig() SeawaterConfigResolver
SeawaterConfig returns SeawaterConfigResolver implementation.
func (*Resolver) SeawaterLiquidity ¶
func (r *Resolver) SeawaterLiquidity() SeawaterLiquidityResolver
SeawaterLiquidity returns SeawaterLiquidityResolver implementation.
func (*Resolver) SeawaterPool ¶
func (r *Resolver) SeawaterPool() SeawaterPoolResolver
SeawaterPool returns SeawaterPoolResolver implementation.
func (*Resolver) SeawaterPosition ¶
func (r *Resolver) SeawaterPosition() SeawaterPositionResolver
SeawaterPosition returns SeawaterPositionResolver implementation.
func (*Resolver) SeawaterPositionsGlobal ¶
func (r *Resolver) SeawaterPositionsGlobal() SeawaterPositionsGlobalResolver
SeawaterPositionsGlobal returns SeawaterPositionsGlobalResolver implementation.
func (*Resolver) SeawaterPositionsUser ¶
func (r *Resolver) SeawaterPositionsUser() SeawaterPositionsUserResolver
SeawaterPositionsUser returns SeawaterPositionsUserResolver implementation.
func (*Resolver) SeawaterSwap ¶
func (r *Resolver) SeawaterSwap() SeawaterSwapResolver
SeawaterSwap returns SeawaterSwapResolver implementation.
func (*Resolver) SeawaterSwaps ¶
func (r *Resolver) SeawaterSwaps() SeawaterSwapsResolver
SeawaterSwaps returns SeawaterSwapsResolver implementation.
func (*Resolver) Token ¶
func (r *Resolver) Token() TokenResolver
Token returns TokenResolver implementation.
func (*Resolver) Wallet ¶
func (r *Resolver) Wallet() WalletResolver
Wallet returns WalletResolver implementation.
type ResolverRoot ¶
type ResolverRoot interface { Amount() AmountResolver LiquidityCampaign() LiquidityCampaignResolver Query() QueryResolver SeawaterConfig() SeawaterConfigResolver SeawaterLiquidity() SeawaterLiquidityResolver SeawaterPool() SeawaterPoolResolver SeawaterPosition() SeawaterPositionResolver SeawaterPositionsGlobal() SeawaterPositionsGlobalResolver SeawaterPositionsUser() SeawaterPositionsUserResolver SeawaterSwap() SeawaterSwapResolver SeawaterSwaps() SeawaterSwapsResolver Token() TokenResolver Wallet() WalletResolver }
type SeawaterConfigResolver ¶
type SeawaterPoolResolver ¶
type SeawaterPoolResolver interface { Served(ctx context.Context, obj *seawater.Pool) (model.Served, error) ID(ctx context.Context, obj *seawater.Pool) (string, error) Fee(ctx context.Context, obj *seawater.Pool) (int, error) Address(ctx context.Context, obj *seawater.Pool) (string, error) TickSpacing(ctx context.Context, obj *seawater.Pool) (string, error) Token(ctx context.Context, obj *seawater.Pool) (model.Token, error) Price(ctx context.Context, obj *seawater.Pool) (string, error) PriceOverTime(ctx context.Context, obj *seawater.Pool) (model.PriceOverTime, error) VolumeOverTime(ctx context.Context, obj *seawater.Pool) (model.VolumeOverTime, error) LiquidityOverTime(ctx context.Context, obj *seawater.Pool) (model.LiquidityOverTime, error) TvlOverTime(ctx context.Context, obj *seawater.Pool) (model.TvlOverTime, error) YieldOverTime(ctx context.Context, obj *seawater.Pool) (model.YieldOverTime, error) EarnedFeesAprfusdc(ctx context.Context, obj *seawater.Pool) ([]string, error) EarnedFeesAPRToken1(ctx context.Context, obj *seawater.Pool) ([]string, error) LiquidityCampaigns(ctx context.Context, obj *seawater.Pool) ([]model.LiquidityCampaign, error) Positions(ctx context.Context, obj *seawater.Pool, first *int, after *int) (model.SeawaterPositionsGlobal, error) PositionsForUser(ctx context.Context, obj *seawater.Pool, wallet string, first *int, after *int) (model.SeawaterPositionsUser, error) Liquidity(ctx context.Context, obj *seawater.Pool) ([]model.SeawaterLiquidity, error) Swaps(ctx context.Context, obj *seawater.Pool, first *int, after *int) (model.SeawaterSwaps, error) Amounts(ctx context.Context, obj *seawater.Pool) (model.PairAmount, error) Config(ctx context.Context, obj *seawater.Pool) (model.SeawaterConfig, error) }
type SeawaterPositionResolver ¶
type SeawaterPositionResolver interface { Served(ctx context.Context, obj *seawater.Position) (model.Served, error) ID(ctx context.Context, obj *seawater.Position) (string, error) Created(ctx context.Context, obj *seawater.Position) (int, error) PositionID(ctx context.Context, obj *seawater.Position) (int, error) Owner(ctx context.Context, obj *seawater.Position) (model.Wallet, error) Pool(ctx context.Context, obj *seawater.Position) (seawater.Pool, error) Lower(ctx context.Context, obj *seawater.Position) (int, error) Upper(ctx context.Context, obj *seawater.Position) (int, error) Liquidity(ctx context.Context, obj *seawater.Position) (model.PairAmount, error) }
type SeawaterPositionsGlobalResolver ¶
type SeawaterPositionsGlobalResolver interface { ID(ctx context.Context, obj *model.SeawaterPositionsGlobal) (string, error) Sum(ctx context.Context, obj *model.SeawaterPositionsGlobal) ([]model.PairAmount, error) Next(ctx context.Context, obj *model.SeawaterPositionsGlobal, first *int) (model.SeawaterPositionsGlobal, error) }
type SeawaterPositionsUserResolver ¶
type SeawaterPositionsUserResolver interface { ID(ctx context.Context, obj *model.SeawaterPositionsUser) (string, error) Sum(ctx context.Context, obj *model.SeawaterPositionsUser) ([]model.PairAmount, error) Next(ctx context.Context, obj *model.SeawaterPositionsUser, first *int) (model.SeawaterPositionsUser, error) }
type SeawaterSwapResolver ¶
type SeawaterSwapResolver interface { Served(ctx context.Context, obj *model.SeawaterSwap) (model.Served, error) Timestamp(ctx context.Context, obj *model.SeawaterSwap) (int, error) Pool(ctx context.Context, obj *model.SeawaterSwap) (seawater.Pool, error) TransactionHash(ctx context.Context, obj *model.SeawaterSwap) (string, error) Sender(ctx context.Context, obj *model.SeawaterSwap) (model.Wallet, error) AmountIn(ctx context.Context, obj *model.SeawaterSwap) (model.Amount, error) AmountOut(ctx context.Context, obj *model.SeawaterSwap) (model.Amount, error) }
type SeawaterSwapsResolver ¶
type SeawaterSwapsResolver interface { Sum(ctx context.Context, obj *model.SeawaterSwaps) ([]model.PairAmount, error) Next(ctx context.Context, obj *model.SeawaterSwaps, first *int) (model.SeawaterSwaps, error) }
type TokenResolver ¶
type WalletResolver ¶
type WalletResolver interface { ID(ctx context.Context, obj *model.Wallet) (string, error) Address(ctx context.Context, obj *model.Wallet) (string, error) Balances(ctx context.Context, obj *model.Wallet) ([]model.Amount, error) Positions(ctx context.Context, obj *model.Wallet, first *int, after *int) (model.SeawaterPositionsUser, error) }