Documentation ¶
Index ¶
- Constants
- Variables
- func CallGetPdexSwapTxStatus(txhash string, config beCommon.Config) (bool, *beCommon.TradeDataRespond, error)
- func CallGetTxsByCoinPubKeys2(coinPubKeys []string, config beCommon.Config, incClient *incclient.IncClient) (map[string]map[string]metadata.Transaction, error)
- func CallSubmitPappSwapTx(txRaw, txHash, feeRefundOTA string, config beCommon.Config, endpoint string) (map[string]interface{}, error)
- func CheckIncTxIsConfirmed(txID string, numRecheck uint) (isConfirm bool, isMaxRecheck bool, shouldRefund bool, numRecheckRes uint, ...)
- func CheckStatusAndHandlePappTx(txData *beCommon.InterSwapTxData, config beCommon.Config) error
- func CheckStatusAndHandlePappTxSecond(txData *beCommon.InterSwapTxData, config beCommon.Config) error
- func CheckStatusAndHandlePdexTx(txData *beCommon.InterSwapTxData, config beCommon.Config) error
- func CheckStatusAndHandlePdexTxSecond(txData *beCommon.InterSwapTxData, config beCommon.Config) error
- func ConvertAmountToWithoutDec(amt uint64, pDecimal uint64) (float64, error)
- func ConvertUint64ToWithoutDecStr(amt uint64, tokenID string, config common.Config) (string, error)
- func ConvertUint64ToWithoutDecStr2(amt uint64, pDecimal uint64) (string, error)
- func EstimateSwap(params *EstimateSwapParam, config common.Config) (map[string][]InterSwapEstRes, error)
- func GetBestRoute(paths map[string][]QuoteData) map[string]*QuoteData
- func GetChildTokenUnified(tokenID string, networkID int, config beCommon.Config) (string, error)
- func Has0xPrefix(str string) bool
- func InitIncClient(network string, config common.Config) error
- func InitSupportedMidTokens(network string) error
- func IsExist(strArr []string, str string) bool
- func IsMidTokens(tokenID string) bool
- func IsOnlySwappablePDexToken(tokenInfo common.TokenInfo) bool
- func IsUniqueSlices(s []string) bool
- func MarshalCoin(utxos []coin.PlainCoin) []string
- func ParseUserAgent(userAgent string) string
- func ProcessInterswapTxRequest(ctx context.Context, m *pubsub.Message)
- func Remove0xPrefix(str string) string
- func SendSlackAlert(msg string)
- func SendSlackInfo(msg string)
- func SendSlackSwapInfo(interswapID string, userAgent string, status string, fromAmt uint64, ...) error
- func StartWorker(cfg wcommon.Config, serviceID uuid.UUID) error
- func UnmarshalCoin(utxoStrs []string) ([]coin.PlainCoin, error)
- type AddOnSwapInfo
- type EstimateSwapParam
- type EstimateSwapResponse
- type EstimateSwapResult
- type InterSwapEstRes
- type InterSwapPath
- type InterswapSubmitTxTask
- type PappNetworkFee
- type PappStatus
- type QuoteData
- type ReceivedTransactionV2
- type ResponseInfo
- type SubmitpAppSwapTxRequest
- type SubmitpAppSwapTxResponse
- type TransactionDetail
- type TxStatusRespond
Constants ¶
View Source
const ( SubmitFailed int = 0 FirstPending = 1 FirstRefunding = 2 FirstRefunded = 3 MidRefunding = 4 MidRefunded = 5 SecondPending = 6 SecondRefunding = 7 SecondRefunded = 8 SecondSuccess = 9 )
View Source
const DefaultDecimal = 9
View Source
const INTERSWAP_TX_TOPIC = "interswaptx_topic"
View Source
const IncNetworkStr = "inc"
View Source
const InterSwapStr = "interswap"
View Source
const InterswapPappPdexTask = "interswaptx_pathtype2" // Path 2: pApp => pDEX
View Source
const InterswapPdexPappTxTask = "interswaptx_pathtype1" // Path 1: pDEX => pApp
task by swap path
View Source
const InterswapPendingStr = "Pending"
View Source
const InterswapRefundedStr = "Refunded"
View Source
const InterswapRefundingStr = "Refunding"
View Source
const InterswapSubmitFailedStr = "Failed"
View Source
const InterswapSuccessStr = "Success"
View Source
const MaxNumRecheck = 5
View Source
const MaxNumRetry = 1
View Source
const MinBalance = 400000000
View Source
const PAppStr = "papp"
View Source
const PAppToPdex = 2
View Source
const PdexToPApp = 1
path type
Variables ¶
View Source
var BEEndpoint = os.Getenv("BE_ENDPOINT")
View Source
var InterswapIncKeySets map[string]*wallet.KeyWallet
View Source
var IsUpdate = false
View Source
var SkipTxs = []string{
"82a30987e144aed3f3a3c56c0f1209477fe1c0444d8c38643989674ed24bf339",
"b8d289152ca4e8819a2cc81cc5cff59ca999a71d80b34c2160df320936cbe669",
"1cd9e638e1a10182348dae56ca974356c5ee2d876b7ba0fedcb44594a08c8711",
}
View Source
var SlackAlert = os.Getenv("INTERSWAP_SLACK_ALERT")
View Source
var SlackInfo = os.Getenv("INTERSWAP_SLACK_INFO")
View Source
var StatusStr = map[int]string{ SubmitFailed: InterswapSubmitFailedStr, FirstPending: InterswapPendingStr, FirstRefunding: InterswapRefundingStr, FirstRefunded: InterswapRefundedStr, MidRefunding: InterswapRefundingStr, MidRefunded: InterswapRefundedStr, SecondPending: InterswapPendingStr, SecondSuccess: InterswapSuccessStr, SecondRefunding: InterswapRefundingStr, SecondRefunded: InterswapRefundedStr, }
View Source
var SupportedMidTokens = []string{}
View Source
var UtxoManager *utxomanager.UTXOManager
Functions ¶
func CallGetPdexSwapTxStatus ¶
func CallSubmitPappSwapTx ¶
func CallSubmitPappSwapTx(txRaw, txHash, feeRefundOTA string, config beCommon.Config, endpoint string) (map[string]interface{}, error)
CallSubmitPappSwapTx calls request to submit tx papp
func CheckIncTxIsConfirmed ¶
func CheckStatusAndHandlePappTx ¶
func CheckStatusAndHandlePappTx(txData *beCommon.InterSwapTxData, config beCommon.Config) error
func CheckStatusAndHandlePappTxSecond ¶
func CheckStatusAndHandlePappTxSecond(txData *beCommon.InterSwapTxData, config beCommon.Config) error
func CheckStatusAndHandlePdexTx ¶
func CheckStatusAndHandlePdexTx(txData *beCommon.InterSwapTxData, config beCommon.Config) error
func CheckStatusAndHandlePdexTxSecond ¶
func CheckStatusAndHandlePdexTxSecond(txData *beCommon.InterSwapTxData, config beCommon.Config) error
CheckStatusAndHandlePdexTxSecond
func EstimateSwap ¶
func EstimateSwap(params *EstimateSwapParam, config common.Config) (map[string][]InterSwapEstRes, error)
InterSwap estimate swap
func GetBestRoute ¶
GetBestRoute return the best one for each network (pdex & papps), and the best one for all pApps
func GetChildTokenUnified ¶
GetChildTokenUnified returns child token of unified token if token is not unified, return itself
func Has0xPrefix ¶
func InitSupportedMidTokens ¶
func IsMidTokens ¶
func IsUniqueSlices ¶
func MarshalCoin ¶
func ParseUserAgent ¶
func Remove0xPrefix ¶
Remove0xPrefix removes 0x prefix (if there) from string
func SendSlackAlert ¶
func SendSlackAlert(msg string)
func SendSlackInfo ¶
func SendSlackInfo(msg string)
func SendSlackSwapInfo ¶
Types ¶
type AddOnSwapInfo ¶
type EstimateSwapParam ¶
type EstimateSwapResponse ¶
type EstimateSwapResponse struct { Result EstimateSwapResult Error interface{} }
type EstimateSwapResult ¶
type EstimateSwapResult struct { Networks map[string][]QuoteData NetworksError map[string]interface{} }
func CallEstimateSwap ¶
func CallEstimateSwap(params *EstimateSwapParam, config beCommon.Config, endpoint string) (*EstimateSwapResult, error)
CallEstimateSwap call request to estimate swap for both pdex and papp
type InterSwapEstRes ¶
type InterSwapPath ¶
type InterSwapPath struct { Paths []*QuoteData FromToken string ToToken string MidToken string TotalFee PappNetworkFee }
type InterswapSubmitTxTask ¶
type InterswapSubmitTxTask struct { TxID string `json:"txid" bson:"txid"` TxRawBytes []byte `json:"txraw" bson:"txraw"` FromToken string `json:"fromtoken" bson:"fromtoken"` ToToken string `json:"totoken" bson:"totoken"` MidToken string `json:"midtoken" bson:"midtoken"` PathType int `json:"pathtype" bson:"pathtype"` FinalMinExpectedAmt uint64 `json:"final_minacceptedamount" bson:"final_minacceptedamount"` OTARefundFee string `json:"ota_refundfee" bson:"ota_refundfee"` OTARefund string `json:"ota_refund" bson:"ota_refund"` OTAFromToken string `json:"ota_fromtoken" bson:"ota_fromtoken"` OTAToToken string `json:"ota_totoken" bson:"ota_totoken"` AddOnTxID string `json:"addon_txid" bson:"addon_txid"` PAppName string `json:"papp_name" bson:"papp_name"` PAppNetwork string `json:"papp_network" bson:"papp_network"` PAppContract string `json:"papp_contract" bson:"papp_contract"` Status int `json:"status" bson:"status"` StatusStr string `json:"statusstr" bson:"statusstr"` UserAgent string `json:"useragent" bson:"useragent"` Error string `json:"error" bson:"error"` }
type PappNetworkFee ¶
type PappStatus ¶
type QuoteData ¶
type QuoteData struct { AppName string PAppNetwork 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 ReceivedTransactionV2 ¶
type ReceivedTransactionV2 struct { TxDetail 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"` Fee uint64 `json:"Fee"` // Fee applies: always consant Image string `json:"Image"` IsPrivacy bool `json:"IsPrivacy"` Proof privacy.Proof `json:"Proof"` // ProofDetail jsonresult.ProofDetail `json:"ProofDetail"` InputCoinPubKey string `json:"InputCoinPubKey"` OutputCoinPubKey []string `json:"OutputCoinPubKey"` OutputCoinSND []string `json:"OutputCoinSND"` TokenInputCoinPubKey string `json:"TokenInputCoinPubKey"` TokenOutputCoinPubKey []string `json:"TokenOutputCoinPubKey"` TokenOutputCoinSND []string `json:"TokenOutputCoinSND"` SigPubKey string `json:"SigPubKey,omitempty"` // 64 bytes Sig string `json:"Sig,omitempty"` // 64 bytes Metatype int `json:"Metatype"` 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 jsonresult.ProofDetail `json:"PrivacyCustomTokenProofDetail"` PrivacyCustomTokenIsPrivacy bool `json:"PrivacyCustomTokenIsPrivacy"` PrivacyCustomTokenFee uint64 `json:"PrivacyCustomTokenFee"` IsInMempool bool `json:"IsInMempool"` IsInBlock bool `json:"IsInBlock"` Info string `json:"Info"` } FromShardID byte }
func CallGetTxsByCoinPubKeys ¶
func CallGetTxsByCoinPubKeys(coinPubKeys []string, config beCommon.Config) ([]ReceivedTransactionV2, error)
call through coin service
type SubmitpAppSwapTxRequest ¶
type SubmitpAppSwapTxResponse ¶
type SubmitpAppSwapTxResponse struct {
Result map[string]interface{}
}
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"` }
func CallGetTxDetails ¶
func CallGetTxDetails(txhash string, config beCommon.Config) (*TransactionDetail, error)
type TxStatusRespond ¶
Click to show internal directories.
Click to hide internal directories.