Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Dev #1

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package cmd
19 changes: 19 additions & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package api

import (
"github.com/deltadefi-protocol/go-sdk/pkg/utils"
)

type ApiNetwork string

const (
ApiNetworkPreprod ApiNetwork = "preprod"
ApiNetworkMainnet ApiNetwork = "mainnet"
)

type ApiConfig struct {
Network *ApiNetwork `json:"network,omitempty"`
// TODO: AppWalletKeyType
SigningKey int `json:"signingKey,omitempty"`
utils.AuthHeaders
}
1 change: 1 addition & 0 deletions pkg/api/common/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package common
1 change: 1 addition & 0 deletions pkg/api/common/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package common
12 changes: 12 additions & 0 deletions pkg/api/requests/params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package requests

import (
rmodels "github.com/sidan-lab/rum/models"
)

type InputUtxos struct {
TxHash string `json:"tx_hash"`
TxID string `json:"tx_id"`
Amount []rmodels.Asset `json:"amount"`
Address string `json:"address"`
}
86 changes: 86 additions & 0 deletions pkg/api/requests/requests.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package requests

import (
"github.com/deltadefi-protocol/go-sdk/pkg/models"
rmodels "github.com/sidan-lab/rum/models"
)

type SignInRequest struct {
WalletAddress string `json:"wallet_address"`
AuthKey string `json:"auth_key"`
}

// type BuildSendRefScriptsTransactionRequest struct {
// InputUTxOs []rmodels.UTxO `json:"input_utxos"`
// TotalDepositAmount []rmodels.Asset `json:"total_deposit_amount"`
// }

// type SubmitSendRefScriptsTransactionRequest struct {
// SignedTx string `json:"signed_tx"`
// }

// type PostOrderRequest = BuildPostOrderTransactionRequest

// type SubmitDeleteAccountTransactionRequest struct {
// SignedTx string `json:"signed_tx"`
// }
type BuildDepositTransactionRequest struct {
DepositAmount []rmodels.Asset `json:"deposit_amount"`
InputUtxos []*rmodels.UTxO `json:"input_utxos"`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[]*rmodels.UTxO

is * necessary here?

}

type BuildWithdrawalTransactionRequest struct {
WithdrawalAmount []rmodels.Asset `json:"withdrawal_amount"`
}

type SubmitDepositTransactionRequest struct {
SignedTx string `json:"signed_tx"`
}

type SubmitWithdrawalTransactionRequest struct {
SignedTxs []string `json:"signed_txs"`
}

type GetMarketDepthRequest struct {
Pair models.TradingSymbol `json:"pair"`
}

type GetMarketPriceRequest struct {
Pair string `json:"pair"`
}

type Interval string

const (
Interval15m Interval = "15m"
Interval30m Interval = "30m"
Interval1h Interval = "1h"
Interval1d Interval = "1d"
Interval1w Interval = "1w"
Interval1M Interval = "1M"
)

type GetAggregatedPriceRequest struct {
Pair string `json:"pair"`
Interval Interval `json:"interval"`
Start *int64 `json:"start,omitempty"` // timestamp
End *int64 `json:"end,omitempty"` // timestamp
}

type BuildPlaceOrderTransactionRequest struct {
Pair models.TradingSymbol `json:"pair"`
Side models.OrderSide `json:"side"`
Type models.OrderType `json:"type"`
Quantity float64 `json:"quantity"`
Price *float64 `json:"price,omitempty"`
BasisPoint *float64 `json:"basis_point,omitempty"`
}

type SubmitPlaceOrderTransactionRequest struct {
OrderID string `json:"order_id"`
SignedTx string `json:"signed_tx"`
}

type SubmitCancelOrderTransactionRequest struct {
SignedTx string `json:"signed_tx"`
}
119 changes: 119 additions & 0 deletions pkg/api/responses/responses.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package responses

import (
"github.com/deltadefi-protocol/go-sdk/pkg/models"
rmodels "github.com/sidan-lab/rum/models"
)

type SignInResponse struct {
Token string `json:"token"`
IsReady bool `json:"is_ready"`
}

type BuildSendRefScriptsTransactionResponse struct {
TxHex string `json:"tx_hex"`
}

type SubmitSendRefScriptsTransactionResponse struct {
TxHash string `json:"tx_hash"`
}
type SubmitPostOrderTransactionResponse struct {
Order *models.OrderJSON `json:"order"`
TxHexes string `json:"tx_hexes"`
}

type PostOrderResponse = *SubmitPostOrderTransactionResponse

type DepositRecord struct {
CreatedAt string `json:"created_at"`
Assets []rmodels.Asset `json:"assets"`
TxHash string `json:"tx_hash"`
}

type GetDepositRecordsResponse []*DepositRecord

type GetOrderRecordResponse struct {
Orders []*models.OrderJSON `json:"Orders"`
}

type WithdrawalRecord struct {
CreatedAt string `json:"created_at"`
Assets []rmodels.Asset `json:"assets"`
}

type GetWithdrawalRecordsResponse []*WithdrawalRecord

type AssetBalance struct {
Asset string `json:"asset"`
Free int64 `json:"free"`
Locked int64 `json:"locked"`
}

type GetAccountBalanceResponse []*AssetBalance

type GenerateNewAPIKeyResponse struct {
APIKey string `json:"api_key"`
}

type BuildDepositTransactionResponse struct {
TxHex string `json:"tx_hex"`
}

type BuildWithdrawalTransactionResponse struct {
TxHex string `json:"tx_hex"`
}

type SubmitDepositTransactionResponse struct {
TxHash string `json:"tx_hash"`
}

type SubmitWithdrawalTransactionResponse struct {
TxHash string `json:"tx_hash"`
}

type GetTermsAndConditionResponse struct {
Value string `json:"value"`
}

type MarketDepth struct {
Price float64 `json:"price"`
Quantity float64 `json:"quantity"`
}

type GetMarketDepthResponse struct {
Bids []MarketDepth `json:"bids"`
Asks []MarketDepth `json:"asks"`
}

type GetMarketPriceResponse struct {
Price float64 `json:"price"`
}

type Trade struct {
Time string `json:"time"`
Symbol string `json:"symbol"`
Open float64 `json:"open"`
High float64 `json:"high"`
Low float64 `json:"low"`
Close float64 `json:"close"`
Volume float64 `json:"volume"`
}

type GetAggregatedPriceResponse []*Trade

type BuildPlaceOrderTransactionResponse struct {
OrderID string `json:"order_id"`
TxHex string `json:"tx_hex"`
}

type BuildCancelOrderTransactionResponse struct {
TxHex string `json:"tx_hex"`
}

type SubmitPlaceOrderTransactionResponse struct {
Order *models.OrderJSON `json:"order"`
}

type SubmitCancelOrderTransactionResponse struct {
TxHash string `json:"txhash"`
}
Loading