api

package
v0.0.0-...-c0e0e34 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolFee = "protocol_fee"
	NetworkFee  = "network_fee"
)
View Source
const EmptyExternalAddress = "0000000000000000000000000000000000000000"
View Source
const (
	UNSHIELD_GAS_LIMIT = 300000
)

Variables

View Source
var (
	NotTradeable = errors.New("No tradeable network found")
)

Functions

func APICollectionAssets

func APICollectionAssets(c *gin.Context)

func APICollectionDetail

func APICollectionDetail(c *gin.Context)

func APIEstimateBuyFee

func APIEstimateBuyFee(c *gin.Context)

func APIEstimateReward

func APIEstimateReward(c *gin.Context)

func APIEstimateSwapFee

func APIEstimateSwapFee(c *gin.Context)

func APIEstimateUnshield

func APIEstimateUnshield(c *gin.Context)

func APIGenShieldAddress

func APIGenShieldAddress(c *gin.Context)

func APIGenUnshieldAddress

func APIGenUnshieldAddress(c *gin.Context)

func APIGetCollections

func APIGetCollections(c *gin.Context)

func APIGetDefaultTokenList

func APIGetDefaultTokenList(c *gin.Context)

func APIGetFailedShieldTx

func APIGetFailedShieldTx(c *gin.Context)

func APIGetInterswapTxStatus

func APIGetInterswapTxStatus(c *gin.Context)

func APIGetNetworksFee

func APIGetNetworksFee(c *gin.Context)

func APIGetPendingShieldTx

func APIGetPendingShieldTx(c *gin.Context)

func APIGetPendingSwapTx

func APIGetPendingSwapTx(c *gin.Context)

func APIGetShieldStatus

func APIGetShieldStatus(c *gin.Context)

func APIGetStatusByShieldService

func APIGetStatusByShieldService(c *gin.Context)

func APIGetSupportedToken

func APIGetSupportedToken(c *gin.Context)

func APIGetSupportedTokenInfo

func APIGetSupportedTokenInfo(c *gin.Context)

func APIGetSupportedTokenInternal

func APIGetSupportedTokenInternal(c *gin.Context)

func APIGetSwapTxStatus

func APIGetSwapTxStatus(c *gin.Context)

func APIGetUnshieldStatus

func APIGetUnshieldStatus(c *gin.Context)

func APIGetUnshieldTxStatus

func APIGetUnshieldTxStatus(c *gin.Context)

func APIGetVaultState

func APIGetVaultState(c *gin.Context)

func APINFTDetail

func APINFTDetail(c *gin.Context)

func APIRetryShieldTx

func APIRetryShieldTx(c *gin.Context)

func APIRetrySwapTx

func APIRetrySwapTx(c *gin.Context)

func APISearchToken

func APISearchToken(c *gin.Context)

func APISubmitBuyTx

func APISubmitBuyTx(c *gin.Context)

func APISubmitInterSwapTx

func APISubmitInterSwapTx(c *gin.Context)

func APISubmitShieldTx

func APISubmitShieldTx(c *gin.Context)

func APISubmitSwapTx

func APISubmitSwapTx(c *gin.Context)

func APISubmitUnshieldTx

func APISubmitUnshieldTx(c *gin.Context)

func APISubmitUnshieldTxNew

func APISubmitUnshieldTxNew(c *gin.Context)

func APITrackDEXSwap

func APITrackDEXSwap(c *gin.Context)

func APIUnshieldFeeEstimate

func APIUnshieldFeeEstimate(c *gin.Context)

func APIValidateAddress

func APIValidateAddress(c *gin.Context)

func ConvertNanoAmountOutChainToIncognitoNanoTokenAmountString

func ConvertNanoAmountOutChainToIncognitoNanoTokenAmountString(amountStr string, decimal, pDecimals int64) uint64

convert nano coin to nano token: ex: 2000000000000000 (nano eth) => 2000000 (nano pETH)

func ConvertNanoIncogTokenToOutChainToken

