├── .github └── workflows │ └── release.yaml ├── .gitignore ├── .goreleaser.yaml ├── Makefile ├── README.md ├── ent ├── client.go ├── delegate.go ├── delegate │ ├── delegate.go │ └── where.go ├── delegate_create.go ├── delegate_delete.go ├── delegate_query.go ├── delegate_update.go ├── delegatorreward.go ├── delegatorreward │ ├── delegatorreward.go │ └── where.go ├── delegatorreward_create.go ├── delegatorreward_delete.go ├── delegatorreward_query.go ├── delegatorreward_update.go ├── ent.go ├── enttest │ └── enttest.go ├── fill.go ├── fill │ ├── fill.go │ └── where.go ├── fill_create.go ├── fill_delete.go ├── fill_query.go ├── fill_update.go ├── funding.go ├── funding │ ├── funding.go │ └── where.go ├── funding_create.go ├── funding_delete.go ├── funding_query.go ├── funding_update.go ├── generate.go ├── hook │ └── hook.go ├── hyperunitoperation.go ├── hyperunitoperation │ ├── hyperunitoperation.go │ └── where.go ├── hyperunitoperation_create.go ├── hyperunitoperation_delete.go ├── hyperunitoperation_query.go ├── hyperunitoperation_update.go ├── internaltransfer.go ├── internaltransfer │ ├── internaltransfer.go │ └── where.go ├── internaltransfer_create.go ├── internaltransfer_delete.go ├── internaltransfer_query.go ├── internaltransfer_update.go ├── migrate │ ├── migrate.go │ └── schema.go ├── mutation.go ├── predicate │ └── predicate.go ├── rewardsclaim.go ├── rewardsclaim │ ├── rewardsclaim.go │ └── where.go ├── rewardsclaim_create.go ├── rewardsclaim_delete.go ├── rewardsclaim_query.go ├── rewardsclaim_update.go ├── runtime.go ├── runtime │ └── runtime.go ├── schema │ ├── delegate.go │ ├── delegator_reward.go │ ├── fill.go │ ├── funding.go │ ├── hyperunit_operation.go │ ├── internal_transfer.go │ ├── rewards_claim.go │ ├── spot_genesis.go │ ├── spot_transfer.go │ ├── twap_slice_fill.go │ ├── vault_delta.go │ ├── vault_leader_commission.go │ ├── vault_withdrawal.go │ └── withdraw.go ├── spotgenesis.go ├── spotgenesis │ ├── spotgenesis.go │ └── where.go ├── spotgenesis_create.go ├── spotgenesis_delete.go ├── spotgenesis_query.go ├── spotgenesis_update.go ├── spottransfer.go ├── spottransfer │ ├── spottransfer.go │ └── where.go ├── spottransfer_create.go ├── spottransfer_delete.go ├── spottransfer_query.go ├── spottransfer_update.go ├── sqlite_driver.go ├── twapslicefill.go ├── twapslicefill │ ├── twapslicefill.go │ └── where.go ├── twapslicefill_create.go ├── twapslicefill_delete.go ├── twapslicefill_query.go ├── twapslicefill_update.go ├── tx.go ├── vaultdelta.go ├── vaultdelta │ ├── vaultdelta.go │ └── where.go ├── vaultdelta_create.go ├── vaultdelta_delete.go ├── vaultdelta_query.go ├── vaultdelta_update.go ├── vaultleadercommission.go ├── vaultleadercommission │ ├── vaultleadercommission.go │ └── where.go ├── vaultleadercommission_create.go ├── vaultleadercommission_delete.go ├── vaultleadercommission_query.go ├── vaultleadercommission_update.go ├── vaultwithdrawal.go ├── vaultwithdrawal │ ├── vaultwithdrawal.go │ └── where.go ├── vaultwithdrawal_create.go ├── vaultwithdrawal_delete.go ├── vaultwithdrawal_query.go ├── vaultwithdrawal_update.go ├── withdraw.go ├── withdraw │ ├── where.go │ └── withdraw.go ├── withdraw_create.go ├── withdraw_delete.go ├── withdraw_query.go └── withdraw_update.go ├── go.mod ├── go.sum └── main.go /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | # .github/workflows/release.yml 2 | name: goreleaser 3 | 4 | on: 5 | pull_request: 6 | push: 7 | # run only against tags 8 | tags: 9 | - "*" 10 | 11 | permissions: 12 | contents: write 13 | # packages: write 14 | # issues: write 15 | # id-token: write 16 | 17 | jobs: 18 | goreleaser: 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Checkout 22 | uses: actions/checkout@v4 23 | with: 24 | fetch-depth: 0 25 | - name: Set up Go 26 | uses: actions/setup-go@v5 27 | with: 28 | go-version: stable 29 | cache: true 30 | # More assembly might be required: Docker logins, GPG, etc. 31 | # It all depends on your needs. 32 | - name: Run GoReleaser 33 | uses: goreleaser/goreleaser-action@v6 34 | with: 35 | # either 'goreleaser' (default) or 'goreleaser-pro' 36 | distribution: goreleaser 37 | # 'latest', 'nightly', or a semver 38 | version: "~> v2" 39 | args: release --clean 40 | env: 41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 42 | # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution 43 | # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | *.sqlite3 3 | *.sqlite3-journal 4 | dist/ 5 | -------------------------------------------------------------------------------- /.goreleaser.yaml: -------------------------------------------------------------------------------- 1 | # This is an example .goreleaser.yml file with some sensible defaults. 2 | # Make sure to check the documentation at https://goreleaser.com 3 | 4 | # The lines below are called `modelines`. See `:help modeline` 5 | # Feel free to remove those if you don't want/need to use them. 6 | # yaml-language-server: $schema=https://goreleaser.com/static/schema.json 7 | # vim: set ts=2 sw=2 tw=0 fo=cnqoj 8 | 9 | version: 2 10 | 11 | before: 12 | hooks: 13 | # You may remove this if you don't use go modules. 14 | - go mod tidy 15 | # you may remove this if you don't need go generate 16 | - go generate ./ent 17 | 18 | builds: 19 | - env: 20 | - CGO_ENABLED=0 21 | goos: 22 | - linux 23 | - windows 24 | - darwin 25 | flags: 26 | - -a 27 | - -tags=netgo 28 | - -installsuffix=netgo 29 | ldflags: 30 | - '-extldflags "-static"' 31 | 32 | archives: 33 | - format: tar.gz 34 | # this name template makes the OS and Arch compatible with the results of `uname`. 35 | name_template: >- 36 | {{ .ProjectName }}_ 37 | {{- title .Os }}_ 38 | {{- if eq .Arch "amd64" }}x86_64 39 | {{- else if eq .Arch "386" }}i386 40 | {{- else }}{{ .Arch }}{{ end }} 41 | {{- if .Arm }}v{{ .Arm }}{{ end }} 42 | # use zip for windows archives 43 | format_overrides: 44 | - goos: windows 45 | format: zip 46 | 47 | changelog: 48 | sort: asc 49 | filters: 50 | exclude: 51 | - "^docs:" 52 | - "^test:" 53 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo --ldflags '-extldflags "-static"' -o bin/hypersync main.go 3 | 4 | generate: 5 | go generate ./ent -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hyperliquid user fill syncer 2 | 3 | Sync your hyperliquid fills with local database to avoid losing your transaction history. 4 | 5 | ## Features 6 | 7 | - Download fills at launch via REST API (max 2000 txs) 8 | - Start syncing fill via websocket realtime 9 | - All your fills will be stored into local database, currenly only sqlite3 is supported. 10 | - By default, db file is created on ./db.sqlite3 11 | - Also support fundings, genesisSpot, rewardsClaim, vault deposit/withdraw/create, withdraw, spot/internal transfers, staking/unstaking, staking rewards, twap fill. 12 | 13 | ## Misc 14 | 15 | Build portable binary, will be built on bin/hypersync 16 | 17 | ``` 18 | make build 19 | ``` 20 | 21 | ## Install 22 | 23 | ``` 24 | make build 25 | sudo mv bin/hypersync /usr/local/bin 26 | sudo chmod +755 /usr/local/bin/hypersync 27 | ``` 28 | 29 | ## Usage 30 | 31 | Help 32 | 33 | ``` 34 | hypersync --help 35 | ``` 36 | 37 | Run syncer 38 | 39 | ``` 40 | hypersync --address $wallet_address --verbose 41 | ``` 42 | 43 | Run syncer with output path 44 | 45 | ``` 46 | hypersync --address $wallet_address \ 47 | --out path/to/database.sqlite3 48 | ``` 49 | 50 | Run syncer with local backup 51 | 52 | ``` 53 | hypersync --address $wallet_address \ 54 | --out path/to/db.sqlite3 \ 55 | --backup file://path/to/backup.sqlite3 \ 56 | --backup-interval-seconds 86400 57 | ``` 58 | 59 | Run syncer with AWS S3 backup (Requires AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in environment variable or ~/.aws/config file) 60 | 61 | ``` 62 | hypersync --address $wallet_address \ 63 | --out path/to/db.sqlite3 \ 64 | --backup s3://s3bucket_name/path/to/backup.sqlite3 \ 65 | --backup-interval-seconds 86400 \ 66 | --aws-s3-region ap-northeast-1 67 | ``` 68 | -------------------------------------------------------------------------------- /ent/delegate.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/delegate" 12 | ) 13 | 14 | // Delegate is the model entity for the Delegate schema. 15 | type Delegate struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // Validator holds the value of the "validator" field. 20 | Validator string `json:"validator,omitempty"` 21 | // Amount holds the value of the "amount" field. 22 | Amount string `json:"amount,omitempty"` 23 | // IsUndelegate holds the value of the "is_undelegate" field. 24 | IsUndelegate bool `json:"is_undelegate,omitempty"` 25 | // Time holds the value of the "time" field. 26 | Time int64 `json:"time,omitempty"` 27 | // Address holds the value of the "address" field. 28 | Address string `json:"address,omitempty"` 29 | selectValues sql.SelectValues 30 | } 31 | 32 | // scanValues returns the types for scanning values from sql.Rows. 33 | func (*Delegate) scanValues(columns []string) ([]any, error) { 34 | values := make([]any, len(columns)) 35 | for i := range columns { 36 | switch columns[i] { 37 | case delegate.FieldIsUndelegate: 38 | values[i] = new(sql.NullBool) 39 | case delegate.FieldID, delegate.FieldTime: 40 | values[i] = new(sql.NullInt64) 41 | case delegate.FieldValidator, delegate.FieldAmount, delegate.FieldAddress: 42 | values[i] = new(sql.NullString) 43 | default: 44 | values[i] = new(sql.UnknownType) 45 | } 46 | } 47 | return values, nil 48 | } 49 | 50 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 51 | // to the Delegate fields. 52 | func (d *Delegate) assignValues(columns []string, values []any) error { 53 | if m, n := len(values), len(columns); m < n { 54 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 55 | } 56 | for i := range columns { 57 | switch columns[i] { 58 | case delegate.FieldID: 59 | value, ok := values[i].(*sql.NullInt64) 60 | if !ok { 61 | return fmt.Errorf("unexpected type %T for field id", value) 62 | } 63 | d.ID = int(value.Int64) 64 | case delegate.FieldValidator: 65 | if value, ok := values[i].(*sql.NullString); !ok { 66 | return fmt.Errorf("unexpected type %T for field validator", values[i]) 67 | } else if value.Valid { 68 | d.Validator = value.String 69 | } 70 | case delegate.FieldAmount: 71 | if value, ok := values[i].(*sql.NullString); !ok { 72 | return fmt.Errorf("unexpected type %T for field amount", values[i]) 73 | } else if value.Valid { 74 | d.Amount = value.String 75 | } 76 | case delegate.FieldIsUndelegate: 77 | if value, ok := values[i].(*sql.NullBool); !ok { 78 | return fmt.Errorf("unexpected type %T for field is_undelegate", values[i]) 79 | } else if value.Valid { 80 | d.IsUndelegate = value.Bool 81 | } 82 | case delegate.FieldTime: 83 | if value, ok := values[i].(*sql.NullInt64); !ok { 84 | return fmt.Errorf("unexpected type %T for field time", values[i]) 85 | } else if value.Valid { 86 | d.Time = value.Int64 87 | } 88 | case delegate.FieldAddress: 89 | if value, ok := values[i].(*sql.NullString); !ok { 90 | return fmt.Errorf("unexpected type %T for field address", values[i]) 91 | } else if value.Valid { 92 | d.Address = value.String 93 | } 94 | default: 95 | d.selectValues.Set(columns[i], values[i]) 96 | } 97 | } 98 | return nil 99 | } 100 | 101 | // Value returns the ent.Value that was dynamically selected and assigned to the Delegate. 102 | // This includes values selected through modifiers, order, etc. 103 | func (d *Delegate) Value(name string) (ent.Value, error) { 104 | return d.selectValues.Get(name) 105 | } 106 | 107 | // Update returns a builder for updating this Delegate. 108 | // Note that you need to call Delegate.Unwrap() before calling this method if this Delegate 109 | // was returned from a transaction, and the transaction was committed or rolled back. 110 | func (d *Delegate) Update() *DelegateUpdateOne { 111 | return NewDelegateClient(d.config).UpdateOne(d) 112 | } 113 | 114 | // Unwrap unwraps the Delegate entity that was returned from a transaction after it was closed, 115 | // so that all future queries will be executed through the driver which created the transaction. 116 | func (d *Delegate) Unwrap() *Delegate { 117 | _tx, ok := d.config.driver.(*txDriver) 118 | if !ok { 119 | panic("ent: Delegate is not a transactional entity") 120 | } 121 | d.config.driver = _tx.drv 122 | return d 123 | } 124 | 125 | // String implements the fmt.Stringer. 126 | func (d *Delegate) String() string { 127 | var builder strings.Builder 128 | builder.WriteString("Delegate(") 129 | builder.WriteString(fmt.Sprintf("id=%v, ", d.ID)) 130 | builder.WriteString("validator=") 131 | builder.WriteString(d.Validator) 132 | builder.WriteString(", ") 133 | builder.WriteString("amount=") 134 | builder.WriteString(d.Amount) 135 | builder.WriteString(", ") 136 | builder.WriteString("is_undelegate=") 137 | builder.WriteString(fmt.Sprintf("%v", d.IsUndelegate)) 138 | builder.WriteString(", ") 139 | builder.WriteString("time=") 140 | builder.WriteString(fmt.Sprintf("%v", d.Time)) 141 | builder.WriteString(", ") 142 | builder.WriteString("address=") 143 | builder.WriteString(d.Address) 144 | builder.WriteByte(')') 145 | return builder.String() 146 | } 147 | 148 | // Delegates is a parsable slice of Delegate. 149 | type Delegates []*Delegate 150 | -------------------------------------------------------------------------------- /ent/delegate/delegate.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package delegate 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the delegate type in the database. 11 | Label = "delegate" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldValidator holds the string denoting the validator field in the database. 15 | FieldValidator = "validator" 16 | // FieldAmount holds the string denoting the amount field in the database. 17 | FieldAmount = "amount" 18 | // FieldIsUndelegate holds the string denoting the is_undelegate field in the database. 19 | FieldIsUndelegate = "is_undelegate" 20 | // FieldTime holds the string denoting the time field in the database. 21 | FieldTime = "time" 22 | // FieldAddress holds the string denoting the address field in the database. 23 | FieldAddress = "address" 24 | // Table holds the table name of the delegate in the database. 25 | Table = "delegates" 26 | ) 27 | 28 | // Columns holds all SQL columns for delegate fields. 29 | var Columns = []string{ 30 | FieldID, 31 | FieldValidator, 32 | FieldAmount, 33 | FieldIsUndelegate, 34 | FieldTime, 35 | FieldAddress, 36 | } 37 | 38 | // ValidColumn reports if the column name is valid (part of the table columns). 39 | func ValidColumn(column string) bool { 40 | for i := range Columns { 41 | if column == Columns[i] { 42 | return true 43 | } 44 | } 45 | return false 46 | } 47 | 48 | // OrderOption defines the ordering options for the Delegate queries. 49 | type OrderOption func(*sql.Selector) 50 | 51 | // ByID orders the results by the id field. 52 | func ByID(opts ...sql.OrderTermOption) OrderOption { 53 | return sql.OrderByField(FieldID, opts...).ToFunc() 54 | } 55 | 56 | // ByValidator orders the results by the validator field. 57 | func ByValidator(opts ...sql.OrderTermOption) OrderOption { 58 | return sql.OrderByField(FieldValidator, opts...).ToFunc() 59 | } 60 | 61 | // ByAmount orders the results by the amount field. 62 | func ByAmount(opts ...sql.OrderTermOption) OrderOption { 63 | return sql.OrderByField(FieldAmount, opts...).ToFunc() 64 | } 65 | 66 | // ByIsUndelegate orders the results by the is_undelegate field. 67 | func ByIsUndelegate(opts ...sql.OrderTermOption) OrderOption { 68 | return sql.OrderByField(FieldIsUndelegate, opts...).ToFunc() 69 | } 70 | 71 | // ByTime orders the results by the time field. 72 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 73 | return sql.OrderByField(FieldTime, opts...).ToFunc() 74 | } 75 | 76 | // ByAddress orders the results by the address field. 77 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 78 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 79 | } 80 | -------------------------------------------------------------------------------- /ent/delegate_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/delegate" 12 | "github.com/yoshiso/hypersync/ent/predicate" 13 | ) 14 | 15 | // DelegateDelete is the builder for deleting a Delegate entity. 16 | type DelegateDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *DelegateMutation 20 | } 21 | 22 | // Where appends a list predicates to the DelegateDelete builder. 23 | func (dd *DelegateDelete) Where(ps ...predicate.Delegate) *DelegateDelete { 24 | dd.mutation.Where(ps...) 25 | return dd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (dd *DelegateDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, dd.sqlExec, dd.mutation, dd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (dd *DelegateDelete) ExecX(ctx context.Context) int { 35 | n, err := dd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (dd *DelegateDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(delegate.Table, sqlgraph.NewFieldSpec(delegate.FieldID, field.TypeInt)) 44 | if ps := dd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, dd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | dd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // DelegateDeleteOne is the builder for deleting a single Delegate entity. 60 | type DelegateDeleteOne struct { 61 | dd *DelegateDelete 62 | } 63 | 64 | // Where appends a list predicates to the DelegateDelete builder. 65 | func (ddo *DelegateDeleteOne) Where(ps ...predicate.Delegate) *DelegateDeleteOne { 66 | ddo.dd.mutation.Where(ps...) 67 | return ddo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (ddo *DelegateDeleteOne) Exec(ctx context.Context) error { 72 | n, err := ddo.dd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{delegate.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (ddo *DelegateDeleteOne) ExecX(ctx context.Context) { 85 | if err := ddo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/delegatorreward.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/delegatorreward" 12 | ) 13 | 14 | // DelegatorReward is the model entity for the DelegatorReward schema. 15 | type DelegatorReward struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // Source holds the value of the "source" field. 20 | Source string `json:"source,omitempty"` 21 | // TotalAmount holds the value of the "total_amount" field. 22 | TotalAmount string `json:"total_amount,omitempty"` 23 | // Time holds the value of the "time" field. 24 | Time int64 `json:"time,omitempty"` 25 | // Address holds the value of the "address" field. 26 | Address string `json:"address,omitempty"` 27 | selectValues sql.SelectValues 28 | } 29 | 30 | // scanValues returns the types for scanning values from sql.Rows. 31 | func (*DelegatorReward) scanValues(columns []string) ([]any, error) { 32 | values := make([]any, len(columns)) 33 | for i := range columns { 34 | switch columns[i] { 35 | case delegatorreward.FieldID, delegatorreward.FieldTime: 36 | values[i] = new(sql.NullInt64) 37 | case delegatorreward.FieldSource, delegatorreward.FieldTotalAmount, delegatorreward.FieldAddress: 38 | values[i] = new(sql.NullString) 39 | default: 40 | values[i] = new(sql.UnknownType) 41 | } 42 | } 43 | return values, nil 44 | } 45 | 46 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 47 | // to the DelegatorReward fields. 48 | func (dr *DelegatorReward) assignValues(columns []string, values []any) error { 49 | if m, n := len(values), len(columns); m < n { 50 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 51 | } 52 | for i := range columns { 53 | switch columns[i] { 54 | case delegatorreward.FieldID: 55 | value, ok := values[i].(*sql.NullInt64) 56 | if !ok { 57 | return fmt.Errorf("unexpected type %T for field id", value) 58 | } 59 | dr.ID = int(value.Int64) 60 | case delegatorreward.FieldSource: 61 | if value, ok := values[i].(*sql.NullString); !ok { 62 | return fmt.Errorf("unexpected type %T for field source", values[i]) 63 | } else if value.Valid { 64 | dr.Source = value.String 65 | } 66 | case delegatorreward.FieldTotalAmount: 67 | if value, ok := values[i].(*sql.NullString); !ok { 68 | return fmt.Errorf("unexpected type %T for field total_amount", values[i]) 69 | } else if value.Valid { 70 | dr.TotalAmount = value.String 71 | } 72 | case delegatorreward.FieldTime: 73 | if value, ok := values[i].(*sql.NullInt64); !ok { 74 | return fmt.Errorf("unexpected type %T for field time", values[i]) 75 | } else if value.Valid { 76 | dr.Time = value.Int64 77 | } 78 | case delegatorreward.FieldAddress: 79 | if value, ok := values[i].(*sql.NullString); !ok { 80 | return fmt.Errorf("unexpected type %T for field address", values[i]) 81 | } else if value.Valid { 82 | dr.Address = value.String 83 | } 84 | default: 85 | dr.selectValues.Set(columns[i], values[i]) 86 | } 87 | } 88 | return nil 89 | } 90 | 91 | // Value returns the ent.Value that was dynamically selected and assigned to the DelegatorReward. 92 | // This includes values selected through modifiers, order, etc. 93 | func (dr *DelegatorReward) Value(name string) (ent.Value, error) { 94 | return dr.selectValues.Get(name) 95 | } 96 | 97 | // Update returns a builder for updating this DelegatorReward. 98 | // Note that you need to call DelegatorReward.Unwrap() before calling this method if this DelegatorReward 99 | // was returned from a transaction, and the transaction was committed or rolled back. 100 | func (dr *DelegatorReward) Update() *DelegatorRewardUpdateOne { 101 | return NewDelegatorRewardClient(dr.config).UpdateOne(dr) 102 | } 103 | 104 | // Unwrap unwraps the DelegatorReward entity that was returned from a transaction after it was closed, 105 | // so that all future queries will be executed through the driver which created the transaction. 106 | func (dr *DelegatorReward) Unwrap() *DelegatorReward { 107 | _tx, ok := dr.config.driver.(*txDriver) 108 | if !ok { 109 | panic("ent: DelegatorReward is not a transactional entity") 110 | } 111 | dr.config.driver = _tx.drv 112 | return dr 113 | } 114 | 115 | // String implements the fmt.Stringer. 116 | func (dr *DelegatorReward) String() string { 117 | var builder strings.Builder 118 | builder.WriteString("DelegatorReward(") 119 | builder.WriteString(fmt.Sprintf("id=%v, ", dr.ID)) 120 | builder.WriteString("source=") 121 | builder.WriteString(dr.Source) 122 | builder.WriteString(", ") 123 | builder.WriteString("total_amount=") 124 | builder.WriteString(dr.TotalAmount) 125 | builder.WriteString(", ") 126 | builder.WriteString("time=") 127 | builder.WriteString(fmt.Sprintf("%v", dr.Time)) 128 | builder.WriteString(", ") 129 | builder.WriteString("address=") 130 | builder.WriteString(dr.Address) 131 | builder.WriteByte(')') 132 | return builder.String() 133 | } 134 | 135 | // DelegatorRewards is a parsable slice of DelegatorReward. 136 | type DelegatorRewards []*DelegatorReward 137 | -------------------------------------------------------------------------------- /ent/delegatorreward/delegatorreward.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package delegatorreward 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the delegatorreward type in the database. 11 | Label = "delegator_reward" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldSource holds the string denoting the source field in the database. 15 | FieldSource = "source" 16 | // FieldTotalAmount holds the string denoting the total_amount field in the database. 17 | FieldTotalAmount = "total_amount" 18 | // FieldTime holds the string denoting the time field in the database. 19 | FieldTime = "time" 20 | // FieldAddress holds the string denoting the address field in the database. 21 | FieldAddress = "address" 22 | // Table holds the table name of the delegatorreward in the database. 23 | Table = "delegator_rewards" 24 | ) 25 | 26 | // Columns holds all SQL columns for delegatorreward fields. 27 | var Columns = []string{ 28 | FieldID, 29 | FieldSource, 30 | FieldTotalAmount, 31 | FieldTime, 32 | FieldAddress, 33 | } 34 | 35 | // ValidColumn reports if the column name is valid (part of the table columns). 36 | func ValidColumn(column string) bool { 37 | for i := range Columns { 38 | if column == Columns[i] { 39 | return true 40 | } 41 | } 42 | return false 43 | } 44 | 45 | // OrderOption defines the ordering options for the DelegatorReward queries. 46 | type OrderOption func(*sql.Selector) 47 | 48 | // ByID orders the results by the id field. 49 | func ByID(opts ...sql.OrderTermOption) OrderOption { 50 | return sql.OrderByField(FieldID, opts...).ToFunc() 51 | } 52 | 53 | // BySource orders the results by the source field. 54 | func BySource(opts ...sql.OrderTermOption) OrderOption { 55 | return sql.OrderByField(FieldSource, opts...).ToFunc() 56 | } 57 | 58 | // ByTotalAmount orders the results by the total_amount field. 59 | func ByTotalAmount(opts ...sql.OrderTermOption) OrderOption { 60 | return sql.OrderByField(FieldTotalAmount, opts...).ToFunc() 61 | } 62 | 63 | // ByTime orders the results by the time field. 64 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 65 | return sql.OrderByField(FieldTime, opts...).ToFunc() 66 | } 67 | 68 | // ByAddress orders the results by the address field. 69 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 70 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 71 | } 72 | -------------------------------------------------------------------------------- /ent/delegatorreward_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/delegatorreward" 12 | "github.com/yoshiso/hypersync/ent/predicate" 13 | ) 14 | 15 | // DelegatorRewardDelete is the builder for deleting a DelegatorReward entity. 16 | type DelegatorRewardDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *DelegatorRewardMutation 20 | } 21 | 22 | // Where appends a list predicates to the DelegatorRewardDelete builder. 23 | func (drd *DelegatorRewardDelete) Where(ps ...predicate.DelegatorReward) *DelegatorRewardDelete { 24 | drd.mutation.Where(ps...) 25 | return drd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (drd *DelegatorRewardDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, drd.sqlExec, drd.mutation, drd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (drd *DelegatorRewardDelete) ExecX(ctx context.Context) int { 35 | n, err := drd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (drd *DelegatorRewardDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(delegatorreward.Table, sqlgraph.NewFieldSpec(delegatorreward.FieldID, field.TypeInt)) 44 | if ps := drd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, drd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | drd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // DelegatorRewardDeleteOne is the builder for deleting a single DelegatorReward entity. 60 | type DelegatorRewardDeleteOne struct { 61 | drd *DelegatorRewardDelete 62 | } 63 | 64 | // Where appends a list predicates to the DelegatorRewardDelete builder. 65 | func (drdo *DelegatorRewardDeleteOne) Where(ps ...predicate.DelegatorReward) *DelegatorRewardDeleteOne { 66 | drdo.drd.mutation.Where(ps...) 67 | return drdo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (drdo *DelegatorRewardDeleteOne) Exec(ctx context.Context) error { 72 | n, err := drdo.drd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{delegatorreward.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (drdo *DelegatorRewardDeleteOne) ExecX(ctx context.Context) { 85 | if err := drdo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/enttest/enttest.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package enttest 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/yoshiso/hypersync/ent" 9 | // required by schema hooks. 10 | _ "github.com/yoshiso/hypersync/ent/runtime" 11 | 12 | "entgo.io/ent/dialect/sql/schema" 13 | "github.com/yoshiso/hypersync/ent/migrate" 14 | ) 15 | 16 | type ( 17 | // TestingT is the interface that is shared between 18 | // testing.T and testing.B and used by enttest. 19 | TestingT interface { 20 | FailNow() 21 | Error(...any) 22 | } 23 | 24 | // Option configures client creation. 25 | Option func(*options) 26 | 27 | options struct { 28 | opts []ent.Option 29 | migrateOpts []schema.MigrateOption 30 | } 31 | ) 32 | 33 | // WithOptions forwards options to client creation. 34 | func WithOptions(opts ...ent.Option) Option { 35 | return func(o *options) { 36 | o.opts = append(o.opts, opts...) 37 | } 38 | } 39 | 40 | // WithMigrateOptions forwards options to auto migration. 41 | func WithMigrateOptions(opts ...schema.MigrateOption) Option { 42 | return func(o *options) { 43 | o.migrateOpts = append(o.migrateOpts, opts...) 44 | } 45 | } 46 | 47 | func newOptions(opts []Option) *options { 48 | o := &options{} 49 | for _, opt := range opts { 50 | opt(o) 51 | } 52 | return o 53 | } 54 | 55 | // Open calls ent.Open and auto-run migration. 56 | func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { 57 | o := newOptions(opts) 58 | c, err := ent.Open(driverName, dataSourceName, o.opts...) 59 | if err != nil { 60 | t.Error(err) 61 | t.FailNow() 62 | } 63 | migrateSchema(t, c, o) 64 | return c 65 | } 66 | 67 | // NewClient calls ent.NewClient and auto-run migration. 68 | func NewClient(t TestingT, opts ...Option) *ent.Client { 69 | o := newOptions(opts) 70 | c := ent.NewClient(o.opts...) 71 | migrateSchema(t, c, o) 72 | return c 73 | } 74 | func migrateSchema(t TestingT, c *ent.Client, o *options) { 75 | tables, err := schema.CopyTables(migrate.Tables) 76 | if err != nil { 77 | t.Error(err) 78 | t.FailNow() 79 | } 80 | if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { 81 | t.Error(err) 82 | t.FailNow() 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /ent/fill.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/fill" 12 | ) 13 | 14 | // Fill is the model entity for the Fill schema. 15 | type Fill struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // Coin holds the value of the "coin" field. 20 | Coin string `json:"coin,omitempty"` 21 | // Address holds the value of the "address" field. 22 | Address string `json:"address,omitempty"` 23 | // Px holds the value of the "px" field. 24 | Px string `json:"px,omitempty"` 25 | // Sz holds the value of the "sz" field. 26 | Sz string `json:"sz,omitempty"` 27 | // Side holds the value of the "side" field. 28 | Side string `json:"side,omitempty"` 29 | // Time holds the value of the "time" field. 30 | Time int64 `json:"time,omitempty"` 31 | // StartPosition holds the value of the "start_position" field. 32 | StartPosition string `json:"start_position,omitempty"` 33 | // ClosedPnl holds the value of the "closed_pnl" field. 34 | ClosedPnl string `json:"closed_pnl,omitempty"` 35 | // Dir holds the value of the "dir" field. 36 | Dir string `json:"dir,omitempty"` 37 | // Hash holds the value of the "hash" field. 38 | Hash string `json:"hash,omitempty"` 39 | // Crossed holds the value of the "crossed" field. 40 | Crossed bool `json:"crossed,omitempty"` 41 | // Fee holds the value of the "fee" field. 42 | Fee string `json:"fee,omitempty"` 43 | // Oid holds the value of the "oid" field. 44 | Oid int64 `json:"oid,omitempty"` 45 | // Tid holds the value of the "tid" field. 46 | Tid int64 `json:"tid,omitempty"` 47 | // FeeToken holds the value of the "fee_token" field. 48 | FeeToken string `json:"fee_token,omitempty"` 49 | // BuilderFee holds the value of the "builder_fee" field. 50 | BuilderFee string `json:"builder_fee,omitempty"` 51 | selectValues sql.SelectValues 52 | } 53 | 54 | // scanValues returns the types for scanning values from sql.Rows. 55 | func (*Fill) scanValues(columns []string) ([]any, error) { 56 | values := make([]any, len(columns)) 57 | for i := range columns { 58 | switch columns[i] { 59 | case fill.FieldCrossed: 60 | values[i] = new(sql.NullBool) 61 | case fill.FieldID, fill.FieldTime, fill.FieldOid, fill.FieldTid: 62 | values[i] = new(sql.NullInt64) 63 | case fill.FieldCoin, fill.FieldAddress, fill.FieldPx, fill.FieldSz, fill.FieldSide, fill.FieldStartPosition, fill.FieldClosedPnl, fill.FieldDir, fill.FieldHash, fill.FieldFee, fill.FieldFeeToken, fill.FieldBuilderFee: 64 | values[i] = new(sql.NullString) 65 | default: 66 | values[i] = new(sql.UnknownType) 67 | } 68 | } 69 | return values, nil 70 | } 71 | 72 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 73 | // to the Fill fields. 74 | func (f *Fill) assignValues(columns []string, values []any) error { 75 | if m, n := len(values), len(columns); m < n { 76 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 77 | } 78 | for i := range columns { 79 | switch columns[i] { 80 | case fill.FieldID: 81 | value, ok := values[i].(*sql.NullInt64) 82 | if !ok { 83 | return fmt.Errorf("unexpected type %T for field id", value) 84 | } 85 | f.ID = int(value.Int64) 86 | case fill.FieldCoin: 87 | if value, ok := values[i].(*sql.NullString); !ok { 88 | return fmt.Errorf("unexpected type %T for field coin", values[i]) 89 | } else if value.Valid { 90 | f.Coin = value.String 91 | } 92 | case fill.FieldAddress: 93 | if value, ok := values[i].(*sql.NullString); !ok { 94 | return fmt.Errorf("unexpected type %T for field address", values[i]) 95 | } else if value.Valid { 96 | f.Address = value.String 97 | } 98 | case fill.FieldPx: 99 | if value, ok := values[i].(*sql.NullString); !ok { 100 | return fmt.Errorf("unexpected type %T for field px", values[i]) 101 | } else if value.Valid { 102 | f.Px = value.String 103 | } 104 | case fill.FieldSz: 105 | if value, ok := values[i].(*sql.NullString); !ok { 106 | return fmt.Errorf("unexpected type %T for field sz", values[i]) 107 | } else if value.Valid { 108 | f.Sz = value.String 109 | } 110 | case fill.FieldSide: 111 | if value, ok := values[i].(*sql.NullString); !ok { 112 | return fmt.Errorf("unexpected type %T for field side", values[i]) 113 | } else if value.Valid { 114 | f.Side = value.String 115 | } 116 | case fill.FieldTime: 117 | if value, ok := values[i].(*sql.NullInt64); !ok { 118 | return fmt.Errorf("unexpected type %T for field time", values[i]) 119 | } else if value.Valid { 120 | f.Time = value.Int64 121 | } 122 | case fill.FieldStartPosition: 123 | if value, ok := values[i].(*sql.NullString); !ok { 124 | return fmt.Errorf("unexpected type %T for field start_position", values[i]) 125 | } else if value.Valid { 126 | f.StartPosition = value.String 127 | } 128 | case fill.FieldClosedPnl: 129 | if value, ok := values[i].(*sql.NullString); !ok { 130 | return fmt.Errorf("unexpected type %T for field closed_pnl", values[i]) 131 | } else if value.Valid { 132 | f.ClosedPnl = value.String 133 | } 134 | case fill.FieldDir: 135 | if value, ok := values[i].(*sql.NullString); !ok { 136 | return fmt.Errorf("unexpected type %T for field dir", values[i]) 137 | } else if value.Valid { 138 | f.Dir = value.String 139 | } 140 | case fill.FieldHash: 141 | if value, ok := values[i].(*sql.NullString); !ok { 142 | return fmt.Errorf("unexpected type %T for field hash", values[i]) 143 | } else if value.Valid { 144 | f.Hash = value.String 145 | } 146 | case fill.FieldCrossed: 147 | if value, ok := values[i].(*sql.NullBool); !ok { 148 | return fmt.Errorf("unexpected type %T for field crossed", values[i]) 149 | } else if value.Valid { 150 | f.Crossed = value.Bool 151 | } 152 | case fill.FieldFee: 153 | if value, ok := values[i].(*sql.NullString); !ok { 154 | return fmt.Errorf("unexpected type %T for field fee", values[i]) 155 | } else if value.Valid { 156 | f.Fee = value.String 157 | } 158 | case fill.FieldOid: 159 | if value, ok := values[i].(*sql.NullInt64); !ok { 160 | return fmt.Errorf("unexpected type %T for field oid", values[i]) 161 | } else if value.Valid { 162 | f.Oid = value.Int64 163 | } 164 | case fill.FieldTid: 165 | if value, ok := values[i].(*sql.NullInt64); !ok { 166 | return fmt.Errorf("unexpected type %T for field tid", values[i]) 167 | } else if value.Valid { 168 | f.Tid = value.Int64 169 | } 170 | case fill.FieldFeeToken: 171 | if value, ok := values[i].(*sql.NullString); !ok { 172 | return fmt.Errorf("unexpected type %T for field fee_token", values[i]) 173 | } else if value.Valid { 174 | f.FeeToken = value.String 175 | } 176 | case fill.FieldBuilderFee: 177 | if value, ok := values[i].(*sql.NullString); !ok { 178 | return fmt.Errorf("unexpected type %T for field builder_fee", values[i]) 179 | } else if value.Valid { 180 | f.BuilderFee = value.String 181 | } 182 | default: 183 | f.selectValues.Set(columns[i], values[i]) 184 | } 185 | } 186 | return nil 187 | } 188 | 189 | // Value returns the ent.Value that was dynamically selected and assigned to the Fill. 190 | // This includes values selected through modifiers, order, etc. 191 | func (f *Fill) Value(name string) (ent.Value, error) { 192 | return f.selectValues.Get(name) 193 | } 194 | 195 | // Update returns a builder for updating this Fill. 196 | // Note that you need to call Fill.Unwrap() before calling this method if this Fill 197 | // was returned from a transaction, and the transaction was committed or rolled back. 198 | func (f *Fill) Update() *FillUpdateOne { 199 | return NewFillClient(f.config).UpdateOne(f) 200 | } 201 | 202 | // Unwrap unwraps the Fill entity that was returned from a transaction after it was closed, 203 | // so that all future queries will be executed through the driver which created the transaction. 204 | func (f *Fill) Unwrap() *Fill { 205 | _tx, ok := f.config.driver.(*txDriver) 206 | if !ok { 207 | panic("ent: Fill is not a transactional entity") 208 | } 209 | f.config.driver = _tx.drv 210 | return f 211 | } 212 | 213 | // String implements the fmt.Stringer. 214 | func (f *Fill) String() string { 215 | var builder strings.Builder 216 | builder.WriteString("Fill(") 217 | builder.WriteString(fmt.Sprintf("id=%v, ", f.ID)) 218 | builder.WriteString("coin=") 219 | builder.WriteString(f.Coin) 220 | builder.WriteString(", ") 221 | builder.WriteString("address=") 222 | builder.WriteString(f.Address) 223 | builder.WriteString(", ") 224 | builder.WriteString("px=") 225 | builder.WriteString(f.Px) 226 | builder.WriteString(", ") 227 | builder.WriteString("sz=") 228 | builder.WriteString(f.Sz) 229 | builder.WriteString(", ") 230 | builder.WriteString("side=") 231 | builder.WriteString(f.Side) 232 | builder.WriteString(", ") 233 | builder.WriteString("time=") 234 | builder.WriteString(fmt.Sprintf("%v", f.Time)) 235 | builder.WriteString(", ") 236 | builder.WriteString("start_position=") 237 | builder.WriteString(f.StartPosition) 238 | builder.WriteString(", ") 239 | builder.WriteString("closed_pnl=") 240 | builder.WriteString(f.ClosedPnl) 241 | builder.WriteString(", ") 242 | builder.WriteString("dir=") 243 | builder.WriteString(f.Dir) 244 | builder.WriteString(", ") 245 | builder.WriteString("hash=") 246 | builder.WriteString(f.Hash) 247 | builder.WriteString(", ") 248 | builder.WriteString("crossed=") 249 | builder.WriteString(fmt.Sprintf("%v", f.Crossed)) 250 | builder.WriteString(", ") 251 | builder.WriteString("fee=") 252 | builder.WriteString(f.Fee) 253 | builder.WriteString(", ") 254 | builder.WriteString("oid=") 255 | builder.WriteString(fmt.Sprintf("%v", f.Oid)) 256 | builder.WriteString(", ") 257 | builder.WriteString("tid=") 258 | builder.WriteString(fmt.Sprintf("%v", f.Tid)) 259 | builder.WriteString(", ") 260 | builder.WriteString("fee_token=") 261 | builder.WriteString(f.FeeToken) 262 | builder.WriteString(", ") 263 | builder.WriteString("builder_fee=") 264 | builder.WriteString(f.BuilderFee) 265 | builder.WriteByte(')') 266 | return builder.String() 267 | } 268 | 269 | // Fills is a parsable slice of Fill. 270 | type Fills []*Fill 271 | -------------------------------------------------------------------------------- /ent/fill/fill.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package fill 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the fill type in the database. 11 | Label = "fill" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldCoin holds the string denoting the coin field in the database. 15 | FieldCoin = "coin" 16 | // FieldAddress holds the string denoting the address field in the database. 17 | FieldAddress = "address" 18 | // FieldPx holds the string denoting the px field in the database. 19 | FieldPx = "px" 20 | // FieldSz holds the string denoting the sz field in the database. 21 | FieldSz = "sz" 22 | // FieldSide holds the string denoting the side field in the database. 23 | FieldSide = "side" 24 | // FieldTime holds the string denoting the time field in the database. 25 | FieldTime = "time" 26 | // FieldStartPosition holds the string denoting the start_position field in the database. 27 | FieldStartPosition = "start_position" 28 | // FieldClosedPnl holds the string denoting the closed_pnl field in the database. 29 | FieldClosedPnl = "closed_pnl" 30 | // FieldDir holds the string denoting the dir field in the database. 31 | FieldDir = "dir" 32 | // FieldHash holds the string denoting the hash field in the database. 33 | FieldHash = "hash" 34 | // FieldCrossed holds the string denoting the crossed field in the database. 35 | FieldCrossed = "crossed" 36 | // FieldFee holds the string denoting the fee field in the database. 37 | FieldFee = "fee" 38 | // FieldOid holds the string denoting the oid field in the database. 39 | FieldOid = "oid" 40 | // FieldTid holds the string denoting the tid field in the database. 41 | FieldTid = "tid" 42 | // FieldFeeToken holds the string denoting the fee_token field in the database. 43 | FieldFeeToken = "fee_token" 44 | // FieldBuilderFee holds the string denoting the builder_fee field in the database. 45 | FieldBuilderFee = "builder_fee" 46 | // Table holds the table name of the fill in the database. 47 | Table = "fills" 48 | ) 49 | 50 | // Columns holds all SQL columns for fill fields. 51 | var Columns = []string{ 52 | FieldID, 53 | FieldCoin, 54 | FieldAddress, 55 | FieldPx, 56 | FieldSz, 57 | FieldSide, 58 | FieldTime, 59 | FieldStartPosition, 60 | FieldClosedPnl, 61 | FieldDir, 62 | FieldHash, 63 | FieldCrossed, 64 | FieldFee, 65 | FieldOid, 66 | FieldTid, 67 | FieldFeeToken, 68 | FieldBuilderFee, 69 | } 70 | 71 | // ValidColumn reports if the column name is valid (part of the table columns). 72 | func ValidColumn(column string) bool { 73 | for i := range Columns { 74 | if column == Columns[i] { 75 | return true 76 | } 77 | } 78 | return false 79 | } 80 | 81 | // OrderOption defines the ordering options for the Fill queries. 82 | type OrderOption func(*sql.Selector) 83 | 84 | // ByID orders the results by the id field. 85 | func ByID(opts ...sql.OrderTermOption) OrderOption { 86 | return sql.OrderByField(FieldID, opts...).ToFunc() 87 | } 88 | 89 | // ByCoin orders the results by the coin field. 90 | func ByCoin(opts ...sql.OrderTermOption) OrderOption { 91 | return sql.OrderByField(FieldCoin, opts...).ToFunc() 92 | } 93 | 94 | // ByAddress orders the results by the address field. 95 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 96 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 97 | } 98 | 99 | // ByPx orders the results by the px field. 100 | func ByPx(opts ...sql.OrderTermOption) OrderOption { 101 | return sql.OrderByField(FieldPx, opts...).ToFunc() 102 | } 103 | 104 | // BySz orders the results by the sz field. 105 | func BySz(opts ...sql.OrderTermOption) OrderOption { 106 | return sql.OrderByField(FieldSz, opts...).ToFunc() 107 | } 108 | 109 | // BySide orders the results by the side field. 110 | func BySide(opts ...sql.OrderTermOption) OrderOption { 111 | return sql.OrderByField(FieldSide, opts...).ToFunc() 112 | } 113 | 114 | // ByTime orders the results by the time field. 115 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 116 | return sql.OrderByField(FieldTime, opts...).ToFunc() 117 | } 118 | 119 | // ByStartPosition orders the results by the start_position field. 120 | func ByStartPosition(opts ...sql.OrderTermOption) OrderOption { 121 | return sql.OrderByField(FieldStartPosition, opts...).ToFunc() 122 | } 123 | 124 | // ByClosedPnl orders the results by the closed_pnl field. 125 | func ByClosedPnl(opts ...sql.OrderTermOption) OrderOption { 126 | return sql.OrderByField(FieldClosedPnl, opts...).ToFunc() 127 | } 128 | 129 | // ByDir orders the results by the dir field. 130 | func ByDir(opts ...sql.OrderTermOption) OrderOption { 131 | return sql.OrderByField(FieldDir, opts...).ToFunc() 132 | } 133 | 134 | // ByHash orders the results by the hash field. 135 | func ByHash(opts ...sql.OrderTermOption) OrderOption { 136 | return sql.OrderByField(FieldHash, opts...).ToFunc() 137 | } 138 | 139 | // ByCrossed orders the results by the crossed field. 140 | func ByCrossed(opts ...sql.OrderTermOption) OrderOption { 141 | return sql.OrderByField(FieldCrossed, opts...).ToFunc() 142 | } 143 | 144 | // ByFee orders the results by the fee field. 145 | func ByFee(opts ...sql.OrderTermOption) OrderOption { 146 | return sql.OrderByField(FieldFee, opts...).ToFunc() 147 | } 148 | 149 | // ByOid orders the results by the oid field. 150 | func ByOid(opts ...sql.OrderTermOption) OrderOption { 151 | return sql.OrderByField(FieldOid, opts...).ToFunc() 152 | } 153 | 154 | // ByTid orders the results by the tid field. 155 | func ByTid(opts ...sql.OrderTermOption) OrderOption { 156 | return sql.OrderByField(FieldTid, opts...).ToFunc() 157 | } 158 | 159 | // ByFeeToken orders the results by the fee_token field. 160 | func ByFeeToken(opts ...sql.OrderTermOption) OrderOption { 161 | return sql.OrderByField(FieldFeeToken, opts...).ToFunc() 162 | } 163 | 164 | // ByBuilderFee orders the results by the builder_fee field. 165 | func ByBuilderFee(opts ...sql.OrderTermOption) OrderOption { 166 | return sql.OrderByField(FieldBuilderFee, opts...).ToFunc() 167 | } 168 | -------------------------------------------------------------------------------- /ent/fill_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/fill" 12 | "github.com/yoshiso/hypersync/ent/predicate" 13 | ) 14 | 15 | // FillDelete is the builder for deleting a Fill entity. 16 | type FillDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *FillMutation 20 | } 21 | 22 | // Where appends a list predicates to the FillDelete builder. 23 | func (fd *FillDelete) Where(ps ...predicate.Fill) *FillDelete { 24 | fd.mutation.Where(ps...) 25 | return fd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (fd *FillDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, fd.sqlExec, fd.mutation, fd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (fd *FillDelete) ExecX(ctx context.Context) int { 35 | n, err := fd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (fd *FillDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(fill.Table, sqlgraph.NewFieldSpec(fill.FieldID, field.TypeInt)) 44 | if ps := fd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, fd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | fd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // FillDeleteOne is the builder for deleting a single Fill entity. 60 | type FillDeleteOne struct { 61 | fd *FillDelete 62 | } 63 | 64 | // Where appends a list predicates to the FillDelete builder. 65 | func (fdo *FillDeleteOne) Where(ps ...predicate.Fill) *FillDeleteOne { 66 | fdo.fd.mutation.Where(ps...) 67 | return fdo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (fdo *FillDeleteOne) Exec(ctx context.Context) error { 72 | n, err := fdo.fd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{fill.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (fdo *FillDeleteOne) ExecX(ctx context.Context) { 85 | if err := fdo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/funding.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/funding" 12 | ) 13 | 14 | // Funding is the model entity for the Funding schema. 15 | type Funding struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // Time holds the value of the "time" field. 20 | Time int64 `json:"time,omitempty"` 21 | // Coin holds the value of the "coin" field. 22 | Coin string `json:"coin,omitempty"` 23 | // Usdc holds the value of the "usdc" field. 24 | Usdc string `json:"usdc,omitempty"` 25 | // Szi holds the value of the "szi" field. 26 | Szi string `json:"szi,omitempty"` 27 | // FundingRate holds the value of the "funding_rate" field. 28 | FundingRate string `json:"funding_rate,omitempty"` 29 | // Address holds the value of the "address" field. 30 | Address string `json:"address,omitempty"` 31 | selectValues sql.SelectValues 32 | } 33 | 34 | // scanValues returns the types for scanning values from sql.Rows. 35 | func (*Funding) scanValues(columns []string) ([]any, error) { 36 | values := make([]any, len(columns)) 37 | for i := range columns { 38 | switch columns[i] { 39 | case funding.FieldID, funding.FieldTime: 40 | values[i] = new(sql.NullInt64) 41 | case funding.FieldCoin, funding.FieldUsdc, funding.FieldSzi, funding.FieldFundingRate, funding.FieldAddress: 42 | values[i] = new(sql.NullString) 43 | default: 44 | values[i] = new(sql.UnknownType) 45 | } 46 | } 47 | return values, nil 48 | } 49 | 50 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 51 | // to the Funding fields. 52 | func (f *Funding) assignValues(columns []string, values []any) error { 53 | if m, n := len(values), len(columns); m < n { 54 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 55 | } 56 | for i := range columns { 57 | switch columns[i] { 58 | case funding.FieldID: 59 | value, ok := values[i].(*sql.NullInt64) 60 | if !ok { 61 | return fmt.Errorf("unexpected type %T for field id", value) 62 | } 63 | f.ID = int(value.Int64) 64 | case funding.FieldTime: 65 | if value, ok := values[i].(*sql.NullInt64); !ok { 66 | return fmt.Errorf("unexpected type %T for field time", values[i]) 67 | } else if value.Valid { 68 | f.Time = value.Int64 69 | } 70 | case funding.FieldCoin: 71 | if value, ok := values[i].(*sql.NullString); !ok { 72 | return fmt.Errorf("unexpected type %T for field coin", values[i]) 73 | } else if value.Valid { 74 | f.Coin = value.String 75 | } 76 | case funding.FieldUsdc: 77 | if value, ok := values[i].(*sql.NullString); !ok { 78 | return fmt.Errorf("unexpected type %T for field usdc", values[i]) 79 | } else if value.Valid { 80 | f.Usdc = value.String 81 | } 82 | case funding.FieldSzi: 83 | if value, ok := values[i].(*sql.NullString); !ok { 84 | return fmt.Errorf("unexpected type %T for field szi", values[i]) 85 | } else if value.Valid { 86 | f.Szi = value.String 87 | } 88 | case funding.FieldFundingRate: 89 | if value, ok := values[i].(*sql.NullString); !ok { 90 | return fmt.Errorf("unexpected type %T for field funding_rate", values[i]) 91 | } else if value.Valid { 92 | f.FundingRate = value.String 93 | } 94 | case funding.FieldAddress: 95 | if value, ok := values[i].(*sql.NullString); !ok { 96 | return fmt.Errorf("unexpected type %T for field address", values[i]) 97 | } else if value.Valid { 98 | f.Address = value.String 99 | } 100 | default: 101 | f.selectValues.Set(columns[i], values[i]) 102 | } 103 | } 104 | return nil 105 | } 106 | 107 | // Value returns the ent.Value that was dynamically selected and assigned to the Funding. 108 | // This includes values selected through modifiers, order, etc. 109 | func (f *Funding) Value(name string) (ent.Value, error) { 110 | return f.selectValues.Get(name) 111 | } 112 | 113 | // Update returns a builder for updating this Funding. 114 | // Note that you need to call Funding.Unwrap() before calling this method if this Funding 115 | // was returned from a transaction, and the transaction was committed or rolled back. 116 | func (f *Funding) Update() *FundingUpdateOne { 117 | return NewFundingClient(f.config).UpdateOne(f) 118 | } 119 | 120 | // Unwrap unwraps the Funding entity that was returned from a transaction after it was closed, 121 | // so that all future queries will be executed through the driver which created the transaction. 122 | func (f *Funding) Unwrap() *Funding { 123 | _tx, ok := f.config.driver.(*txDriver) 124 | if !ok { 125 | panic("ent: Funding is not a transactional entity") 126 | } 127 | f.config.driver = _tx.drv 128 | return f 129 | } 130 | 131 | // String implements the fmt.Stringer. 132 | func (f *Funding) String() string { 133 | var builder strings.Builder 134 | builder.WriteString("Funding(") 135 | builder.WriteString(fmt.Sprintf("id=%v, ", f.ID)) 136 | builder.WriteString("time=") 137 | builder.WriteString(fmt.Sprintf("%v", f.Time)) 138 | builder.WriteString(", ") 139 | builder.WriteString("coin=") 140 | builder.WriteString(f.Coin) 141 | builder.WriteString(", ") 142 | builder.WriteString("usdc=") 143 | builder.WriteString(f.Usdc) 144 | builder.WriteString(", ") 145 | builder.WriteString("szi=") 146 | builder.WriteString(f.Szi) 147 | builder.WriteString(", ") 148 | builder.WriteString("funding_rate=") 149 | builder.WriteString(f.FundingRate) 150 | builder.WriteString(", ") 151 | builder.WriteString("address=") 152 | builder.WriteString(f.Address) 153 | builder.WriteByte(')') 154 | return builder.String() 155 | } 156 | 157 | // Fundings is a parsable slice of Funding. 158 | type Fundings []*Funding 159 | -------------------------------------------------------------------------------- /ent/funding/funding.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package funding 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the funding type in the database. 11 | Label = "funding" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldTime holds the string denoting the time field in the database. 15 | FieldTime = "time" 16 | // FieldCoin holds the string denoting the coin field in the database. 17 | FieldCoin = "coin" 18 | // FieldUsdc holds the string denoting the usdc field in the database. 19 | FieldUsdc = "usdc" 20 | // FieldSzi holds the string denoting the szi field in the database. 21 | FieldSzi = "szi" 22 | // FieldFundingRate holds the string denoting the funding_rate field in the database. 23 | FieldFundingRate = "funding_rate" 24 | // FieldAddress holds the string denoting the address field in the database. 25 | FieldAddress = "address" 26 | // Table holds the table name of the funding in the database. 27 | Table = "fundings" 28 | ) 29 | 30 | // Columns holds all SQL columns for funding fields. 31 | var Columns = []string{ 32 | FieldID, 33 | FieldTime, 34 | FieldCoin, 35 | FieldUsdc, 36 | FieldSzi, 37 | FieldFundingRate, 38 | FieldAddress, 39 | } 40 | 41 | // ValidColumn reports if the column name is valid (part of the table columns). 42 | func ValidColumn(column string) bool { 43 | for i := range Columns { 44 | if column == Columns[i] { 45 | return true 46 | } 47 | } 48 | return false 49 | } 50 | 51 | // OrderOption defines the ordering options for the Funding queries. 52 | type OrderOption func(*sql.Selector) 53 | 54 | // ByID orders the results by the id field. 55 | func ByID(opts ...sql.OrderTermOption) OrderOption { 56 | return sql.OrderByField(FieldID, opts...).ToFunc() 57 | } 58 | 59 | // ByTime orders the results by the time field. 60 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 61 | return sql.OrderByField(FieldTime, opts...).ToFunc() 62 | } 63 | 64 | // ByCoin orders the results by the coin field. 65 | func ByCoin(opts ...sql.OrderTermOption) OrderOption { 66 | return sql.OrderByField(FieldCoin, opts...).ToFunc() 67 | } 68 | 69 | // ByUsdc orders the results by the usdc field. 70 | func ByUsdc(opts ...sql.OrderTermOption) OrderOption { 71 | return sql.OrderByField(FieldUsdc, opts...).ToFunc() 72 | } 73 | 74 | // BySzi orders the results by the szi field. 75 | func BySzi(opts ...sql.OrderTermOption) OrderOption { 76 | return sql.OrderByField(FieldSzi, opts...).ToFunc() 77 | } 78 | 79 | // ByFundingRate orders the results by the funding_rate field. 80 | func ByFundingRate(opts ...sql.OrderTermOption) OrderOption { 81 | return sql.OrderByField(FieldFundingRate, opts...).ToFunc() 82 | } 83 | 84 | // ByAddress orders the results by the address field. 85 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 86 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 87 | } 88 | -------------------------------------------------------------------------------- /ent/funding_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/funding" 12 | "github.com/yoshiso/hypersync/ent/predicate" 13 | ) 14 | 15 | // FundingDelete is the builder for deleting a Funding entity. 16 | type FundingDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *FundingMutation 20 | } 21 | 22 | // Where appends a list predicates to the FundingDelete builder. 23 | func (fd *FundingDelete) Where(ps ...predicate.Funding) *FundingDelete { 24 | fd.mutation.Where(ps...) 25 | return fd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (fd *FundingDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, fd.sqlExec, fd.mutation, fd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (fd *FundingDelete) ExecX(ctx context.Context) int { 35 | n, err := fd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (fd *FundingDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(funding.Table, sqlgraph.NewFieldSpec(funding.FieldID, field.TypeInt)) 44 | if ps := fd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, fd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | fd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // FundingDeleteOne is the builder for deleting a single Funding entity. 60 | type FundingDeleteOne struct { 61 | fd *FundingDelete 62 | } 63 | 64 | // Where appends a list predicates to the FundingDelete builder. 65 | func (fdo *FundingDeleteOne) Where(ps ...predicate.Funding) *FundingDeleteOne { 66 | fdo.fd.mutation.Where(ps...) 67 | return fdo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (fdo *FundingDeleteOne) Exec(ctx context.Context) error { 72 | n, err := fdo.fd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{funding.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (fdo *FundingDeleteOne) ExecX(ctx context.Context) { 85 | if err := fdo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/generate.go: -------------------------------------------------------------------------------- 1 | package ent 2 | 3 | //go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/upsert ./schema 4 | -------------------------------------------------------------------------------- /ent/hyperunitoperation/hyperunitoperation.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package hyperunitoperation 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the hyperunitoperation type in the database. 11 | Label = "hyperunit_operation" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldAddress holds the string denoting the address field in the database. 15 | FieldAddress = "address" 16 | // FieldOperationID holds the string denoting the operation_id field in the database. 17 | FieldOperationID = "operation_id" 18 | // FieldSourceChain holds the string denoting the source_chain field in the database. 19 | FieldSourceChain = "source_chain" 20 | // FieldSourceAmount holds the string denoting the source_amount field in the database. 21 | FieldSourceAmount = "source_amount" 22 | // FieldSourceAddress holds the string denoting the source_address field in the database. 23 | FieldSourceAddress = "source_address" 24 | // FieldSourceTxHash holds the string denoting the source_tx_hash field in the database. 25 | FieldSourceTxHash = "source_tx_hash" 26 | // FieldDestinationTxHash holds the string denoting the destination_tx_hash field in the database. 27 | FieldDestinationTxHash = "destination_tx_hash" 28 | // FieldDestinationFeeAmount holds the string denoting the destination_fee_amount field in the database. 29 | FieldDestinationFeeAmount = "destination_fee_amount" 30 | // FieldDestinationChain holds the string denoting the destination_chain field in the database. 31 | FieldDestinationChain = "destination_chain" 32 | // FieldDestinationAddress holds the string denoting the destination_address field in the database. 33 | FieldDestinationAddress = "destination_address" 34 | // FieldSweepFeeAmount holds the string denoting the sweep_fee_amount field in the database. 35 | FieldSweepFeeAmount = "sweep_fee_amount" 36 | // FieldOpCreatedAt holds the string denoting the op_created_at field in the database. 37 | FieldOpCreatedAt = "op_created_at" 38 | // FieldBroadcastAt holds the string denoting the broadcast_at field in the database. 39 | FieldBroadcastAt = "broadcast_at" 40 | // FieldStateUpdatedAt holds the string denoting the state_updated_at field in the database. 41 | FieldStateUpdatedAt = "state_updated_at" 42 | // Table holds the table name of the hyperunitoperation in the database. 43 | Table = "hyperunit_operations" 44 | ) 45 | 46 | // Columns holds all SQL columns for hyperunitoperation fields. 47 | var Columns = []string{ 48 | FieldID, 49 | FieldAddress, 50 | FieldOperationID, 51 | FieldSourceChain, 52 | FieldSourceAmount, 53 | FieldSourceAddress, 54 | FieldSourceTxHash, 55 | FieldDestinationTxHash, 56 | FieldDestinationFeeAmount, 57 | FieldDestinationChain, 58 | FieldDestinationAddress, 59 | FieldSweepFeeAmount, 60 | FieldOpCreatedAt, 61 | FieldBroadcastAt, 62 | FieldStateUpdatedAt, 63 | } 64 | 65 | // ValidColumn reports if the column name is valid (part of the table columns). 66 | func ValidColumn(column string) bool { 67 | for i := range Columns { 68 | if column == Columns[i] { 69 | return true 70 | } 71 | } 72 | return false 73 | } 74 | 75 | // OrderOption defines the ordering options for the HyperunitOperation queries. 76 | type OrderOption func(*sql.Selector) 77 | 78 | // ByID orders the results by the id field. 79 | func ByID(opts ...sql.OrderTermOption) OrderOption { 80 | return sql.OrderByField(FieldID, opts...).ToFunc() 81 | } 82 | 83 | // ByAddress orders the results by the address field. 84 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 85 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 86 | } 87 | 88 | // ByOperationID orders the results by the operation_id field. 89 | func ByOperationID(opts ...sql.OrderTermOption) OrderOption { 90 | return sql.OrderByField(FieldOperationID, opts...).ToFunc() 91 | } 92 | 93 | // BySourceChain orders the results by the source_chain field. 94 | func BySourceChain(opts ...sql.OrderTermOption) OrderOption { 95 | return sql.OrderByField(FieldSourceChain, opts...).ToFunc() 96 | } 97 | 98 | // BySourceAmount orders the results by the source_amount field. 99 | func BySourceAmount(opts ...sql.OrderTermOption) OrderOption { 100 | return sql.OrderByField(FieldSourceAmount, opts...).ToFunc() 101 | } 102 | 103 | // BySourceAddress orders the results by the source_address field. 104 | func BySourceAddress(opts ...sql.OrderTermOption) OrderOption { 105 | return sql.OrderByField(FieldSourceAddress, opts...).ToFunc() 106 | } 107 | 108 | // BySourceTxHash orders the results by the source_tx_hash field. 109 | func BySourceTxHash(opts ...sql.OrderTermOption) OrderOption { 110 | return sql.OrderByField(FieldSourceTxHash, opts...).ToFunc() 111 | } 112 | 113 | // ByDestinationTxHash orders the results by the destination_tx_hash field. 114 | func ByDestinationTxHash(opts ...sql.OrderTermOption) OrderOption { 115 | return sql.OrderByField(FieldDestinationTxHash, opts...).ToFunc() 116 | } 117 | 118 | // ByDestinationFeeAmount orders the results by the destination_fee_amount field. 119 | func ByDestinationFeeAmount(opts ...sql.OrderTermOption) OrderOption { 120 | return sql.OrderByField(FieldDestinationFeeAmount, opts...).ToFunc() 121 | } 122 | 123 | // ByDestinationChain orders the results by the destination_chain field. 124 | func ByDestinationChain(opts ...sql.OrderTermOption) OrderOption { 125 | return sql.OrderByField(FieldDestinationChain, opts...).ToFunc() 126 | } 127 | 128 | // ByDestinationAddress orders the results by the destination_address field. 129 | func ByDestinationAddress(opts ...sql.OrderTermOption) OrderOption { 130 | return sql.OrderByField(FieldDestinationAddress, opts...).ToFunc() 131 | } 132 | 133 | // BySweepFeeAmount orders the results by the sweep_fee_amount field. 134 | func BySweepFeeAmount(opts ...sql.OrderTermOption) OrderOption { 135 | return sql.OrderByField(FieldSweepFeeAmount, opts...).ToFunc() 136 | } 137 | 138 | // ByOpCreatedAt orders the results by the op_created_at field. 139 | func ByOpCreatedAt(opts ...sql.OrderTermOption) OrderOption { 140 | return sql.OrderByField(FieldOpCreatedAt, opts...).ToFunc() 141 | } 142 | 143 | // ByBroadcastAt orders the results by the broadcast_at field. 144 | func ByBroadcastAt(opts ...sql.OrderTermOption) OrderOption { 145 | return sql.OrderByField(FieldBroadcastAt, opts...).ToFunc() 146 | } 147 | 148 | // ByStateUpdatedAt orders the results by the state_updated_at field. 149 | func ByStateUpdatedAt(opts ...sql.OrderTermOption) OrderOption { 150 | return sql.OrderByField(FieldStateUpdatedAt, opts...).ToFunc() 151 | } 152 | -------------------------------------------------------------------------------- /ent/hyperunitoperation_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/hyperunitoperation" 12 | "github.com/yoshiso/hypersync/ent/predicate" 13 | ) 14 | 15 | // HyperunitOperationDelete is the builder for deleting a HyperunitOperation entity. 16 | type HyperunitOperationDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *HyperunitOperationMutation 20 | } 21 | 22 | // Where appends a list predicates to the HyperunitOperationDelete builder. 23 | func (hod *HyperunitOperationDelete) Where(ps ...predicate.HyperunitOperation) *HyperunitOperationDelete { 24 | hod.mutation.Where(ps...) 25 | return hod 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (hod *HyperunitOperationDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, hod.sqlExec, hod.mutation, hod.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (hod *HyperunitOperationDelete) ExecX(ctx context.Context) int { 35 | n, err := hod.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (hod *HyperunitOperationDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(hyperunitoperation.Table, sqlgraph.NewFieldSpec(hyperunitoperation.FieldID, field.TypeInt)) 44 | if ps := hod.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, hod.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | hod.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // HyperunitOperationDeleteOne is the builder for deleting a single HyperunitOperation entity. 60 | type HyperunitOperationDeleteOne struct { 61 | hod *HyperunitOperationDelete 62 | } 63 | 64 | // Where appends a list predicates to the HyperunitOperationDelete builder. 65 | func (hodo *HyperunitOperationDeleteOne) Where(ps ...predicate.HyperunitOperation) *HyperunitOperationDeleteOne { 66 | hodo.hod.mutation.Where(ps...) 67 | return hodo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (hodo *HyperunitOperationDeleteOne) Exec(ctx context.Context) error { 72 | n, err := hodo.hod.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{hyperunitoperation.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (hodo *HyperunitOperationDeleteOne) ExecX(ctx context.Context) { 85 | if err := hodo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/internaltransfer.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/internaltransfer" 12 | ) 13 | 14 | // InternalTransfer is the model entity for the InternalTransfer schema. 15 | type InternalTransfer struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // User holds the value of the "user" field. 20 | User string `json:"user,omitempty"` 21 | // Destination holds the value of the "destination" field. 22 | Destination string `json:"destination,omitempty"` 23 | // Usdc holds the value of the "usdc" field. 24 | Usdc string `json:"usdc,omitempty"` 25 | // Fee holds the value of the "fee" field. 26 | Fee string `json:"fee,omitempty"` 27 | // Time holds the value of the "time" field. 28 | Time int64 `json:"time,omitempty"` 29 | // Address holds the value of the "address" field. 30 | Address string `json:"address,omitempty"` 31 | selectValues sql.SelectValues 32 | } 33 | 34 | // scanValues returns the types for scanning values from sql.Rows. 35 | func (*InternalTransfer) scanValues(columns []string) ([]any, error) { 36 | values := make([]any, len(columns)) 37 | for i := range columns { 38 | switch columns[i] { 39 | case internaltransfer.FieldID, internaltransfer.FieldTime: 40 | values[i] = new(sql.NullInt64) 41 | case internaltransfer.FieldUser, internaltransfer.FieldDestination, internaltransfer.FieldUsdc, internaltransfer.FieldFee, internaltransfer.FieldAddress: 42 | values[i] = new(sql.NullString) 43 | default: 44 | values[i] = new(sql.UnknownType) 45 | } 46 | } 47 | return values, nil 48 | } 49 | 50 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 51 | // to the InternalTransfer fields. 52 | func (it *InternalTransfer) assignValues(columns []string, values []any) error { 53 | if m, n := len(values), len(columns); m < n { 54 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 55 | } 56 | for i := range columns { 57 | switch columns[i] { 58 | case internaltransfer.FieldID: 59 | value, ok := values[i].(*sql.NullInt64) 60 | if !ok { 61 | return fmt.Errorf("unexpected type %T for field id", value) 62 | } 63 | it.ID = int(value.Int64) 64 | case internaltransfer.FieldUser: 65 | if value, ok := values[i].(*sql.NullString); !ok { 66 | return fmt.Errorf("unexpected type %T for field user", values[i]) 67 | } else if value.Valid { 68 | it.User = value.String 69 | } 70 | case internaltransfer.FieldDestination: 71 | if value, ok := values[i].(*sql.NullString); !ok { 72 | return fmt.Errorf("unexpected type %T for field destination", values[i]) 73 | } else if value.Valid { 74 | it.Destination = value.String 75 | } 76 | case internaltransfer.FieldUsdc: 77 | if value, ok := values[i].(*sql.NullString); !ok { 78 | return fmt.Errorf("unexpected type %T for field usdc", values[i]) 79 | } else if value.Valid { 80 | it.Usdc = value.String 81 | } 82 | case internaltransfer.FieldFee: 83 | if value, ok := values[i].(*sql.NullString); !ok { 84 | return fmt.Errorf("unexpected type %T for field fee", values[i]) 85 | } else if value.Valid { 86 | it.Fee = value.String 87 | } 88 | case internaltransfer.FieldTime: 89 | if value, ok := values[i].(*sql.NullInt64); !ok { 90 | return fmt.Errorf("unexpected type %T for field time", values[i]) 91 | } else if value.Valid { 92 | it.Time = value.Int64 93 | } 94 | case internaltransfer.FieldAddress: 95 | if value, ok := values[i].(*sql.NullString); !ok { 96 | return fmt.Errorf("unexpected type %T for field address", values[i]) 97 | } else if value.Valid { 98 | it.Address = value.String 99 | } 100 | default: 101 | it.selectValues.Set(columns[i], values[i]) 102 | } 103 | } 104 | return nil 105 | } 106 | 107 | // Value returns the ent.Value that was dynamically selected and assigned to the InternalTransfer. 108 | // This includes values selected through modifiers, order, etc. 109 | func (it *InternalTransfer) Value(name string) (ent.Value, error) { 110 | return it.selectValues.Get(name) 111 | } 112 | 113 | // Update returns a builder for updating this InternalTransfer. 114 | // Note that you need to call InternalTransfer.Unwrap() before calling this method if this InternalTransfer 115 | // was returned from a transaction, and the transaction was committed or rolled back. 116 | func (it *InternalTransfer) Update() *InternalTransferUpdateOne { 117 | return NewInternalTransferClient(it.config).UpdateOne(it) 118 | } 119 | 120 | // Unwrap unwraps the InternalTransfer entity that was returned from a transaction after it was closed, 121 | // so that all future queries will be executed through the driver which created the transaction. 122 | func (it *InternalTransfer) Unwrap() *InternalTransfer { 123 | _tx, ok := it.config.driver.(*txDriver) 124 | if !ok { 125 | panic("ent: InternalTransfer is not a transactional entity") 126 | } 127 | it.config.driver = _tx.drv 128 | return it 129 | } 130 | 131 | // String implements the fmt.Stringer. 132 | func (it *InternalTransfer) String() string { 133 | var builder strings.Builder 134 | builder.WriteString("InternalTransfer(") 135 | builder.WriteString(fmt.Sprintf("id=%v, ", it.ID)) 136 | builder.WriteString("user=") 137 | builder.WriteString(it.User) 138 | builder.WriteString(", ") 139 | builder.WriteString("destination=") 140 | builder.WriteString(it.Destination) 141 | builder.WriteString(", ") 142 | builder.WriteString("usdc=") 143 | builder.WriteString(it.Usdc) 144 | builder.WriteString(", ") 145 | builder.WriteString("fee=") 146 | builder.WriteString(it.Fee) 147 | builder.WriteString(", ") 148 | builder.WriteString("time=") 149 | builder.WriteString(fmt.Sprintf("%v", it.Time)) 150 | builder.WriteString(", ") 151 | builder.WriteString("address=") 152 | builder.WriteString(it.Address) 153 | builder.WriteByte(')') 154 | return builder.String() 155 | } 156 | 157 | // InternalTransfers is a parsable slice of InternalTransfer. 158 | type InternalTransfers []*InternalTransfer 159 | -------------------------------------------------------------------------------- /ent/internaltransfer/internaltransfer.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package internaltransfer 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the internaltransfer type in the database. 11 | Label = "internal_transfer" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldUser holds the string denoting the user field in the database. 15 | FieldUser = "user" 16 | // FieldDestination holds the string denoting the destination field in the database. 17 | FieldDestination = "destination" 18 | // FieldUsdc holds the string denoting the usdc field in the database. 19 | FieldUsdc = "usdc" 20 | // FieldFee holds the string denoting the fee field in the database. 21 | FieldFee = "fee" 22 | // FieldTime holds the string denoting the time field in the database. 23 | FieldTime = "time" 24 | // FieldAddress holds the string denoting the address field in the database. 25 | FieldAddress = "address" 26 | // Table holds the table name of the internaltransfer in the database. 27 | Table = "internal_transfers" 28 | ) 29 | 30 | // Columns holds all SQL columns for internaltransfer fields. 31 | var Columns = []string{ 32 | FieldID, 33 | FieldUser, 34 | FieldDestination, 35 | FieldUsdc, 36 | FieldFee, 37 | FieldTime, 38 | FieldAddress, 39 | } 40 | 41 | // ValidColumn reports if the column name is valid (part of the table columns). 42 | func ValidColumn(column string) bool { 43 | for i := range Columns { 44 | if column == Columns[i] { 45 | return true 46 | } 47 | } 48 | return false 49 | } 50 | 51 | // OrderOption defines the ordering options for the InternalTransfer queries. 52 | type OrderOption func(*sql.Selector) 53 | 54 | // ByID orders the results by the id field. 55 | func ByID(opts ...sql.OrderTermOption) OrderOption { 56 | return sql.OrderByField(FieldID, opts...).ToFunc() 57 | } 58 | 59 | // ByUser orders the results by the user field. 60 | func ByUser(opts ...sql.OrderTermOption) OrderOption { 61 | return sql.OrderByField(FieldUser, opts...).ToFunc() 62 | } 63 | 64 | // ByDestination orders the results by the destination field. 65 | func ByDestination(opts ...sql.OrderTermOption) OrderOption { 66 | return sql.OrderByField(FieldDestination, opts...).ToFunc() 67 | } 68 | 69 | // ByUsdc orders the results by the usdc field. 70 | func ByUsdc(opts ...sql.OrderTermOption) OrderOption { 71 | return sql.OrderByField(FieldUsdc, opts...).ToFunc() 72 | } 73 | 74 | // ByFee orders the results by the fee field. 75 | func ByFee(opts ...sql.OrderTermOption) OrderOption { 76 | return sql.OrderByField(FieldFee, opts...).ToFunc() 77 | } 78 | 79 | // ByTime orders the results by the time field. 80 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 81 | return sql.OrderByField(FieldTime, opts...).ToFunc() 82 | } 83 | 84 | // ByAddress orders the results by the address field. 85 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 86 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 87 | } 88 | -------------------------------------------------------------------------------- /ent/internaltransfer_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/internaltransfer" 12 | "github.com/yoshiso/hypersync/ent/predicate" 13 | ) 14 | 15 | // InternalTransferDelete is the builder for deleting a InternalTransfer entity. 16 | type InternalTransferDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *InternalTransferMutation 20 | } 21 | 22 | // Where appends a list predicates to the InternalTransferDelete builder. 23 | func (itd *InternalTransferDelete) Where(ps ...predicate.InternalTransfer) *InternalTransferDelete { 24 | itd.mutation.Where(ps...) 25 | return itd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (itd *InternalTransferDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, itd.sqlExec, itd.mutation, itd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (itd *InternalTransferDelete) ExecX(ctx context.Context) int { 35 | n, err := itd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (itd *InternalTransferDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(internaltransfer.Table, sqlgraph.NewFieldSpec(internaltransfer.FieldID, field.TypeInt)) 44 | if ps := itd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, itd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | itd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // InternalTransferDeleteOne is the builder for deleting a single InternalTransfer entity. 60 | type InternalTransferDeleteOne struct { 61 | itd *InternalTransferDelete 62 | } 63 | 64 | // Where appends a list predicates to the InternalTransferDelete builder. 65 | func (itdo *InternalTransferDeleteOne) Where(ps ...predicate.InternalTransfer) *InternalTransferDeleteOne { 66 | itdo.itd.mutation.Where(ps...) 67 | return itdo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (itdo *InternalTransferDeleteOne) Exec(ctx context.Context) error { 72 | n, err := itdo.itd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{internaltransfer.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (itdo *InternalTransferDeleteOne) ExecX(ctx context.Context) { 85 | if err := itdo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/migrate/migrate.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package migrate 4 | 5 | import ( 6 | "context" 7 | "fmt" 8 | "io" 9 | 10 | "entgo.io/ent/dialect" 11 | "entgo.io/ent/dialect/sql/schema" 12 | ) 13 | 14 | var ( 15 | // WithGlobalUniqueID sets the universal ids options to the migration. 16 | // If this option is enabled, ent migration will allocate a 1<<32 range 17 | // for the ids of each entity (table). 18 | // Note that this option cannot be applied on tables that already exist. 19 | WithGlobalUniqueID = schema.WithGlobalUniqueID 20 | // WithDropColumn sets the drop column option to the migration. 21 | // If this option is enabled, ent migration will drop old columns 22 | // that were used for both fields and edges. This defaults to false. 23 | WithDropColumn = schema.WithDropColumn 24 | // WithDropIndex sets the drop index option to the migration. 25 | // If this option is enabled, ent migration will drop old indexes 26 | // that were defined in the schema. This defaults to false. 27 | // Note that unique constraints are defined using `UNIQUE INDEX`, 28 | // and therefore, it's recommended to enable this option to get more 29 | // flexibility in the schema changes. 30 | WithDropIndex = schema.WithDropIndex 31 | // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. 32 | WithForeignKeys = schema.WithForeignKeys 33 | ) 34 | 35 | // Schema is the API for creating, migrating and dropping a schema. 36 | type Schema struct { 37 | drv dialect.Driver 38 | } 39 | 40 | // NewSchema creates a new schema client. 41 | func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } 42 | 43 | // Create creates all schema resources. 44 | func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { 45 | return Create(ctx, s, Tables, opts...) 46 | } 47 | 48 | // Create creates all table resources using the given schema driver. 49 | func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { 50 | migrate, err := schema.NewMigrate(s.drv, opts...) 51 | if err != nil { 52 | return fmt.Errorf("ent/migrate: %w", err) 53 | } 54 | return migrate.Create(ctx, tables...) 55 | } 56 | 57 | // WriteTo writes the schema changes to w instead of running them against the database. 58 | // 59 | // if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { 60 | // log.Fatal(err) 61 | // } 62 | func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { 63 | return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) 64 | } 65 | -------------------------------------------------------------------------------- /ent/predicate/predicate.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package predicate 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | // Delegate is the predicate function for delegate builders. 10 | type Delegate func(*sql.Selector) 11 | 12 | // DelegatorReward is the predicate function for delegatorreward builders. 13 | type DelegatorReward func(*sql.Selector) 14 | 15 | // Fill is the predicate function for fill builders. 16 | type Fill func(*sql.Selector) 17 | 18 | // Funding is the predicate function for funding builders. 19 | type Funding func(*sql.Selector) 20 | 21 | // HyperunitOperation is the predicate function for hyperunitoperation builders. 22 | type HyperunitOperation func(*sql.Selector) 23 | 24 | // InternalTransfer is the predicate function for internaltransfer builders. 25 | type InternalTransfer func(*sql.Selector) 26 | 27 | // RewardsClaim is the predicate function for rewardsclaim builders. 28 | type RewardsClaim func(*sql.Selector) 29 | 30 | // SpotGenesis is the predicate function for spotgenesis builders. 31 | type SpotGenesis func(*sql.Selector) 32 | 33 | // SpotTransfer is the predicate function for spottransfer builders. 34 | type SpotTransfer func(*sql.Selector) 35 | 36 | // TwapSliceFill is the predicate function for twapslicefill builders. 37 | type TwapSliceFill func(*sql.Selector) 38 | 39 | // VaultDelta is the predicate function for vaultdelta builders. 40 | type VaultDelta func(*sql.Selector) 41 | 42 | // VaultLeaderCommission is the predicate function for vaultleadercommission builders. 43 | type VaultLeaderCommission func(*sql.Selector) 44 | 45 | // VaultWithdrawal is the predicate function for vaultwithdrawal builders. 46 | type VaultWithdrawal func(*sql.Selector) 47 | 48 | // Withdraw is the predicate function for withdraw builders. 49 | type Withdraw func(*sql.Selector) 50 | -------------------------------------------------------------------------------- /ent/rewardsclaim.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/rewardsclaim" 12 | ) 13 | 14 | // RewardsClaim is the model entity for the RewardsClaim schema. 15 | type RewardsClaim struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // Amount holds the value of the "amount" field. 20 | Amount string `json:"amount,omitempty"` 21 | // Time holds the value of the "time" field. 22 | Time int64 `json:"time,omitempty"` 23 | // Address holds the value of the "address" field. 24 | Address string `json:"address,omitempty"` 25 | selectValues sql.SelectValues 26 | } 27 | 28 | // scanValues returns the types for scanning values from sql.Rows. 29 | func (*RewardsClaim) scanValues(columns []string) ([]any, error) { 30 | values := make([]any, len(columns)) 31 | for i := range columns { 32 | switch columns[i] { 33 | case rewardsclaim.FieldID, rewardsclaim.FieldTime: 34 | values[i] = new(sql.NullInt64) 35 | case rewardsclaim.FieldAmount, rewardsclaim.FieldAddress: 36 | values[i] = new(sql.NullString) 37 | default: 38 | values[i] = new(sql.UnknownType) 39 | } 40 | } 41 | return values, nil 42 | } 43 | 44 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 45 | // to the RewardsClaim fields. 46 | func (rc *RewardsClaim) assignValues(columns []string, values []any) error { 47 | if m, n := len(values), len(columns); m < n { 48 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 49 | } 50 | for i := range columns { 51 | switch columns[i] { 52 | case rewardsclaim.FieldID: 53 | value, ok := values[i].(*sql.NullInt64) 54 | if !ok { 55 | return fmt.Errorf("unexpected type %T for field id", value) 56 | } 57 | rc.ID = int(value.Int64) 58 | case rewardsclaim.FieldAmount: 59 | if value, ok := values[i].(*sql.NullString); !ok { 60 | return fmt.Errorf("unexpected type %T for field amount", values[i]) 61 | } else if value.Valid { 62 | rc.Amount = value.String 63 | } 64 | case rewardsclaim.FieldTime: 65 | if value, ok := values[i].(*sql.NullInt64); !ok { 66 | return fmt.Errorf("unexpected type %T for field time", values[i]) 67 | } else if value.Valid { 68 | rc.Time = value.Int64 69 | } 70 | case rewardsclaim.FieldAddress: 71 | if value, ok := values[i].(*sql.NullString); !ok { 72 | return fmt.Errorf("unexpected type %T for field address", values[i]) 73 | } else if value.Valid { 74 | rc.Address = value.String 75 | } 76 | default: 77 | rc.selectValues.Set(columns[i], values[i]) 78 | } 79 | } 80 | return nil 81 | } 82 | 83 | // Value returns the ent.Value that was dynamically selected and assigned to the RewardsClaim. 84 | // This includes values selected through modifiers, order, etc. 85 | func (rc *RewardsClaim) Value(name string) (ent.Value, error) { 86 | return rc.selectValues.Get(name) 87 | } 88 | 89 | // Update returns a builder for updating this RewardsClaim. 90 | // Note that you need to call RewardsClaim.Unwrap() before calling this method if this RewardsClaim 91 | // was returned from a transaction, and the transaction was committed or rolled back. 92 | func (rc *RewardsClaim) Update() *RewardsClaimUpdateOne { 93 | return NewRewardsClaimClient(rc.config).UpdateOne(rc) 94 | } 95 | 96 | // Unwrap unwraps the RewardsClaim entity that was returned from a transaction after it was closed, 97 | // so that all future queries will be executed through the driver which created the transaction. 98 | func (rc *RewardsClaim) Unwrap() *RewardsClaim { 99 | _tx, ok := rc.config.driver.(*txDriver) 100 | if !ok { 101 | panic("ent: RewardsClaim is not a transactional entity") 102 | } 103 | rc.config.driver = _tx.drv 104 | return rc 105 | } 106 | 107 | // String implements the fmt.Stringer. 108 | func (rc *RewardsClaim) String() string { 109 | var builder strings.Builder 110 | builder.WriteString("RewardsClaim(") 111 | builder.WriteString(fmt.Sprintf("id=%v, ", rc.ID)) 112 | builder.WriteString("amount=") 113 | builder.WriteString(rc.Amount) 114 | builder.WriteString(", ") 115 | builder.WriteString("time=") 116 | builder.WriteString(fmt.Sprintf("%v", rc.Time)) 117 | builder.WriteString(", ") 118 | builder.WriteString("address=") 119 | builder.WriteString(rc.Address) 120 | builder.WriteByte(')') 121 | return builder.String() 122 | } 123 | 124 | // RewardsClaims is a parsable slice of RewardsClaim. 125 | type RewardsClaims []*RewardsClaim 126 | -------------------------------------------------------------------------------- /ent/rewardsclaim/rewardsclaim.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package rewardsclaim 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the rewardsclaim type in the database. 11 | Label = "rewards_claim" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldAmount holds the string denoting the amount field in the database. 15 | FieldAmount = "amount" 16 | // FieldTime holds the string denoting the time field in the database. 17 | FieldTime = "time" 18 | // FieldAddress holds the string denoting the address field in the database. 19 | FieldAddress = "address" 20 | // Table holds the table name of the rewardsclaim in the database. 21 | Table = "rewards_claims" 22 | ) 23 | 24 | // Columns holds all SQL columns for rewardsclaim fields. 25 | var Columns = []string{ 26 | FieldID, 27 | FieldAmount, 28 | FieldTime, 29 | FieldAddress, 30 | } 31 | 32 | // ValidColumn reports if the column name is valid (part of the table columns). 33 | func ValidColumn(column string) bool { 34 | for i := range Columns { 35 | if column == Columns[i] { 36 | return true 37 | } 38 | } 39 | return false 40 | } 41 | 42 | // OrderOption defines the ordering options for the RewardsClaim queries. 43 | type OrderOption func(*sql.Selector) 44 | 45 | // ByID orders the results by the id field. 46 | func ByID(opts ...sql.OrderTermOption) OrderOption { 47 | return sql.OrderByField(FieldID, opts...).ToFunc() 48 | } 49 | 50 | // ByAmount orders the results by the amount field. 51 | func ByAmount(opts ...sql.OrderTermOption) OrderOption { 52 | return sql.OrderByField(FieldAmount, opts...).ToFunc() 53 | } 54 | 55 | // ByTime orders the results by the time field. 56 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 57 | return sql.OrderByField(FieldTime, opts...).ToFunc() 58 | } 59 | 60 | // ByAddress orders the results by the address field. 61 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 62 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 63 | } 64 | -------------------------------------------------------------------------------- /ent/rewardsclaim/where.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package rewardsclaim 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | "github.com/yoshiso/hypersync/ent/predicate" 8 | ) 9 | 10 | // ID filters vertices based on their ID field. 11 | func ID(id int) predicate.RewardsClaim { 12 | return predicate.RewardsClaim(sql.FieldEQ(FieldID, id)) 13 | } 14 | 15 | // IDEQ applies the EQ predicate on the ID field. 16 | func IDEQ(id int) predicate.RewardsClaim { 17 | return predicate.RewardsClaim(sql.FieldEQ(FieldID, id)) 18 | } 19 | 20 | // IDNEQ applies the NEQ predicate on the ID field. 21 | func IDNEQ(id int) predicate.RewardsClaim { 22 | return predicate.RewardsClaim(sql.FieldNEQ(FieldID, id)) 23 | } 24 | 25 | // IDIn applies the In predicate on the ID field. 26 | func IDIn(ids ...int) predicate.RewardsClaim { 27 | return predicate.RewardsClaim(sql.FieldIn(FieldID, ids...)) 28 | } 29 | 30 | // IDNotIn applies the NotIn predicate on the ID field. 31 | func IDNotIn(ids ...int) predicate.RewardsClaim { 32 | return predicate.RewardsClaim(sql.FieldNotIn(FieldID, ids...)) 33 | } 34 | 35 | // IDGT applies the GT predicate on the ID field. 36 | func IDGT(id int) predicate.RewardsClaim { 37 | return predicate.RewardsClaim(sql.FieldGT(FieldID, id)) 38 | } 39 | 40 | // IDGTE applies the GTE predicate on the ID field. 41 | func IDGTE(id int) predicate.RewardsClaim { 42 | return predicate.RewardsClaim(sql.FieldGTE(FieldID, id)) 43 | } 44 | 45 | // IDLT applies the LT predicate on the ID field. 46 | func IDLT(id int) predicate.RewardsClaim { 47 | return predicate.RewardsClaim(sql.FieldLT(FieldID, id)) 48 | } 49 | 50 | // IDLTE applies the LTE predicate on the ID field. 51 | func IDLTE(id int) predicate.RewardsClaim { 52 | return predicate.RewardsClaim(sql.FieldLTE(FieldID, id)) 53 | } 54 | 55 | // Amount applies equality check predicate on the "amount" field. It's identical to AmountEQ. 56 | func Amount(v string) predicate.RewardsClaim { 57 | return predicate.RewardsClaim(sql.FieldEQ(FieldAmount, v)) 58 | } 59 | 60 | // Time applies equality check predicate on the "time" field. It's identical to TimeEQ. 61 | func Time(v int64) predicate.RewardsClaim { 62 | return predicate.RewardsClaim(sql.FieldEQ(FieldTime, v)) 63 | } 64 | 65 | // Address applies equality check predicate on the "address" field. It's identical to AddressEQ. 66 | func Address(v string) predicate.RewardsClaim { 67 | return predicate.RewardsClaim(sql.FieldEQ(FieldAddress, v)) 68 | } 69 | 70 | // AmountEQ applies the EQ predicate on the "amount" field. 71 | func AmountEQ(v string) predicate.RewardsClaim { 72 | return predicate.RewardsClaim(sql.FieldEQ(FieldAmount, v)) 73 | } 74 | 75 | // AmountNEQ applies the NEQ predicate on the "amount" field. 76 | func AmountNEQ(v string) predicate.RewardsClaim { 77 | return predicate.RewardsClaim(sql.FieldNEQ(FieldAmount, v)) 78 | } 79 | 80 | // AmountIn applies the In predicate on the "amount" field. 81 | func AmountIn(vs ...string) predicate.RewardsClaim { 82 | return predicate.RewardsClaim(sql.FieldIn(FieldAmount, vs...)) 83 | } 84 | 85 | // AmountNotIn applies the NotIn predicate on the "amount" field. 86 | func AmountNotIn(vs ...string) predicate.RewardsClaim { 87 | return predicate.RewardsClaim(sql.FieldNotIn(FieldAmount, vs...)) 88 | } 89 | 90 | // AmountGT applies the GT predicate on the "amount" field. 91 | func AmountGT(v string) predicate.RewardsClaim { 92 | return predicate.RewardsClaim(sql.FieldGT(FieldAmount, v)) 93 | } 94 | 95 | // AmountGTE applies the GTE predicate on the "amount" field. 96 | func AmountGTE(v string) predicate.RewardsClaim { 97 | return predicate.RewardsClaim(sql.FieldGTE(FieldAmount, v)) 98 | } 99 | 100 | // AmountLT applies the LT predicate on the "amount" field. 101 | func AmountLT(v string) predicate.RewardsClaim { 102 | return predicate.RewardsClaim(sql.FieldLT(FieldAmount, v)) 103 | } 104 | 105 | // AmountLTE applies the LTE predicate on the "amount" field. 106 | func AmountLTE(v string) predicate.RewardsClaim { 107 | return predicate.RewardsClaim(sql.FieldLTE(FieldAmount, v)) 108 | } 109 | 110 | // AmountContains applies the Contains predicate on the "amount" field. 111 | func AmountContains(v string) predicate.RewardsClaim { 112 | return predicate.RewardsClaim(sql.FieldContains(FieldAmount, v)) 113 | } 114 | 115 | // AmountHasPrefix applies the HasPrefix predicate on the "amount" field. 116 | func AmountHasPrefix(v string) predicate.RewardsClaim { 117 | return predicate.RewardsClaim(sql.FieldHasPrefix(FieldAmount, v)) 118 | } 119 | 120 | // AmountHasSuffix applies the HasSuffix predicate on the "amount" field. 121 | func AmountHasSuffix(v string) predicate.RewardsClaim { 122 | return predicate.RewardsClaim(sql.FieldHasSuffix(FieldAmount, v)) 123 | } 124 | 125 | // AmountEqualFold applies the EqualFold predicate on the "amount" field. 126 | func AmountEqualFold(v string) predicate.RewardsClaim { 127 | return predicate.RewardsClaim(sql.FieldEqualFold(FieldAmount, v)) 128 | } 129 | 130 | // AmountContainsFold applies the ContainsFold predicate on the "amount" field. 131 | func AmountContainsFold(v string) predicate.RewardsClaim { 132 | return predicate.RewardsClaim(sql.FieldContainsFold(FieldAmount, v)) 133 | } 134 | 135 | // TimeEQ applies the EQ predicate on the "time" field. 136 | func TimeEQ(v int64) predicate.RewardsClaim { 137 | return predicate.RewardsClaim(sql.FieldEQ(FieldTime, v)) 138 | } 139 | 140 | // TimeNEQ applies the NEQ predicate on the "time" field. 141 | func TimeNEQ(v int64) predicate.RewardsClaim { 142 | return predicate.RewardsClaim(sql.FieldNEQ(FieldTime, v)) 143 | } 144 | 145 | // TimeIn applies the In predicate on the "time" field. 146 | func TimeIn(vs ...int64) predicate.RewardsClaim { 147 | return predicate.RewardsClaim(sql.FieldIn(FieldTime, vs...)) 148 | } 149 | 150 | // TimeNotIn applies the NotIn predicate on the "time" field. 151 | func TimeNotIn(vs ...int64) predicate.RewardsClaim { 152 | return predicate.RewardsClaim(sql.FieldNotIn(FieldTime, vs...)) 153 | } 154 | 155 | // TimeGT applies the GT predicate on the "time" field. 156 | func TimeGT(v int64) predicate.RewardsClaim { 157 | return predicate.RewardsClaim(sql.FieldGT(FieldTime, v)) 158 | } 159 | 160 | // TimeGTE applies the GTE predicate on the "time" field. 161 | func TimeGTE(v int64) predicate.RewardsClaim { 162 | return predicate.RewardsClaim(sql.FieldGTE(FieldTime, v)) 163 | } 164 | 165 | // TimeLT applies the LT predicate on the "time" field. 166 | func TimeLT(v int64) predicate.RewardsClaim { 167 | return predicate.RewardsClaim(sql.FieldLT(FieldTime, v)) 168 | } 169 | 170 | // TimeLTE applies the LTE predicate on the "time" field. 171 | func TimeLTE(v int64) predicate.RewardsClaim { 172 | return predicate.RewardsClaim(sql.FieldLTE(FieldTime, v)) 173 | } 174 | 175 | // AddressEQ applies the EQ predicate on the "address" field. 176 | func AddressEQ(v string) predicate.RewardsClaim { 177 | return predicate.RewardsClaim(sql.FieldEQ(FieldAddress, v)) 178 | } 179 | 180 | // AddressNEQ applies the NEQ predicate on the "address" field. 181 | func AddressNEQ(v string) predicate.RewardsClaim { 182 | return predicate.RewardsClaim(sql.FieldNEQ(FieldAddress, v)) 183 | } 184 | 185 | // AddressIn applies the In predicate on the "address" field. 186 | func AddressIn(vs ...string) predicate.RewardsClaim { 187 | return predicate.RewardsClaim(sql.FieldIn(FieldAddress, vs...)) 188 | } 189 | 190 | // AddressNotIn applies the NotIn predicate on the "address" field. 191 | func AddressNotIn(vs ...string) predicate.RewardsClaim { 192 | return predicate.RewardsClaim(sql.FieldNotIn(FieldAddress, vs...)) 193 | } 194 | 195 | // AddressGT applies the GT predicate on the "address" field. 196 | func AddressGT(v string) predicate.RewardsClaim { 197 | return predicate.RewardsClaim(sql.FieldGT(FieldAddress, v)) 198 | } 199 | 200 | // AddressGTE applies the GTE predicate on the "address" field. 201 | func AddressGTE(v string) predicate.RewardsClaim { 202 | return predicate.RewardsClaim(sql.FieldGTE(FieldAddress, v)) 203 | } 204 | 205 | // AddressLT applies the LT predicate on the "address" field. 206 | func AddressLT(v string) predicate.RewardsClaim { 207 | return predicate.RewardsClaim(sql.FieldLT(FieldAddress, v)) 208 | } 209 | 210 | // AddressLTE applies the LTE predicate on the "address" field. 211 | func AddressLTE(v string) predicate.RewardsClaim { 212 | return predicate.RewardsClaim(sql.FieldLTE(FieldAddress, v)) 213 | } 214 | 215 | // AddressContains applies the Contains predicate on the "address" field. 216 | func AddressContains(v string) predicate.RewardsClaim { 217 | return predicate.RewardsClaim(sql.FieldContains(FieldAddress, v)) 218 | } 219 | 220 | // AddressHasPrefix applies the HasPrefix predicate on the "address" field. 221 | func AddressHasPrefix(v string) predicate.RewardsClaim { 222 | return predicate.RewardsClaim(sql.FieldHasPrefix(FieldAddress, v)) 223 | } 224 | 225 | // AddressHasSuffix applies the HasSuffix predicate on the "address" field. 226 | func AddressHasSuffix(v string) predicate.RewardsClaim { 227 | return predicate.RewardsClaim(sql.FieldHasSuffix(FieldAddress, v)) 228 | } 229 | 230 | // AddressEqualFold applies the EqualFold predicate on the "address" field. 231 | func AddressEqualFold(v string) predicate.RewardsClaim { 232 | return predicate.RewardsClaim(sql.FieldEqualFold(FieldAddress, v)) 233 | } 234 | 235 | // AddressContainsFold applies the ContainsFold predicate on the "address" field. 236 | func AddressContainsFold(v string) predicate.RewardsClaim { 237 | return predicate.RewardsClaim(sql.FieldContainsFold(FieldAddress, v)) 238 | } 239 | 240 | // And groups predicates with the AND operator between them. 241 | func And(predicates ...predicate.RewardsClaim) predicate.RewardsClaim { 242 | return predicate.RewardsClaim(sql.AndPredicates(predicates...)) 243 | } 244 | 245 | // Or groups predicates with the OR operator between them. 246 | func Or(predicates ...predicate.RewardsClaim) predicate.RewardsClaim { 247 | return predicate.RewardsClaim(sql.OrPredicates(predicates...)) 248 | } 249 | 250 | // Not applies the not operator on the given predicate. 251 | func Not(p predicate.RewardsClaim) predicate.RewardsClaim { 252 | return predicate.RewardsClaim(sql.NotPredicates(p)) 253 | } 254 | -------------------------------------------------------------------------------- /ent/rewardsclaim_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/predicate" 12 | "github.com/yoshiso/hypersync/ent/rewardsclaim" 13 | ) 14 | 15 | // RewardsClaimDelete is the builder for deleting a RewardsClaim entity. 16 | type RewardsClaimDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *RewardsClaimMutation 20 | } 21 | 22 | // Where appends a list predicates to the RewardsClaimDelete builder. 23 | func (rcd *RewardsClaimDelete) Where(ps ...predicate.RewardsClaim) *RewardsClaimDelete { 24 | rcd.mutation.Where(ps...) 25 | return rcd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (rcd *RewardsClaimDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, rcd.sqlExec, rcd.mutation, rcd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (rcd *RewardsClaimDelete) ExecX(ctx context.Context) int { 35 | n, err := rcd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (rcd *RewardsClaimDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(rewardsclaim.Table, sqlgraph.NewFieldSpec(rewardsclaim.FieldID, field.TypeInt)) 44 | if ps := rcd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, rcd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | rcd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // RewardsClaimDeleteOne is the builder for deleting a single RewardsClaim entity. 60 | type RewardsClaimDeleteOne struct { 61 | rcd *RewardsClaimDelete 62 | } 63 | 64 | // Where appends a list predicates to the RewardsClaimDelete builder. 65 | func (rcdo *RewardsClaimDeleteOne) Where(ps ...predicate.RewardsClaim) *RewardsClaimDeleteOne { 66 | rcdo.rcd.mutation.Where(ps...) 67 | return rcdo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (rcdo *RewardsClaimDeleteOne) Exec(ctx context.Context) error { 72 | n, err := rcdo.rcd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{rewardsclaim.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (rcdo *RewardsClaimDeleteOne) ExecX(ctx context.Context) { 85 | if err := rcdo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/rewardsclaim_update.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "fmt" 9 | 10 | "entgo.io/ent/dialect/sql" 11 | "entgo.io/ent/dialect/sql/sqlgraph" 12 | "entgo.io/ent/schema/field" 13 | "github.com/yoshiso/hypersync/ent/predicate" 14 | "github.com/yoshiso/hypersync/ent/rewardsclaim" 15 | ) 16 | 17 | // RewardsClaimUpdate is the builder for updating RewardsClaim entities. 18 | type RewardsClaimUpdate struct { 19 | config 20 | hooks []Hook 21 | mutation *RewardsClaimMutation 22 | } 23 | 24 | // Where appends a list predicates to the RewardsClaimUpdate builder. 25 | func (rcu *RewardsClaimUpdate) Where(ps ...predicate.RewardsClaim) *RewardsClaimUpdate { 26 | rcu.mutation.Where(ps...) 27 | return rcu 28 | } 29 | 30 | // SetAmount sets the "amount" field. 31 | func (rcu *RewardsClaimUpdate) SetAmount(s string) *RewardsClaimUpdate { 32 | rcu.mutation.SetAmount(s) 33 | return rcu 34 | } 35 | 36 | // SetNillableAmount sets the "amount" field if the given value is not nil. 37 | func (rcu *RewardsClaimUpdate) SetNillableAmount(s *string) *RewardsClaimUpdate { 38 | if s != nil { 39 | rcu.SetAmount(*s) 40 | } 41 | return rcu 42 | } 43 | 44 | // SetTime sets the "time" field. 45 | func (rcu *RewardsClaimUpdate) SetTime(i int64) *RewardsClaimUpdate { 46 | rcu.mutation.ResetTime() 47 | rcu.mutation.SetTime(i) 48 | return rcu 49 | } 50 | 51 | // SetNillableTime sets the "time" field if the given value is not nil. 52 | func (rcu *RewardsClaimUpdate) SetNillableTime(i *int64) *RewardsClaimUpdate { 53 | if i != nil { 54 | rcu.SetTime(*i) 55 | } 56 | return rcu 57 | } 58 | 59 | // AddTime adds i to the "time" field. 60 | func (rcu *RewardsClaimUpdate) AddTime(i int64) *RewardsClaimUpdate { 61 | rcu.mutation.AddTime(i) 62 | return rcu 63 | } 64 | 65 | // SetAddress sets the "address" field. 66 | func (rcu *RewardsClaimUpdate) SetAddress(s string) *RewardsClaimUpdate { 67 | rcu.mutation.SetAddress(s) 68 | return rcu 69 | } 70 | 71 | // SetNillableAddress sets the "address" field if the given value is not nil. 72 | func (rcu *RewardsClaimUpdate) SetNillableAddress(s *string) *RewardsClaimUpdate { 73 | if s != nil { 74 | rcu.SetAddress(*s) 75 | } 76 | return rcu 77 | } 78 | 79 | // Mutation returns the RewardsClaimMutation object of the builder. 80 | func (rcu *RewardsClaimUpdate) Mutation() *RewardsClaimMutation { 81 | return rcu.mutation 82 | } 83 | 84 | // Save executes the query and returns the number of nodes affected by the update operation. 85 | func (rcu *RewardsClaimUpdate) Save(ctx context.Context) (int, error) { 86 | return withHooks(ctx, rcu.sqlSave, rcu.mutation, rcu.hooks) 87 | } 88 | 89 | // SaveX is like Save, but panics if an error occurs. 90 | func (rcu *RewardsClaimUpdate) SaveX(ctx context.Context) int { 91 | affected, err := rcu.Save(ctx) 92 | if err != nil { 93 | panic(err) 94 | } 95 | return affected 96 | } 97 | 98 | // Exec executes the query. 99 | func (rcu *RewardsClaimUpdate) Exec(ctx context.Context) error { 100 | _, err := rcu.Save(ctx) 101 | return err 102 | } 103 | 104 | // ExecX is like Exec, but panics if an error occurs. 105 | func (rcu *RewardsClaimUpdate) ExecX(ctx context.Context) { 106 | if err := rcu.Exec(ctx); err != nil { 107 | panic(err) 108 | } 109 | } 110 | 111 | func (rcu *RewardsClaimUpdate) sqlSave(ctx context.Context) (n int, err error) { 112 | _spec := sqlgraph.NewUpdateSpec(rewardsclaim.Table, rewardsclaim.Columns, sqlgraph.NewFieldSpec(rewardsclaim.FieldID, field.TypeInt)) 113 | if ps := rcu.mutation.predicates; len(ps) > 0 { 114 | _spec.Predicate = func(selector *sql.Selector) { 115 | for i := range ps { 116 | ps[i](selector) 117 | } 118 | } 119 | } 120 | if value, ok := rcu.mutation.Amount(); ok { 121 | _spec.SetField(rewardsclaim.FieldAmount, field.TypeString, value) 122 | } 123 | if value, ok := rcu.mutation.Time(); ok { 124 | _spec.SetField(rewardsclaim.FieldTime, field.TypeInt64, value) 125 | } 126 | if value, ok := rcu.mutation.AddedTime(); ok { 127 | _spec.AddField(rewardsclaim.FieldTime, field.TypeInt64, value) 128 | } 129 | if value, ok := rcu.mutation.Address(); ok { 130 | _spec.SetField(rewardsclaim.FieldAddress, field.TypeString, value) 131 | } 132 | if n, err = sqlgraph.UpdateNodes(ctx, rcu.driver, _spec); err != nil { 133 | if _, ok := err.(*sqlgraph.NotFoundError); ok { 134 | err = &NotFoundError{rewardsclaim.Label} 135 | } else if sqlgraph.IsConstraintError(err) { 136 | err = &ConstraintError{msg: err.Error(), wrap: err} 137 | } 138 | return 0, err 139 | } 140 | rcu.mutation.done = true 141 | return n, nil 142 | } 143 | 144 | // RewardsClaimUpdateOne is the builder for updating a single RewardsClaim entity. 145 | type RewardsClaimUpdateOne struct { 146 | config 147 | fields []string 148 | hooks []Hook 149 | mutation *RewardsClaimMutation 150 | } 151 | 152 | // SetAmount sets the "amount" field. 153 | func (rcuo *RewardsClaimUpdateOne) SetAmount(s string) *RewardsClaimUpdateOne { 154 | rcuo.mutation.SetAmount(s) 155 | return rcuo 156 | } 157 | 158 | // SetNillableAmount sets the "amount" field if the given value is not nil. 159 | func (rcuo *RewardsClaimUpdateOne) SetNillableAmount(s *string) *RewardsClaimUpdateOne { 160 | if s != nil { 161 | rcuo.SetAmount(*s) 162 | } 163 | return rcuo 164 | } 165 | 166 | // SetTime sets the "time" field. 167 | func (rcuo *RewardsClaimUpdateOne) SetTime(i int64) *RewardsClaimUpdateOne { 168 | rcuo.mutation.ResetTime() 169 | rcuo.mutation.SetTime(i) 170 | return rcuo 171 | } 172 | 173 | // SetNillableTime sets the "time" field if the given value is not nil. 174 | func (rcuo *RewardsClaimUpdateOne) SetNillableTime(i *int64) *RewardsClaimUpdateOne { 175 | if i != nil { 176 | rcuo.SetTime(*i) 177 | } 178 | return rcuo 179 | } 180 | 181 | // AddTime adds i to the "time" field. 182 | func (rcuo *RewardsClaimUpdateOne) AddTime(i int64) *RewardsClaimUpdateOne { 183 | rcuo.mutation.AddTime(i) 184 | return rcuo 185 | } 186 | 187 | // SetAddress sets the "address" field. 188 | func (rcuo *RewardsClaimUpdateOne) SetAddress(s string) *RewardsClaimUpdateOne { 189 | rcuo.mutation.SetAddress(s) 190 | return rcuo 191 | } 192 | 193 | // SetNillableAddress sets the "address" field if the given value is not nil. 194 | func (rcuo *RewardsClaimUpdateOne) SetNillableAddress(s *string) *RewardsClaimUpdateOne { 195 | if s != nil { 196 | rcuo.SetAddress(*s) 197 | } 198 | return rcuo 199 | } 200 | 201 | // Mutation returns the RewardsClaimMutation object of the builder. 202 | func (rcuo *RewardsClaimUpdateOne) Mutation() *RewardsClaimMutation { 203 | return rcuo.mutation 204 | } 205 | 206 | // Where appends a list predicates to the RewardsClaimUpdate builder. 207 | func (rcuo *RewardsClaimUpdateOne) Where(ps ...predicate.RewardsClaim) *RewardsClaimUpdateOne { 208 | rcuo.mutation.Where(ps...) 209 | return rcuo 210 | } 211 | 212 | // Select allows selecting one or more fields (columns) of the returned entity. 213 | // The default is selecting all fields defined in the entity schema. 214 | func (rcuo *RewardsClaimUpdateOne) Select(field string, fields ...string) *RewardsClaimUpdateOne { 215 | rcuo.fields = append([]string{field}, fields...) 216 | return rcuo 217 | } 218 | 219 | // Save executes the query and returns the updated RewardsClaim entity. 220 | func (rcuo *RewardsClaimUpdateOne) Save(ctx context.Context) (*RewardsClaim, error) { 221 | return withHooks(ctx, rcuo.sqlSave, rcuo.mutation, rcuo.hooks) 222 | } 223 | 224 | // SaveX is like Save, but panics if an error occurs. 225 | func (rcuo *RewardsClaimUpdateOne) SaveX(ctx context.Context) *RewardsClaim { 226 | node, err := rcuo.Save(ctx) 227 | if err != nil { 228 | panic(err) 229 | } 230 | return node 231 | } 232 | 233 | // Exec executes the query on the entity. 234 | func (rcuo *RewardsClaimUpdateOne) Exec(ctx context.Context) error { 235 | _, err := rcuo.Save(ctx) 236 | return err 237 | } 238 | 239 | // ExecX is like Exec, but panics if an error occurs. 240 | func (rcuo *RewardsClaimUpdateOne) ExecX(ctx context.Context) { 241 | if err := rcuo.Exec(ctx); err != nil { 242 | panic(err) 243 | } 244 | } 245 | 246 | func (rcuo *RewardsClaimUpdateOne) sqlSave(ctx context.Context) (_node *RewardsClaim, err error) { 247 | _spec := sqlgraph.NewUpdateSpec(rewardsclaim.Table, rewardsclaim.Columns, sqlgraph.NewFieldSpec(rewardsclaim.FieldID, field.TypeInt)) 248 | id, ok := rcuo.mutation.ID() 249 | if !ok { 250 | return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RewardsClaim.id" for update`)} 251 | } 252 | _spec.Node.ID.Value = id 253 | if fields := rcuo.fields; len(fields) > 0 { 254 | _spec.Node.Columns = make([]string, 0, len(fields)) 255 | _spec.Node.Columns = append(_spec.Node.Columns, rewardsclaim.FieldID) 256 | for _, f := range fields { 257 | if !rewardsclaim.ValidColumn(f) { 258 | return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} 259 | } 260 | if f != rewardsclaim.FieldID { 261 | _spec.Node.Columns = append(_spec.Node.Columns, f) 262 | } 263 | } 264 | } 265 | if ps := rcuo.mutation.predicates; len(ps) > 0 { 266 | _spec.Predicate = func(selector *sql.Selector) { 267 | for i := range ps { 268 | ps[i](selector) 269 | } 270 | } 271 | } 272 | if value, ok := rcuo.mutation.Amount(); ok { 273 | _spec.SetField(rewardsclaim.FieldAmount, field.TypeString, value) 274 | } 275 | if value, ok := rcuo.mutation.Time(); ok { 276 | _spec.SetField(rewardsclaim.FieldTime, field.TypeInt64, value) 277 | } 278 | if value, ok := rcuo.mutation.AddedTime(); ok { 279 | _spec.AddField(rewardsclaim.FieldTime, field.TypeInt64, value) 280 | } 281 | if value, ok := rcuo.mutation.Address(); ok { 282 | _spec.SetField(rewardsclaim.FieldAddress, field.TypeString, value) 283 | } 284 | _node = &RewardsClaim{config: rcuo.config} 285 | _spec.Assign = _node.assignValues 286 | _spec.ScanValues = _node.scanValues 287 | if err = sqlgraph.UpdateNode(ctx, rcuo.driver, _spec); err != nil { 288 | if _, ok := err.(*sqlgraph.NotFoundError); ok { 289 | err = &NotFoundError{rewardsclaim.Label} 290 | } else if sqlgraph.IsConstraintError(err) { 291 | err = &ConstraintError{msg: err.Error(), wrap: err} 292 | } 293 | return nil, err 294 | } 295 | rcuo.mutation.done = true 296 | return _node, nil 297 | } 298 | -------------------------------------------------------------------------------- /ent/runtime.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | // The init function reads all schema descriptors with runtime code 6 | // (default values, validators, hooks and policies) and stitches it 7 | // to their package variables. 8 | func init() { 9 | } 10 | -------------------------------------------------------------------------------- /ent/runtime/runtime.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package runtime 4 | 5 | // The schema-stitching logic is generated in github.com/yoshiso/hypersync/ent/runtime.go 6 | 7 | const ( 8 | Version = "v0.14.1" // Version of ent codegen. 9 | Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen. 10 | ) 11 | -------------------------------------------------------------------------------- /ent/schema/delegate.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type Delegate struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (Delegate) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.String("validator"), 18 | field.String("amount"), 19 | field.Bool("is_undelegate"), 20 | field.Int64("time"), 21 | field.String("address"), 22 | } 23 | } 24 | 25 | // Edges of the User. 26 | func (Delegate) Edges() []ent.Edge { 27 | return nil 28 | } 29 | 30 | func (Delegate) Indexes() []ent.Index { 31 | return []ent.Index{ 32 | index.Fields("address", "time", "validator"). 33 | Unique(), 34 | } 35 | } -------------------------------------------------------------------------------- /ent/schema/delegator_reward.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type DelegatorReward struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (DelegatorReward) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.String("source"), 18 | field.String("total_amount"), 19 | field.Int64("time"), 20 | field.String("address"), 21 | } 22 | } 23 | 24 | // Edges of the User. 25 | func (DelegatorReward) Edges() []ent.Edge { 26 | return nil 27 | } 28 | 29 | func (DelegatorReward) Indexes() []ent.Index { 30 | return []ent.Index{ 31 | index.Fields("address", "time", "source"). 32 | Unique(), 33 | } 34 | } -------------------------------------------------------------------------------- /ent/schema/fill.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | ) 7 | 8 | // User holds the schema definition for the User entity. 9 | type Fill struct { 10 | ent.Schema 11 | } 12 | 13 | // Fields of the User. 14 | func (Fill) Fields() []ent.Field { 15 | return []ent.Field{ 16 | field.String("coin"), 17 | field.String("address"), 18 | field.String("px"), 19 | field.String("sz"), 20 | field.String("side"), 21 | field.Int64("time"), 22 | field.String("start_position"), 23 | field.String("closed_pnl"), 24 | field.String("dir"), 25 | field.String("hash"), 26 | field.Bool("crossed"), 27 | field.String("fee"), 28 | field.Int64("oid"), 29 | field.Int64("tid").Unique(), 30 | field.String("fee_token"), 31 | field.String("builder_fee").Optional(), 32 | } 33 | } 34 | 35 | // Edges of the User. 36 | func (Fill) Edges() []ent.Edge { 37 | return nil 38 | } -------------------------------------------------------------------------------- /ent/schema/funding.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type Funding struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (Funding) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.Int64("time"), 18 | field.String("coin"), 19 | field.String("usdc"), 20 | field.String("szi"), 21 | field.String("funding_rate"), 22 | field.String("address"), 23 | } 24 | } 25 | 26 | // Edges of the User. 27 | func (Funding) Edges() []ent.Edge { 28 | return nil 29 | } 30 | 31 | func (Funding) Indexes() []ent.Index { 32 | return []ent.Index{ 33 | index.Fields("address", "time", "coin"). 34 | Unique(), 35 | } 36 | } -------------------------------------------------------------------------------- /ent/schema/hyperunit_operation.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type HyperunitOperation struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (HyperunitOperation) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.String("address"), 18 | field.String("operation_id"), 19 | field.String("source_chain"), 20 | field.String("source_amount"), 21 | field.String("source_address"), 22 | field.String("source_tx_hash"), 23 | field.String("destination_tx_hash"), 24 | field.String("destination_fee_amount"), 25 | field.String("destination_chain"), 26 | field.String("destination_address"), 27 | field.String("sweep_fee_amount"), 28 | field.Time("op_created_at"), 29 | field.Time("broadcast_at"), 30 | field.Time("state_updated_at"), 31 | } 32 | } 33 | 34 | // Edges of the User. 35 | func (HyperunitOperation) Edges() []ent.Edge { 36 | return nil 37 | } 38 | 39 | func (HyperunitOperation) Indexes() []ent.Index { 40 | return []ent.Index{ 41 | index.Fields("address", "operation_id"). 42 | Unique(), 43 | } 44 | } -------------------------------------------------------------------------------- /ent/schema/internal_transfer.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type InternalTransfer struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (InternalTransfer) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.String("user"), 18 | field.String("destination"), 19 | field.String("usdc"), 20 | field.String("fee"), 21 | field.Int64("time"), 22 | field.String("address"), 23 | } 24 | } 25 | 26 | // Edges of the User. 27 | func (InternalTransfer) Edges() []ent.Edge { 28 | return nil 29 | } 30 | 31 | func (InternalTransfer) Indexes() []ent.Index { 32 | return []ent.Index{ 33 | index.Fields("address", "time", "user", "destination"). 34 | Unique(), 35 | } 36 | } -------------------------------------------------------------------------------- /ent/schema/rewards_claim.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type RewardsClaim struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (RewardsClaim) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.String("amount"), 18 | field.Int64("time"), 19 | field.String("address"), 20 | } 21 | } 22 | 23 | // Edges of the User. 24 | func (RewardsClaim) Edges() []ent.Edge { 25 | return nil 26 | } 27 | 28 | func (RewardsClaim) Indexes() []ent.Index { 29 | return []ent.Index{ 30 | index.Fields("address", "time"). 31 | Unique(), 32 | } 33 | } -------------------------------------------------------------------------------- /ent/schema/spot_genesis.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type SpotGenesis struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (SpotGenesis) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.String("coin"), 18 | field.String("amount"), 19 | field.Int64("time"), 20 | field.String("address"), 21 | } 22 | } 23 | 24 | // Edges of the User. 25 | func (SpotGenesis) Edges() []ent.Edge { 26 | return nil 27 | } 28 | 29 | func (SpotGenesis) Indexes() []ent.Index { 30 | return []ent.Index{ 31 | index.Fields("address", "time", "coin"). 32 | Unique(), 33 | } 34 | } -------------------------------------------------------------------------------- /ent/schema/spot_transfer.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type SpotTransfer struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (SpotTransfer) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.String("user"), 18 | field.String("destination"), 19 | field.String("token"), 20 | field.String("amount"), 21 | field.String("fee"), 22 | field.Int64("time"), 23 | field.String("address"), 24 | } 25 | } 26 | 27 | // Edges of the User. 28 | func (SpotTransfer) Edges() []ent.Edge { 29 | return nil 30 | } 31 | 32 | func (SpotTransfer) Indexes() []ent.Index { 33 | return []ent.Index{ 34 | index.Fields("address", "time", "token", "user", "destination"). 35 | Unique(), 36 | } 37 | } -------------------------------------------------------------------------------- /ent/schema/twap_slice_fill.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | ) 7 | 8 | // User holds the schema definition for the User entity. 9 | type TwapSliceFill struct { 10 | ent.Schema 11 | } 12 | 13 | // Fields of the User. 14 | func (TwapSliceFill) Fields() []ent.Field { 15 | return []ent.Field{ 16 | field.String("coin"), 17 | field.String("address"), 18 | field.String("px"), 19 | field.String("sz"), 20 | field.String("side"), 21 | field.Int64("time"), 22 | field.String("start_position"), 23 | field.String("closed_pnl"), 24 | field.String("dir"), 25 | field.String("hash"), 26 | field.Bool("crossed"), 27 | field.String("fee"), 28 | field.Int64("oid"), 29 | field.Int64("tid").Unique(), 30 | field.Int64("twap_id"), 31 | field.String("fee_token"), 32 | field.String("builder_fee").Optional(), 33 | } 34 | } 35 | 36 | // Edges of the User. 37 | func (TwapSliceFill) Edges() []ent.Edge { 38 | return nil 39 | } -------------------------------------------------------------------------------- /ent/schema/vault_delta.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type VaultDelta struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (VaultDelta) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.String("type"), 18 | field.String("vault"), 19 | field.String("usdc"), 20 | field.Int64("time"), 21 | field.String("address"), 22 | } 23 | } 24 | 25 | // Edges of the User. 26 | func (VaultDelta) Edges() []ent.Edge { 27 | return nil 28 | } 29 | 30 | func (VaultDelta) Indexes() []ent.Index { 31 | return []ent.Index{ 32 | index.Fields("address", "time", "vault"). 33 | Unique(), 34 | } 35 | } -------------------------------------------------------------------------------- /ent/schema/vault_leader_commission.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type VaultLeaderCommission struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (VaultLeaderCommission) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.String("user"), 18 | field.String("usdc"), 19 | field.Int64("time"), 20 | field.String("address"), 21 | } 22 | } 23 | 24 | // Edges of the User. 25 | func (VaultLeaderCommission) Edges() []ent.Edge { 26 | return nil 27 | } 28 | 29 | 30 | func (VaultLeaderCommission) Indexes() []ent.Index { 31 | return []ent.Index{ 32 | index.Fields("address", "time", "user"). 33 | Unique(), 34 | } 35 | } -------------------------------------------------------------------------------- /ent/schema/vault_withdrawal.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type VaultWithdrawal struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (VaultWithdrawal) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.String("vault"), 18 | field.String("user"), 19 | field.String("requested_usd"), 20 | field.String("commission"), 21 | field.String("closing_cost"), 22 | field.String("basis"), 23 | field.String("net_withdrawn_usd"), 24 | field.Int64("time"), 25 | field.String("address"), 26 | } 27 | } 28 | 29 | // Edges of the User. 30 | func (VaultWithdrawal) Edges() []ent.Edge { 31 | return nil 32 | } 33 | 34 | func (VaultWithdrawal) Indexes() []ent.Index { 35 | return []ent.Index{ 36 | index.Fields("address", "time", "vault"). 37 | Unique(), 38 | } 39 | } -------------------------------------------------------------------------------- /ent/schema/withdraw.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/schema/field" 6 | "entgo.io/ent/schema/index" 7 | ) 8 | 9 | // User holds the schema definition for the User entity. 10 | type Withdraw struct { 11 | ent.Schema 12 | } 13 | 14 | // Fields of the User. 15 | func (Withdraw) Fields() []ent.Field { 16 | return []ent.Field{ 17 | field.String("usdc"), 18 | field.Int64("nonce"), 19 | field.String("fee"), 20 | field.Int64("time"), 21 | field.String("address"), 22 | } 23 | } 24 | 25 | // Edges of the User. 26 | func (Withdraw) Edges() []ent.Edge { 27 | return nil 28 | } 29 | 30 | func (Withdraw) Indexes() []ent.Index { 31 | return []ent.Index{ 32 | index.Fields("address", "time", "nonce"). 33 | Unique(), 34 | } 35 | } -------------------------------------------------------------------------------- /ent/spotgenesis.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/spotgenesis" 12 | ) 13 | 14 | // SpotGenesis is the model entity for the SpotGenesis schema. 15 | type SpotGenesis struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // Coin holds the value of the "coin" field. 20 | Coin string `json:"coin,omitempty"` 21 | // Amount holds the value of the "amount" field. 22 | Amount string `json:"amount,omitempty"` 23 | // Time holds the value of the "time" field. 24 | Time int64 `json:"time,omitempty"` 25 | // Address holds the value of the "address" field. 26 | Address string `json:"address,omitempty"` 27 | selectValues sql.SelectValues 28 | } 29 | 30 | // scanValues returns the types for scanning values from sql.Rows. 31 | func (*SpotGenesis) scanValues(columns []string) ([]any, error) { 32 | values := make([]any, len(columns)) 33 | for i := range columns { 34 | switch columns[i] { 35 | case spotgenesis.FieldID, spotgenesis.FieldTime: 36 | values[i] = new(sql.NullInt64) 37 | case spotgenesis.FieldCoin, spotgenesis.FieldAmount, spotgenesis.FieldAddress: 38 | values[i] = new(sql.NullString) 39 | default: 40 | values[i] = new(sql.UnknownType) 41 | } 42 | } 43 | return values, nil 44 | } 45 | 46 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 47 | // to the SpotGenesis fields. 48 | func (sg *SpotGenesis) assignValues(columns []string, values []any) error { 49 | if m, n := len(values), len(columns); m < n { 50 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 51 | } 52 | for i := range columns { 53 | switch columns[i] { 54 | case spotgenesis.FieldID: 55 | value, ok := values[i].(*sql.NullInt64) 56 | if !ok { 57 | return fmt.Errorf("unexpected type %T for field id", value) 58 | } 59 | sg.ID = int(value.Int64) 60 | case spotgenesis.FieldCoin: 61 | if value, ok := values[i].(*sql.NullString); !ok { 62 | return fmt.Errorf("unexpected type %T for field coin", values[i]) 63 | } else if value.Valid { 64 | sg.Coin = value.String 65 | } 66 | case spotgenesis.FieldAmount: 67 | if value, ok := values[i].(*sql.NullString); !ok { 68 | return fmt.Errorf("unexpected type %T for field amount", values[i]) 69 | } else if value.Valid { 70 | sg.Amount = value.String 71 | } 72 | case spotgenesis.FieldTime: 73 | if value, ok := values[i].(*sql.NullInt64); !ok { 74 | return fmt.Errorf("unexpected type %T for field time", values[i]) 75 | } else if value.Valid { 76 | sg.Time = value.Int64 77 | } 78 | case spotgenesis.FieldAddress: 79 | if value, ok := values[i].(*sql.NullString); !ok { 80 | return fmt.Errorf("unexpected type %T for field address", values[i]) 81 | } else if value.Valid { 82 | sg.Address = value.String 83 | } 84 | default: 85 | sg.selectValues.Set(columns[i], values[i]) 86 | } 87 | } 88 | return nil 89 | } 90 | 91 | // Value returns the ent.Value that was dynamically selected and assigned to the SpotGenesis. 92 | // This includes values selected through modifiers, order, etc. 93 | func (sg *SpotGenesis) Value(name string) (ent.Value, error) { 94 | return sg.selectValues.Get(name) 95 | } 96 | 97 | // Update returns a builder for updating this SpotGenesis. 98 | // Note that you need to call SpotGenesis.Unwrap() before calling this method if this SpotGenesis 99 | // was returned from a transaction, and the transaction was committed or rolled back. 100 | func (sg *SpotGenesis) Update() *SpotGenesisUpdateOne { 101 | return NewSpotGenesisClient(sg.config).UpdateOne(sg) 102 | } 103 | 104 | // Unwrap unwraps the SpotGenesis entity that was returned from a transaction after it was closed, 105 | // so that all future queries will be executed through the driver which created the transaction. 106 | func (sg *SpotGenesis) Unwrap() *SpotGenesis { 107 | _tx, ok := sg.config.driver.(*txDriver) 108 | if !ok { 109 | panic("ent: SpotGenesis is not a transactional entity") 110 | } 111 | sg.config.driver = _tx.drv 112 | return sg 113 | } 114 | 115 | // String implements the fmt.Stringer. 116 | func (sg *SpotGenesis) String() string { 117 | var builder strings.Builder 118 | builder.WriteString("SpotGenesis(") 119 | builder.WriteString(fmt.Sprintf("id=%v, ", sg.ID)) 120 | builder.WriteString("coin=") 121 | builder.WriteString(sg.Coin) 122 | builder.WriteString(", ") 123 | builder.WriteString("amount=") 124 | builder.WriteString(sg.Amount) 125 | builder.WriteString(", ") 126 | builder.WriteString("time=") 127 | builder.WriteString(fmt.Sprintf("%v", sg.Time)) 128 | builder.WriteString(", ") 129 | builder.WriteString("address=") 130 | builder.WriteString(sg.Address) 131 | builder.WriteByte(')') 132 | return builder.String() 133 | } 134 | 135 | // SpotGeneses is a parsable slice of SpotGenesis. 136 | type SpotGeneses []*SpotGenesis 137 | -------------------------------------------------------------------------------- /ent/spotgenesis/spotgenesis.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package spotgenesis 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the spotgenesis type in the database. 11 | Label = "spot_genesis" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldCoin holds the string denoting the coin field in the database. 15 | FieldCoin = "coin" 16 | // FieldAmount holds the string denoting the amount field in the database. 17 | FieldAmount = "amount" 18 | // FieldTime holds the string denoting the time field in the database. 19 | FieldTime = "time" 20 | // FieldAddress holds the string denoting the address field in the database. 21 | FieldAddress = "address" 22 | // Table holds the table name of the spotgenesis in the database. 23 | Table = "spot_geneses" 24 | ) 25 | 26 | // Columns holds all SQL columns for spotgenesis fields. 27 | var Columns = []string{ 28 | FieldID, 29 | FieldCoin, 30 | FieldAmount, 31 | FieldTime, 32 | FieldAddress, 33 | } 34 | 35 | // ValidColumn reports if the column name is valid (part of the table columns). 36 | func ValidColumn(column string) bool { 37 | for i := range Columns { 38 | if column == Columns[i] { 39 | return true 40 | } 41 | } 42 | return false 43 | } 44 | 45 | // OrderOption defines the ordering options for the SpotGenesis queries. 46 | type OrderOption func(*sql.Selector) 47 | 48 | // ByID orders the results by the id field. 49 | func ByID(opts ...sql.OrderTermOption) OrderOption { 50 | return sql.OrderByField(FieldID, opts...).ToFunc() 51 | } 52 | 53 | // ByCoin orders the results by the coin field. 54 | func ByCoin(opts ...sql.OrderTermOption) OrderOption { 55 | return sql.OrderByField(FieldCoin, opts...).ToFunc() 56 | } 57 | 58 | // ByAmount orders the results by the amount field. 59 | func ByAmount(opts ...sql.OrderTermOption) OrderOption { 60 | return sql.OrderByField(FieldAmount, opts...).ToFunc() 61 | } 62 | 63 | // ByTime orders the results by the time field. 64 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 65 | return sql.OrderByField(FieldTime, opts...).ToFunc() 66 | } 67 | 68 | // ByAddress orders the results by the address field. 69 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 70 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 71 | } 72 | -------------------------------------------------------------------------------- /ent/spotgenesis_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/predicate" 12 | "github.com/yoshiso/hypersync/ent/spotgenesis" 13 | ) 14 | 15 | // SpotGenesisDelete is the builder for deleting a SpotGenesis entity. 16 | type SpotGenesisDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *SpotGenesisMutation 20 | } 21 | 22 | // Where appends a list predicates to the SpotGenesisDelete builder. 23 | func (sgd *SpotGenesisDelete) Where(ps ...predicate.SpotGenesis) *SpotGenesisDelete { 24 | sgd.mutation.Where(ps...) 25 | return sgd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (sgd *SpotGenesisDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, sgd.sqlExec, sgd.mutation, sgd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (sgd *SpotGenesisDelete) ExecX(ctx context.Context) int { 35 | n, err := sgd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (sgd *SpotGenesisDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(spotgenesis.Table, sqlgraph.NewFieldSpec(spotgenesis.FieldID, field.TypeInt)) 44 | if ps := sgd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, sgd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | sgd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // SpotGenesisDeleteOne is the builder for deleting a single SpotGenesis entity. 60 | type SpotGenesisDeleteOne struct { 61 | sgd *SpotGenesisDelete 62 | } 63 | 64 | // Where appends a list predicates to the SpotGenesisDelete builder. 65 | func (sgdo *SpotGenesisDeleteOne) Where(ps ...predicate.SpotGenesis) *SpotGenesisDeleteOne { 66 | sgdo.sgd.mutation.Where(ps...) 67 | return sgdo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (sgdo *SpotGenesisDeleteOne) Exec(ctx context.Context) error { 72 | n, err := sgdo.sgd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{spotgenesis.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (sgdo *SpotGenesisDeleteOne) ExecX(ctx context.Context) { 85 | if err := sgdo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/spottransfer.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/spottransfer" 12 | ) 13 | 14 | // SpotTransfer is the model entity for the SpotTransfer schema. 15 | type SpotTransfer struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // User holds the value of the "user" field. 20 | User string `json:"user,omitempty"` 21 | // Destination holds the value of the "destination" field. 22 | Destination string `json:"destination,omitempty"` 23 | // Token holds the value of the "token" field. 24 | Token string `json:"token,omitempty"` 25 | // Amount holds the value of the "amount" field. 26 | Amount string `json:"amount,omitempty"` 27 | // Fee holds the value of the "fee" field. 28 | Fee string `json:"fee,omitempty"` 29 | // Time holds the value of the "time" field. 30 | Time int64 `json:"time,omitempty"` 31 | // Address holds the value of the "address" field. 32 | Address string `json:"address,omitempty"` 33 | selectValues sql.SelectValues 34 | } 35 | 36 | // scanValues returns the types for scanning values from sql.Rows. 37 | func (*SpotTransfer) scanValues(columns []string) ([]any, error) { 38 | values := make([]any, len(columns)) 39 | for i := range columns { 40 | switch columns[i] { 41 | case spottransfer.FieldID, spottransfer.FieldTime: 42 | values[i] = new(sql.NullInt64) 43 | case spottransfer.FieldUser, spottransfer.FieldDestination, spottransfer.FieldToken, spottransfer.FieldAmount, spottransfer.FieldFee, spottransfer.FieldAddress: 44 | values[i] = new(sql.NullString) 45 | default: 46 | values[i] = new(sql.UnknownType) 47 | } 48 | } 49 | return values, nil 50 | } 51 | 52 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 53 | // to the SpotTransfer fields. 54 | func (st *SpotTransfer) assignValues(columns []string, values []any) error { 55 | if m, n := len(values), len(columns); m < n { 56 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 57 | } 58 | for i := range columns { 59 | switch columns[i] { 60 | case spottransfer.FieldID: 61 | value, ok := values[i].(*sql.NullInt64) 62 | if !ok { 63 | return fmt.Errorf("unexpected type %T for field id", value) 64 | } 65 | st.ID = int(value.Int64) 66 | case spottransfer.FieldUser: 67 | if value, ok := values[i].(*sql.NullString); !ok { 68 | return fmt.Errorf("unexpected type %T for field user", values[i]) 69 | } else if value.Valid { 70 | st.User = value.String 71 | } 72 | case spottransfer.FieldDestination: 73 | if value, ok := values[i].(*sql.NullString); !ok { 74 | return fmt.Errorf("unexpected type %T for field destination", values[i]) 75 | } else if value.Valid { 76 | st.Destination = value.String 77 | } 78 | case spottransfer.FieldToken: 79 | if value, ok := values[i].(*sql.NullString); !ok { 80 | return fmt.Errorf("unexpected type %T for field token", values[i]) 81 | } else if value.Valid { 82 | st.Token = value.String 83 | } 84 | case spottransfer.FieldAmount: 85 | if value, ok := values[i].(*sql.NullString); !ok { 86 | return fmt.Errorf("unexpected type %T for field amount", values[i]) 87 | } else if value.Valid { 88 | st.Amount = value.String 89 | } 90 | case spottransfer.FieldFee: 91 | if value, ok := values[i].(*sql.NullString); !ok { 92 | return fmt.Errorf("unexpected type %T for field fee", values[i]) 93 | } else if value.Valid { 94 | st.Fee = value.String 95 | } 96 | case spottransfer.FieldTime: 97 | if value, ok := values[i].(*sql.NullInt64); !ok { 98 | return fmt.Errorf("unexpected type %T for field time", values[i]) 99 | } else if value.Valid { 100 | st.Time = value.Int64 101 | } 102 | case spottransfer.FieldAddress: 103 | if value, ok := values[i].(*sql.NullString); !ok { 104 | return fmt.Errorf("unexpected type %T for field address", values[i]) 105 | } else if value.Valid { 106 | st.Address = value.String 107 | } 108 | default: 109 | st.selectValues.Set(columns[i], values[i]) 110 | } 111 | } 112 | return nil 113 | } 114 | 115 | // Value returns the ent.Value that was dynamically selected and assigned to the SpotTransfer. 116 | // This includes values selected through modifiers, order, etc. 117 | func (st *SpotTransfer) Value(name string) (ent.Value, error) { 118 | return st.selectValues.Get(name) 119 | } 120 | 121 | // Update returns a builder for updating this SpotTransfer. 122 | // Note that you need to call SpotTransfer.Unwrap() before calling this method if this SpotTransfer 123 | // was returned from a transaction, and the transaction was committed or rolled back. 124 | func (st *SpotTransfer) Update() *SpotTransferUpdateOne { 125 | return NewSpotTransferClient(st.config).UpdateOne(st) 126 | } 127 | 128 | // Unwrap unwraps the SpotTransfer entity that was returned from a transaction after it was closed, 129 | // so that all future queries will be executed through the driver which created the transaction. 130 | func (st *SpotTransfer) Unwrap() *SpotTransfer { 131 | _tx, ok := st.config.driver.(*txDriver) 132 | if !ok { 133 | panic("ent: SpotTransfer is not a transactional entity") 134 | } 135 | st.config.driver = _tx.drv 136 | return st 137 | } 138 | 139 | // String implements the fmt.Stringer. 140 | func (st *SpotTransfer) String() string { 141 | var builder strings.Builder 142 | builder.WriteString("SpotTransfer(") 143 | builder.WriteString(fmt.Sprintf("id=%v, ", st.ID)) 144 | builder.WriteString("user=") 145 | builder.WriteString(st.User) 146 | builder.WriteString(", ") 147 | builder.WriteString("destination=") 148 | builder.WriteString(st.Destination) 149 | builder.WriteString(", ") 150 | builder.WriteString("token=") 151 | builder.WriteString(st.Token) 152 | builder.WriteString(", ") 153 | builder.WriteString("amount=") 154 | builder.WriteString(st.Amount) 155 | builder.WriteString(", ") 156 | builder.WriteString("fee=") 157 | builder.WriteString(st.Fee) 158 | builder.WriteString(", ") 159 | builder.WriteString("time=") 160 | builder.WriteString(fmt.Sprintf("%v", st.Time)) 161 | builder.WriteString(", ") 162 | builder.WriteString("address=") 163 | builder.WriteString(st.Address) 164 | builder.WriteByte(')') 165 | return builder.String() 166 | } 167 | 168 | // SpotTransfers is a parsable slice of SpotTransfer. 169 | type SpotTransfers []*SpotTransfer 170 | -------------------------------------------------------------------------------- /ent/spottransfer/spottransfer.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package spottransfer 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the spottransfer type in the database. 11 | Label = "spot_transfer" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldUser holds the string denoting the user field in the database. 15 | FieldUser = "user" 16 | // FieldDestination holds the string denoting the destination field in the database. 17 | FieldDestination = "destination" 18 | // FieldToken holds the string denoting the token field in the database. 19 | FieldToken = "token" 20 | // FieldAmount holds the string denoting the amount field in the database. 21 | FieldAmount = "amount" 22 | // FieldFee holds the string denoting the fee field in the database. 23 | FieldFee = "fee" 24 | // FieldTime holds the string denoting the time field in the database. 25 | FieldTime = "time" 26 | // FieldAddress holds the string denoting the address field in the database. 27 | FieldAddress = "address" 28 | // Table holds the table name of the spottransfer in the database. 29 | Table = "spot_transfers" 30 | ) 31 | 32 | // Columns holds all SQL columns for spottransfer fields. 33 | var Columns = []string{ 34 | FieldID, 35 | FieldUser, 36 | FieldDestination, 37 | FieldToken, 38 | FieldAmount, 39 | FieldFee, 40 | FieldTime, 41 | FieldAddress, 42 | } 43 | 44 | // ValidColumn reports if the column name is valid (part of the table columns). 45 | func ValidColumn(column string) bool { 46 | for i := range Columns { 47 | if column == Columns[i] { 48 | return true 49 | } 50 | } 51 | return false 52 | } 53 | 54 | // OrderOption defines the ordering options for the SpotTransfer queries. 55 | type OrderOption func(*sql.Selector) 56 | 57 | // ByID orders the results by the id field. 58 | func ByID(opts ...sql.OrderTermOption) OrderOption { 59 | return sql.OrderByField(FieldID, opts...).ToFunc() 60 | } 61 | 62 | // ByUser orders the results by the user field. 63 | func ByUser(opts ...sql.OrderTermOption) OrderOption { 64 | return sql.OrderByField(FieldUser, opts...).ToFunc() 65 | } 66 | 67 | // ByDestination orders the results by the destination field. 68 | func ByDestination(opts ...sql.OrderTermOption) OrderOption { 69 | return sql.OrderByField(FieldDestination, opts...).ToFunc() 70 | } 71 | 72 | // ByToken orders the results by the token field. 73 | func ByToken(opts ...sql.OrderTermOption) OrderOption { 74 | return sql.OrderByField(FieldToken, opts...).ToFunc() 75 | } 76 | 77 | // ByAmount orders the results by the amount field. 78 | func ByAmount(opts ...sql.OrderTermOption) OrderOption { 79 | return sql.OrderByField(FieldAmount, opts...).ToFunc() 80 | } 81 | 82 | // ByFee orders the results by the fee field. 83 | func ByFee(opts ...sql.OrderTermOption) OrderOption { 84 | return sql.OrderByField(FieldFee, opts...).ToFunc() 85 | } 86 | 87 | // ByTime orders the results by the time field. 88 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 89 | return sql.OrderByField(FieldTime, opts...).ToFunc() 90 | } 91 | 92 | // ByAddress orders the results by the address field. 93 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 94 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 95 | } 96 | -------------------------------------------------------------------------------- /ent/spottransfer_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/predicate" 12 | "github.com/yoshiso/hypersync/ent/spottransfer" 13 | ) 14 | 15 | // SpotTransferDelete is the builder for deleting a SpotTransfer entity. 16 | type SpotTransferDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *SpotTransferMutation 20 | } 21 | 22 | // Where appends a list predicates to the SpotTransferDelete builder. 23 | func (std *SpotTransferDelete) Where(ps ...predicate.SpotTransfer) *SpotTransferDelete { 24 | std.mutation.Where(ps...) 25 | return std 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (std *SpotTransferDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, std.sqlExec, std.mutation, std.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (std *SpotTransferDelete) ExecX(ctx context.Context) int { 35 | n, err := std.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (std *SpotTransferDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(spottransfer.Table, sqlgraph.NewFieldSpec(spottransfer.FieldID, field.TypeInt)) 44 | if ps := std.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, std.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | std.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // SpotTransferDeleteOne is the builder for deleting a single SpotTransfer entity. 60 | type SpotTransferDeleteOne struct { 61 | std *SpotTransferDelete 62 | } 63 | 64 | // Where appends a list predicates to the SpotTransferDelete builder. 65 | func (stdo *SpotTransferDeleteOne) Where(ps ...predicate.SpotTransfer) *SpotTransferDeleteOne { 66 | stdo.std.mutation.Where(ps...) 67 | return stdo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (stdo *SpotTransferDeleteOne) Exec(ctx context.Context) error { 72 | n, err := stdo.std.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{spottransfer.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (stdo *SpotTransferDeleteOne) ExecX(ctx context.Context) { 85 | if err := stdo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/sqlite_driver.go: -------------------------------------------------------------------------------- 1 | package ent 2 | 3 | import ( 4 | "database/sql" 5 | "database/sql/driver" 6 | "fmt" 7 | 8 | "modernc.org/sqlite" 9 | ) 10 | 11 | type sqliteDriver struct { 12 | *sqlite.Driver 13 | } 14 | 15 | func (d sqliteDriver) Open(name string) (driver.Conn, error) { 16 | conn, err := d.Driver.Open(name) 17 | if err != nil { 18 | return conn, err 19 | } 20 | c := conn.(interface { 21 | Exec(stmt string, args []driver.Value) (driver.Result, error) 22 | }) 23 | if _, err := c.Exec("PRAGMA foreign_keys = on;", nil); err != nil { 24 | conn.Close() 25 | return nil, fmt.Errorf("failed to enable enable foreign keys: %w", err) 26 | } 27 | return conn, nil 28 | } 29 | 30 | func init() { 31 | sql.Register("sqlite3", sqliteDriver{Driver: &sqlite.Driver{}}) 32 | } -------------------------------------------------------------------------------- /ent/twapslicefill/twapslicefill.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package twapslicefill 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the twapslicefill type in the database. 11 | Label = "twap_slice_fill" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldCoin holds the string denoting the coin field in the database. 15 | FieldCoin = "coin" 16 | // FieldAddress holds the string denoting the address field in the database. 17 | FieldAddress = "address" 18 | // FieldPx holds the string denoting the px field in the database. 19 | FieldPx = "px" 20 | // FieldSz holds the string denoting the sz field in the database. 21 | FieldSz = "sz" 22 | // FieldSide holds the string denoting the side field in the database. 23 | FieldSide = "side" 24 | // FieldTime holds the string denoting the time field in the database. 25 | FieldTime = "time" 26 | // FieldStartPosition holds the string denoting the start_position field in the database. 27 | FieldStartPosition = "start_position" 28 | // FieldClosedPnl holds the string denoting the closed_pnl field in the database. 29 | FieldClosedPnl = "closed_pnl" 30 | // FieldDir holds the string denoting the dir field in the database. 31 | FieldDir = "dir" 32 | // FieldHash holds the string denoting the hash field in the database. 33 | FieldHash = "hash" 34 | // FieldCrossed holds the string denoting the crossed field in the database. 35 | FieldCrossed = "crossed" 36 | // FieldFee holds the string denoting the fee field in the database. 37 | FieldFee = "fee" 38 | // FieldOid holds the string denoting the oid field in the database. 39 | FieldOid = "oid" 40 | // FieldTid holds the string denoting the tid field in the database. 41 | FieldTid = "tid" 42 | // FieldTwapID holds the string denoting the twap_id field in the database. 43 | FieldTwapID = "twap_id" 44 | // FieldFeeToken holds the string denoting the fee_token field in the database. 45 | FieldFeeToken = "fee_token" 46 | // FieldBuilderFee holds the string denoting the builder_fee field in the database. 47 | FieldBuilderFee = "builder_fee" 48 | // Table holds the table name of the twapslicefill in the database. 49 | Table = "twap_slice_fills" 50 | ) 51 | 52 | // Columns holds all SQL columns for twapslicefill fields. 53 | var Columns = []string{ 54 | FieldID, 55 | FieldCoin, 56 | FieldAddress, 57 | FieldPx, 58 | FieldSz, 59 | FieldSide, 60 | FieldTime, 61 | FieldStartPosition, 62 | FieldClosedPnl, 63 | FieldDir, 64 | FieldHash, 65 | FieldCrossed, 66 | FieldFee, 67 | FieldOid, 68 | FieldTid, 69 | FieldTwapID, 70 | FieldFeeToken, 71 | FieldBuilderFee, 72 | } 73 | 74 | // ValidColumn reports if the column name is valid (part of the table columns). 75 | func ValidColumn(column string) bool { 76 | for i := range Columns { 77 | if column == Columns[i] { 78 | return true 79 | } 80 | } 81 | return false 82 | } 83 | 84 | // OrderOption defines the ordering options for the TwapSliceFill queries. 85 | type OrderOption func(*sql.Selector) 86 | 87 | // ByID orders the results by the id field. 88 | func ByID(opts ...sql.OrderTermOption) OrderOption { 89 | return sql.OrderByField(FieldID, opts...).ToFunc() 90 | } 91 | 92 | // ByCoin orders the results by the coin field. 93 | func ByCoin(opts ...sql.OrderTermOption) OrderOption { 94 | return sql.OrderByField(FieldCoin, opts...).ToFunc() 95 | } 96 | 97 | // ByAddress orders the results by the address field. 98 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 99 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 100 | } 101 | 102 | // ByPx orders the results by the px field. 103 | func ByPx(opts ...sql.OrderTermOption) OrderOption { 104 | return sql.OrderByField(FieldPx, opts...).ToFunc() 105 | } 106 | 107 | // BySz orders the results by the sz field. 108 | func BySz(opts ...sql.OrderTermOption) OrderOption { 109 | return sql.OrderByField(FieldSz, opts...).ToFunc() 110 | } 111 | 112 | // BySide orders the results by the side field. 113 | func BySide(opts ...sql.OrderTermOption) OrderOption { 114 | return sql.OrderByField(FieldSide, opts...).ToFunc() 115 | } 116 | 117 | // ByTime orders the results by the time field. 118 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 119 | return sql.OrderByField(FieldTime, opts...).ToFunc() 120 | } 121 | 122 | // ByStartPosition orders the results by the start_position field. 123 | func ByStartPosition(opts ...sql.OrderTermOption) OrderOption { 124 | return sql.OrderByField(FieldStartPosition, opts...).ToFunc() 125 | } 126 | 127 | // ByClosedPnl orders the results by the closed_pnl field. 128 | func ByClosedPnl(opts ...sql.OrderTermOption) OrderOption { 129 | return sql.OrderByField(FieldClosedPnl, opts...).ToFunc() 130 | } 131 | 132 | // ByDir orders the results by the dir field. 133 | func ByDir(opts ...sql.OrderTermOption) OrderOption { 134 | return sql.OrderByField(FieldDir, opts...).ToFunc() 135 | } 136 | 137 | // ByHash orders the results by the hash field. 138 | func ByHash(opts ...sql.OrderTermOption) OrderOption { 139 | return sql.OrderByField(FieldHash, opts...).ToFunc() 140 | } 141 | 142 | // ByCrossed orders the results by the crossed field. 143 | func ByCrossed(opts ...sql.OrderTermOption) OrderOption { 144 | return sql.OrderByField(FieldCrossed, opts...).ToFunc() 145 | } 146 | 147 | // ByFee orders the results by the fee field. 148 | func ByFee(opts ...sql.OrderTermOption) OrderOption { 149 | return sql.OrderByField(FieldFee, opts...).ToFunc() 150 | } 151 | 152 | // ByOid orders the results by the oid field. 153 | func ByOid(opts ...sql.OrderTermOption) OrderOption { 154 | return sql.OrderByField(FieldOid, opts...).ToFunc() 155 | } 156 | 157 | // ByTid orders the results by the tid field. 158 | func ByTid(opts ...sql.OrderTermOption) OrderOption { 159 | return sql.OrderByField(FieldTid, opts...).ToFunc() 160 | } 161 | 162 | // ByTwapID orders the results by the twap_id field. 163 | func ByTwapID(opts ...sql.OrderTermOption) OrderOption { 164 | return sql.OrderByField(FieldTwapID, opts...).ToFunc() 165 | } 166 | 167 | // ByFeeToken orders the results by the fee_token field. 168 | func ByFeeToken(opts ...sql.OrderTermOption) OrderOption { 169 | return sql.OrderByField(FieldFeeToken, opts...).ToFunc() 170 | } 171 | 172 | // ByBuilderFee orders the results by the builder_fee field. 173 | func ByBuilderFee(opts ...sql.OrderTermOption) OrderOption { 174 | return sql.OrderByField(FieldBuilderFee, opts...).ToFunc() 175 | } 176 | -------------------------------------------------------------------------------- /ent/twapslicefill_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/predicate" 12 | "github.com/yoshiso/hypersync/ent/twapslicefill" 13 | ) 14 | 15 | // TwapSliceFillDelete is the builder for deleting a TwapSliceFill entity. 16 | type TwapSliceFillDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *TwapSliceFillMutation 20 | } 21 | 22 | // Where appends a list predicates to the TwapSliceFillDelete builder. 23 | func (tsfd *TwapSliceFillDelete) Where(ps ...predicate.TwapSliceFill) *TwapSliceFillDelete { 24 | tsfd.mutation.Where(ps...) 25 | return tsfd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (tsfd *TwapSliceFillDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, tsfd.sqlExec, tsfd.mutation, tsfd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (tsfd *TwapSliceFillDelete) ExecX(ctx context.Context) int { 35 | n, err := tsfd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (tsfd *TwapSliceFillDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(twapslicefill.Table, sqlgraph.NewFieldSpec(twapslicefill.FieldID, field.TypeInt)) 44 | if ps := tsfd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, tsfd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | tsfd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // TwapSliceFillDeleteOne is the builder for deleting a single TwapSliceFill entity. 60 | type TwapSliceFillDeleteOne struct { 61 | tsfd *TwapSliceFillDelete 62 | } 63 | 64 | // Where appends a list predicates to the TwapSliceFillDelete builder. 65 | func (tsfdo *TwapSliceFillDeleteOne) Where(ps ...predicate.TwapSliceFill) *TwapSliceFillDeleteOne { 66 | tsfdo.tsfd.mutation.Where(ps...) 67 | return tsfdo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (tsfdo *TwapSliceFillDeleteOne) Exec(ctx context.Context) error { 72 | n, err := tsfdo.tsfd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{twapslicefill.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (tsfdo *TwapSliceFillDeleteOne) ExecX(ctx context.Context) { 85 | if err := tsfdo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/tx.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | "sync" 8 | 9 | "entgo.io/ent/dialect" 10 | ) 11 | 12 | // Tx is a transactional client that is created by calling Client.Tx(). 13 | type Tx struct { 14 | config 15 | // Delegate is the client for interacting with the Delegate builders. 16 | Delegate *DelegateClient 17 | // DelegatorReward is the client for interacting with the DelegatorReward builders. 18 | DelegatorReward *DelegatorRewardClient 19 | // Fill is the client for interacting with the Fill builders. 20 | Fill *FillClient 21 | // Funding is the client for interacting with the Funding builders. 22 | Funding *FundingClient 23 | // HyperunitOperation is the client for interacting with the HyperunitOperation builders. 24 | HyperunitOperation *HyperunitOperationClient 25 | // InternalTransfer is the client for interacting with the InternalTransfer builders. 26 | InternalTransfer *InternalTransferClient 27 | // RewardsClaim is the client for interacting with the RewardsClaim builders. 28 | RewardsClaim *RewardsClaimClient 29 | // SpotGenesis is the client for interacting with the SpotGenesis builders. 30 | SpotGenesis *SpotGenesisClient 31 | // SpotTransfer is the client for interacting with the SpotTransfer builders. 32 | SpotTransfer *SpotTransferClient 33 | // TwapSliceFill is the client for interacting with the TwapSliceFill builders. 34 | TwapSliceFill *TwapSliceFillClient 35 | // VaultDelta is the client for interacting with the VaultDelta builders. 36 | VaultDelta *VaultDeltaClient 37 | // VaultLeaderCommission is the client for interacting with the VaultLeaderCommission builders. 38 | VaultLeaderCommission *VaultLeaderCommissionClient 39 | // VaultWithdrawal is the client for interacting with the VaultWithdrawal builders. 40 | VaultWithdrawal *VaultWithdrawalClient 41 | // Withdraw is the client for interacting with the Withdraw builders. 42 | Withdraw *WithdrawClient 43 | 44 | // lazily loaded. 45 | client *Client 46 | clientOnce sync.Once 47 | // ctx lives for the life of the transaction. It is 48 | // the same context used by the underlying connection. 49 | ctx context.Context 50 | } 51 | 52 | type ( 53 | // Committer is the interface that wraps the Commit method. 54 | Committer interface { 55 | Commit(context.Context, *Tx) error 56 | } 57 | 58 | // The CommitFunc type is an adapter to allow the use of ordinary 59 | // function as a Committer. If f is a function with the appropriate 60 | // signature, CommitFunc(f) is a Committer that calls f. 61 | CommitFunc func(context.Context, *Tx) error 62 | 63 | // CommitHook defines the "commit middleware". A function that gets a Committer 64 | // and returns a Committer. For example: 65 | // 66 | // hook := func(next ent.Committer) ent.Committer { 67 | // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { 68 | // // Do some stuff before. 69 | // if err := next.Commit(ctx, tx); err != nil { 70 | // return err 71 | // } 72 | // // Do some stuff after. 73 | // return nil 74 | // }) 75 | // } 76 | // 77 | CommitHook func(Committer) Committer 78 | ) 79 | 80 | // Commit calls f(ctx, m). 81 | func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { 82 | return f(ctx, tx) 83 | } 84 | 85 | // Commit commits the transaction. 86 | func (tx *Tx) Commit() error { 87 | txDriver := tx.config.driver.(*txDriver) 88 | var fn Committer = CommitFunc(func(context.Context, *Tx) error { 89 | return txDriver.tx.Commit() 90 | }) 91 | txDriver.mu.Lock() 92 | hooks := append([]CommitHook(nil), txDriver.onCommit...) 93 | txDriver.mu.Unlock() 94 | for i := len(hooks) - 1; i >= 0; i-- { 95 | fn = hooks[i](fn) 96 | } 97 | return fn.Commit(tx.ctx, tx) 98 | } 99 | 100 | // OnCommit adds a hook to call on commit. 101 | func (tx *Tx) OnCommit(f CommitHook) { 102 | txDriver := tx.config.driver.(*txDriver) 103 | txDriver.mu.Lock() 104 | txDriver.onCommit = append(txDriver.onCommit, f) 105 | txDriver.mu.Unlock() 106 | } 107 | 108 | type ( 109 | // Rollbacker is the interface that wraps the Rollback method. 110 | Rollbacker interface { 111 | Rollback(context.Context, *Tx) error 112 | } 113 | 114 | // The RollbackFunc type is an adapter to allow the use of ordinary 115 | // function as a Rollbacker. If f is a function with the appropriate 116 | // signature, RollbackFunc(f) is a Rollbacker that calls f. 117 | RollbackFunc func(context.Context, *Tx) error 118 | 119 | // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker 120 | // and returns a Rollbacker. For example: 121 | // 122 | // hook := func(next ent.Rollbacker) ent.Rollbacker { 123 | // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { 124 | // // Do some stuff before. 125 | // if err := next.Rollback(ctx, tx); err != nil { 126 | // return err 127 | // } 128 | // // Do some stuff after. 129 | // return nil 130 | // }) 131 | // } 132 | // 133 | RollbackHook func(Rollbacker) Rollbacker 134 | ) 135 | 136 | // Rollback calls f(ctx, m). 137 | func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { 138 | return f(ctx, tx) 139 | } 140 | 141 | // Rollback rollbacks the transaction. 142 | func (tx *Tx) Rollback() error { 143 | txDriver := tx.config.driver.(*txDriver) 144 | var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { 145 | return txDriver.tx.Rollback() 146 | }) 147 | txDriver.mu.Lock() 148 | hooks := append([]RollbackHook(nil), txDriver.onRollback...) 149 | txDriver.mu.Unlock() 150 | for i := len(hooks) - 1; i >= 0; i-- { 151 | fn = hooks[i](fn) 152 | } 153 | return fn.Rollback(tx.ctx, tx) 154 | } 155 | 156 | // OnRollback adds a hook to call on rollback. 157 | func (tx *Tx) OnRollback(f RollbackHook) { 158 | txDriver := tx.config.driver.(*txDriver) 159 | txDriver.mu.Lock() 160 | txDriver.onRollback = append(txDriver.onRollback, f) 161 | txDriver.mu.Unlock() 162 | } 163 | 164 | // Client returns a Client that binds to current transaction. 165 | func (tx *Tx) Client() *Client { 166 | tx.clientOnce.Do(func() { 167 | tx.client = &Client{config: tx.config} 168 | tx.client.init() 169 | }) 170 | return tx.client 171 | } 172 | 173 | func (tx *Tx) init() { 174 | tx.Delegate = NewDelegateClient(tx.config) 175 | tx.DelegatorReward = NewDelegatorRewardClient(tx.config) 176 | tx.Fill = NewFillClient(tx.config) 177 | tx.Funding = NewFundingClient(tx.config) 178 | tx.HyperunitOperation = NewHyperunitOperationClient(tx.config) 179 | tx.InternalTransfer = NewInternalTransferClient(tx.config) 180 | tx.RewardsClaim = NewRewardsClaimClient(tx.config) 181 | tx.SpotGenesis = NewSpotGenesisClient(tx.config) 182 | tx.SpotTransfer = NewSpotTransferClient(tx.config) 183 | tx.TwapSliceFill = NewTwapSliceFillClient(tx.config) 184 | tx.VaultDelta = NewVaultDeltaClient(tx.config) 185 | tx.VaultLeaderCommission = NewVaultLeaderCommissionClient(tx.config) 186 | tx.VaultWithdrawal = NewVaultWithdrawalClient(tx.config) 187 | tx.Withdraw = NewWithdrawClient(tx.config) 188 | } 189 | 190 | // txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. 191 | // The idea is to support transactions without adding any extra code to the builders. 192 | // When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. 193 | // Commit and Rollback are nop for the internal builders and the user must call one 194 | // of them in order to commit or rollback the transaction. 195 | // 196 | // If a closed transaction is embedded in one of the generated entities, and the entity 197 | // applies a query, for example: Delegate.QueryXXX(), the query will be executed 198 | // through the driver which created this transaction. 199 | // 200 | // Note that txDriver is not goroutine safe. 201 | type txDriver struct { 202 | // the driver we started the transaction from. 203 | drv dialect.Driver 204 | // tx is the underlying transaction. 205 | tx dialect.Tx 206 | // completion hooks. 207 | mu sync.Mutex 208 | onCommit []CommitHook 209 | onRollback []RollbackHook 210 | } 211 | 212 | // newTx creates a new transactional driver. 213 | func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { 214 | tx, err := drv.Tx(ctx) 215 | if err != nil { 216 | return nil, err 217 | } 218 | return &txDriver{tx: tx, drv: drv}, nil 219 | } 220 | 221 | // Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls 222 | // from the internal builders. Should be called only by the internal builders. 223 | func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } 224 | 225 | // Dialect returns the dialect of the driver we started the transaction from. 226 | func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } 227 | 228 | // Close is a nop close. 229 | func (*txDriver) Close() error { return nil } 230 | 231 | // Commit is a nop commit for the internal builders. 232 | // User must call `Tx.Commit` in order to commit the transaction. 233 | func (*txDriver) Commit() error { return nil } 234 | 235 | // Rollback is a nop rollback for the internal builders. 236 | // User must call `Tx.Rollback` in order to rollback the transaction. 237 | func (*txDriver) Rollback() error { return nil } 238 | 239 | // Exec calls tx.Exec. 240 | func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error { 241 | return tx.tx.Exec(ctx, query, args, v) 242 | } 243 | 244 | // Query calls tx.Query. 245 | func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error { 246 | return tx.tx.Query(ctx, query, args, v) 247 | } 248 | 249 | var _ dialect.Driver = (*txDriver)(nil) 250 | -------------------------------------------------------------------------------- /ent/vaultdelta.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/vaultdelta" 12 | ) 13 | 14 | // VaultDelta is the model entity for the VaultDelta schema. 15 | type VaultDelta struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // Type holds the value of the "type" field. 20 | Type string `json:"type,omitempty"` 21 | // Vault holds the value of the "vault" field. 22 | Vault string `json:"vault,omitempty"` 23 | // Usdc holds the value of the "usdc" field. 24 | Usdc string `json:"usdc,omitempty"` 25 | // Time holds the value of the "time" field. 26 | Time int64 `json:"time,omitempty"` 27 | // Address holds the value of the "address" field. 28 | Address string `json:"address,omitempty"` 29 | selectValues sql.SelectValues 30 | } 31 | 32 | // scanValues returns the types for scanning values from sql.Rows. 33 | func (*VaultDelta) scanValues(columns []string) ([]any, error) { 34 | values := make([]any, len(columns)) 35 | for i := range columns { 36 | switch columns[i] { 37 | case vaultdelta.FieldID, vaultdelta.FieldTime: 38 | values[i] = new(sql.NullInt64) 39 | case vaultdelta.FieldType, vaultdelta.FieldVault, vaultdelta.FieldUsdc, vaultdelta.FieldAddress: 40 | values[i] = new(sql.NullString) 41 | default: 42 | values[i] = new(sql.UnknownType) 43 | } 44 | } 45 | return values, nil 46 | } 47 | 48 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 49 | // to the VaultDelta fields. 50 | func (vd *VaultDelta) assignValues(columns []string, values []any) error { 51 | if m, n := len(values), len(columns); m < n { 52 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 53 | } 54 | for i := range columns { 55 | switch columns[i] { 56 | case vaultdelta.FieldID: 57 | value, ok := values[i].(*sql.NullInt64) 58 | if !ok { 59 | return fmt.Errorf("unexpected type %T for field id", value) 60 | } 61 | vd.ID = int(value.Int64) 62 | case vaultdelta.FieldType: 63 | if value, ok := values[i].(*sql.NullString); !ok { 64 | return fmt.Errorf("unexpected type %T for field type", values[i]) 65 | } else if value.Valid { 66 | vd.Type = value.String 67 | } 68 | case vaultdelta.FieldVault: 69 | if value, ok := values[i].(*sql.NullString); !ok { 70 | return fmt.Errorf("unexpected type %T for field vault", values[i]) 71 | } else if value.Valid { 72 | vd.Vault = value.String 73 | } 74 | case vaultdelta.FieldUsdc: 75 | if value, ok := values[i].(*sql.NullString); !ok { 76 | return fmt.Errorf("unexpected type %T for field usdc", values[i]) 77 | } else if value.Valid { 78 | vd.Usdc = value.String 79 | } 80 | case vaultdelta.FieldTime: 81 | if value, ok := values[i].(*sql.NullInt64); !ok { 82 | return fmt.Errorf("unexpected type %T for field time", values[i]) 83 | } else if value.Valid { 84 | vd.Time = value.Int64 85 | } 86 | case vaultdelta.FieldAddress: 87 | if value, ok := values[i].(*sql.NullString); !ok { 88 | return fmt.Errorf("unexpected type %T for field address", values[i]) 89 | } else if value.Valid { 90 | vd.Address = value.String 91 | } 92 | default: 93 | vd.selectValues.Set(columns[i], values[i]) 94 | } 95 | } 96 | return nil 97 | } 98 | 99 | // Value returns the ent.Value that was dynamically selected and assigned to the VaultDelta. 100 | // This includes values selected through modifiers, order, etc. 101 | func (vd *VaultDelta) Value(name string) (ent.Value, error) { 102 | return vd.selectValues.Get(name) 103 | } 104 | 105 | // Update returns a builder for updating this VaultDelta. 106 | // Note that you need to call VaultDelta.Unwrap() before calling this method if this VaultDelta 107 | // was returned from a transaction, and the transaction was committed or rolled back. 108 | func (vd *VaultDelta) Update() *VaultDeltaUpdateOne { 109 | return NewVaultDeltaClient(vd.config).UpdateOne(vd) 110 | } 111 | 112 | // Unwrap unwraps the VaultDelta entity that was returned from a transaction after it was closed, 113 | // so that all future queries will be executed through the driver which created the transaction. 114 | func (vd *VaultDelta) Unwrap() *VaultDelta { 115 | _tx, ok := vd.config.driver.(*txDriver) 116 | if !ok { 117 | panic("ent: VaultDelta is not a transactional entity") 118 | } 119 | vd.config.driver = _tx.drv 120 | return vd 121 | } 122 | 123 | // String implements the fmt.Stringer. 124 | func (vd *VaultDelta) String() string { 125 | var builder strings.Builder 126 | builder.WriteString("VaultDelta(") 127 | builder.WriteString(fmt.Sprintf("id=%v, ", vd.ID)) 128 | builder.WriteString("type=") 129 | builder.WriteString(vd.Type) 130 | builder.WriteString(", ") 131 | builder.WriteString("vault=") 132 | builder.WriteString(vd.Vault) 133 | builder.WriteString(", ") 134 | builder.WriteString("usdc=") 135 | builder.WriteString(vd.Usdc) 136 | builder.WriteString(", ") 137 | builder.WriteString("time=") 138 | builder.WriteString(fmt.Sprintf("%v", vd.Time)) 139 | builder.WriteString(", ") 140 | builder.WriteString("address=") 141 | builder.WriteString(vd.Address) 142 | builder.WriteByte(')') 143 | return builder.String() 144 | } 145 | 146 | // VaultDeltaSlice is a parsable slice of VaultDelta. 147 | type VaultDeltaSlice []*VaultDelta 148 | -------------------------------------------------------------------------------- /ent/vaultdelta/vaultdelta.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package vaultdelta 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the vaultdelta type in the database. 11 | Label = "vault_delta" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldType holds the string denoting the type field in the database. 15 | FieldType = "type" 16 | // FieldVault holds the string denoting the vault field in the database. 17 | FieldVault = "vault" 18 | // FieldUsdc holds the string denoting the usdc field in the database. 19 | FieldUsdc = "usdc" 20 | // FieldTime holds the string denoting the time field in the database. 21 | FieldTime = "time" 22 | // FieldAddress holds the string denoting the address field in the database. 23 | FieldAddress = "address" 24 | // Table holds the table name of the vaultdelta in the database. 25 | Table = "vault_delta" 26 | ) 27 | 28 | // Columns holds all SQL columns for vaultdelta fields. 29 | var Columns = []string{ 30 | FieldID, 31 | FieldType, 32 | FieldVault, 33 | FieldUsdc, 34 | FieldTime, 35 | FieldAddress, 36 | } 37 | 38 | // ValidColumn reports if the column name is valid (part of the table columns). 39 | func ValidColumn(column string) bool { 40 | for i := range Columns { 41 | if column == Columns[i] { 42 | return true 43 | } 44 | } 45 | return false 46 | } 47 | 48 | // OrderOption defines the ordering options for the VaultDelta queries. 49 | type OrderOption func(*sql.Selector) 50 | 51 | // ByID orders the results by the id field. 52 | func ByID(opts ...sql.OrderTermOption) OrderOption { 53 | return sql.OrderByField(FieldID, opts...).ToFunc() 54 | } 55 | 56 | // ByType orders the results by the type field. 57 | func ByType(opts ...sql.OrderTermOption) OrderOption { 58 | return sql.OrderByField(FieldType, opts...).ToFunc() 59 | } 60 | 61 | // ByVault orders the results by the vault field. 62 | func ByVault(opts ...sql.OrderTermOption) OrderOption { 63 | return sql.OrderByField(FieldVault, opts...).ToFunc() 64 | } 65 | 66 | // ByUsdc orders the results by the usdc field. 67 | func ByUsdc(opts ...sql.OrderTermOption) OrderOption { 68 | return sql.OrderByField(FieldUsdc, opts...).ToFunc() 69 | } 70 | 71 | // ByTime orders the results by the time field. 72 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 73 | return sql.OrderByField(FieldTime, opts...).ToFunc() 74 | } 75 | 76 | // ByAddress orders the results by the address field. 77 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 78 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 79 | } 80 | -------------------------------------------------------------------------------- /ent/vaultdelta_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/predicate" 12 | "github.com/yoshiso/hypersync/ent/vaultdelta" 13 | ) 14 | 15 | // VaultDeltaDelete is the builder for deleting a VaultDelta entity. 16 | type VaultDeltaDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *VaultDeltaMutation 20 | } 21 | 22 | // Where appends a list predicates to the VaultDeltaDelete builder. 23 | func (vdd *VaultDeltaDelete) Where(ps ...predicate.VaultDelta) *VaultDeltaDelete { 24 | vdd.mutation.Where(ps...) 25 | return vdd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (vdd *VaultDeltaDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, vdd.sqlExec, vdd.mutation, vdd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (vdd *VaultDeltaDelete) ExecX(ctx context.Context) int { 35 | n, err := vdd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (vdd *VaultDeltaDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(vaultdelta.Table, sqlgraph.NewFieldSpec(vaultdelta.FieldID, field.TypeInt)) 44 | if ps := vdd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, vdd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | vdd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // VaultDeltaDeleteOne is the builder for deleting a single VaultDelta entity. 60 | type VaultDeltaDeleteOne struct { 61 | vdd *VaultDeltaDelete 62 | } 63 | 64 | // Where appends a list predicates to the VaultDeltaDelete builder. 65 | func (vddo *VaultDeltaDeleteOne) Where(ps ...predicate.VaultDelta) *VaultDeltaDeleteOne { 66 | vddo.vdd.mutation.Where(ps...) 67 | return vddo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (vddo *VaultDeltaDeleteOne) Exec(ctx context.Context) error { 72 | n, err := vddo.vdd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{vaultdelta.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (vddo *VaultDeltaDeleteOne) ExecX(ctx context.Context) { 85 | if err := vddo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/vaultleadercommission.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/vaultleadercommission" 12 | ) 13 | 14 | // VaultLeaderCommission is the model entity for the VaultLeaderCommission schema. 15 | type VaultLeaderCommission struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // User holds the value of the "user" field. 20 | User string `json:"user,omitempty"` 21 | // Usdc holds the value of the "usdc" field. 22 | Usdc string `json:"usdc,omitempty"` 23 | // Time holds the value of the "time" field. 24 | Time int64 `json:"time,omitempty"` 25 | // Address holds the value of the "address" field. 26 | Address string `json:"address,omitempty"` 27 | selectValues sql.SelectValues 28 | } 29 | 30 | // scanValues returns the types for scanning values from sql.Rows. 31 | func (*VaultLeaderCommission) scanValues(columns []string) ([]any, error) { 32 | values := make([]any, len(columns)) 33 | for i := range columns { 34 | switch columns[i] { 35 | case vaultleadercommission.FieldID, vaultleadercommission.FieldTime: 36 | values[i] = new(sql.NullInt64) 37 | case vaultleadercommission.FieldUser, vaultleadercommission.FieldUsdc, vaultleadercommission.FieldAddress: 38 | values[i] = new(sql.NullString) 39 | default: 40 | values[i] = new(sql.UnknownType) 41 | } 42 | } 43 | return values, nil 44 | } 45 | 46 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 47 | // to the VaultLeaderCommission fields. 48 | func (vlc *VaultLeaderCommission) assignValues(columns []string, values []any) error { 49 | if m, n := len(values), len(columns); m < n { 50 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 51 | } 52 | for i := range columns { 53 | switch columns[i] { 54 | case vaultleadercommission.FieldID: 55 | value, ok := values[i].(*sql.NullInt64) 56 | if !ok { 57 | return fmt.Errorf("unexpected type %T for field id", value) 58 | } 59 | vlc.ID = int(value.Int64) 60 | case vaultleadercommission.FieldUser: 61 | if value, ok := values[i].(*sql.NullString); !ok { 62 | return fmt.Errorf("unexpected type %T for field user", values[i]) 63 | } else if value.Valid { 64 | vlc.User = value.String 65 | } 66 | case vaultleadercommission.FieldUsdc: 67 | if value, ok := values[i].(*sql.NullString); !ok { 68 | return fmt.Errorf("unexpected type %T for field usdc", values[i]) 69 | } else if value.Valid { 70 | vlc.Usdc = value.String 71 | } 72 | case vaultleadercommission.FieldTime: 73 | if value, ok := values[i].(*sql.NullInt64); !ok { 74 | return fmt.Errorf("unexpected type %T for field time", values[i]) 75 | } else if value.Valid { 76 | vlc.Time = value.Int64 77 | } 78 | case vaultleadercommission.FieldAddress: 79 | if value, ok := values[i].(*sql.NullString); !ok { 80 | return fmt.Errorf("unexpected type %T for field address", values[i]) 81 | } else if value.Valid { 82 | vlc.Address = value.String 83 | } 84 | default: 85 | vlc.selectValues.Set(columns[i], values[i]) 86 | } 87 | } 88 | return nil 89 | } 90 | 91 | // Value returns the ent.Value that was dynamically selected and assigned to the VaultLeaderCommission. 92 | // This includes values selected through modifiers, order, etc. 93 | func (vlc *VaultLeaderCommission) Value(name string) (ent.Value, error) { 94 | return vlc.selectValues.Get(name) 95 | } 96 | 97 | // Update returns a builder for updating this VaultLeaderCommission. 98 | // Note that you need to call VaultLeaderCommission.Unwrap() before calling this method if this VaultLeaderCommission 99 | // was returned from a transaction, and the transaction was committed or rolled back. 100 | func (vlc *VaultLeaderCommission) Update() *VaultLeaderCommissionUpdateOne { 101 | return NewVaultLeaderCommissionClient(vlc.config).UpdateOne(vlc) 102 | } 103 | 104 | // Unwrap unwraps the VaultLeaderCommission entity that was returned from a transaction after it was closed, 105 | // so that all future queries will be executed through the driver which created the transaction. 106 | func (vlc *VaultLeaderCommission) Unwrap() *VaultLeaderCommission { 107 | _tx, ok := vlc.config.driver.(*txDriver) 108 | if !ok { 109 | panic("ent: VaultLeaderCommission is not a transactional entity") 110 | } 111 | vlc.config.driver = _tx.drv 112 | return vlc 113 | } 114 | 115 | // String implements the fmt.Stringer. 116 | func (vlc *VaultLeaderCommission) String() string { 117 | var builder strings.Builder 118 | builder.WriteString("VaultLeaderCommission(") 119 | builder.WriteString(fmt.Sprintf("id=%v, ", vlc.ID)) 120 | builder.WriteString("user=") 121 | builder.WriteString(vlc.User) 122 | builder.WriteString(", ") 123 | builder.WriteString("usdc=") 124 | builder.WriteString(vlc.Usdc) 125 | builder.WriteString(", ") 126 | builder.WriteString("time=") 127 | builder.WriteString(fmt.Sprintf("%v", vlc.Time)) 128 | builder.WriteString(", ") 129 | builder.WriteString("address=") 130 | builder.WriteString(vlc.Address) 131 | builder.WriteByte(')') 132 | return builder.String() 133 | } 134 | 135 | // VaultLeaderCommissions is a parsable slice of VaultLeaderCommission. 136 | type VaultLeaderCommissions []*VaultLeaderCommission 137 | -------------------------------------------------------------------------------- /ent/vaultleadercommission/vaultleadercommission.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package vaultleadercommission 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the vaultleadercommission type in the database. 11 | Label = "vault_leader_commission" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldUser holds the string denoting the user field in the database. 15 | FieldUser = "user" 16 | // FieldUsdc holds the string denoting the usdc field in the database. 17 | FieldUsdc = "usdc" 18 | // FieldTime holds the string denoting the time field in the database. 19 | FieldTime = "time" 20 | // FieldAddress holds the string denoting the address field in the database. 21 | FieldAddress = "address" 22 | // Table holds the table name of the vaultleadercommission in the database. 23 | Table = "vault_leader_commissions" 24 | ) 25 | 26 | // Columns holds all SQL columns for vaultleadercommission fields. 27 | var Columns = []string{ 28 | FieldID, 29 | FieldUser, 30 | FieldUsdc, 31 | FieldTime, 32 | FieldAddress, 33 | } 34 | 35 | // ValidColumn reports if the column name is valid (part of the table columns). 36 | func ValidColumn(column string) bool { 37 | for i := range Columns { 38 | if column == Columns[i] { 39 | return true 40 | } 41 | } 42 | return false 43 | } 44 | 45 | // OrderOption defines the ordering options for the VaultLeaderCommission queries. 46 | type OrderOption func(*sql.Selector) 47 | 48 | // ByID orders the results by the id field. 49 | func ByID(opts ...sql.OrderTermOption) OrderOption { 50 | return sql.OrderByField(FieldID, opts...).ToFunc() 51 | } 52 | 53 | // ByUser orders the results by the user field. 54 | func ByUser(opts ...sql.OrderTermOption) OrderOption { 55 | return sql.OrderByField(FieldUser, opts...).ToFunc() 56 | } 57 | 58 | // ByUsdc orders the results by the usdc field. 59 | func ByUsdc(opts ...sql.OrderTermOption) OrderOption { 60 | return sql.OrderByField(FieldUsdc, opts...).ToFunc() 61 | } 62 | 63 | // ByTime orders the results by the time field. 64 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 65 | return sql.OrderByField(FieldTime, opts...).ToFunc() 66 | } 67 | 68 | // ByAddress orders the results by the address field. 69 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 70 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 71 | } 72 | -------------------------------------------------------------------------------- /ent/vaultleadercommission_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/predicate" 12 | "github.com/yoshiso/hypersync/ent/vaultleadercommission" 13 | ) 14 | 15 | // VaultLeaderCommissionDelete is the builder for deleting a VaultLeaderCommission entity. 16 | type VaultLeaderCommissionDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *VaultLeaderCommissionMutation 20 | } 21 | 22 | // Where appends a list predicates to the VaultLeaderCommissionDelete builder. 23 | func (vlcd *VaultLeaderCommissionDelete) Where(ps ...predicate.VaultLeaderCommission) *VaultLeaderCommissionDelete { 24 | vlcd.mutation.Where(ps...) 25 | return vlcd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (vlcd *VaultLeaderCommissionDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, vlcd.sqlExec, vlcd.mutation, vlcd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (vlcd *VaultLeaderCommissionDelete) ExecX(ctx context.Context) int { 35 | n, err := vlcd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (vlcd *VaultLeaderCommissionDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(vaultleadercommission.Table, sqlgraph.NewFieldSpec(vaultleadercommission.FieldID, field.TypeInt)) 44 | if ps := vlcd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, vlcd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | vlcd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // VaultLeaderCommissionDeleteOne is the builder for deleting a single VaultLeaderCommission entity. 60 | type VaultLeaderCommissionDeleteOne struct { 61 | vlcd *VaultLeaderCommissionDelete 62 | } 63 | 64 | // Where appends a list predicates to the VaultLeaderCommissionDelete builder. 65 | func (vlcdo *VaultLeaderCommissionDeleteOne) Where(ps ...predicate.VaultLeaderCommission) *VaultLeaderCommissionDeleteOne { 66 | vlcdo.vlcd.mutation.Where(ps...) 67 | return vlcdo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (vlcdo *VaultLeaderCommissionDeleteOne) Exec(ctx context.Context) error { 72 | n, err := vlcdo.vlcd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{vaultleadercommission.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (vlcdo *VaultLeaderCommissionDeleteOne) ExecX(ctx context.Context) { 85 | if err := vlcdo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/vaultwithdrawal.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/vaultwithdrawal" 12 | ) 13 | 14 | // VaultWithdrawal is the model entity for the VaultWithdrawal schema. 15 | type VaultWithdrawal struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // Vault holds the value of the "vault" field. 20 | Vault string `json:"vault,omitempty"` 21 | // User holds the value of the "user" field. 22 | User string `json:"user,omitempty"` 23 | // RequestedUsd holds the value of the "requested_usd" field. 24 | RequestedUsd string `json:"requested_usd,omitempty"` 25 | // Commission holds the value of the "commission" field. 26 | Commission string `json:"commission,omitempty"` 27 | // ClosingCost holds the value of the "closing_cost" field. 28 | ClosingCost string `json:"closing_cost,omitempty"` 29 | // Basis holds the value of the "basis" field. 30 | Basis string `json:"basis,omitempty"` 31 | // NetWithdrawnUsd holds the value of the "net_withdrawn_usd" field. 32 | NetWithdrawnUsd string `json:"net_withdrawn_usd,omitempty"` 33 | // Time holds the value of the "time" field. 34 | Time int64 `json:"time,omitempty"` 35 | // Address holds the value of the "address" field. 36 | Address string `json:"address,omitempty"` 37 | selectValues sql.SelectValues 38 | } 39 | 40 | // scanValues returns the types for scanning values from sql.Rows. 41 | func (*VaultWithdrawal) scanValues(columns []string) ([]any, error) { 42 | values := make([]any, len(columns)) 43 | for i := range columns { 44 | switch columns[i] { 45 | case vaultwithdrawal.FieldID, vaultwithdrawal.FieldTime: 46 | values[i] = new(sql.NullInt64) 47 | case vaultwithdrawal.FieldVault, vaultwithdrawal.FieldUser, vaultwithdrawal.FieldRequestedUsd, vaultwithdrawal.FieldCommission, vaultwithdrawal.FieldClosingCost, vaultwithdrawal.FieldBasis, vaultwithdrawal.FieldNetWithdrawnUsd, vaultwithdrawal.FieldAddress: 48 | values[i] = new(sql.NullString) 49 | default: 50 | values[i] = new(sql.UnknownType) 51 | } 52 | } 53 | return values, nil 54 | } 55 | 56 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 57 | // to the VaultWithdrawal fields. 58 | func (vw *VaultWithdrawal) assignValues(columns []string, values []any) error { 59 | if m, n := len(values), len(columns); m < n { 60 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 61 | } 62 | for i := range columns { 63 | switch columns[i] { 64 | case vaultwithdrawal.FieldID: 65 | value, ok := values[i].(*sql.NullInt64) 66 | if !ok { 67 | return fmt.Errorf("unexpected type %T for field id", value) 68 | } 69 | vw.ID = int(value.Int64) 70 | case vaultwithdrawal.FieldVault: 71 | if value, ok := values[i].(*sql.NullString); !ok { 72 | return fmt.Errorf("unexpected type %T for field vault", values[i]) 73 | } else if value.Valid { 74 | vw.Vault = value.String 75 | } 76 | case vaultwithdrawal.FieldUser: 77 | if value, ok := values[i].(*sql.NullString); !ok { 78 | return fmt.Errorf("unexpected type %T for field user", values[i]) 79 | } else if value.Valid { 80 | vw.User = value.String 81 | } 82 | case vaultwithdrawal.FieldRequestedUsd: 83 | if value, ok := values[i].(*sql.NullString); !ok { 84 | return fmt.Errorf("unexpected type %T for field requested_usd", values[i]) 85 | } else if value.Valid { 86 | vw.RequestedUsd = value.String 87 | } 88 | case vaultwithdrawal.FieldCommission: 89 | if value, ok := values[i].(*sql.NullString); !ok { 90 | return fmt.Errorf("unexpected type %T for field commission", values[i]) 91 | } else if value.Valid { 92 | vw.Commission = value.String 93 | } 94 | case vaultwithdrawal.FieldClosingCost: 95 | if value, ok := values[i].(*sql.NullString); !ok { 96 | return fmt.Errorf("unexpected type %T for field closing_cost", values[i]) 97 | } else if value.Valid { 98 | vw.ClosingCost = value.String 99 | } 100 | case vaultwithdrawal.FieldBasis: 101 | if value, ok := values[i].(*sql.NullString); !ok { 102 | return fmt.Errorf("unexpected type %T for field basis", values[i]) 103 | } else if value.Valid { 104 | vw.Basis = value.String 105 | } 106 | case vaultwithdrawal.FieldNetWithdrawnUsd: 107 | if value, ok := values[i].(*sql.NullString); !ok { 108 | return fmt.Errorf("unexpected type %T for field net_withdrawn_usd", values[i]) 109 | } else if value.Valid { 110 | vw.NetWithdrawnUsd = value.String 111 | } 112 | case vaultwithdrawal.FieldTime: 113 | if value, ok := values[i].(*sql.NullInt64); !ok { 114 | return fmt.Errorf("unexpected type %T for field time", values[i]) 115 | } else if value.Valid { 116 | vw.Time = value.Int64 117 | } 118 | case vaultwithdrawal.FieldAddress: 119 | if value, ok := values[i].(*sql.NullString); !ok { 120 | return fmt.Errorf("unexpected type %T for field address", values[i]) 121 | } else if value.Valid { 122 | vw.Address = value.String 123 | } 124 | default: 125 | vw.selectValues.Set(columns[i], values[i]) 126 | } 127 | } 128 | return nil 129 | } 130 | 131 | // Value returns the ent.Value that was dynamically selected and assigned to the VaultWithdrawal. 132 | // This includes values selected through modifiers, order, etc. 133 | func (vw *VaultWithdrawal) Value(name string) (ent.Value, error) { 134 | return vw.selectValues.Get(name) 135 | } 136 | 137 | // Update returns a builder for updating this VaultWithdrawal. 138 | // Note that you need to call VaultWithdrawal.Unwrap() before calling this method if this VaultWithdrawal 139 | // was returned from a transaction, and the transaction was committed or rolled back. 140 | func (vw *VaultWithdrawal) Update() *VaultWithdrawalUpdateOne { 141 | return NewVaultWithdrawalClient(vw.config).UpdateOne(vw) 142 | } 143 | 144 | // Unwrap unwraps the VaultWithdrawal entity that was returned from a transaction after it was closed, 145 | // so that all future queries will be executed through the driver which created the transaction. 146 | func (vw *VaultWithdrawal) Unwrap() *VaultWithdrawal { 147 | _tx, ok := vw.config.driver.(*txDriver) 148 | if !ok { 149 | panic("ent: VaultWithdrawal is not a transactional entity") 150 | } 151 | vw.config.driver = _tx.drv 152 | return vw 153 | } 154 | 155 | // String implements the fmt.Stringer. 156 | func (vw *VaultWithdrawal) String() string { 157 | var builder strings.Builder 158 | builder.WriteString("VaultWithdrawal(") 159 | builder.WriteString(fmt.Sprintf("id=%v, ", vw.ID)) 160 | builder.WriteString("vault=") 161 | builder.WriteString(vw.Vault) 162 | builder.WriteString(", ") 163 | builder.WriteString("user=") 164 | builder.WriteString(vw.User) 165 | builder.WriteString(", ") 166 | builder.WriteString("requested_usd=") 167 | builder.WriteString(vw.RequestedUsd) 168 | builder.WriteString(", ") 169 | builder.WriteString("commission=") 170 | builder.WriteString(vw.Commission) 171 | builder.WriteString(", ") 172 | builder.WriteString("closing_cost=") 173 | builder.WriteString(vw.ClosingCost) 174 | builder.WriteString(", ") 175 | builder.WriteString("basis=") 176 | builder.WriteString(vw.Basis) 177 | builder.WriteString(", ") 178 | builder.WriteString("net_withdrawn_usd=") 179 | builder.WriteString(vw.NetWithdrawnUsd) 180 | builder.WriteString(", ") 181 | builder.WriteString("time=") 182 | builder.WriteString(fmt.Sprintf("%v", vw.Time)) 183 | builder.WriteString(", ") 184 | builder.WriteString("address=") 185 | builder.WriteString(vw.Address) 186 | builder.WriteByte(')') 187 | return builder.String() 188 | } 189 | 190 | // VaultWithdrawals is a parsable slice of VaultWithdrawal. 191 | type VaultWithdrawals []*VaultWithdrawal 192 | -------------------------------------------------------------------------------- /ent/vaultwithdrawal/vaultwithdrawal.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package vaultwithdrawal 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the vaultwithdrawal type in the database. 11 | Label = "vault_withdrawal" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldVault holds the string denoting the vault field in the database. 15 | FieldVault = "vault" 16 | // FieldUser holds the string denoting the user field in the database. 17 | FieldUser = "user" 18 | // FieldRequestedUsd holds the string denoting the requested_usd field in the database. 19 | FieldRequestedUsd = "requested_usd" 20 | // FieldCommission holds the string denoting the commission field in the database. 21 | FieldCommission = "commission" 22 | // FieldClosingCost holds the string denoting the closing_cost field in the database. 23 | FieldClosingCost = "closing_cost" 24 | // FieldBasis holds the string denoting the basis field in the database. 25 | FieldBasis = "basis" 26 | // FieldNetWithdrawnUsd holds the string denoting the net_withdrawn_usd field in the database. 27 | FieldNetWithdrawnUsd = "net_withdrawn_usd" 28 | // FieldTime holds the string denoting the time field in the database. 29 | FieldTime = "time" 30 | // FieldAddress holds the string denoting the address field in the database. 31 | FieldAddress = "address" 32 | // Table holds the table name of the vaultwithdrawal in the database. 33 | Table = "vault_withdrawals" 34 | ) 35 | 36 | // Columns holds all SQL columns for vaultwithdrawal fields. 37 | var Columns = []string{ 38 | FieldID, 39 | FieldVault, 40 | FieldUser, 41 | FieldRequestedUsd, 42 | FieldCommission, 43 | FieldClosingCost, 44 | FieldBasis, 45 | FieldNetWithdrawnUsd, 46 | FieldTime, 47 | FieldAddress, 48 | } 49 | 50 | // ValidColumn reports if the column name is valid (part of the table columns). 51 | func ValidColumn(column string) bool { 52 | for i := range Columns { 53 | if column == Columns[i] { 54 | return true 55 | } 56 | } 57 | return false 58 | } 59 | 60 | // OrderOption defines the ordering options for the VaultWithdrawal queries. 61 | type OrderOption func(*sql.Selector) 62 | 63 | // ByID orders the results by the id field. 64 | func ByID(opts ...sql.OrderTermOption) OrderOption { 65 | return sql.OrderByField(FieldID, opts...).ToFunc() 66 | } 67 | 68 | // ByVault orders the results by the vault field. 69 | func ByVault(opts ...sql.OrderTermOption) OrderOption { 70 | return sql.OrderByField(FieldVault, opts...).ToFunc() 71 | } 72 | 73 | // ByUser orders the results by the user field. 74 | func ByUser(opts ...sql.OrderTermOption) OrderOption { 75 | return sql.OrderByField(FieldUser, opts...).ToFunc() 76 | } 77 | 78 | // ByRequestedUsd orders the results by the requested_usd field. 79 | func ByRequestedUsd(opts ...sql.OrderTermOption) OrderOption { 80 | return sql.OrderByField(FieldRequestedUsd, opts...).ToFunc() 81 | } 82 | 83 | // ByCommission orders the results by the commission field. 84 | func ByCommission(opts ...sql.OrderTermOption) OrderOption { 85 | return sql.OrderByField(FieldCommission, opts...).ToFunc() 86 | } 87 | 88 | // ByClosingCost orders the results by the closing_cost field. 89 | func ByClosingCost(opts ...sql.OrderTermOption) OrderOption { 90 | return sql.OrderByField(FieldClosingCost, opts...).ToFunc() 91 | } 92 | 93 | // ByBasis orders the results by the basis field. 94 | func ByBasis(opts ...sql.OrderTermOption) OrderOption { 95 | return sql.OrderByField(FieldBasis, opts...).ToFunc() 96 | } 97 | 98 | // ByNetWithdrawnUsd orders the results by the net_withdrawn_usd field. 99 | func ByNetWithdrawnUsd(opts ...sql.OrderTermOption) OrderOption { 100 | return sql.OrderByField(FieldNetWithdrawnUsd, opts...).ToFunc() 101 | } 102 | 103 | // ByTime orders the results by the time field. 104 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 105 | return sql.OrderByField(FieldTime, opts...).ToFunc() 106 | } 107 | 108 | // ByAddress orders the results by the address field. 109 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 110 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 111 | } 112 | -------------------------------------------------------------------------------- /ent/vaultwithdrawal_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/predicate" 12 | "github.com/yoshiso/hypersync/ent/vaultwithdrawal" 13 | ) 14 | 15 | // VaultWithdrawalDelete is the builder for deleting a VaultWithdrawal entity. 16 | type VaultWithdrawalDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *VaultWithdrawalMutation 20 | } 21 | 22 | // Where appends a list predicates to the VaultWithdrawalDelete builder. 23 | func (vwd *VaultWithdrawalDelete) Where(ps ...predicate.VaultWithdrawal) *VaultWithdrawalDelete { 24 | vwd.mutation.Where(ps...) 25 | return vwd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (vwd *VaultWithdrawalDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, vwd.sqlExec, vwd.mutation, vwd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (vwd *VaultWithdrawalDelete) ExecX(ctx context.Context) int { 35 | n, err := vwd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (vwd *VaultWithdrawalDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(vaultwithdrawal.Table, sqlgraph.NewFieldSpec(vaultwithdrawal.FieldID, field.TypeInt)) 44 | if ps := vwd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, vwd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | vwd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // VaultWithdrawalDeleteOne is the builder for deleting a single VaultWithdrawal entity. 60 | type VaultWithdrawalDeleteOne struct { 61 | vwd *VaultWithdrawalDelete 62 | } 63 | 64 | // Where appends a list predicates to the VaultWithdrawalDelete builder. 65 | func (vwdo *VaultWithdrawalDeleteOne) Where(ps ...predicate.VaultWithdrawal) *VaultWithdrawalDeleteOne { 66 | vwdo.vwd.mutation.Where(ps...) 67 | return vwdo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (vwdo *VaultWithdrawalDeleteOne) Exec(ctx context.Context) error { 72 | n, err := vwdo.vwd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{vaultwithdrawal.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (vwdo *VaultWithdrawalDeleteOne) ExecX(ctx context.Context) { 85 | if err := vwdo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ent/withdraw.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "fmt" 7 | "strings" 8 | 9 | "entgo.io/ent" 10 | "entgo.io/ent/dialect/sql" 11 | "github.com/yoshiso/hypersync/ent/withdraw" 12 | ) 13 | 14 | // Withdraw is the model entity for the Withdraw schema. 15 | type Withdraw struct { 16 | config `json:"-"` 17 | // ID of the ent. 18 | ID int `json:"id,omitempty"` 19 | // Usdc holds the value of the "usdc" field. 20 | Usdc string `json:"usdc,omitempty"` 21 | // Nonce holds the value of the "nonce" field. 22 | Nonce int64 `json:"nonce,omitempty"` 23 | // Fee holds the value of the "fee" field. 24 | Fee string `json:"fee,omitempty"` 25 | // Time holds the value of the "time" field. 26 | Time int64 `json:"time,omitempty"` 27 | // Address holds the value of the "address" field. 28 | Address string `json:"address,omitempty"` 29 | selectValues sql.SelectValues 30 | } 31 | 32 | // scanValues returns the types for scanning values from sql.Rows. 33 | func (*Withdraw) scanValues(columns []string) ([]any, error) { 34 | values := make([]any, len(columns)) 35 | for i := range columns { 36 | switch columns[i] { 37 | case withdraw.FieldID, withdraw.FieldNonce, withdraw.FieldTime: 38 | values[i] = new(sql.NullInt64) 39 | case withdraw.FieldUsdc, withdraw.FieldFee, withdraw.FieldAddress: 40 | values[i] = new(sql.NullString) 41 | default: 42 | values[i] = new(sql.UnknownType) 43 | } 44 | } 45 | return values, nil 46 | } 47 | 48 | // assignValues assigns the values that were returned from sql.Rows (after scanning) 49 | // to the Withdraw fields. 50 | func (w *Withdraw) assignValues(columns []string, values []any) error { 51 | if m, n := len(values), len(columns); m < n { 52 | return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 53 | } 54 | for i := range columns { 55 | switch columns[i] { 56 | case withdraw.FieldID: 57 | value, ok := values[i].(*sql.NullInt64) 58 | if !ok { 59 | return fmt.Errorf("unexpected type %T for field id", value) 60 | } 61 | w.ID = int(value.Int64) 62 | case withdraw.FieldUsdc: 63 | if value, ok := values[i].(*sql.NullString); !ok { 64 | return fmt.Errorf("unexpected type %T for field usdc", values[i]) 65 | } else if value.Valid { 66 | w.Usdc = value.String 67 | } 68 | case withdraw.FieldNonce: 69 | if value, ok := values[i].(*sql.NullInt64); !ok { 70 | return fmt.Errorf("unexpected type %T for field nonce", values[i]) 71 | } else if value.Valid { 72 | w.Nonce = value.Int64 73 | } 74 | case withdraw.FieldFee: 75 | if value, ok := values[i].(*sql.NullString); !ok { 76 | return fmt.Errorf("unexpected type %T for field fee", values[i]) 77 | } else if value.Valid { 78 | w.Fee = value.String 79 | } 80 | case withdraw.FieldTime: 81 | if value, ok := values[i].(*sql.NullInt64); !ok { 82 | return fmt.Errorf("unexpected type %T for field time", values[i]) 83 | } else if value.Valid { 84 | w.Time = value.Int64 85 | } 86 | case withdraw.FieldAddress: 87 | if value, ok := values[i].(*sql.NullString); !ok { 88 | return fmt.Errorf("unexpected type %T for field address", values[i]) 89 | } else if value.Valid { 90 | w.Address = value.String 91 | } 92 | default: 93 | w.selectValues.Set(columns[i], values[i]) 94 | } 95 | } 96 | return nil 97 | } 98 | 99 | // Value returns the ent.Value that was dynamically selected and assigned to the Withdraw. 100 | // This includes values selected through modifiers, order, etc. 101 | func (w *Withdraw) Value(name string) (ent.Value, error) { 102 | return w.selectValues.Get(name) 103 | } 104 | 105 | // Update returns a builder for updating this Withdraw. 106 | // Note that you need to call Withdraw.Unwrap() before calling this method if this Withdraw 107 | // was returned from a transaction, and the transaction was committed or rolled back. 108 | func (w *Withdraw) Update() *WithdrawUpdateOne { 109 | return NewWithdrawClient(w.config).UpdateOne(w) 110 | } 111 | 112 | // Unwrap unwraps the Withdraw entity that was returned from a transaction after it was closed, 113 | // so that all future queries will be executed through the driver which created the transaction. 114 | func (w *Withdraw) Unwrap() *Withdraw { 115 | _tx, ok := w.config.driver.(*txDriver) 116 | if !ok { 117 | panic("ent: Withdraw is not a transactional entity") 118 | } 119 | w.config.driver = _tx.drv 120 | return w 121 | } 122 | 123 | // String implements the fmt.Stringer. 124 | func (w *Withdraw) String() string { 125 | var builder strings.Builder 126 | builder.WriteString("Withdraw(") 127 | builder.WriteString(fmt.Sprintf("id=%v, ", w.ID)) 128 | builder.WriteString("usdc=") 129 | builder.WriteString(w.Usdc) 130 | builder.WriteString(", ") 131 | builder.WriteString("nonce=") 132 | builder.WriteString(fmt.Sprintf("%v", w.Nonce)) 133 | builder.WriteString(", ") 134 | builder.WriteString("fee=") 135 | builder.WriteString(w.Fee) 136 | builder.WriteString(", ") 137 | builder.WriteString("time=") 138 | builder.WriteString(fmt.Sprintf("%v", w.Time)) 139 | builder.WriteString(", ") 140 | builder.WriteString("address=") 141 | builder.WriteString(w.Address) 142 | builder.WriteByte(')') 143 | return builder.String() 144 | } 145 | 146 | // Withdraws is a parsable slice of Withdraw. 147 | type Withdraws []*Withdraw 148 | -------------------------------------------------------------------------------- /ent/withdraw/withdraw.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package withdraw 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | const ( 10 | // Label holds the string label denoting the withdraw type in the database. 11 | Label = "withdraw" 12 | // FieldID holds the string denoting the id field in the database. 13 | FieldID = "id" 14 | // FieldUsdc holds the string denoting the usdc field in the database. 15 | FieldUsdc = "usdc" 16 | // FieldNonce holds the string denoting the nonce field in the database. 17 | FieldNonce = "nonce" 18 | // FieldFee holds the string denoting the fee field in the database. 19 | FieldFee = "fee" 20 | // FieldTime holds the string denoting the time field in the database. 21 | FieldTime = "time" 22 | // FieldAddress holds the string denoting the address field in the database. 23 | FieldAddress = "address" 24 | // Table holds the table name of the withdraw in the database. 25 | Table = "withdraws" 26 | ) 27 | 28 | // Columns holds all SQL columns for withdraw fields. 29 | var Columns = []string{ 30 | FieldID, 31 | FieldUsdc, 32 | FieldNonce, 33 | FieldFee, 34 | FieldTime, 35 | FieldAddress, 36 | } 37 | 38 | // ValidColumn reports if the column name is valid (part of the table columns). 39 | func ValidColumn(column string) bool { 40 | for i := range Columns { 41 | if column == Columns[i] { 42 | return true 43 | } 44 | } 45 | return false 46 | } 47 | 48 | // OrderOption defines the ordering options for the Withdraw queries. 49 | type OrderOption func(*sql.Selector) 50 | 51 | // ByID orders the results by the id field. 52 | func ByID(opts ...sql.OrderTermOption) OrderOption { 53 | return sql.OrderByField(FieldID, opts...).ToFunc() 54 | } 55 | 56 | // ByUsdc orders the results by the usdc field. 57 | func ByUsdc(opts ...sql.OrderTermOption) OrderOption { 58 | return sql.OrderByField(FieldUsdc, opts...).ToFunc() 59 | } 60 | 61 | // ByNonce orders the results by the nonce field. 62 | func ByNonce(opts ...sql.OrderTermOption) OrderOption { 63 | return sql.OrderByField(FieldNonce, opts...).ToFunc() 64 | } 65 | 66 | // ByFee orders the results by the fee field. 67 | func ByFee(opts ...sql.OrderTermOption) OrderOption { 68 | return sql.OrderByField(FieldFee, opts...).ToFunc() 69 | } 70 | 71 | // ByTime orders the results by the time field. 72 | func ByTime(opts ...sql.OrderTermOption) OrderOption { 73 | return sql.OrderByField(FieldTime, opts...).ToFunc() 74 | } 75 | 76 | // ByAddress orders the results by the address field. 77 | func ByAddress(opts ...sql.OrderTermOption) OrderOption { 78 | return sql.OrderByField(FieldAddress, opts...).ToFunc() 79 | } 80 | -------------------------------------------------------------------------------- /ent/withdraw_delete.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | import ( 6 | "context" 7 | 8 | "entgo.io/ent/dialect/sql" 9 | "entgo.io/ent/dialect/sql/sqlgraph" 10 | "entgo.io/ent/schema/field" 11 | "github.com/yoshiso/hypersync/ent/predicate" 12 | "github.com/yoshiso/hypersync/ent/withdraw" 13 | ) 14 | 15 | // WithdrawDelete is the builder for deleting a Withdraw entity. 16 | type WithdrawDelete struct { 17 | config 18 | hooks []Hook 19 | mutation *WithdrawMutation 20 | } 21 | 22 | // Where appends a list predicates to the WithdrawDelete builder. 23 | func (wd *WithdrawDelete) Where(ps ...predicate.Withdraw) *WithdrawDelete { 24 | wd.mutation.Where(ps...) 25 | return wd 26 | } 27 | 28 | // Exec executes the deletion query and returns how many vertices were deleted. 29 | func (wd *WithdrawDelete) Exec(ctx context.Context) (int, error) { 30 | return withHooks(ctx, wd.sqlExec, wd.mutation, wd.hooks) 31 | } 32 | 33 | // ExecX is like Exec, but panics if an error occurs. 34 | func (wd *WithdrawDelete) ExecX(ctx context.Context) int { 35 | n, err := wd.Exec(ctx) 36 | if err != nil { 37 | panic(err) 38 | } 39 | return n 40 | } 41 | 42 | func (wd *WithdrawDelete) sqlExec(ctx context.Context) (int, error) { 43 | _spec := sqlgraph.NewDeleteSpec(withdraw.Table, sqlgraph.NewFieldSpec(withdraw.FieldID, field.TypeInt)) 44 | if ps := wd.mutation.predicates; len(ps) > 0 { 45 | _spec.Predicate = func(selector *sql.Selector) { 46 | for i := range ps { 47 | ps[i](selector) 48 | } 49 | } 50 | } 51 | affected, err := sqlgraph.DeleteNodes(ctx, wd.driver, _spec) 52 | if err != nil && sqlgraph.IsConstraintError(err) { 53 | err = &ConstraintError{msg: err.Error(), wrap: err} 54 | } 55 | wd.mutation.done = true 56 | return affected, err 57 | } 58 | 59 | // WithdrawDeleteOne is the builder for deleting a single Withdraw entity. 60 | type WithdrawDeleteOne struct { 61 | wd *WithdrawDelete 62 | } 63 | 64 | // Where appends a list predicates to the WithdrawDelete builder. 65 | func (wdo *WithdrawDeleteOne) Where(ps ...predicate.Withdraw) *WithdrawDeleteOne { 66 | wdo.wd.mutation.Where(ps...) 67 | return wdo 68 | } 69 | 70 | // Exec executes the deletion query. 71 | func (wdo *WithdrawDeleteOne) Exec(ctx context.Context) error { 72 | n, err := wdo.wd.Exec(ctx) 73 | switch { 74 | case err != nil: 75 | return err 76 | case n == 0: 77 | return &NotFoundError{withdraw.Label} 78 | default: 79 | return nil 80 | } 81 | } 82 | 83 | // ExecX is like Exec, but panics if an error occurs. 84 | func (wdo *WithdrawDeleteOne) ExecX(ctx context.Context) { 85 | if err := wdo.Exec(ctx); err != nil { 86 | panic(err) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/yoshiso/hypersync 2 | 3 | go 1.23.0 4 | 5 | toolchain go1.23.4 6 | 7 | require ( 8 | entgo.io/ent v0.14.1 9 | github.com/aws/aws-sdk-go v1.55.5 10 | github.com/gorilla/websocket v1.5.1 11 | github.com/urfave/cli/v3 v3.0.0-beta1 12 | modernc.org/sqlite v1.34.2 13 | ) 14 | 15 | require ( 16 | ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect 17 | github.com/agext/levenshtein v1.2.1 // indirect 18 | github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect 19 | github.com/dustin/go-humanize v1.0.1 // indirect 20 | github.com/go-openapi/inflect v0.19.0 // indirect 21 | github.com/google/go-cmp v0.6.0 // indirect 22 | github.com/google/uuid v1.6.0 // indirect 23 | github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect 24 | github.com/hashicorp/hcl/v2 v2.13.0 // indirect 25 | github.com/jmespath/go-jmespath v0.4.0 // indirect 26 | github.com/mattn/go-isatty v0.0.20 // indirect 27 | github.com/mattn/go-sqlite3 v1.14.24 // indirect 28 | github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect 29 | github.com/ncruces/go-strftime v0.1.9 // indirect 30 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect 31 | github.com/zclconf/go-cty v1.8.0 // indirect 32 | golang.org/x/mod v0.23.0 // indirect 33 | golang.org/x/net v0.35.0 // indirect 34 | golang.org/x/sys v0.30.0 // indirect 35 | golang.org/x/text v0.22.0 // indirect 36 | golang.org/x/tools v0.30.0 // indirect 37 | modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect 38 | modernc.org/libc v1.55.3 // indirect 39 | modernc.org/mathutil v1.6.0 // indirect 40 | modernc.org/memory v1.8.0 // indirect 41 | modernc.org/strutil v1.2.0 // indirect 42 | modernc.org/token v1.1.0 // indirect 43 | ) 44 | --------------------------------------------------------------------------------