From de8d2466ce8735f2d1dcb3a70122968ab4048e27 Mon Sep 17 00:00:00 2001 From: jeffyanta Date: Tue, 17 Feb 2026 15:06:39 -0500 Subject: [PATCH 1/5] Update common VM and mint utilities to be dynamic --- ocp/common/mint.go | 48 +++++-- ocp/common/vm.go | 344 ++++++--------------------------------------- 2 files changed, 80 insertions(+), 312 deletions(-) diff --git a/ocp/common/mint.go b/ocp/common/mint.go index ec2fff3..cb1c44a 100644 --- a/ocp/common/mint.go +++ b/ocp/common/mint.go @@ -4,6 +4,8 @@ import ( "bytes" "context" "errors" + "sync" + "time" commonpb "github.com/code-payments/ocp-protobuf-api/generated/go/common/v1" "github.com/code-payments/ocp-server/ocp/config" @@ -22,21 +24,16 @@ var ( ErrUnsupportedMint = errors.New("unsupported mint") - badBoysMintAccount, _ = NewAccountFromPublicKeyString(config.BadBoysMintPublicKey) - bluebucksMintAccount, _ = NewAccountFromPublicKeyString(config.BluebucksMintPublicKey) - bitsMintAccount, _ = NewAccountFromPublicKeyString(config.BitsMintPublicKey) - bogeyMintAccount, _ = NewAccountFromPublicKeyString(config.BogeyMintPublicKey) - floatMintAccount, _ = NewAccountFromPublicKeyString(config.FloatMintPublicKey) - jeffyMintAccount, _ = NewAccountFromPublicKeyString(config.JeffyMintPublicKey) - lightspeedMintAccount, _ = NewAccountFromPublicKeyString(config.LightspeedMintPublicKey) - linksMintAccount, _ = NewAccountFromPublicKeyString(config.LinksMintPublicKey) - marketCoinMintAccount, _ = NewAccountFromPublicKeyString(config.MarketCoinMintPublicKey) - moonyMintAccount, _ = NewAccountFromPublicKeyString(config.MoonyMintPublicKey) - testMintAccount, _ = NewAccountFromPublicKeyString(config.TestMintPublicKey) - toshiMintAccount, _ = NewAccountFromPublicKeyString(config.ToshiMintPublicKey) - xpMintAccount, _ = NewAccountFromPublicKeyString(config.XpMintPublicKey) + supportedMintCacheMu sync.RWMutex + supportedMintCache = make(map[string]supportedMintCacheEntry) + supportedMintCacheTTL = 1 * time.Minute ) +type supportedMintCacheEntry struct { + isSupported bool + cachedAt time.Time +} + func GetBackwardsCompatMint(protoMint *commonpb.SolanaAccountId) (*Account, error) { if protoMint == nil { return CoreMintAccount, nil @@ -74,6 +71,31 @@ func GetMintQuarksPerUnit(mint *Account) uint64 { } func IsSupportedMint(ctx context.Context, data ocp_data.Provider, mintAccount *Account) (bool, error) { + mintAddress := mintAccount.PublicKey().ToBase58() + + supportedMintCacheMu.RLock() + entry, ok := supportedMintCache[mintAddress] + supportedMintCacheMu.RUnlock() + if ok && time.Since(entry.cachedAt) < supportedMintCacheTTL { + return entry.isSupported, nil + } + + isSupported, err := isSupportedMint(ctx, data, mintAccount) + if err != nil { + return false, err + } + + supportedMintCacheMu.Lock() + supportedMintCache[mintAddress] = supportedMintCacheEntry{ + isSupported: isSupported, + cachedAt: time.Now(), + } + supportedMintCacheMu.Unlock() + + return isSupported, nil +} + +func isSupportedMint(ctx context.Context, data ocp_data.Provider, mintAccount *Account) (bool, error) { if !IsCoreMint(mintAccount) && !IsCoreMintUsdStableCoin() { return false, nil } diff --git a/ocp/common/vm.go b/ocp/common/vm.go index e908f22..7baef16 100644 --- a/ocp/common/vm.go +++ b/ocp/common/vm.go @@ -2,68 +2,19 @@ package common import ( "context" + "sync" "github.com/code-payments/ocp-server/ocp/config" ocp_data "github.com/code-payments/ocp-server/ocp/data" + vm_metadata "github.com/code-payments/ocp-server/ocp/data/vm/metadata" ) var ( CoreMintVmAccount, _ = NewAccountFromPublicKeyString(config.CoreMintVmAccountPublicKey) CoreMintVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.CoreMintVmOmnibusPublicKey) - // todo: DB store to track VM per mint - - badBoysAuthority, _ = NewAccountFromPublicKeyString(config.BadBoysAuthorityPublicKey) - badBoysVmAccount, _ = NewAccountFromPublicKeyString(config.BadBoysVmAccountPublicKey) - badBoysVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.BadBoysVmOmnibusPublicKey) - - bluebucksAuthority, _ = NewAccountFromPublicKeyString(config.BluebucksAuthorityPublicKey) - bluebucksVmAccount, _ = NewAccountFromPublicKeyString(config.BluebucksVmAccountPublicKey) - bluebucksVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.BluebucksVmOmnibusPublicKey) - - bitsAuthority, _ = NewAccountFromPublicKeyString(config.BitsAuthorityPublicKey) - bitsVmAccount, _ = NewAccountFromPublicKeyString(config.BitsVmAccountPublicKey) - bitsVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.BitsVmOmnibusPublicKey) - - bogeyAuthority, _ = NewAccountFromPublicKeyString(config.BogeyAuthorityPublicKey) - bogeyVmAccount, _ = NewAccountFromPublicKeyString(config.BogeyVmAccountPublicKey) - bogeyVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.BogeyVmOmnibusPublicKey) - - floatAuthority, _ = NewAccountFromPublicKeyString(config.FloatAuthorityPublicKey) - floatVmAccount, _ = NewAccountFromPublicKeyString(config.FloatVmAccountPublicKey) - floatVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.FloatVmOmnibusPublicKey) - - jeffyAuthority, _ = NewAccountFromPublicKeyString(config.JeffyAuthorityPublicKey) - jeffyVmAccount, _ = NewAccountFromPublicKeyString(config.JeffyVmAccountPublicKey) - jeffyVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.JeffyVmOmnibusPublicKey) - - lightspeedAuthority, _ = NewAccountFromPublicKeyString(config.LightspeedAuthorityPublicKey) - lightspeedVmAccount, _ = NewAccountFromPublicKeyString(config.LightspeedVmAccountPublicKey) - lightspeedVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.LightspeedVmOmnibusPublicKey) - - linksAuthority, _ = NewAccountFromPublicKeyString(config.LinksAuthorityPublicKey) - linksVmAccount, _ = NewAccountFromPublicKeyString(config.LinksVmAccountPublicKey) - linksVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.LinksVmOmnibusPublicKey) - - marketCoinAuthority, _ = NewAccountFromPublicKeyString(config.MarketCoinAuthorityPublicKey) - marketCoinVmAccount, _ = NewAccountFromPublicKeyString(config.MarketCoinVmAccountPublicKey) - marketCoinVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.MarketCoinVmOmnibusPublicKey) - - moonyAuthority, _ = NewAccountFromPublicKeyString(config.MoonyAuthorityPublicKey) - moonyVmAccount, _ = NewAccountFromPublicKeyString(config.MoonyVmAccountPublicKey) - moonyVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.MoonyVmOmnibusPublicKey) - - testAuthority, _ = NewAccountFromPublicKeyString(config.TestAuthorityPublicKey) - testVmAccount, _ = NewAccountFromPublicKeyString(config.TestVmAccountPublicKey) - testVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.TestVmOmnibusPublicKey) - - toshiAuthority, _ = NewAccountFromPublicKeyString(config.ToshiAuthorityPublicKey) - toshiVmAccount, _ = NewAccountFromPublicKeyString(config.ToshiVmAccountPublicKey) - toshiVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.ToshiVmOmnibusPublicKey) - - xpAuthority, _ = NewAccountFromPublicKeyString(config.XpAuthorityPublicKey) - xpVmAccount, _ = NewAccountFromPublicKeyString(config.XpVmAccountPublicKey) - xpVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.XpVmOmnibusPublicKey) + vmConfigCacheMu sync.RWMutex + vmConfigCache = make(map[string]*VmConfig) ) type VmConfig struct { @@ -74,266 +25,61 @@ type VmConfig struct { } func GetVmConfigForMint(ctx context.Context, data ocp_data.Provider, mintAccount *Account) (*VmConfig, error) { - if !IsCoreMint(mintAccount) && !IsCoreMintUsdStableCoin() { - return nil, ErrUnsupportedMint - } - - switch mintAccount.PublicKey().ToBase58() { - case CoreMintAccount.PublicKey().ToBase58(): + if IsCoreMint(mintAccount) { return &VmConfig{ Authority: GetSubsidizer(), Vm: CoreMintVmAccount, Omnibus: CoreMintVmOmnibusAccount, Mint: CoreMintAccount, }, nil - case badBoysMintAccount.PublicKey().ToBase58(): - if badBoysAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, badBoysAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } - - badBoysAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } - - return &VmConfig{ - Authority: badBoysAuthority, - Vm: badBoysVmAccount, - Omnibus: badBoysVmOmnibusAccount, - Mint: mintAccount, - }, nil - case bluebucksMintAccount.PublicKey().ToBase58(): - if bluebucksAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, bluebucksAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } - - bluebucksAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } - - return &VmConfig{ - Authority: bluebucksAuthority, - Vm: bluebucksVmAccount, - Omnibus: bluebucksVmOmnibusAccount, - Mint: mintAccount, - }, nil - case bitsMintAccount.PublicKey().ToBase58(): - if bitsAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, bitsAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } - - bitsAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } - - return &VmConfig{ - Authority: bitsAuthority, - Vm: bitsVmAccount, - Omnibus: bitsVmOmnibusAccount, - Mint: mintAccount, - }, nil - case bogeyMintAccount.PublicKey().ToBase58(): - if bogeyAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, bogeyAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } - - bogeyAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } - - return &VmConfig{ - Authority: bogeyAuthority, - Vm: bogeyVmAccount, - Omnibus: bogeyVmOmnibusAccount, - Mint: mintAccount, - }, nil - case floatMintAccount.PublicKey().ToBase58(): - if floatAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, floatAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } - - floatAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } - - return &VmConfig{ - Authority: floatAuthority, - Vm: floatVmAccount, - Omnibus: floatVmOmnibusAccount, - Mint: mintAccount, - }, nil - case jeffyMintAccount.PublicKey().ToBase58(): - if jeffyAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, jeffyAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } - - jeffyAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } - - return &VmConfig{ - Authority: jeffyAuthority, - Vm: jeffyVmAccount, - Omnibus: jeffyVmOmnibusAccount, - Mint: mintAccount, - }, nil - case lightspeedMintAccount.PublicKey().ToBase58(): - if lightspeedAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, lightspeedAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } - - lightspeedAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } - - return &VmConfig{ - Authority: lightspeedAuthority, - Vm: lightspeedVmAccount, - Omnibus: lightspeedVmOmnibusAccount, - Mint: mintAccount, - }, nil - case linksMintAccount.PublicKey().ToBase58(): - if linksAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, linksAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } - - linksAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } - - return &VmConfig{ - Authority: linksAuthority, - Vm: linksVmAccount, - Omnibus: linksVmOmnibusAccount, - Mint: mintAccount, - }, nil - case marketCoinMintAccount.PublicKey().ToBase58(): - if marketCoinAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, marketCoinAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } + } - marketCoinAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } + mintAddress := mintAccount.PublicKey().ToBase58() - return &VmConfig{ - Authority: marketCoinAuthority, - Vm: marketCoinVmAccount, - Omnibus: marketCoinVmOmnibusAccount, - Mint: mintAccount, - }, nil - case moonyMintAccount.PublicKey().ToBase58(): - if moonyAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, moonyAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } + vmConfigCacheMu.RLock() + cached, ok := vmConfigCache[mintAddress] + vmConfigCacheMu.RUnlock() + if ok { + return cached, nil + } - moonyAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } + record, err := data.GetVmMetadataByMint(ctx, mintAddress) + if err == vm_metadata.ErrNotFound { + return nil, ErrUnsupportedMint + } else if err != nil { + return nil, err + } - return &VmConfig{ - Authority: moonyAuthority, - Vm: moonyVmAccount, - Omnibus: moonyVmOmnibusAccount, - Mint: mintAccount, - }, nil - case testMintAccount.PublicKey().ToBase58(): - if testAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, testAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } + vaultRecord, err := data.GetKey(ctx, record.Authority) + if err != nil { + return nil, err + } - testAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } + authority, err := NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) + if err != nil { + return nil, err + } - return &VmConfig{ - Authority: testAuthority, - Vm: testVmAccount, - Omnibus: testVmOmnibusAccount, - Mint: mintAccount, - }, nil - case toshiMintAccount.PublicKey().ToBase58(): - if toshiAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, toshiAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } + vmAccount, err := NewAccountFromPublicKeyString(record.Vm) + if err != nil { + return nil, err + } - toshiAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } + omnibusAccount, err := NewAccountFromPublicKeyString(record.Omnibus) + if err != nil { + return nil, err + } - return &VmConfig{ - Authority: toshiAuthority, - Vm: toshiVmAccount, - Omnibus: toshiVmOmnibusAccount, - Mint: mintAccount, - }, nil - case xpMintAccount.PublicKey().ToBase58(): - if xpAuthority.PrivateKey() == nil { - vaultRecord, err := data.GetKey(ctx, xpAuthority.PublicKey().ToBase58()) - if err != nil { - return nil, err - } + vmConfig := &VmConfig{ + Authority: authority, + Vm: vmAccount, + Omnibus: omnibusAccount, + Mint: mintAccount, + } - xpAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey) - if err != nil { - return nil, err - } - } + vmConfigCacheMu.Lock() + vmConfigCache[mintAddress] = vmConfig + vmConfigCacheMu.Unlock() - return &VmConfig{ - Authority: xpAuthority, - Vm: xpVmAccount, - Omnibus: xpVmOmnibusAccount, - Mint: mintAccount, - }, nil - default: - return nil, ErrUnsupportedMint - } + return vmConfig, nil } From 2c24f6f9be7b07279d0546894993d7405ba8a93e Mon Sep 17 00:00:00 2001 From: jeffyanta Date: Tue, 17 Feb 2026 15:06:56 -0500 Subject: [PATCH 2/5] Remove launchpad currency hardcoded configs --- ocp/config/config.go | 67 -------------------------------------------- 1 file changed, 67 deletions(-) diff --git a/ocp/config/config.go b/ocp/config/config.go index 5230503..7456153 100644 --- a/ocp/config/config.go +++ b/ocp/config/config.go @@ -22,73 +22,6 @@ const ( CoreMintVmAccountPublicKey = "JACkaKsm2Rd6TNJwH4UB7G6tHrWUATJPTgNNnRVsg4ip" CoreMintVmOmnibusPublicKey = "D8oUTXRvarxhx9cjYdFJqWAVj2rmzry58bS6JSTiQsv5" - - // todo: DB store to track VM per mint - - BadBoysMintPublicKey = "64dkhPKhdjc2xg3NLyDjC14wiXHLnGXHHUxJnqZVugJt" - BadBoysAuthorityPublicKey = "bbVCosXYRMBTbcmLsRXqHSzaUDJpSStYRqTstcpVxwx" - BadBoysVmAccountPublicKey = "9EpU4RGoe7zfJdLjLyXWLpza6RZHqN6QV73z1gfNKCJa" - BadBoysVmOmnibusPublicKey = "7pQkiRaXdMW3bLJK6D1huP175AF5wD6gXNPBsvQ8bJZ3" - - BluebucksMintPublicKey = "4MrV36dgdC9kjkC3ibbe1LMUijXde27iJAjJByB7naSN" - BluebucksAuthorityPublicKey = "b1ue4ZAdQeQXw6fi8Gkn9vtmFsGmgFgARiAEwprrkBY" - BluebucksVmAccountPublicKey = "ED1AYFh6bfYCynvfYCiRHKrPSWvw4PfzprM7o3R954Bu" - BluebucksVmOmnibusPublicKey = "7EPGFrgYPNbVtHg5ovnhThSjiUST39R8jRegriadgehk" - - BitsMintPublicKey = "A3e8dzb1y4gqGP2cnCS3UU8dm5YNrFpZBpjjdoZdtfnB" - BitsAuthorityPublicKey = "bit8rCyAcstm1ZiwLq22FHdz8wAigKU46hmtrigrGub" - BitsVmAccountPublicKey = "5zDzL3CHb3wFxs7xnkxmWMGMR1gjNtYgV46PTBgSHmsJ" - BitsVmOmnibusPublicKey = "872F9FFXnSMPahkYjB8uF1pz1CrgMrmbfKQMGNCdVBvc" - - BogeyMintPublicKey = "3AhBb1fpDTp1F9hPkZjRPDejXBM9S5vfpVdvn66vLYnT" - BogeyAuthorityPublicKey = "bgy6SZdBCjVbftagjp4Vv5rvajTHmmh4ccsZbD9F3m3" - BogeyVmAccountPublicKey = "2KWN2ame8kZKfFc6iyNAWNZsTvByfo3Mrzue6NasNC5B" - BogeyVmOmnibusPublicKey = "H52LuBfwtBNZ3qrX8gqteF2mLx3EscdeUiryUC4fFFfR" - - FloatMintPublicKey = "5APqK9YUZupKt7rRUrpYy6WV3RPuxA71ZtKJffDUMdPP" - FloatAuthorityPublicKey = "f1t57oRwzBvtcqfAkjGKsEAbXymDSbL7pp3iRmDw9iz" - FloatVmAccountPublicKey = "5PKurz63VfSozHbkzwdudpDeA7mUuif8XTfNP932jRYy" - FloatVmOmnibusPublicKey = "98W5qFv7jiFvNA5c72kj7ku2hhFgaAEUfBXcLw8SK1yY" - - JeffyMintPublicKey = "54ggcQ23uen5b9QXMAns99MQNTKn7iyzq4wvCW6e8r25" - JeffyAuthorityPublicKey = "jfy1btcfsjSn2WCqLVaxiEjp4zgmemGyRsdCPbPwnZV" - JeffyVmAccountPublicKey = "8rwgUXsLSq1Pn51UJs4NGVA1cTkemwBgKyWPfFYgnm3B" - JeffyVmOmnibusPublicKey = "9XiqBPYSG2cBwpb8MqJeuFmLaQaAAr6gwikyBrPZDQ8R" - - LightspeedMintPublicKey = "D4Srn1tRU69JWvPeNGre1AiF2swFhw6bpUNyH18Dfag6" - LightspeedAuthorityPublicKey = "1spdvA8EGbo56cnGUDzt2FjWCwEWF5hY3jw6yz8BcWw" - LightspeedVmAccountPublicKey = "GkYnW2md9TdWV7ZmSnShaFGg3S1e62UmJMDtnYXG4gpe" - LightspeedVmOmnibusPublicKey = "5sBqTvFrfu6hCJPrxEcQ2PXvzLTfy4UCJjYxDoJcaP19" - - LinksMintPublicKey = "CPBcprSXXYerwh6LE6o3yc6NJqeZvm87GRSySgjTicE5" - LinksAuthorityPublicKey = "1nkSmZ9VCLBiQqSuMdmv9SXQ2y5wTJVnBW5ZsESjvzd" - LinksVmAccountPublicKey = "2s18j1EyBjRTcie48Hn6wyiZVCD9NrmkqH1JAKchoKT2" - LinksVmOmnibusPublicKey = "uWfyTHepnjF5KeJSTSWG7nUYsYrcFxV2URUh7Hh8htb" - - MarketCoinMintPublicKey = "311m6Sb1814PfAxkEcqq6MNdBiVZLr8VWuAWDSC72euW" - MarketCoinAuthorityPublicKey = "mrkthxqn4rKCZw1pDxhJTpCrvUBtK9m6aLvCeY3PyWR" - MarketCoinVmAccountPublicKey = "AeJ6x6mtwdjUM2AqppQ7zG6m89sx5c8qegfFPzjmD2x6" - MarketCoinVmOmnibusPublicKey = "CQMdG8AKtLP9JCU4GAzKunKnsfpXVFdMcSwQd3Hd5oZg" - - MoonyMintPublicKey = "4muAfB6m1P7C3Znad1VUsoqYFwvGQRkWGpJ3A4vupxz6" - MoonyAuthorityPublicKey = "mnyXRKy3pz8WXG4XQC6inaKNbzrqq2xRJfGv5Lq9qgR" - MoonyVmAccountPublicKey = "FCZitKZWuMfrZ3Krcp67egUwPzFoWM9Xo913S17qdjWV" - MoonyVmOmnibusPublicKey = "FvhtPHhARVkRJKfkM96Wvo2WEwjtiweyLAdpAroqT646" - - TestMintPublicKey = "2psDP3LAvbNzfvBYNMs9ieMpsD8PVzyQsKNfZrjEKoDN" - TestAuthorityPublicKey = "tstBCPtzNDycsM7rAd2CxzdgKh1gWrMULzrDHuGVXAW" - TestVmAccountPublicKey = "CYtzE732LQ7YP9sngSPUQhCCTQ8GY14dmjWX2hXP16Np" - TestVmOmnibusPublicKey = "65Ghp2FFPmdB3FLkC2NCKkBQ3RuXgmjZ56DDGZLVAZZa" - - ToshiMintPublicKey = "EfBCnuhon2uWSRB3WFqmWRQumiHvhZXYbUZXUcHDHNyz" - ToshiAuthorityPublicKey = "tshUiGXuyb4ujawe2fByjissauSdgDjuysSeGoV9Aga" - ToshiVmAccountPublicKey = "9VpRW29UXcyAZkXJpk4Pqcdz2HyprKPft6pyBKH6LGC1" - ToshiVmOmnibusPublicKey = "AmYSBrPT5ozvxjYT7Gq3B3imRHGoEoNpZ7ZDzcxJ1xKp" - - XpMintPublicKey = "6oZnhB1FPrUaDfhRCVZnbVWNKVx9wgj84vKGH7eMpzXL" - XpAuthorityPublicKey = "xpTXV7BNXwsdvCaFKfeT4h6rSnKck2Bv5iBAFFS5Uwk" - XpVmAccountPublicKey = "4qnCaQkGxCnr66cmPfpNfM2rxaaTMFSSfbY9gXZgCYdS" - XpVmOmnibusPublicKey = "5FCroyNvCXpLFkNuNQ4fw8Lk8xNGwGpwoTjzhRMbaBUo" ) var ( From 6b44587043e9740477432afa86742a508da53886 Mon Sep 17 00:00:00 2001 From: jeffyanta Date: Tue, 17 Feb 2026 15:07:16 -0500 Subject: [PATCH 3/5] Add dynamic Geyser token mint handling --- ocp/worker/geyser/handler.go | 69 +++++++++++++++--------------------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/ocp/worker/geyser/handler.go b/ocp/worker/geyser/handler.go index 774bc21..1c77fed 100644 --- a/ocp/worker/geyser/handler.go +++ b/ocp/worker/geyser/handler.go @@ -7,7 +7,6 @@ import ( "github.com/mr-tron/base58" "github.com/pkg/errors" - "github.com/code-payments/ocp-server/ocp/config" geyserpb "github.com/code-payments/ocp-server/ocp/worker/geyser/api/gen" "github.com/code-payments/ocp-server/ocp/common" @@ -76,56 +75,44 @@ func (h *TokenProgramAccountHandler) Handle(ctx context.Context, update *geyserp return errors.Wrap(err, "invalid owner account") } + // Not an ATA, so filter it out. It cannot be a VM deposit ATA + if bytes.Equal(tokenAccount.PublicKey().ToBytes(), ownerAccount.PublicKey().ToBytes()) { + return nil + } + mintAccount, err := common.NewAccountFromPublicKeyBytes(unmarshalled.Mint) if err != nil { return errors.Wrap(err, "invalid mint account") } - switch mintAccount.PublicKey().ToBase58() { - - // todo: Don't hardcode Jeffy and other Flipcash currencies - case common.CoreMintAccount.PublicKey().ToBase58(), - config.BadBoysMintPublicKey, - config.BluebucksMintPublicKey, - config.BitsMintPublicKey, - config.BogeyMintPublicKey, - config.FloatMintPublicKey, - config.JeffyMintPublicKey, - config.LightspeedMintPublicKey, - config.LinksMintPublicKey, - config.MarketCoinMintPublicKey, - config.MoonyMintPublicKey, - config.TestMintPublicKey, - config.ToshiMintPublicKey, - config.XpMintPublicKey: - // Not an ATA, so filter it out. It cannot be a VM deposit ATA - if bytes.Equal(tokenAccount.PublicKey().ToBytes(), ownerAccount.PublicKey().ToBytes()) { - return nil - } + isSupportedMint, err := common.IsSupportedMint(ctx, h.data, mintAccount) + if err != nil { + return errors.Wrap(err, "error checking if mint is supported") + } + if !isSupportedMint { + return nil + } - exists, userAuthorityAccount, err := testForKnownUserAuthorityFromDepositPda(ctx, h.data, ownerAccount) - if err != nil { - return errors.Wrap(err, "error testing for user authority from deposit pda") - } else if !exists { - return nil - } + exists, userAuthorityAccount, err := testForKnownUserAuthorityFromDepositPda(ctx, h.data, ownerAccount) + if err != nil { + return errors.Wrap(err, "error testing for user authority from deposit pda") + } else if !exists { + return nil + } - err = processPotentialExternalDepositIntoVm(ctx, h.data, h.integration, signature, userAuthorityAccount, mintAccount) - if err != nil { - return errors.Wrap(err, "error processing signature for external deposit into vm") - } + err = processPotentialExternalDepositIntoVm(ctx, h.data, h.integration, signature, userAuthorityAccount, mintAccount) + if err != nil { + return errors.Wrap(err, "error processing signature for external deposit into vm") + } - if unmarshalled.Amount > 0 { - err = initiateExternalDepositIntoVm(ctx, h.data, userAuthorityAccount, mintAccount, unmarshalled.Amount) - if err != nil { - return errors.Wrap(err, "error depositing into the vm") - } + if unmarshalled.Amount > 0 { + err = initiateExternalDepositIntoVm(ctx, h.data, userAuthorityAccount, mintAccount, unmarshalled.Amount) + if err != nil { + return errors.Wrap(err, "error depositing into the vm") } - - return nil - default: - return nil } + + return nil } func initializeProgramAccountUpdateHandlers(conf *conf, data ocp_data.Provider, integration Integration) map[string]ProgramAccountUpdateHandler { From b57aa8b9339ad0e11b0c87dbda21a9fa2f280624 Mon Sep 17 00:00:00 2001 From: jeffyanta Date: Tue, 17 Feb 2026 15:29:57 -0500 Subject: [PATCH 4/5] Add GetAllMints to currency store --- ocp/data/currency/memory/store.go | 16 +++++++ ocp/data/currency/postgres/model.go | 16 +++++++ ocp/data/currency/postgres/store.go | 4 ++ ocp/data/currency/store.go | 5 +++ ocp/data/currency/tests/tests.go | 65 +++++++++++++++++++++++++++++ ocp/data/internal.go | 4 ++ 6 files changed, 110 insertions(+) diff --git a/ocp/data/currency/memory/store.go b/ocp/data/currency/memory/store.go index a67d7c6..7b59de1 100644 --- a/ocp/data/currency/memory/store.go +++ b/ocp/data/currency/memory/store.go @@ -193,6 +193,22 @@ func (s *store) GetMetadata(ctx context.Context, mint string) (*currency.Metadat return nil, currency.ErrNotFound } +func (s *store) GetAllMints(ctx context.Context) ([]string, error) { + s.mu.Lock() + defer s.mu.Unlock() + + if len(s.metadataRecords) == 0 { + return nil, currency.ErrNotFound + } + + var mints []string + for _, item := range s.metadataRecords { + mints = append(mints, item.Mint) + } + + return mints, nil +} + func (s *store) PutReserveRecord(ctx context.Context, data *currency.ReserveRecord) error { if err := data.Validate(); err != nil { return err diff --git a/ocp/data/currency/postgres/model.go b/ocp/data/currency/postgres/model.go index a04366c..9ab4344 100644 --- a/ocp/data/currency/postgres/model.go +++ b/ocp/data/currency/postgres/model.go @@ -383,6 +383,22 @@ func dbGetMetadataByMint(ctx context.Context, db *sqlx.DB, mint string) (*metada return res, pgutil.CheckNoRows(err, currency.ErrNotFound) } +func dbGetAllMints(ctx context.Context, db *sqlx.DB) ([]string, error) { + var res []string + err := db.SelectContext(ctx, &res, + `SELECT mint FROM `+metadataTableName, + ) + + if err != nil { + return nil, pgutil.CheckNoRows(err, currency.ErrNotFound) + } + if len(res) == 0 { + return nil, currency.ErrNotFound + } + + return res, nil +} + func dbGetReserveByMintAndTime(ctx context.Context, db *sqlx.DB, mint string, t time.Time, ordering q.Ordering) (*reserveModel, error) { res := &reserveModel{} err := db.GetContext(ctx, res, diff --git a/ocp/data/currency/postgres/store.go b/ocp/data/currency/postgres/store.go index d5d03eb..d6823bc 100644 --- a/ocp/data/currency/postgres/store.go +++ b/ocp/data/currency/postgres/store.go @@ -124,6 +124,10 @@ func (s *store) GetMetadata(ctx context.Context, mint string) (*currency.Metadat return fromMetadataModel(model), nil } +func (s *store) GetAllMints(ctx context.Context) ([]string, error) { + return dbGetAllMints(ctx, s.db) +} + func (s *store) PutReserveRecord(ctx context.Context, record *currency.ReserveRecord) error { model, err := toReserveModel(record) if err != nil { diff --git a/ocp/data/currency/store.go b/ocp/data/currency/store.go index 964ede2..3b8e1c9 100644 --- a/ocp/data/currency/store.go +++ b/ocp/data/currency/store.go @@ -49,6 +49,11 @@ type Store interface { // GetMetadata gets currency creator mint metadata by the mint address GetMetadata(ctx context.Context, mint string) (*MetadataRecord, error) + // GetAllMints returns the public keys of all currency creator mints + // + // ErrNotFound is returned if no mints exist + GetAllMints(ctx context.Context) ([]string, error) + // PutReserveRecord puts a currency creator mint reserve records into the store. PutReserveRecord(ctx context.Context, record *ReserveRecord) error diff --git a/ocp/data/currency/tests/tests.go b/ocp/data/currency/tests/tests.go index 342a547..1e2c53a 100644 --- a/ocp/data/currency/tests/tests.go +++ b/ocp/data/currency/tests/tests.go @@ -18,6 +18,7 @@ func RunTests(t *testing.T, s currency.Store, teardown func()) { testExchangeRateRoundTrip, testGetExchangeRatesInRange, testMetadataRoundTrip, + testGetAllMints, testReserveRoundTrip, testGetReservesInRange, } { @@ -188,6 +189,70 @@ func testMetadataRoundTrip(t *testing.T, s currency.Store) { assertEquivalentMetadataRecords(t, cloned, actual) } +func testGetAllMints(t *testing.T, s currency.Store) { + // No mints should exist initially + mints, err := s.GetAllMints(context.Background()) + assert.Nil(t, mints) + assert.Equal(t, currency.ErrNotFound, err) + + // Insert two metadata records with different mints + record1 := ¤cy.MetadataRecord{ + Name: "Currency1", + Symbol: "C1", + Description: "First test currency", + ImageUrl: "https://example.com/c1.png", + BillColors: []string{"#000000"}, + SocialLinks: []currency.SocialLink{{Type: currency.SocialLinkTypeWebsite, Value: "https://example.com"}}, + + Seed: "seed1", + Authority: "auth1", + + Mint: "mint1111111111111111111111111111111111111111111", + MintBump: 255, + Decimals: currencycreator.DefaultMintDecimals, + + CurrencyConfig: "config1111111111111111111111111111111111111111", + CurrencyConfigBump: 255, + + LiquidityPool: "pool111111111111111111111111111111111111111111", + LiquidityPoolBump: 255, + + VaultMint: "vmint11111111111111111111111111111111111111111", + VaultMintBump: 255, + + VaultCore: "vcore11111111111111111111111111111111111111111", + VaultCoreBump: 255, + + SellFeeBps: currencycreator.DefaultSellFeeBps, + + Alt: "alt111111111111111111111111111111111111111111111", + + CreatedBy: "creator1", + CreatedAt: time.Now(), + } + + record2 := record1.Clone() + record2.Name = "Currency2" + record2.Symbol = "C2" + record2.Description = "Second test currency" + record2.Seed = "seed2" + record2.Mint = "mint2222222222222222222222222222222222222222222" + record2.CurrencyConfig = "config2222222222222222222222222222222222222222" + record2.LiquidityPool = "pool222222222222222222222222222222222222222222" + record2.VaultMint = "vmint22222222222222222222222222222222222222222" + record2.VaultCore = "vcore22222222222222222222222222222222222222222" + record2.Alt = "alt222222222222222222222222222222222222222222222" + + require.NoError(t, s.PutMetadata(context.Background(), record1)) + require.NoError(t, s.PutMetadata(context.Background(), record2)) + + mints, err = s.GetAllMints(context.Background()) + require.NoError(t, err) + assert.Len(t, mints, 2) + assert.Contains(t, mints, record1.Mint) + assert.Contains(t, mints, record2.Mint) +} + func testReserveRoundTrip(t *testing.T, s currency.Store) { now := time.Date(2021, 01, 29, 13, 0, 5, 0, time.UTC) diff --git a/ocp/data/internal.go b/ocp/data/internal.go index 0851afb..aa11a6a 100644 --- a/ocp/data/internal.go +++ b/ocp/data/internal.go @@ -137,6 +137,7 @@ type DatabaseData interface { ImportExchangeRates(ctx context.Context, record *currency.MultiRateRecord) error PutCurrencyMetadata(ctx context.Context, record *currency.MetadataRecord) error GetCurrencyMetadata(ctx context.Context, mint string) (*currency.MetadataRecord, error) + GetAllCurrencyMints(ctx context.Context) ([]string, error) PutCurrencyReserve(ctx context.Context, record *currency.ReserveRecord) error GetCurrencyReserveAtTime(ctx context.Context, mint string, t time.Time) (*currency.ReserveRecord, error) GetCurrencyReserveHistory(ctx context.Context, mint string, opts ...query.Option) ([]*currency.ReserveRecord, error) @@ -522,6 +523,9 @@ func (dp *DatabaseProvider) PutCurrencyMetadata(ctx context.Context, record *cur func (dp *DatabaseProvider) GetCurrencyMetadata(ctx context.Context, mint string) (*currency.MetadataRecord, error) { return dp.currencies.GetMetadata(ctx, mint) } +func (dp *DatabaseProvider) GetAllCurrencyMints(ctx context.Context) ([]string, error) { + return dp.currencies.GetAllMints(ctx) +} func (dp *DatabaseProvider) PutCurrencyReserve(ctx context.Context, record *currency.ReserveRecord) error { return dp.currencies.PutReserveRecord(ctx, record) } From 432250cab3f0d52b588369f92bedd7395aa0c3cc Mon Sep 17 00:00:00 2001 From: jeffyanta Date: Wed, 18 Feb 2026 12:26:06 -0500 Subject: [PATCH 5/5] Add dynamic currency reserve worker mint handling --- ocp/worker/currency/reserve.go | 281 +++++++-------------------------- 1 file changed, 61 insertions(+), 220 deletions(-) diff --git a/ocp/worker/currency/reserve.go b/ocp/worker/currency/reserve.go index c63ad17..88b8fa6 100644 --- a/ocp/worker/currency/reserve.go +++ b/ocp/worker/currency/reserve.go @@ -2,13 +2,13 @@ package currency import ( "context" + "sync" "time" "go.uber.org/zap" "github.com/code-payments/ocp-server/metrics" "github.com/code-payments/ocp-server/ocp/common" - "github.com/code-payments/ocp-server/ocp/config" currency_util "github.com/code-payments/ocp-server/ocp/currency" ocp_data "github.com/code-payments/ocp-server/ocp/data" "github.com/code-payments/ocp-server/ocp/data/currency" @@ -20,6 +20,9 @@ import ( type reserveRuntime struct { log *zap.Logger data ocp_data.Provider + + mintsMu sync.RWMutex + mints []*common.Account } func NewReserveRuntime(log *zap.Logger, data ocp_data.Provider) worker.Runtime { @@ -30,6 +33,8 @@ func NewReserveRuntime(log *zap.Logger, data ocp_data.Provider) worker.Runtime { } func (p *reserveRuntime) Start(runtimeCtx context.Context, interval time.Duration) error { + go p.pollMints(runtimeCtx, interval/3) + for { _, err := retry.Retry( func() error { @@ -68,241 +73,77 @@ func (p *reserveRuntime) Start(runtimeCtx context.Context, interval time.Duratio } } -// todo: Don't hardcode Jeffy and other Flipcash currencies -func (p *reserveRuntime) UpdateAllLaunchpadCurrencyReserves(ctx context.Context) error { - err1 := func() error { - bitsMintAccount, _ := common.NewAccountFromPublicKeyString(config.BitsMintPublicKey) - - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, bitsMintAccount) - if err != nil { - return err - } - - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: bitsMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() - - err2 := func() error { - bogeyMintAccount, _ := common.NewAccountFromPublicKeyString(config.BogeyMintPublicKey) - - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, bogeyMintAccount) - if err != nil { - return err - } - - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: bogeyMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() - - err3 := func() error { - floatMintAccount, _ := common.NewAccountFromPublicKeyString(config.FloatMintPublicKey) - - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, floatMintAccount) - if err != nil { - return err - } - - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: floatMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() - - err4 := func() error { - jeffyMintAccount, _ := common.NewAccountFromPublicKeyString(config.JeffyMintPublicKey) - - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, jeffyMintAccount) - if err != nil { - return err - } - - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: jeffyMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() - - err5 := func() error { - marketCoinMintAccount, _ := common.NewAccountFromPublicKeyString(config.MarketCoinMintPublicKey) - - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, marketCoinMintAccount) - if err != nil { - return err - } - - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: marketCoinMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() - - err6 := func() error { - xpMintAccount, _ := common.NewAccountFromPublicKeyString(config.XpMintPublicKey) - - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, xpMintAccount) - if err != nil { - return err - } - - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: xpMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() - - err7 := func() error { - badBoysMintAccount, _ := common.NewAccountFromPublicKeyString(config.BadBoysMintPublicKey) - - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, badBoysMintAccount) - if err != nil { - return err - } - - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: badBoysMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() - - err8 := func() error { - testMintAccount, _ := common.NewAccountFromPublicKeyString(config.TestMintPublicKey) +func (p *reserveRuntime) pollMints(ctx context.Context, interval time.Duration) { + // Initial fetch before the first reserve update + p.refreshMints(ctx) - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, testMintAccount) - if err != nil { - return err - } - - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: testMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() - - err9 := func() error { - moonyMintAccount, _ := common.NewAccountFromPublicKeyString(config.MoonyMintPublicKey) - - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, moonyMintAccount) - if err != nil { - return err + for { + select { + case <-ctx.Done(): + return + case <-time.After(interval): + p.refreshMints(ctx) } + } +} - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: moonyMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() - - err10 := func() error { - bluebucksMintAccount, _ := common.NewAccountFromPublicKeyString(config.BluebucksMintPublicKey) +func (p *reserveRuntime) refreshMints(ctx context.Context) { + mintStrings, err := p.data.GetAllCurrencyMints(ctx) + if err != nil { + p.log.With(zap.Error(err)).Warn("failed to refresh currency mints") + return + } - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, bluebucksMintAccount) + var mints []*common.Account + for _, mint := range mintStrings { + account, err := common.NewAccountFromPublicKeyString(mint) if err != nil { - return err + p.log.With(zap.Error(err), zap.String("mint", mint)).Warn("invalid mint public key") + continue } - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: bluebucksMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() - - err11 := func() error { - linksMintAccount, _ := common.NewAccountFromPublicKeyString(config.LinksMintPublicKey) - - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, linksMintAccount) - if err != nil { - return err + if common.IsCoreMint(account) { + continue } - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: linksMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() + mints = append(mints, account) + } - err12 := func() error { - lightspeedMintAccount, _ := common.NewAccountFromPublicKeyString(config.LightspeedMintPublicKey) + p.mintsMu.Lock() + p.mints = mints + p.mintsMu.Unlock() +} - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, lightspeedMintAccount) - if err != nil { - return err - } +func (p *reserveRuntime) getMints() []*common.Account { + p.mintsMu.RLock() + defer p.mintsMu.RUnlock() - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: lightspeedMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() + return p.mints +} - err13 := func() error { - toshiMintAccount, _ := common.NewAccountFromPublicKeyString(config.ToshiMintPublicKey) +func (p *reserveRuntime) UpdateAllLaunchpadCurrencyReserves(ctx context.Context) error { + mints := p.getMints() - ciculatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, toshiMintAccount) - if err != nil { - return err - } + for _, mint := range mints { + go func(mint *common.Account) { + log := p.log.With(zap.String("mint", mint.PublicKey().ToBase58())) - return p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ - Mint: toshiMintAccount.PublicKey().ToBase58(), - SupplyFromBonding: ciculatingSupply, - Time: ts, - }) - }() + circulatingSupply, ts, err := currency_util.GetLaunchpadCurrencyCirculatingSupply(ctx, p.data, mint) + if err != nil { + log.With(zap.Error(err)).Warn("failed to get circulating supply") + return + } - if err1 != nil { - return err1 - } - if err2 != nil { - return err2 - } - if err3 != nil { - return err3 - } - if err4 != nil { - return err4 - } - if err5 != nil { - return err5 - } - if err6 != nil { - return err6 - } - if err7 != nil { - return err7 - } - if err8 != nil { - return err8 - } - if err9 != nil { - return err9 - } - if err10 != nil { - return err10 - } - if err11 != nil { - return err11 - } - if err12 != nil { - return err12 - } - if err13 != nil { - return err13 + err = p.data.PutCurrencyReserve(ctx, ¤cy.ReserveRecord{ + Mint: mint.PublicKey().ToBase58(), + SupplyFromBonding: circulatingSupply, + Time: ts, + }) + if err != nil { + log.With(zap.Error(err)).Warn("failed to put currency reserve") + return + } + }(mint) } return nil