Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
filippo.io/edwards25519 v1.1.0
github.com/aws/aws-sdk-go-v2 v0.17.0
github.com/code-payments/code-vm-indexer v1.2.0
github.com/code-payments/ocp-protobuf-api v0.4.0
github.com/code-payments/ocp-protobuf-api v0.5.0
github.com/emirpasic/gods v1.12.0
github.com/envoyproxy/protoc-gen-validate v1.2.1
github.com/golang/protobuf v1.5.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/code-payments/code-vm-indexer v1.2.0 h1:rSHpBMiT9BKgmKcXg/VIoi/h0t7jNxGx07Qz59m+6Q0=
github.com/code-payments/code-vm-indexer v1.2.0/go.mod h1:vn91YN2qNqb+gGJeZe2+l+TNxVmEEiRHXXnIn2Y40h8=
github.com/code-payments/ocp-protobuf-api v0.4.0 h1:fexDlRbI/VNOc+VU7pF5fEc8wv7LJ6c+Een9OV+dHkE=
github.com/code-payments/ocp-protobuf-api v0.4.0/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8=
github.com/code-payments/ocp-protobuf-api v0.5.0 h1:ns3pztvgukRubQlJcuRxAiQmpmCqZimtkCA1pTFJpF8=
github.com/code-payments/ocp-protobuf-api v0.5.0/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
Expand Down
1 change: 0 additions & 1 deletion ocp/currency/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ func validateCurrencyLaunchpadClientExchangeData(ctx context.Context, log *zap.L
log := log.With(
zap.String("core_mint_sell_value", coreMintSellValueInUnits.Text('f', 10)),
zap.String("potential_native_amount", potentialNativeAmount.Text('f', 10)),
zap.Uint64("found_core_mint_locked", reserveRecord.CoreMintLocked),
zap.String("found_usd_rate", usdRate.Text('f', 10)),
zap.String("found_other_rate", otherRate.Text('f', 10)),
)
Expand Down
3 changes: 0 additions & 3 deletions ocp/data/currency/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ type ReserveRecord struct {
Id uint64
Mint string
SupplyFromBonding uint64
CoreMintLocked uint64
Time time.Time
}

Expand All @@ -246,7 +245,6 @@ func (m *ReserveRecord) Clone() *ReserveRecord {
Id: m.Id,
Mint: m.Mint,
SupplyFromBonding: m.SupplyFromBonding,
CoreMintLocked: m.CoreMintLocked,
Time: m.Time,
}
}
Expand All @@ -255,6 +253,5 @@ func (m *ReserveRecord) CopyTo(dst *ReserveRecord) {
dst.Id = m.Id
dst.Mint = m.Mint
dst.SupplyFromBonding = m.SupplyFromBonding
dst.CoreMintLocked = m.CoreMintLocked
dst.Time = m.Time
}
10 changes: 3 additions & 7 deletions ocp/data/currency/postgres/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ type reserveModel struct {
ForTimestamp time.Time `db:"for_timestamp"`
Mint string `db:"mint"`
SupplyFromBonding uint64 `db:"supply_from_bonding"`
CoreMintLocked uint64 `db:"core_mint_locked"`
}

func toReserveModel(obj *currency.ReserveRecord) (*reserveModel, error) {
Expand All @@ -184,7 +183,6 @@ func toReserveModel(obj *currency.ReserveRecord) (*reserveModel, error) {
ForTimestamp: obj.Time.UTC(),
Mint: obj.Mint,
SupplyFromBonding: obj.SupplyFromBonding,
CoreMintLocked: obj.CoreMintLocked,
}, nil
}

Expand All @@ -194,7 +192,6 @@ func fromReserveModel(obj *reserveModel) *currency.ReserveRecord {
Time: obj.ForTimestamp.UTC(),
Mint: obj.Mint,
SupplyFromBonding: obj.SupplyFromBonding,
CoreMintLocked: obj.CoreMintLocked,
}
}