func ConvertNanoIncogTokenToOutChainToken(amountStr string, decimal, pDecimals int64) uint64

func ConvertToNanoIncognitoToken

func ConvertToNanoIncognitoToken(coinAmount *big.Float, pdecimal int64) *big.Float

convert coin amount to incognito nano token amount: ex: 002(ETH)*1e9=2000000 nano pETH

func InitInterswapIncKeySet

func InitInterswapIncKeySet(keys map[string]string) error

func IsValidOTAs

func IsValidOTAs(otas []string) (bool, error)

func StartAPIservice

func StartAPIservice(cfg common.Config)

func ValidateSubmitInterSwapTxRequest

func ValidateSubmitInterSwapTxRequest(req SubmitInterSwapTxRequest, network string) (bool, string, error)

validate sanity request

func VerifyCaptcha

func VerifyCaptcha(clientCaptcha string, secret string) (bool, error)

Types

type APIRespond

type APIRespond struct {
	Result interface{}
	Error  *string
}

type APITokenInfoRequest

type APITokenInfoRequest struct {
	TokenIDs []string
	Nocache  bool
}

type AddOnSwapInfo

type AddOnSwapInfo struct {
	ToToken        string
	Path           []string
	MinAcceptedAmt uint64
	CallContract   string
	AppName        string
}

type CurvePoolIndex

type CurvePoolIndex struct {
	CurveTokenIndex  int
	CurvePoolAddress string
	DappTokenAddress string
	DappTokenSymbol  string
}

type DexSwap

type DexSwap struct {
	Txhash       string `json:"txhash"`
	TokenSell    string `json:"token_sell"`
	TokenBuy     string `json:"token_buy"`
	AmountIn     string `json:"amount_in"`
	MinAmountOut string `json:"amount_out"`
}

type EstimateRewardRequest

type EstimateRewardRequest struct {
	UnifiedTokenID string
	TokenID        string
	Amount         uint64
}

type EstimateRewardRespond

type EstimateRewardRespond struct {
	ReceiveAmount uint64
	Reward        uint64
}

type EstimateSwapRequest

type EstimateSwapRequest struct {
	FeeAddress  string
	Network     string
	Amount      string
	Slippage    string
	MultiTrades bool
	MinSplit    int
	FromToken   string // IncTokenID
	ToToken     string // IncTokenID
	ShardID     string

	IsFromInterswap bool // dafault false
}

type EstimateSwapRespond

type EstimateSwapRespond struct {
	Networks      map[string]interface{}
	NetworksError map[string]interface{}
}

type EstimateSwapResult

type EstimateSwapResult struct {
	EstimateReceive float64
	Fees            map[string]FeeModel
	Rewards         map[string]RewardModel
}

type EstimateUnshieldRequest

type EstimateUnshieldRequest struct {
	UnifiedTokenID string
	TokenID        string
	ExpectedAmount uint64
	BurntAmount    uint64

	Network string
}

type EstimateUnshieldRespond

type EstimateUnshieldRespond struct {
	BurntAmount       uint64
	Fee               uint64
	ReceivedAmount    uint64
	MaxFee            uint64
	MinReceivedAmount uint64
}

type FeeModel

type FeeModel struct {
	FeeType string
	Fee     float64
	TokenID string
}

type GenBTCShieldAddressRequest

type GenBTCShieldAddressRequest struct {
	ShieldAddress string `json:"btcaddress"`
	IncAddress    string `json:"incaddress"`
}

type GenShieldAddressRequest

type GenShieldAddressRequest struct {
	Network             string
	AddressType         int
	CurrencyType        int
	PrivacyTokenAddress string
	WalletAddress       string
	RequestedAmount     string
	IncognitoAmount     string
	PaymentAddress      string

	BTCIncAddress string
}

type GenUnshieldAddressRequest

type GenUnshieldAddressRequest struct {
	Network             string
	RequestedAmount     string
	AddressType         int
	IncognitoAmount     string
	PaymentAddress      string
	PrivacyTokenAddress string
	WalletAddress       string
	IncognitoTx         string
	UnifiedTokenID      string
	SignPublicKeyEncode string
	CurrencyType        int
}

