include token data in transferPrices collection

This commit is contained in:
gipsh 2023-09-27 09:47:32 -03:00
parent 5c49a5ee9c
commit 1300ead930
1 changed files with 10 additions and 1 deletions

View File

@ -29,6 +29,12 @@ type TransferPriceDoc struct {
TokenAmount string `bson:"tokenAmount"`
// UsdAmount is the value in USD of the token being transferred.
UsdAmount string `bson:"usdAmount"`
// TokenChain is the chain ID of the token being transferred.
TokenChain uint16 `bson:"tokenChain"`
// TokenAddress is the address of the token being transferred.
TokenAddress string `bson:"tokenAddress"`
// CoinGeckoID is the CoinGecko ID of the token being transferred.
CoinGeckoID string `bson:"coinGeckoId"`
}
func upsertTransferPrices(
@ -92,10 +98,13 @@ func upsertTransferPrices(
SymbolPriceUsd: notionalUSD.Truncate(8).String(),
TokenAmount: tokenAmount.Truncate(8).String(),
UsdAmount: usdAmount.Truncate(8).String(),
TokenChain: uint16(transferredToken.TokenChain),
TokenAddress: transferredToken.TokenAddress.String(),
CoinGeckoID: tokenMeta.CoingeckoID,
},
}
_, err = transferPrices.UpdateByID(
context.Background(),
ctx,
vaa.MessageID(),
update,
options.Update().SetUpsert(true),