Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Update API changes, use proper types
Browse files Browse the repository at this point in the history
  • Loading branch information
echa committed Jul 7, 2023
1 parent 61318b3 commit 8d35c40
Show file tree
Hide file tree
Showing 20 changed files with 191 additions and 197 deletions.
13 changes: 7 additions & 6 deletions tzpro/defi/dex_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

type DexEvent struct {
Id uint64 `json:"id"`
Contract string `json:"contract"`
PairId int64 `json:"pair_id"`
Contract Address `json:"contract"`
PairId int `json:"pair_id"`
Name string `json:"name"`
Entity string `json:"entity"`
Pair string `json:"pair"`
Expand All @@ -26,10 +26,11 @@ type DexEvent struct {
SupplyA Z `json:"supply_a"`
SupplyB Z `json:"supply_b"`
SupplyLP Z `json:"supply_lp"`
Signer string `json:"signer"`
Sender string `json:"sender"`
Receiver string `json:"receiver"`
Router string `json:"router"`
ValueUSD float64 `json:"value_usd,string"`
Signer Address `json:"signer"`
Sender Address `json:"sender"`
Receiver Address `json:"receiver"`
Router Address `json:"router"`
TxHash OpHash `json:"tx_hash"`
TxFee int64 `json:"tx_fee,string"`
Block int64 `json:"block"`
Expand Down
42 changes: 22 additions & 20 deletions tzpro/defi/dex_position.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,39 @@ import (

type DexPosition struct {
Id uint64 `json:"id"`
Contract string `json:"contract"`
PairId int64 `json:"pair_id"`
Contract Address `json:"contract"`
PairId int `json:"pair_id"`
Name string `json:"name"`
Entity string `json:"entity"`
Pair string `json:"pair"`
Owner string `json:"owner"`
Owner Address `json:"owner"`
DecimalsA int `json:"decimals_a"`
DecimalsB int `json:"decimals_b"`
DecimalsLP int `json:"decimals_lp"`
TotalShares string `json:"total_shares"`
Shares string `json:"shares"`
ValueA string `json:"value_a"`
ValueB string `json:"value_b"`
SharesMinted string `json:"shares_minted"`
SharesBurned string `json:"shares_burned"`
SharesSent string `json:"shares_sent"`
SharesReceived string `json:"shares_received"`
DepositedA string `json:"deposited_a"`
DepositedB string `json:"deposited_b"`
WithdrawnA string `json:"withdrawn_a"`
WithdrawnB string `json:"withdrawn_b"`
TotalShares Z `json:"total_shares"`
Shares Z `json:"shares"`
ValueA Z `json:"value_a"`
ValueB Z `json:"value_b"`
SharesMinted Z `json:"shares_minted"`
SharesBurned Z `json:"shares_burned"`
SharesSent Z `json:"shares_sent"`
SharesReceived Z `json:"shares_received"`
DepositedA Z `json:"deposited_a"`
DepositedB Z `json:"deposited_b"`
WithdrawnA Z `json:"withdrawn_a"`
WithdrawnB Z `json:"withdrawn_b"`
IsClosed bool `json:"is_closed"`
OpenBlock int64 `json:"open_block"`
OpenTime time.Time `json:"open_time"`
CloseBlock int64 `json:"close_block,omitempty"`
CloseTime *time.Time `json:"close_time,omitempty"`
PositionValueUSD string `json:"position_value_usd"`
ShareValueUSD string `json:"share_value_usd"`
OpenValueUSD string `json:"open_value_usd"`
CloseValueUSD string `json:"close_value_usd"`
ProfitLossUSD string `json:"pnl_usd"`
PositionValueUSD float64 `json:"position_value_usd,string"`
ShareValueUSD float64 `json:"share_value_usd,string"`
OpenValueUSD float64 `json:"open_value_usd,string"`
CloseValueUSD float64 `json:"close_value_usd,string"`
FeeIncomeUSD float64 `json:"fee_income_usd,string"`
FeeIncomeBps float64 `json:"fee_income_bps,string"`
ProfitLossUSD float64 `json:"pnl_usd,string"`
ProfitLossBps float64 `json:"pnl_bps,string"`
}

Expand Down
42 changes: 21 additions & 21 deletions tzpro/defi/dex_ticker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ import (
)

type DexTicker struct {
Pair string `json:"pair"`
Pool string `json:"pool"`
Name string `json:"name"`
Entity string `json:"entity"`
PriceChange string `json:"price_change"`
PriceChangeBps string `json:"price_change_bps"`
AskPrice string `json:"ask_price"`
WeightedAvgPrice string `json:"weighted_avg_price"`
LastPrice string `json:"last_price"`
LastQty string `json:"last_qty"`
LastTradeTime string `json:"last_trade_time"`
BaseVolume string `json:"base_volume"`
QuoteVolume string `json:"quote_volume"`
OpenPrice string `json:"open_price"`
HighPrice string `json:"high_price"`
LowPrice string `json:"low_price"`
OpenTime time.Time `json:"open_time"`
CloseTime time.Time `json:"close_time"`
NumTrades int `json:"num_trades"`
LiquidityUSD string `json:"liquidity_usd"`
PriceUSD string `json:"price_usd"`
Pair string `json:"pair"`
Pool PoolAddress `json:"pool"`
Name string `json:"name"`
Entity string `json:"entity"`
PriceChange float64 `json:"price_change,string"`
PriceChangeBps float64 `json:"price_change_bps,string"`
AskPrice float64 `json:"ask_price,string"`
WeightedAvgPrice float64 `json:"weighted_avg_price,string"`
LastPrice float64 `json:"last_price,string"`
LastQty float64 `json:"last_qty,string"`
LastTradeTime float64 `json:"last_trade_time,string"`
BaseVolume float64 `json:"base_volume,string"`
QuoteVolume float64 `json:"quote_volume,string"`
OpenPrice float64 `json:"open_price,string"`
HighPrice float64 `json:"high_price,string"`
LowPrice float64 `json:"low_price,string"`
OpenTime time.Time `json:"open_time"`
CloseTime time.Time `json:"close_time"`
NumTrades int `json:"num_trades"`
LiquidityUSD string `json:"liquidity_usd"`
PriceUSD string `json:"price_usd"`
}

func (c *dexClient) GetTicker(ctx context.Context, addr PoolAddress) (*DexTicker, error) {
Expand Down
2 changes: 1 addition & 1 deletion tzpro/defi/dex_trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

type DexTrade struct {
Id uint64 `json:"id"`
Contract string `json:"contract"`
Contract Address `json:"contract"`
PairId int `json:"pair_id"`
Name string `json:"name"`
Entity string `json:"entity"`
Expand Down
11 changes: 5 additions & 6 deletions tzpro/defi/farm.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,25 @@ type farmClient struct {

type Farm struct {
Id uint64 `json:"id"`
Contract string `json:"contract"`
Contract Address `json:"contract"`
PoolId int `json:"pool_id"`
Creator string `json:"creator"`
Creator Address `json:"creator"`
Name string `json:"name"`
Entity string `json:"entity"`
StakeToken *Token `json:"stake_token"`
RewardToken *Token `json:"reward_token"`
FirstBlock int64 `json:"first_block"`
FirstTime time.Time `json:"first_time"`
Tags []string `json:"tags"`
TotalStake string `json:"total_stake"`
RemainingRewards string `json:"remaining_rewards"`
TotalStake Z `json:"total_stake"`
RemainingRewards Z `json:"remaining_rewards"`
NumPositions int `json:"num_positions"`
StartTime *time.Time `json:"start_time,omitempty"`
EndTime *time.Time `json:"end_time,omitempty"`
}

func (p Farm) Address() PoolAddress {
a, _ := ParseAddress(p.Contract)
return NewPoolAddress(a, p.PoolId)
return NewPoolAddress(p.Contract, p.PoolId)
}

func (c *farmClient) GetFarm(ctx context.Context, addr PoolAddress) (*Farm, error) {
Expand Down
52 changes: 26 additions & 26 deletions tzpro/defi/farm_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ import (
)

type FarmEvent struct {
Id uint64 `json:"id"`
Contract string `json:"contract"`
PoolId int64 `json:"pool_id"`
Name string `json:"name"`
Entity string `json:"entity"`
Type string `json:"event_type"`
StakeToken string `json:"stake_token"`
RewardToken string `json:"reward_token"`
StakeSymbol string `json:"stake_symbol"`
RewardSymbol string `json:"reward_symbol"`
StakeDecimals int `json:"stake_decimals"`
RewardDecimals int `json:"reward_decimals"`
Volume Z `json:"volume"`
Reward Z `json:"reward"`
Fee Z `json:"fee"`
FeeBps float64 `json:"fee_bps,string"`
StakeId int64 `json:"stake_id"`
StakeSupply Z `json:"stake_supply"`
RewardSupply Z `json:"reward_supply"`
Signer string `json:"signer"`
Sender string `json:"sender"`
Receiver string `json:"receiver"`
TxHash string `json:"tx_hash"`
TxFee int64 `json:"tx_fee,string"`
Block int64 `json:"block"`
Time time.Time `json:"time"`
Id uint64 `json:"id"`
Contract Address `json:"contract"`
PoolId int `json:"pool_id"`
Name string `json:"name"`
Entity string `json:"entity"`
Type string `json:"event_type"`
StakeToken TokenAddress `json:"stake_token"`
RewardToken TokenAddress `json:"reward_token"`
StakeSymbol string `json:"stake_symbol"`
RewardSymbol string `json:"reward_symbol"`
StakeDecimals int `json:"stake_decimals"`
RewardDecimals int `json:"reward_decimals"`
Volume Z `json:"volume"`
Reward Z `json:"reward"`
Fee Z `json:"fee"`
FeeBps float64 `json:"fee_bps,string"`
StakeId int64 `json:"stake_id"`
StakeSupply Z `json:"stake_supply"`
RewardSupply Z `json:"reward_supply"`
Signer Address `json:"signer"`
Sender Address `json:"sender"`
Receiver Address `json:"receiver"`
TxHash OpHash `json:"tx_hash"`
TxFee int64 `json:"tx_fee,string"`
Block int64 `json:"block"`
Time time.Time `json:"time"`
}

func (c *farmClient) ListEvents(ctx context.Context, params Query) ([]*FarmEvent, error) {
Expand Down
51 changes: 27 additions & 24 deletions tzpro/defi/farm_position.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,33 @@ import (
)

type FarmPosition struct {
Id uint64 `json:"id"`
Contract string `json:"contract"`
PoolId int64 `json:"pool_id"`
Name string `json:"name"`
Entity string `json:"entity"`
Owner string `json:"owner"`
StakeToken string `json:"stake_token"`
RewardToken string `json:"reward_token"`
StakeSymbol string `json:"stake_symbol"`
RewardSymbol string `json:"reward_symbol"`
StakeDecimals int `json:"stake_decimals"`
RewardDecimals int `json:"reward_decimals"`
TotalStake string `json:"total_stake"`
StakeId int64 `json:"stake_id"`
Stake Z `json:"stake_balance"`
Deposited Z `json:"stake_deposited"`
Withdrawn Z `json:"stake_withdrawn"`
Claimed Z `json:"rewards_claimed"`
Pending Z `json:"rewards_pending"`
IsClosed bool `json:"is_closed"`
OpenBlock int64 `json:"open_block"`
OpenTime time.Time `json:"open_time"`
CloseBlock int64 `json:"close_block,omitempty"`
CloseTime *time.Time `json:"close_time,omitempty"`
Id uint64 `json:"id"`
Contract Address `json:"contract"`
PoolId int `json:"pool_id"`
Name string `json:"name"`
Entity string `json:"entity"`
Owner Address `json:"owner"`
StakeToken TokenAddress `json:"stake_token"`
RewardToken TokenAddress `json:"reward_token"`
StakeSymbol string `json:"stake_symbol"`
RewardSymbol string `json:"reward_symbol"`
StakeDecimals int `json:"stake_decimals"`
RewardDecimals int `json:"reward_decimals"`
TotalStake Z `json:"total_stake"`
StakeId int64 `json:"stake_id"`
Stake Z `json:"stake_balance"`
Deposited Z `json:"stake_deposited"`
Withdrawn Z `json:"stake_withdrawn"`
Claimed Z `json:"rewards_claimed"`
Pending Z `json:"rewards_pending"`
IsClosed bool `json:"is_closed"`
OpenBlock int64 `json:"open_block"`
OpenTime time.Time `json:"open_time"`
CloseBlock int64 `json:"close_block,omitempty"`
CloseTime *time.Time `json:"close_time,omitempty"`
ValueUSD float64 `json:"value_usd,string"`
PendingUSD float64 `json:"pending_usd,string"`
ClaimedUSD float64 `json:"claimed_usd,string"`
}

func (c *farmClient) ListPositions(ctx context.Context, params Query) ([]*FarmPosition, error) {
Expand Down
11 changes: 5 additions & 6 deletions tzpro/defi/lend.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,24 @@ type lendClient struct {

type LendingPool struct {
Id uint64 `json:"id"`
Contract string `json:"contract"`
Contract Address `json:"contract"`
PoolId int `json:"pool_id"`
Creator string `json:"creator"`
Creator Address `json:"creator"`
Name string `json:"name"`
Entity string `json:"entity"`
DebtToken *Token `json:"debt_token"`
CollateralToken *Token `json:"collateral_token"`
FirstBlock int64 `json:"first_block"`
FirstTime time.Time `json:"first_time"`
Tags []string `json:"tags"`
TotalCollateral string `json:"total_collateral"`
TotalDebt string `json:"total_debt"`
TotalCollateral Z `json:"total_collateral"`
TotalDebt Z `json:"total_debt"`
NumDeposits int `json:"num_deposits"`
NumBorrows int `json:"num_borrows"`
}

func (p LendingPool) Address() PoolAddress {
a, _ := ParseAddress(p.Contract)
return NewPoolAddress(a, p.PoolId)
return NewPoolAddress(p.Contract, p.PoolId)
}

func (c *lendClient) GetPool(ctx context.Context, addr PoolAddress) (*LendingPool, error) {
Expand Down
52 changes: 26 additions & 26 deletions tzpro/defi/lend_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ import (
)

type LendingEvent struct {
Id uint64 `json:"id"`
Contract string `json:"contract"`
PoolId int64 `json:"pool_id"`
Name string `json:"name"`
Entity string `json:"entity"`
Type string `json:"event_type"`
DebtToken string `json:"debt_token"`
CollateralToken string `json:"collateral_token"`
DebtDecimals int `json:"debt_decimals"`
CollateralDecimals int `json:"collateral_decimals"`
DebtSymbol string `json:"debt_symbol"`
CollateralSymbol string `json:"collateral_symbol"`
Owner string `json:"owner"`
StakeId int64 `json:"stake_id"`
Volume Z `json:"volume"`
Debt Z `json:"debt"`
Collateral Z `json:"collateral"`
Fee Z `json:"fee"`
Interest Z `json:"interest"`
Signer string `json:"signer"`
Sender string `json:"sender"`
Receiver string `json:"receiver"`
TxHash string `json:"tx_hash"`
TxFee int64 `json:"tx_fee,string"`
Block int64 `json:"block"`
Time time.Time `json:"time"`
Id uint64 `json:"id"`
Contract Address `json:"contract"`
PoolId int `json:"pool_id"`
Name string `json:"name"`
Entity string `json:"entity"`
Type string `json:"event_type"`
DebtToken TokenAddress `json:"debt_token"`
CollateralToken TokenAddress `json:"collateral_token"`
DebtDecimals int `json:"debt_decimals"`
CollateralDecimals int `json:"collateral_decimals"`
DebtSymbol string `json:"debt_symbol"`
CollateralSymbol string `json:"collateral_symbol"`
Owner Address `json:"owner"`
StakeId int64 `json:"stake_id"`
Volume Z `json:"volume"`
Debt Z `json:"debt"`
Collateral Z `json:"collateral"`
Fee Z `json:"fee"`
Interest Z `json:"interest"`
Signer Address `json:"signer"`
Sender Address `json:"sender"`
Receiver Address `json:"receiver"`
TxHash OpHash `json:"tx_hash"`
TxFee int64 `json:"tx_fee,string"`
Block int64 `json:"block"`
Time time.Time `json:"time"`
}

func (c *lendClient) ListEvents(ctx context.Context, params Query) ([]*LendingEvent, error) {
Expand Down
Loading

0 comments on commit 8d35c40

Please sign in to comment.