type HistoryAddressResp

type HistoryAddressResp struct {
	ID      uint
	UserID  uint
	Address string

	ExpiredAt time.Time

	EstFeeAt *time.Time

	AddressType int
	Status      int

	StatusMessage string
	StatusDetail  string

	CurrencyType       int
	Network            string
	WalletAddress      string
	UserPaymentAddress string
	RequestedAmount    string
	ReceivedAmount     string
	IncognitoAmount    string

	EthereumTx  string
	IncognitoTx string

	Erc20TokenTx string

	PrivacyTokenAddress string
	Erc20TokenAddress   string

	CreatedAt time.Time
	UpdatedAt time.Time

	Decentralized int

	OutChainTx string
	InChainTx  string

	TokenFee   string
	PrivacyFee string

	OutChainPrivacyFee string
	OutChainTokenFee   string

	BurnTokenFee   string
	BurnPrivacyFee string

	IncognitoTxToPayOutsideChainFee string

	Note string
	Memo string

	TxReceive string

	UnifiedStatus *UnifiedStatus

	UnifiedReward *UnifiedReward

	Decimals  int64
	PDecimals uint64
}

type InterswapStatus

type InterswapStatus struct {
	Status       string
	PdexTxID     string
	PappTxID     string
	FromAmount   uint64
	FromToken    string
	ToAmount     uint64
	ToToken      string
	ResponseTxID string
	RefundAmount uint64
	RefundToken  string
	RefundTxID   string
	TxIDOutchain string
}

type OpenSeaFee

type OpenSeaFee struct {
	FeeAddress        string `json:"feeAddress"`
	FeeAddressShardID int    `json:"feeAddressShardID"`
	TokenID           string `json:"tokenid"`
	Amount            uint64 `json:"feeAmount"`
	PrivacyFee        uint64 `json:"privacyFee"`
	// ProtocolFee       uint64  `json:"protocolFee"`
	FeeInUSD float64 `json:"feeInUSD"`
}

type PancakeQuote

type PancakeQuote struct {
	Data struct {
		Outputs []string `json:"outputs"`
		Route   []string `json:"paths"`
		Impact  float64  `json:"impactAmount"`
	} `json:"data"`
	Message string `json:"message"`
	Error   string `json:"error"`
}

type PancakeTokenMapItem

type PancakeTokenMapItem struct {
	Decimals int    `json:"decimals"`
	Symbol   string `json:"symbol"`
}

type PappNetworkFee

type PappNetworkFee struct {
	TokenID          string  `json:"tokenid"`
	Amount           uint64  `json:"amount"`
	AmountInBuyToken string  `json:"amountInBuyToken"`
	PrivacyFee       uint64  `json:"privacyFee"`
	FeeInUSD         float64 `json:"feeInUSD"`
}

type PappSupportedTokenData

type PappSupportedTokenData struct {
	ID                string
	ContractID        string
	ContractIDGetRate string
	Name              string
	Symbol            string
	PricePrv          float64
	Decimals          int
	PDecimals         int
	Protocol          string
	Verify            bool
	IsPopular         bool
	Priority          int
	DappID            int
	CurrencyType      int
	NetworkID         int
	MovedUnifiedToken bool
	NetworkName       string
}

type PdexEstimateRespond

type PdexEstimateRespond struct {
	SellAmount    float64
	MaxGet        float64
	Fee           uint64
	Route         []string
	TokenRoute    []string
	IsSignificant bool
	ImpactAmount  float64
}

type QuoteDataResp

type QuoteDataResp struct {
	AppName              string
	CallContract         string
	AmountIn             string
	AmountInRaw          string
	AmountOut            string
	AmountOutRaw         string
	AmountOutPreSlippage string
	RedepositReward      string
	Rate                 string
	Fee                  []PappNetworkFee
	FeeAddress           string
	FeeAddressShardID    int
	Paths                interface{}
	PathsContract        interface{}
	PoolPairs            []string
	Calldata             string
	ImpactAmount         string
	RouteDebug           interface{}
}

