From b9d306894e68f6dbc0727d65a5b6fd090dcc8b11 Mon Sep 17 00:00:00 2001 From: jeffyanta Date: Fri, 12 Dec 2025 11:39:51 -0500 Subject: [PATCH] Add USDC package --- ocp/common/mint.go | 3 ++- ocp/data/external.go | 11 ++++++----- ocp/transaction/alt.go | 2 ++ usdc/usdc.go | 15 +++++++++++++++ usdf/usdf.go | 4 ++-- 5 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 usdc/usdc.go diff --git a/ocp/common/mint.go b/ocp/common/mint.go index 17cf02f..03375fe 100644 --- a/ocp/common/mint.go +++ b/ocp/common/mint.go @@ -9,6 +9,7 @@ import ( "github.com/code-payments/ocp-server/ocp/config" ocp_data "github.com/code-payments/ocp-server/ocp/data" "github.com/code-payments/ocp-server/solana/currencycreator" + "github.com/code-payments/ocp-server/usdc" "github.com/code-payments/ocp-server/usdf" ) @@ -46,7 +47,7 @@ func IsCoreMint(mint *Account) bool { func IsCoreMintUsdStableCoin() bool { switch CoreMintAccount.PublicKey().ToBase58() { - case usdf.Mint: + case usdf.Mint, usdc.Mint: return true default: return false diff --git a/ocp/data/external.go b/ocp/data/external.go index 20419fd..0eb131e 100644 --- a/ocp/data/external.go +++ b/ocp/data/external.go @@ -5,12 +5,13 @@ import ( "errors" "time" - "github.com/code-payments/ocp-server/ocp/config" - "github.com/code-payments/ocp-server/ocp/data/currency" currency_lib "github.com/code-payments/ocp-server/currency" "github.com/code-payments/ocp-server/currency/coingecko" "github.com/code-payments/ocp-server/currency/fixer" "github.com/code-payments/ocp-server/metrics" + "github.com/code-payments/ocp-server/ocp/config" + "github.com/code-payments/ocp-server/ocp/data/currency" + "github.com/code-payments/ocp-server/usdc" "github.com/code-payments/ocp-server/usdf" ) @@ -50,7 +51,7 @@ func (dp *WebProvider) GetCurrentExchangeRatesFromExternalProviders(ctx context. var err error switch config.CoreMintPublicKeyString { - case usdf.Mint: + case usdc.Mint, usdf.Mint: coinGeckoRates[string(currency_lib.USD)] = 1.0 default: coinGeckoData, err := dp.coinGecko.GetCurrentRates(ctx, string(config.CoreMintSymbol)) @@ -83,7 +84,7 @@ func (dp *WebProvider) GetPastExchangeRatesFromExternalProviders(ctx context.Con ts := t var err error switch config.CoreMintPublicKeyString { - case usdf.Mint: + case usdc.Mint, usdf.Mint: coinGeckoRates[string(currency_lib.USD)] = 1.0 default: coinGeckoData, err := dp.coinGecko.GetCurrentRates(ctx, string(config.CoreMintSymbol)) @@ -116,7 +117,7 @@ func computeAllExchangeRates(coreMintRates map[string]float64, usdRates map[stri return nil, errors.New("usd rate missing") } switch config.CoreMintPublicKeyString { - case usdf.Mint: + case usdc.Mint, usdf.Mint: coreMintToUsd = 1.0 } diff --git a/ocp/transaction/alt.go b/ocp/transaction/alt.go index 1a0f661..a205725 100644 --- a/ocp/transaction/alt.go +++ b/ocp/transaction/alt.go @@ -10,6 +10,7 @@ import ( ocp_data "github.com/code-payments/ocp-server/ocp/data" "github.com/code-payments/ocp-server/solana" "github.com/code-payments/ocp-server/solana/system" + "github.com/code-payments/ocp-server/usdc" ) // GetAltForMint gets an address lookup table to operate in a versioned @@ -47,6 +48,7 @@ func GetAltForMint(ctx context.Context, data ocp_data.Provider, mint *common.Acc common.CoreMintAccount.PublicKey().ToBytes(), system.RentSysVar, system.RecentBlockhashesSysVar, + usdc.TokenMint, }, }, nil } diff --git a/usdc/usdc.go b/usdc/usdc.go new file mode 100644 index 0000000..0f2a7c7 --- /dev/null +++ b/usdc/usdc.go @@ -0,0 +1,15 @@ +package usdc + +import ( + "crypto/ed25519" +) + +const ( + Mint = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" + QuarksPerUsdf = 1000000 + Decimals = 6 +) + +var ( + TokenMint = ed25519.PublicKey{198, 250, 122, 243, 190, 219, 173, 58, 61, 101, 243, 106, 171, 201, 116, 49, 177, 187, 228, 194, 210, 246, 224, 228, 124, 166, 2, 3, 69, 47, 93, 97} +) diff --git a/usdf/usdf.go b/usdf/usdf.go index b0efaed..f755645 100644 --- a/usdf/usdf.go +++ b/usdf/usdf.go @@ -7,11 +7,11 @@ import ( // todo: Update config once USDF is created const ( - Mint = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" + Mint = "USDFmFa553nkGNSvFn2gXCnpPuWLkgre2aHmPMDyaWi" QuarksPerUsdf = 1000000 Decimals = 6 ) var ( - TokenMint = ed25519.PublicKey{198, 250, 122, 243, 190, 219, 173, 58, 61, 101, 243, 106, 171, 201, 116, 49, 177, 187, 228, 194, 210, 246, 224, 228, 124, 166, 2, 3, 69, 47, 93, 97} + TokenMint = ed25519.PublicKey{7, 7, 48, 54, 200, 135, 41, 84, 87, 240, 35, 129, 5, 62, 49, 49, 241, 253, 42, 157, 138, 222, 175, 252, 65, 146, 180, 12, 103, 218, 59, 22} )