Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API-3583] Track tx costs #57

Merged
merged 23 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a836022
change tx price oracle to be slightly more chain agnostic, pull confi…
mattac21 Nov 19, 2024
526f1ca
add tx cost to submitted txs table and update queries
mattac21 Nov 19, 2024
d000b5f
move evmrpc tx price oracle to chain agnostic oracle package and allo…
mattac21 Nov 19, 2024
c7cabfe
parse fee out of tx result to use as gas cost
mattac21 Nov 19, 2024
fb3d9e5
rename evm tx price oracle -> price oracle
mattac21 Nov 19, 2024
61c4a6c
update interface for calling tx price oracle from hyperlane client
mattac21 Nov 19, 2024
94bb59e
get gas cost in uusdc when verifying a submitted tx
mattac21 Nov 19, 2024
8133aaa
add rebalance_transfer_id column to submitted txs table
mattac21 Nov 20, 2024
1920828
insert fund rebalancer txs into submitted txs table
mattac21 Nov 20, 2024
51c66f4
erc20 approval before gas cost estimation
mattac21 Nov 20, 2024
84b3d8e
Merge branch 'main' into ma/track-profit-in-db
mattac21 Nov 28, 2024
6cd7b23
move evm tx price oracle to generic oracle package to not be evm spec…
mattac21 Dec 2, 2024
44a9465
add db queries to support fund rebalancer to add txns to submitted tx…
mattac21 Dec 2, 2024
8b0cb8c
fund rebalancer adds txs to submitted txs table
mattac21 Dec 2, 2024
4d4f52f
add test for fund rebalancer adding txns to submitted txns table
mattac21 Dec 2, 2024
bee959e
Merge branch 'main' into ma/track-profit-in-db
mattac21 Dec 2, 2024
c666e81
fix imports
mattac21 Dec 2, 2024
10825ff
dont link erc20 approval txs to rebalance txs in fund rebalancer
mattac21 Dec 5, 2024
aa84081
change fee parsing to decode tx auth info bytes and return gas denom fee
mattac21 Dec 5, 2024
a77316f
return an error if fee for gas denom is not found in cosmos tx result
mattac21 Dec 5, 2024
14099d3
Merge branch 'main' into ma/track-profit-in-db
mattac21 Dec 5, 2024
b4f08e5
fix db migration naming and make rebalance_transfer_id a foreign key
mattac21 Dec 6, 2024
5408834
pass chainid to tx price oracle
mattac21 Dec 6, 2024
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
4 changes: 3 additions & 1 deletion .mockery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ packages:
interfaces:
EVMRPCClientManager:
EVMChainRPC:
IOracle:
github.com/skip-mev/go-fast-solver/shared/oracle:
interfaces:
TxPriceOracle:
github.com/skip-mev/go-fast-solver/shared/http:
interfaces:
Client:
Expand Down
9 changes: 5 additions & 4 deletions cmd/solver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/skip-mev/go-fast-solver/gasmonitor"

"github.com/skip-mev/go-fast-solver/shared/oracle"
"github.com/skip-mev/go-fast-solver/shared/txexecutor/cosmos"
"github.com/skip-mev/go-fast-solver/shared/txexecutor/evm"

Expand Down Expand Up @@ -97,9 +98,9 @@ func main() {
rateLimitedClient := utils.DefaultRateLimitedHTTPClient(3)
coingeckoClient := coingecko.NewCoingeckoClient(rateLimitedClient, "https://api.coingecko.com/api/v3/", "")
cachedCoinGeckoClient := coingecko.NewCachedPriceClient(coingeckoClient, 15*time.Minute)
evmTxPriceOracle := evmrpc.NewOracle(cachedCoinGeckoClient)
txPriceOracle := oracle.NewOracle(cachedCoinGeckoClient)

hype, err := hyperlane.NewMultiClientFromConfig(ctx, evmManager, keyStore, evmTxPriceOracle, evmTxExecutor)
hype, err := hyperlane.NewMultiClientFromConfig(ctx, evmManager, keyStore, txPriceOracle, evmTxExecutor)
if err != nil {
lmt.Logger(ctx).Fatal("creating hyperlane multi client from config", zap.Error(err))
}
Expand Down Expand Up @@ -144,7 +145,7 @@ func main() {
})