type RetrySwapTx

type RetrySwapTx struct {
	Txs []string
}

type RewardModel

type RewardModel struct {
	RewardType string
	Reward     float64
	TokenID    string
}

type ShieldStatus

type ShieldStatus struct {
	Status    byte               `json:"Status"`
	Data      []ShieldStatusData `json:"Data,omitempty"`
	ErrorCode int                `json:"ErrorCode,omitempty"`
}

type ShieldStatusData

type ShieldStatusData struct {
	Amount uint64 `json:"Amount"`
	Reward uint64 `json:"Reward"`
}

type StatusSwapTxDetail

type StatusSwapTxDetail struct {
	SellToken  string
	SellAmount uint64
	BuyToken   string
	Networks   []string
}

type SubmitInterSwapTxRequest

type SubmitInterSwapTxRequest struct {
	TxRaw  string
	TxHash string

	FromToken           string
	ToToken             string
	MidToken            string
	FinalMinExpectedAmt uint64
	Slippage            string

	PAppName    string
	PAppNetwork string
	ShardID     string

	OTARefundFee    string // user's OTA to receive refunded swap papp fee (sender is BE, receiver is user)
	OTARefund       string // user's OTA to receive fund from InterswapBE only in case PappPdexType and the first tx is reverted (sender is InterswapBE, receiver is user)
	OTAFromToken    string // user's OTA to receive refunded swap amount (sell token || mid token)
	OTAToToken      string // user's OTA to receive buy token
	WithdrawAddress string // only withdraw when PathType = pDexToPapp
}

type SubmitShieldTx

type SubmitShieldTx struct {
	Txhash  string
	Network int
	TokenID string
	Captcha string
}

type SubmitSwapTx

type SubmitSwapTx struct {
	Network string
	Txhash  string
}

type SubmitSwapTxRequest

type SubmitSwapTxRequest struct {
	TxRaw            string
	TxHash           string
	FeeRefundOTA     string
	FeeRefundAddress string
}

type SubmitTxListRequest

type SubmitTxListRequest struct {
	TxList []string
}

type SubmitUnshieldTxRequest

type SubmitUnshieldTxRequest struct {
	Network             string
	IncognitoAmount     string
	PaymentAddress      string
	PrivacyTokenAddress string
	WalletAddress       string

	UserFeeLevel     int
	ID               int
	IncognitoTx      string
	UserFeeSelection int

	//centralized
	PrivacyFee                      string
	TokenFee                        string
	Address                         string
	IncognitoTxToPayOutsideChainFee string
}

type TokenStruct

type TokenStruct struct {
	ID string `json:"id"`
}

type TransactionDetail

type TransactionDetail struct {
	BlockHash   string `json:"BlockHash"`
	BlockHeight uint64 `json:"BlockHeight"`
	TxSize      uint64 `json:"TxSize"`
	Index       uint64 `json:"Index"`
	ShardID     byte   `json:"ShardID"`
	Hash        string `json:"Hash"`
	Version     int8   `json:"Version"`
	Type        string `json:"Type"` // Transaction type
	LockTime    string `json:"LockTime"`
	RawLockTime int64  `json:"RawLockTime,omitempty"`
	Fee         uint64 `json:"Fee"` // Fee applies: always consant
	Image       string `json:"Image"`

	IsPrivacy bool `json:"IsPrivacy"`
	// Proof           privacy.Proof `json:"Proof"`
	// ProofDetail     interface{}   `json:"ProofDetail"`
	InputCoinPubKey string `json:"InputCoinPubKey"`
	SigPubKey       string `json:"SigPubKey,omitempty"` // 64 bytes
	RawSigPubKey    []byte `json:"RawSigPubKey,omitempty"`
	Sig             string `json:"Sig,omitempty"` // 64 bytes

	Metadata                      string      `json:"Metadata"`
	CustomTokenData               string      `json:"CustomTokenData"`
	PrivacyCustomTokenID          string      `json:"PrivacyCustomTokenID"`
	PrivacyCustomTokenName        string      `json:"PrivacyCustomTokenName"`
	PrivacyCustomTokenSymbol      string      `json:"PrivacyCustomTokenSymbol"`
	PrivacyCustomTokenData        string      `json:"PrivacyCustomTokenData"`
	PrivacyCustomTokenProofDetail interface{} `json:"PrivacyCustomTokenProofDetail"`
	PrivacyCustomTokenIsPrivacy   bool        `json:"PrivacyCustomTokenIsPrivacy"`
	PrivacyCustomTokenFee         uint64      `json:"PrivacyCustomTokenFee"`

	IsInMempool bool `json:"IsInMempool"`
	IsInBlock   bool `json:"IsInBlock"`

	Info string `json:"Info"`
}

