Skip to content

Commit 0376ec8

Browse files
committed
improve liquid staking
1 parent e90b907 commit 0376ec8

18 files changed

+839
-10
lines changed

api/openapi.json

+57-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
"required": false,
132132
"schema": {
133133
"default": 30,
134-
"maximum": 90,
134+
"maximum": 360,
135135
"minimum": 1,
136136
"type": "integer"
137137
}
@@ -1297,6 +1297,24 @@
12971297
],
12981298
"type": "object"
12991299
},
1300+
"DomainInfo": {
1301+
"properties": {
1302+
"expiring_at": {
1303+
"description": "date of expiring. optional. not all domain in ton has expiration date",
1304+
"type": "integer"
1305+
},
1306+
"item": {
1307+
"$ref": "#/components/schemas/NftItem"
1308+
},
1309+
"name": {
1310+
"type": "string"
1311+
}
1312+
},
1313+
"required": [
1314+
"name"
1315+
],
1316+
"type": "object"
1317+
},
13001318
"DomainNames": {
13011319
"properties": {
13021320
"domains": {
@@ -4024,6 +4042,44 @@
40244042
]
40254043
}
40264044
},
4045+
"/v2/dns/{domain_name}": {
4046+
"get": {
4047+
"description": "get full information about domain name",
4048+
"operationId": "dnsInfo",
4049+
"parameters": [
4050+
{
4051+
"$ref": "#/components/parameters/domainNameParameter"
4052+
}
4053+
],
4054+
"responses": {
4055+
"200": {
4056+
"content": {
4057+
"application/json": {
4058+
"schema": {
4059+
"$ref": "#/components/schemas/DomainInfo"
4060+
}
4061+
}
4062+
},
4063+
"description": "domain info"
4064+
},
4065+
"400": {
4066+
"$ref": "#/components/responses/BadRequest"
4067+
},
4068+
"401": {
4069+
"$ref": "#/components/responses/UnauthorizedError"
4070+
},
4071+
"404": {
4072+
"$ref": "#/components/responses/NotFound"
4073+
},
4074+
"500": {
4075+
"$ref": "#/components/responses/InternalError"
4076+
}
4077+
},
4078+
"tags": [
4079+
"DNS"
4080+
]
4081+
}
4082+
},
40274083
"/v2/dns/{domain_name}/bids": {
40284084
"get": {
40294085
"description": "Get domain bids",

api/openapi.yml

+36-2
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,29 @@ paths:
798798
'500':
799799
$ref: '#/components/responses/InternalError'
800800

801+
/v2/dns/{domain_name}:
802+
get:
803+
description: get full information about domain name
804+
operationId: dnsInfo
805+
tags:
806+
- DNS
807+
parameters:
808+
- $ref: '#/components/parameters/domainNameParameter'
809+
responses:
810+
'200':
811+
description: "domain info"
812+
content:
813+
application/json:
814+
schema:
815+
$ref: '#/components/schemas/DomainInfo'
816+
'401':
817+
$ref: '#/components/responses/UnauthorizedError'
818+
'400':
819+
$ref: '#/components/responses/BadRequest'
820+
'404':
821+
$ref: '#/components/responses/NotFound'
822+
'500':
823+
$ref: '#/components/responses/InternalError'
801824
/v2/dns/{domain_name}/resolve:
802825
get:
803826
description: DNS resolve for domain name
@@ -1487,7 +1510,7 @@ components:
14871510
type: integer
14881511
default: 30
14891512
minimum: 1
1490-
maximum: 90
1513+
maximum: 360
14911514
collectionQuery:
14921515
in: query
14931516
name: collection
@@ -3053,7 +3076,18 @@ components:
30533076
items:
30543077
type: string
30553078
example: "name"
3056-
3079+
DomainInfo:
3080+
type: object
3081+
required:
3082+
- name
3083+
properties:
3084+
name:
3085+
type: string
3086+
expiring_at:
3087+
type: integer
3088+
description: date of expiring. optional. not all domain in ton has expiration date
3089+
item:
3090+
$ref: '#/components/schemas/NftItem'
30573091
DnsRecord:
30583092
type: object
30593093
required:

pkg/api/interfaces.go

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type storage interface {
4141
GetTFPools(ctx context.Context) ([]core.TFPool, error)
4242
GetTFPool(ctx context.Context, pool tongo.AccountID) (core.TFPool, error)
4343
GetLiquidPool(ctx context.Context, pool tongo.AccountID) (core.LiquidPool, error)
44+
GetLiquidPools(ctx context.Context) ([]core.LiquidPool, error)
4445

4546
GetNFTs(ctx context.Context, accounts []tongo.AccountID) ([]core.NftItem, error)
4647
SearchNFTs(ctx context.Context,

pkg/api/staking_converters.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,16 @@ func convertStakingTFPool(p core.TFPool, info addressbook.TFPoolInfo, apy float6
4646
}
4747

4848
func convertLiquidStaking(p core.LiquidPool, apy float64) oas.PoolInfo {
49-
5049
name := p.Address.ToHuman(true, false)
51-
5250
return oas.PoolInfo{
5351
Address: p.Address.ToRaw(),
5452
Name: name,
5553
TotalAmount: p.TotalAmount,
5654
Implementation: oas.PoolInfoImplementationLiquidTF,
57-
Apy: apy * 0.6,
55+
Apy: 330,
5856
MinStake: 10,
5957
Verified: p.VerifiedSources,
60-
CurrentNominators: 0,
58+
CurrentNominators: 1,
6159
MaxNominators: 0,
6260
}
6361
}

pkg/api/staking_handlers.go

+13
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ func (h Handler) StakingPools(ctx context.Context, params oas.StakingPoolsParams
107107
result.Pools = append(result.Pools, pool)
108108
}
109109

110+
liquidPools, err := h.storage.GetLiquidPools(ctx)
111+
if err != nil {
112+
return nil, err
113+
}
114+
for _, p := range liquidPools {
115+
result.Pools = append(result.Pools, convertLiquidStaking(p, h.state.GetAPY()))
116+
}
117+
110118
slices.SortFunc(result.Pools, func(a, b oas.PoolInfo) bool {
111119
return a.Apy > b.Apy
112120
})
@@ -124,6 +132,11 @@ func (h Handler) StakingPools(ctx context.Context, params oas.StakingPoolsParams
124132
Description: i18n.T(params.AcceptLanguage.Value, i18n.C{MessageID: "poolImplementationDescription", TemplateData: map[string]interface{}{"Deposit": minTF / 1_000_000_000}}),
125133
URL: references.TFPoolImplementationsURL,
126134
},
135+
string(oas.PoolInfoImplementationLiquidTF): {
136+
Name: references.LiquidImplementationsName,
137+
Description: i18n.T(params.AcceptLanguage.Value, i18n.C{MessageID: "poolImplementationDescription", TemplateData: map[string]interface{}{"Deposit": 10}}),
138+
URL: references.LiquidImplementationsUrl,
139+
},
127140
})
128141

129142
return &result, nil

pkg/litestorage/stacking.go

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7+
78
"github.com/prometheus/client_golang/prometheus"
89

910
"github.com/tonkeeper/opentonapi/pkg/core"
@@ -151,3 +152,7 @@ func (s *LiteStorage) GetLiquidPool(ctx context.Context, pool tongo.AccountID) (
151152
VerifiedSources: bytes.Equal(hash, references.TFLiquidPoolCodeHash[:]),
152153
}, err
153154
}
155+
156+
func (s *LiteStorage) GetLiquidPools(ctx context.Context) ([]core.LiquidPool, error) {
157+
return nil, nil
158+
}

pkg/oas/oas_client_gen.go

+76
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/oas/oas_handlers_gen.go

+99
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)