包含 webapp(Next.js 用户端)、webapp-back(Go 后端)、 antdesign(管理后台)、landingpage(营销落地页)、 数据库 SQL 和配置文件。
114 lines
3.6 KiB
Go
114 lines
3.6 KiB
Go
package lending
|
|
|
|
|
|
|
|
// UserPosition represents user's lending position (from chain)
|
|
type UserPosition struct {
|
|
UserAddress string `json:"user_address"`
|
|
WalletAddress string `json:"wallet_address"`
|
|
SuppliedBalance string `json:"supplied_balance"` // USDC supplied
|
|
SuppliedBalanceUSD float64 `json:"supplied_balance_usd"` // USD value
|
|
BorrowedBalance string `json:"borrowed_balance"` // USDC borrowed
|
|
BorrowedBalanceUSD float64 `json:"borrowed_balance_usd"` // USD value
|
|
CollateralBalances map[string]CollateralInfo `json:"collateral_balances"` // YT-A, YT-B, YT-C
|
|
HealthFactor float64 `json:"health_factor"`
|
|
LTV float64 `json:"ltv"` // Loan-to-Value ratio
|
|
SupplyAPY float64 `json:"supply_apy"`
|
|
BorrowAPY float64 `json:"borrow_apy"`
|
|
}
|
|
|
|
// CollateralInfo represents collateral asset information
|
|
type CollateralInfo struct {
|
|
TokenSymbol string `json:"token_symbol"` // YT-A, YT-B, YT-C
|
|
Balance string `json:"balance"` // Token balance
|
|
BalanceUSD float64 `json:"balance_usd"` // USD value
|
|
CollateralValue float64 `json:"collateral_value"` // Collateral value (with factor)
|
|
}
|
|
|
|
// LendingStats represents lending market statistics
|
|
type LendingStats struct {
|
|
TotalSuppliedUSD float64 `json:"total_supplied_usd"`
|
|
TotalBorrowedUSD float64 `json:"total_borrowed_usd"`
|
|
TotalCollateralUSD float64 `json:"total_collateral_usd"`
|
|
UtilizationRate float64 `json:"utilization_rate"`
|
|
AvgSupplyAPY float64 `json:"avg_supply_apy"`
|
|
AvgBorrowAPY float64 `json:"avg_borrow_apy"`
|
|
TotalUsers int `json:"total_users"`
|
|
ActiveBorrowers int `json:"active_borrowers"`
|
|
TotalTVL float64 `json:"total_tvl"`
|
|
}
|
|
|
|
// Supply request/response
|
|
type SupplyRequest struct {
|
|
Amount string `json:"amount" binding:"required"`
|
|
TxHash string `json:"tx_hash"`
|
|
}
|
|
|
|
type SupplyResponse struct {
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
Data *UserPosition `json:"data,omitempty"`
|
|
}
|
|
|
|
// Withdraw request/response
|
|
type WithdrawRequest struct {
|
|
Amount string `json:"amount" binding:"required"`
|
|
TxHash string `json:"tx_hash"`
|
|
}
|
|
|
|
type WithdrawResponse struct {
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
Data *UserPosition `json:"data,omitempty"`
|
|
}
|
|
|
|
// SupplyCollateral request/response
|
|
type SupplyCollateralRequest struct {
|
|
Asset string `json:"asset" binding:"required"` // YT-A, YT-B, YT-C
|
|
Amount string `json:"amount" binding:"required"`
|
|
TxHash string `json:"tx_hash"`
|
|
}
|
|
|
|
type SupplyCollateralResponse struct {
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
Data *UserPosition `json:"data,omitempty"`
|
|
}
|
|
|
|
// WithdrawCollateral request/response
|
|
type WithdrawCollateralRequest struct {
|
|
Asset string `json:"asset" binding:"required"` // YT-A, YT-B, YT-C
|
|
Amount string `json:"amount" binding:"required"`
|
|
TxHash string `json:"tx_hash"`
|
|
}
|
|
|
|
type WithdrawCollateralResponse struct {
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
Data *UserPosition `json:"data,omitempty"`
|
|
}
|
|
|
|
// Borrow request/response
|
|
type BorrowRequest struct {
|
|
Amount string `json:"amount" binding:"required"`
|
|
TxHash string `json:"tx_hash"`
|
|
}
|
|
|
|
type BorrowResponse struct {
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
Data *UserPosition `json:"data,omitempty"`
|
|
}
|
|
|
|
// Repay request/response
|
|
type RepayRequest struct {
|
|
Amount string `json:"amount" binding:"required"`
|
|
TxHash string `json:"tx_hash"`
|
|
}
|
|
|
|
type RepayResponse struct {
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
Data *UserPosition `json:"data,omitempty"`
|
|
}
|