Expand Down Expand Up @@ -280,14 +277,13 @@ func (m *reserveModel) dbSave(ctx context.Context, db *sqlx.DB) error {
return pgutil.ExecuteInTx(ctx, db, sql.LevelDefault, func(tx *sqlx.Tx) error {
err := tx.QueryRowxContext(ctx,
`INSERT INTO `+reserveTableName+`
(for_date, for_timestamp, mint, supply_from_bonding, core_mint_locked)
VALUES ($1, $2, $3, $4, $5)
RETURNING id, for_date, for_timestamp, mint, supply_from_bonding, core_mint_locked`,
(for_date, for_timestamp, mint, supply_from_bonding)
VALUES ($1, $2, $3, $4)
RETURNING id, for_date, for_timestamp, mint, supply_from_bonding`,
m.ForDate,
m.ForTimestamp,
m.Mint,
m.SupplyFromBonding,
m.CoreMintLocked,
).StructScan(m)

return pgutil.CheckUniqueViolation(err, currency.ErrExists)
Expand Down
1 change: 0 additions & 1 deletion ocp/data/currency/postgres/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ const (
for_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
mint TEXT NOT NULL,
supply_from_bonding BIGINT NOT NULL,
core_mint_locked BIGINT NOT NULL,

CONSTRAINT ocp__core_currencyreserve__uniq__timestamp__and__mint UNIQUE (for_timestamp, mint)
);
Expand Down
3 changes: 0 additions & 3 deletions ocp/data/currency/tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ func testReserveRoundTrip(t *testing.T, s currency.Store) {
expected := &currency.ReserveRecord{
Mint: "mint",
SupplyFromBonding: 1,
CoreMintLocked: 2,
Time: now,
}
require.NoError(t, s.PutReserveRecord(context.Background(), expected))
Expand All @@ -184,14 +183,12 @@ func testReserveRoundTrip(t *testing.T, s currency.Store) {
require.NoError(t, err)
assert.Equal(t, now.Unix(), actual.Time.Unix())
assert.Equal(t, actual.SupplyFromBonding, expected.SupplyFromBonding)
assert.Equal(t, actual.CoreMintLocked, expected.CoreMintLocked)

actual, err = s.GetReserveAtTime(context.Background(), "mint", time.Date(2021, 01, 29, 14, 0, 5, 0, time.UTC))
require.NoError(t, err)

assert.Equal(t, now.Unix(), actual.Time.Unix())
assert.Equal(t, actual.SupplyFromBonding, expected.SupplyFromBonding)
assert.Equal(t, actual.CoreMintLocked, expected.CoreMintLocked)

tomorrow := time.Date(2021, 01, 30, 0, 0, 0, 0, time.UTC)
actual, err = s.GetReserveAtTime(context.Background(), "mint", tomorrow)
Expand Down
1 change: 0 additions & 1 deletion ocp/rpc/currency/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func (s *currencyServer) GetMints(ctx context.Context, req *currencypb.GetMintsR
MintVault: mintVaultAccount.ToProto(),
CoreMintVault: coreMintVaultAccount.ToProto(),
SupplyFromBonding: reserveRecord.SupplyFromBonding,
CoreMintLocked: reserveRecord.CoreMintLocked,
SellFeeBps: uint32(metadataRecord.SellFeeBps),
},
CreatedAt: timestamppb.New(metadataRecord.CreatedAt),
Expand Down
9 changes: 0 additions & 9 deletions ocp/worker/currency/reserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func (p *reserveRuntime) UpdateAllLaunchpadCurrencyReserves(ctx context.Context)
err1 := func() error {
jeffyMintAccount, _ := common.NewAccountFromPublicKeyString("todo")
jeffyVaultAccount, _ := common.NewAccountFromPublicKeyString("todo")
coreMintVaultAccount, _ := common.NewAccountFromPublicKeyString("todo")

var tokenAccount token.Account
ai, err := p.data.GetBlockchainAccountInfo(ctx, jeffyVaultAccount.PublicKey().ToBase58(), solana.CommitmentFinalized)
Expand All @@ -84,17 +83,9 @@ func (p *reserveRuntime) UpdateAllLaunchpadCurrencyReserves(ctx context.Context)
tokenAccount.Unmarshal(ai.Data)
jeffyVaultBalance := tokenAccount.Amount

ai, err = p.data.GetBlockchainAccountInfo(ctx, coreMintVaultAccount.PublicKey().ToBase58(), solana.CommitmentFinalized)
if err != nil {
return err
}
tokenAccount.Unmarshal(ai.Data)
coreMintVaultBalance := tokenAccount.Amount

return p.data.PutCurrencyReserve(ctx, &currency.ReserveRecord{
Mint: jeffyMintAccount.PublicKey().ToBase58(),
SupplyFromBonding: currencycreator.DefaultMintMaxQuarkSupply - jeffyVaultBalance,
CoreMintLocked: coreMintVaultBalance,
Time: time.Now(),
})
}()
Expand Down
Loading