Skip to content

Commit 1cc3222

Browse files
committed
Support a third launchpad currency
1 parent 95ae4f8 commit 1cc3222

File tree

7 files changed

+67
-2
lines changed

7 files changed

+67
-2
lines changed

pkg/code/async/currency/reserve.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (p *reserveService) Start(serviceCtx context.Context, interval time.Duratio
7070
}
7171
}
7272

73-
// todo: Don't hardcode Jeffy
73+
// todo: Don't hardcode Jeffy and other Flipcash currencies
7474
func (p *reserveService) UpdateAllLaunchpadCurrencyReserves(ctx context.Context) error {
7575
err1 := func() error {
7676
jeffyMintAccount, _ := common.NewAccountFromPublicKeyString("52MNGpgvydSwCtC2H4qeiZXZ1TxEuRVCRGa8LAfk2kSj")
@@ -128,12 +128,43 @@ func (p *reserveService) UpdateAllLaunchpadCurrencyReserves(ctx context.Context)
128128
})
129129
}()
130130

131+
err3 := func() error {
132+
farmerCoinMintAccount, _ := common.NewAccountFromPublicKeyString("2o4PFbDZ73BihFraknfVTQeUtELKAeVUL4oa6bkrYU3A")
133+
farmerCoinVaultAccount, _ := common.NewAccountFromPublicKeyString("29LVpSKGQ9PmdWnXmrTD6RmNqNTW9umCjfJzdFPXNKAR")
134+
coreMintVaultAccount, _ := common.NewAccountFromPublicKeyString("7hdq6ipigk9Jb5LwpK8M4688Fch4a8Q9HLsjQp8R2VLw")
135+
136+
var tokenAccount token.Account
137+
ai, err := p.data.GetBlockchainAccountInfo(ctx, farmerCoinVaultAccount.PublicKey().ToBase58(), solana.CommitmentFinalized)
138+
if err != nil {
139+
return err
140+
}
141+
tokenAccount.Unmarshal(ai.Data)
142+
farmerCoinVaultBalance := tokenAccount.Amount
143+
144+
ai, err = p.data.GetBlockchainAccountInfo(ctx, coreMintVaultAccount.PublicKey().ToBase58(), solana.CommitmentFinalized)
145+
if err != nil {
146+
return err
147+
}
148+
tokenAccount.Unmarshal(ai.Data)
149+
coreMintVaultBalance := tokenAccount.Amount
150+
151+
return p.data.PutCurrencyReserve(ctx, &currency.ReserveRecord{
152+
Mint: farmerCoinMintAccount.PublicKey().ToBase58(),
153+
SupplyFromBonding: currencycreator.DefaultMintMaxQuarkSupply - farmerCoinVaultBalance,
154+
CoreMintLocked: coreMintVaultBalance,
155+
Time: time.Now(),
156+
})
157+
}()
158+
131159
if err1 != nil {
132160
return err1
133161
}
134162
if err2 != nil {
135163
return err2
136164
}
165+
if err3 != nil {
166+
return err3
167+
}
137168

138169
return nil
139170
}