type TxStatusRespond

type TxStatusRespond struct {
	TxHash string
	Status string
	Error  string
}

type UnifiedReward

type UnifiedReward struct {
	Status int
	Amount uint64
	Reward uint64
}

type UnifiedStatus

type UnifiedStatus struct {
	Fee            uint64
	ReceivedAmount uint64
	Status         int
}

type UniswapQuote

type UniswapQuote struct {
	Data struct {
		AmountIn         string           `json:"amountIn"`
		AmountOut        string           `json:"amountOut"`
		AmountOutRaw     string           `json:"amountOutRaw"`
		Route            [][]UniswapRoute `json:"route"`
		Impact           float64          `json:"impact"`
		EstimatedGasUsed string           `json:"estimatedGasUsed"`
	} `json:"data"`
	Message string `json:"message"`
	Error   string `json:"error"`
}

type UniswapQuoteToken

type UniswapQuoteToken struct {
	Address  string `json:"address"`
	Name     string `json:"name"`
	Symbol   string `json:"symbol"`
	IsNative bool   `json:"isNative"`
}

type UniswapRoute

type UniswapRoute struct {
	AmountIn          string            `json:"amountIn"`
	AmountOut         string            `json:"amountOut"`
	Fee               int64             `json:"fee"`
	Liquidity         string            `json:"liquidity"`
	Percent           float64           `json:"percent"`
	Type              string            `json:"type"`
	PoolAddress       string            `json:"poolAddress"`
	RawQuote          string            `json:"rawQuote"`
	SqrtPriceX96After string            `json:"sqrtPriceX96After"`
	TokenIn           UniswapQuoteToken `json:"tokenIn"`
	TokenOut          UniswapQuoteToken `json:"tokenOut"`
}

type UnshieldNetworkFee

type UnshieldNetworkFee struct {
	FeeAddress        string  `json:"feeAddress"`
	FeeAddressShardID int     `json:"feeAddressShardID"`
	ExpectedReceive   uint64  `json:"expectedReceive"`
	BurntAmount       uint64  `json:"burntAmount"`
	TokenID           string  `json:"tokenid"`
	Amount            uint64  `json:"feeAmount"`
	PrivacyFee        uint64  `json:"privacyFee"`
	ProtocolFee       uint64  `json:"protocolFee"`
	FeeInUSD          float64 `json:"feeInUSD"`
}

type UnshieldRequest

type UnshieldRequest struct {
	UnifiedTokenID common.Hash           `json:"UnifiedTokenID"`
	Data           []UnshieldRequestData `json:"Data"`
	Receiver       coin.OTAReceiver      `json:"Receiver"`
	IsDepositToSC  bool                  `json:"IsDepositToSC"`
	metadataCommon.MetadataBase
}

type UnshieldRequestData

type UnshieldRequestData struct {
	IncTokenID        common.Hash `json:"IncTokenID"`
	BurningAmount     uint64      `json:"BurningAmount"`
	MinExpectedAmount uint64      `json:"MinExpectedAmount"`
	RemoteAddress     string      `json:"RemoteAddress"`
}

type UnshieldServiceAuth

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

Jump to

Keyboard shortcuts

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