Skip to content

Commit

Permalink
rename stonfi swap to jetton swap
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tron committed Jul 22, 2023
1 parent 15b6a15 commit d37493f
Show file tree
Hide file tree
Showing 6 changed files with 605 additions and 493 deletions.
102 changes: 55 additions & 47 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,9 @@
"DepositStake": {
"$ref": "#/components/schemas/DepositStakeAction"
},
"JettonSwap": {
"$ref": "#/components/schemas/JettonSwapAction"
},
"JettonTransfer": {
"$ref": "#/components/schemas/JettonTransferAction"
},
Expand All @@ -867,9 +870,6 @@
"RecoverStake": {
"$ref": "#/components/schemas/RecoverStakeAction"
},
"STONfiSwap": {
"$ref": "#/components/schemas/STONfiSwapAction"
},
"SmartContractExec": {
"$ref": "#/components/schemas/SmartContractAction"
},
Expand Down Expand Up @@ -906,7 +906,7 @@
"NftPurchase",
"DepositStake",
"RecoverStake",
"STONfiSwap",
"JettonSwap",
"SmartContractExec",
"Unknown"
],
Expand Down Expand Up @@ -1918,6 +1918,57 @@
],
"type": "object"
},
"JettonSwapAction": {
"properties": {
"amount_in": {
"example": "1660050553",
"type": "string"
},
"amount_out": {
"example": "1660050553",
"type": "string"
},
"dex": {
"enum": [
"stonfi",
"dedust"
],
"type": "string"
},
"jetton_master_in": {
"$ref": "#/components/schemas/JettonPreview"
},
"jetton_master_out": {
"$ref": "#/components/schemas/JettonPreview"
},
"jetton_wallet_in": {
"example": "0:dea8f638b789172ce36d10a20318125e52c649aa84893cd77858224fe2b9b0ee",
"type": "string"
},
"jetton_wallet_out": {
"example": "0:dea8f638b789172ce36d10a20318125e52c649aa84893cd77858224fe2b9b0ee",
"type": "string"
},
"router": {
"$ref": "#/components/schemas/AccountAddress"
},
"user_wallet": {
"$ref": "#/components/schemas/AccountAddress"
}
},
"required": [
"dex",
"amount_in",
"amount_out",
"user_wallet",
"router",
"jetton_wallet_in",
"jetton_master_in",
"jetton_wallet_out",
"jetton_master_out"
],
"type": "object"
},
"JettonTransferAction": {
"properties": {
"amount": {
Expand Down Expand Up @@ -2561,49 +2612,6 @@
],
"type": "object"
},
"STONfiSwapAction": {
"properties": {
"amount_in": {
"example": "1660050553",
"type": "string"
},
"amount_out": {
"example": "1660050553",
"type": "string"
},
"jetton_master_in": {
"$ref": "#/components/schemas/JettonPreview"
},
"jetton_master_out": {
"$ref": "#/components/schemas/JettonPreview"
},
"jetton_wallet_in": {
"example": "0:dea8f638b789172ce36d10a20318125e52c649aa84893cd77858224fe2b9b0ee",
"type": "string"
},
"jetton_wallet_out": {
"example": "0:dea8f638b789172ce36d10a20318125e52c649aa84893cd77858224fe2b9b0ee",
"type": "string"
},
"stonfi_router": {
"$ref": "#/components/schemas/AccountAddress"
},
"user_wallet": {
"$ref": "#/components/schemas/AccountAddress"
}
},
"required": [
"amount_in",
"amount_out",
"user_wallet",
"stonfi_router",
"jetton_wallet_in",
"jetton_master_in",
"jetton_wallet_out",
"jetton_master_out"
],
"type": "object"
},
"Sale": {
"properties": {
"address": {
Expand Down
18 changes: 12 additions & 6 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3551,7 +3551,7 @@ components:
- NftPurchase
- DepositStake
- RecoverStake
- STONfiSwap
- JettonSwap
- SmartContractExec
- Unknown
status:
Expand Down Expand Up @@ -3581,8 +3581,8 @@ components:
$ref: '#/components/schemas/DepositStakeAction'
RecoverStake:
$ref: '#/components/schemas/RecoverStakeAction'
STONfiSwap:
$ref: '#/components/schemas/STONfiSwapAction'
JettonSwap:
$ref: '#/components/schemas/JettonSwapAction'
SmartContractExec:
$ref: '#/components/schemas/SmartContractAction'
simple_preview:
Expand Down Expand Up @@ -3797,18 +3797,24 @@ components:
staker:
$ref: '#/components/schemas/AccountAddress'

STONfiSwapAction:
JettonSwapAction:
type: object
required:
- dex
- amount_in
- amount_out
- user_wallet
- stonfi_router
- router
- jetton_wallet_in
- jetton_master_in
- jetton_wallet_out
- jetton_master_out
properties:
dex:
type: string
enum:
- stonfi
- dedust
amount_in:
type: string
example: "1660050553"
Expand All @@ -3817,7 +3823,7 @@ components:
example: "1660050553"
user_wallet:
$ref: '#/components/schemas/AccountAddress'
stonfi_router:
router:
$ref: '#/components/schemas/AccountAddress'
jetton_wallet_in:
type: string
Expand Down
8 changes: 5 additions & 3 deletions pkg/api/event_converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,22 +341,24 @@ func (h Handler) convertAction(ctx context.Context, viewer tongo.AccountID, a ba
Accounts: distinctAccounts(h.addressBook, &a.RecoverStake.Elector, &a.RecoverStake.Staker),
}
case bath.STONfiSwap:
action.Type = "JettonSwap"
jettonInMeta := h.GetJettonNormalizedMetadata(ctx, a.STONfiSwap.JettonMasterIn)
jettonInPreview := jettonPreview(a.STONfiSwap.JettonMasterIn, jettonInMeta, h.previewGenerator)
jettonOutMeta := h.GetJettonNormalizedMetadata(ctx, a.STONfiSwap.JettonMasterOut)
jettonOutPreview := jettonPreview(a.STONfiSwap.JettonMasterOut, jettonOutMeta, h.previewGenerator)
action.STONfiSwap.SetTo(oas.STONfiSwapAction{
action.JettonSwap.SetTo(oas.JettonSwapAction{
Dex: oas.JettonSwapActionDexStonfi,
AmountIn: fmt.Sprintf("%v", a.STONfiSwap.AmountIn),
AmountOut: fmt.Sprintf("%v", a.STONfiSwap.AmountOut),
UserWallet: convertAccountAddress(a.STONfiSwap.UserWallet, h.addressBook),
StonfiRouter: convertAccountAddress(a.STONfiSwap.STONfiRouter, h.addressBook),
Router: convertAccountAddress(a.STONfiSwap.STONfiRouter, h.addressBook),
JettonWalletIn: a.STONfiSwap.JettonWalletIn.String(),
JettonMasterIn: jettonInPreview,
JettonWalletOut: a.STONfiSwap.JettonWalletOut.String(),
JettonMasterOut: jettonOutPreview,
})
action.SimplePreview = oas.ActionSimplePreview{
Name: "STONfi Swap",
Name: "Swap Tokens",
Description: i18n.T(acceptLanguage.Value, i18n.C{
MessageID: stonfiSwapMessageID,
TemplateData: map[string]interface{}{
Expand Down
Loading

0 comments on commit d37493f

Please sign in to comment.