pkg/code/async/geyser/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (h *TokenProgramAccountHandler) Handle(ctx context.Context, update *geyserp
8585

8686
switch mintAccount.PublicKey().ToBase58() {
8787

88-
case common.CoreMintAccount.PublicKey().ToBase58(), "52MNGpgvydSwCtC2H4qeiZXZ1TxEuRVCRGa8LAfk2kSj", "497Wy6cY9BjWBiaDHzJ7TcUZqF2gE1Qm7yXtSj1vSr5W":
88+
case common.CoreMintAccount.PublicKey().ToBase58(), "52MNGpgvydSwCtC2H4qeiZXZ1TxEuRVCRGa8LAfk2kSj", "497Wy6cY9BjWBiaDHzJ7TcUZqF2gE1Qm7yXtSj1vSr5W", "2o4PFbDZ73BihFraknfVTQeUtELKAeVUL4oa6bkrYU3A":
8989
// Not an ATA, so filter it out. It cannot be a VM deposit ATA
9090
if bytes.Equal(tokenAccount.PublicKey().ToBytes(), ownerAccount.PublicKey().ToBytes()) {
9191
return nil

pkg/code/async/nonce/metrics.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ func (p *service) metricsGaugeWorker(ctx context.Context) error {
5151
}
5252
recordNonceCountEvent(ctx, nonce.EnvironmentCvm, "9Du5GuKYT21ydLQ9KzUTWWQ7NKdwoXB15y4ypNnnpbJa", state, nonce.PurposeClientTransaction, count)
5353

54+
count, err = p.data.GetNonceCountByStateAndPurpose(ctx, nonce.EnvironmentCvm, "5x9SP9a7dEGxK4xy8kurh8RC2fxvL1DSXhTCdcAMgpdb", state, nonce.PurposeClientTransaction)
55+
if err != nil {
56+
continue
57+
}
58+
recordNonceCountEvent(ctx, nonce.EnvironmentCvm, "5x9SP9a7dEGxK4xy8kurh8RC2fxvL1DSXhTCdcAMgpdb", state, nonce.PurposeClientTransaction, count)
59+
5460
count, err = p.data.GetNonceCountByStateAndPurpose(ctx, nonce.EnvironmentSolana, nonce.EnvironmentInstanceSolanaMainnet, state, nonce.PurposeOnDemandTransaction)
5561
if err != nil {
5662
continue

pkg/code/async/nonce/service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func (p *service) Start(ctx context.Context, interval time.Duration) error {
6969
common.CodeVmAccount.PublicKey().ToBase58(),
7070
"Bii3UFB9DzPq6UxgewF5iv9h1Gi8ZnP6mr7PtocHGNta",
7171
"9Du5GuKYT21ydLQ9KzUTWWQ7NKdwoXB15y4ypNnnpbJa",
72+
"5x9SP9a7dEGxK4xy8kurh8RC2fxvL1DSXhTCdcAMgpdb",
7273
} {
7374
for _, state := range []nonce.State{
7475
nonce.StateReleased,

pkg/code/common/mint.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var (
2424

2525
jeffyMintAccount, _ = NewAccountFromPublicKeyString(config.JeffyMintPublicKey)
2626
knicksNightMintAccount, _ = NewAccountFromPublicKeyString(config.KnicksNightMintPublicKey)
27+
farmerCoinMintAccount, _ = NewAccountFromPublicKeyString(config.FarmerCoinMintPublicKey)
2728
)
2829

2930
func GetBackwardsCompatMint(protoMint *commonpb.SolanaAccountId) (*Account, error) {

pkg/code/common/vm.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ var (
2121
knicksNightAuthority, _ = NewAccountFromPublicKeyString(config.KnicksNightAuthorityPublicKey)
2222
knicksNightVmAccount, _ = NewAccountFromPublicKeyString(config.KnicksNightVmAccountPublicKey)
2323
knicksNightVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.KnicksNightVmOmnibusPublicKey)
24+
farmerCoinAuthority, _ = NewAccountFromPublicKeyString(config.FarmerCoinAuthorityPublicKey)
25+
farmerCoinVmAccount, _ = NewAccountFromPublicKeyString(config.FarmerCoinVmAccountPublicKey)
26+
farmerCoinVmOmnibusAccount, _ = NewAccountFromPublicKeyString(config.FarmerCoinVmOmnibusPublicKey)
2427
)
2528

2629
type VmConfig struct {
@@ -77,6 +80,25 @@ func GetVmConfigForMint(ctx context.Context, data code_data.Provider, mint *Acco
7780
Omnibus: knicksNightVmOmnibusAccount,
7881
Mint: mint,
7982
}, nil
83+
case farmerCoinMintAccount.PublicKey().ToBase58():
84+
if farmerCoinAuthority.PrivateKey() == nil {
85+
vaultRecord, err := data.GetKey(ctx, farmerCoinAuthority.PublicKey().ToBase58())
86+
if err != nil {
87+
return nil, err
88+
}
89+
90+
farmerCoinAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey)
91+
if err != nil {
92+
return nil, err
93+
}
94+
}
95+
96+
return &VmConfig{
97+
Authority: farmerCoinAuthority,
98+
Vm: farmerCoinVmAccount,
99+
Omnibus: farmerCoinVmOmnibusAccount,
100+
Mint: mint,
101+
}, nil
80102
default:
81103
return nil, ErrUnsupportedMint
82104
}

pkg/code/config/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ const (
3535
KnicksNightAuthorityPublicKey = "kn1VC4z3LUupQu41jCxx3PGNDmVyN3PswcAuvtyyHzS"
3636
KnicksNightVmAccountPublicKey = "9Du5GuKYT21ydLQ9KzUTWWQ7NKdwoXB15y4ypNnnpbJa"
3737
KnicksNightVmOmnibusPublicKey = "CqiUoainSQuqJNUxngLxemtGHcJR8tAueReduaL42kmK"
38+
FarmerCoinMintPublicKey = "2o4PFbDZ73BihFraknfVTQeUtELKAeVUL4oa6bkrYU3A"
39+
FarmerCoinAuthorityPublicKey = "Farms86uyc1wqeHemtxFeUnN3Cs28d4PVYKymXzbMy6T"
40+
FarmerCoinVmAccountPublicKey = "5x9SP9a7dEGxK4xy8kurh8RC2fxvL1DSXhTCdcAMgpdb"
41+
FarmerCoinVmOmnibusPublicKey = "ANHQ3psrtquyYS2sGbJ6tpmVxZ9Sxq21BTNjD2Rf9Uvj"
3842
)
3943

4044
var (

0 commit comments

Comments
 (0)