eg.Go(func() error {
r, err := fundrebalancer.NewFundRebalancer(ctx, keyStore, skipgo, evmManager, db.New(dbConn), evmTxPriceOracle, evmTxExecutor)
r, err := fundrebalancer.NewFundRebalancer(ctx, keyStore, skipgo, evmManager, db.New(dbConn), txPriceOracle, evmTxExecutor)
if err != nil {
return fmt.Errorf("creating fund rebalancer: %w", err)
}
Expand All @@ -153,7 +154,7 @@ func main() {
})

eg.Go(func() error {
r, err := txverifier.NewTxVerifier(ctx, db.New(dbConn), clientManager)
r, err := txverifier.NewTxVerifier(ctx, db.New(dbConn), clientManager, txPriceOracle)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/solvercli/cmd/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"time"

"github.com/skip-mev/go-fast-solver/shared/oracle"
"github.com/skip-mev/go-fast-solver/shared/txexecutor/evm"

"os/signal"
Expand Down Expand Up @@ -97,9 +98,9 @@ var relayCmd = &cobra.Command{
rateLimitedClient := utils.DefaultRateLimitedHTTPClient(3)
coingeckoClient := coingecko.NewCoingeckoClient(rateLimitedClient, "https://api.coingecko.com/api/v3/", "")
cachedCoinGeckoClient := coingecko.NewCachedPriceClient(coingeckoClient, 15*time.Minute)
evmTxPriceOracle := evmrpc.NewOracle(cachedCoinGeckoClient)
txPriceOracle := oracle.NewOracle(cachedCoinGeckoClient)
evmTxExecutor := evm.DefaultEVMTxExecutor()
hype, err := hyperlane.NewMultiClientFromConfig(ctx, evmrpc.NewEVMRPCClientManager(), keyStore, evmTxPriceOracle, evmTxExecutor)
hype, err := hyperlane.NewMultiClientFromConfig(ctx, evmrpc.NewEVMRPCClientManager(), keyStore, txPriceOracle, evmTxExecutor)
if err != nil {
lmt.Logger(ctx).Error("Error creating hyperlane multi client from config", zap.Error(err))
}
Expand Down
2 changes: 2 additions & 0 deletions db/gen/db/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions db/gen/db/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 94 additions & 0 deletions db/gen/db/rebalance_transactions.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 24 additions & 6 deletions db/gen/db/transactions.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion db/migrations/000004_add_submitted_tx_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ WHERE order_settlement_id IS NOT NULL;

CREATE UNIQUE INDEX submitted_txs_chain_tx_key
ON submitted_txs(chain_id, tx_hash)
WHERE order_settlement_id IS NULL;
WHERE order_settlement_id IS NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE submitted_txs DROP COLUMN tx_cost_uusdc;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE submitted_txs ADD tx_cost_uusdc TEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE submitted_txs DROP COLUMN rebalance_transfer_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE submitted_txs ADD rebalance_transfer_id INT;
24 changes: 24 additions & 0 deletions db/queries/rebalance_transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,27 @@ WHERE status = 'PENDING';
UPDATE rebalance_transfers
SET updated_at=CURRENT_TIMESTAMP, status = ?
WHERE id = ?;

-- name: UpdateTransfer :exec
UPDATE rebalance_transfers
SET updated_at=CURRENT_TIMESTAMP, tx_hash = ?, amount = ?
WHERE id = ?;

-- name: InitializeRebalanceTransfer :one
INSERT INTO rebalance_transfers (
tx_hash,
source_chain_id,
destination_chain_id,
amount
) VALUES ('', ?, ?, '0') RETURNING id;

-- name: GetPendingRebalanceTransfersBetweenChains :many
SELECT
id,
tx_hash,
source_chain_id,
destination_chain_id,
amount,
created_at
FROM rebalance_transfers
WHERE status = 'PENDING' AND source_chain_id = ? AND destination_chain_id = ?;
Loading
Loading