Skip to content

Commit 0fa43b8

Browse files
authored
feat: Add deBridge plugin (#364)
* add deBridge plugin * Update deBridge plugin readme * Update deBridge plugin readme and add linting * Update get_supported_chains tool and add author information
1 parent faec658 commit 0fa43b8

File tree

5 files changed

+560
-0
lines changed

5 files changed

+560
-0
lines changed

python/src/plugins/debridge/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# deBridge Plugin for GOAT SDK
2+
3+
A plugin for the GOAT SDK that provides access to deBridge Liquidity Network (DLN) functionality.
4+
5+
## Installation
6+
7+
```bash
8+
# Install the plugin
9+
poetry add goat-sdk-plugin-debridge
10+
11+
12+
```
13+
14+
## Usage
15+
16+
```python
17+
from goat_plugins.debridge import debridge, DebridgePluginOptions
18+
19+
# Initialize the plugin
20+
options = DebridgePluginOptions()
21+
plugin = debridge(options)
22+
23+
# Get order data
24+
order_data = await plugin.get_order_data(
25+
id="0x81fbb0ed8209eb57d084aee1986c00e597c1e1ec6bb93bc4dbe97266ca0398fb"
26+
)
27+
28+
# Get supported chains
29+
chains = await plugin.get_supported_chains()
30+
31+
# Get order IDs
32+
order_IDs = await plugin.get_order_IDs(
33+
hash="0xbe9071de34de9bd84a52039bc4bc6c8229d4bd65127d034ffc66b600d8260276" # Hash of the creation transaction
34+
)
35+
```
36+
37+
## Features
38+
39+
- DLN
40+
- Create order transaction `create_order_transaction`
41+
- Get order data `get_order_data`
42+
- Get order status `get_order_status`
43+
- Get order IDs `get_order_IDs`
44+
- Cancel order `cancel_order`
45+
- Cancel external call `cancel_external_call`
46+
- Utils
47+
- Get supported chains `get_supported_chains`
48+
- Get token list `get_token_list`
49+
- Single Chain Swap
50+
- Estimation `single_chain_swap_estimation`
51+
- Transaction `single_chain_swap_transaction`
52+
53+
### DLN Swagger Docs
54+
The deBridge plugin tools is a 1-to-1 representation of the DLN API.
55+
You can access the [deBridge Swagger docs](https://dln.debridge.finance/v1.0) page for more information about the various parameters.
56+
57+
## License
58+
59+
This project is licensed under the terms of the MIT license.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from dataclasses import dataclass
2+
from goat.classes.plugin_base import PluginBase
3+
from .service import DebridgeService
4+
5+
6+
@dataclass
7+
class DebridgePluginOptions:
8+
# Debridge currently doesn't require any auth keys
9+
pass
10+
11+
12+
class DebridgePlugin(PluginBase):
13+
14+
def __init__(self, options: DebridgePluginOptions):
15+
super().__init__("debridge", [DebridgeService()])
16+
17+
def supports_chain(self, chain) -> bool:
18+
return True
19+
20+
21+
def debridge(options: DebridgePluginOptions) -> DebridgePlugin:
22+
return DebridgePlugin(options)
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
from pydantic import BaseModel, Field
2+
from typing import Optional
3+
4+
5+
class EmptyParameters(BaseModel):
6+
pass
7+
8+
9+
class GetTokenListParameters(BaseModel):
10+
chainId: str = Field(description="ID of a chain")
11+
12+
13+
class GetOrderDataParameters(BaseModel):
14+
id: str = Field(description="ID of the order")
15+
16+
17+
class GetOrderStatusParameters(BaseModel):
18+
id: str = Field(description="ID of the order")
19+
20+
21+
class GetOrderIDsParameters(BaseModel):
22+
hash: str = Field(description="Hash of the creation transaction")
23+
24+
25+
class CancelOrderParameters(BaseModel):
26+
id: str = Field(description="ID of the order")
27+
28+
29+
class CancelExternalCallParameters(BaseModel):
30+
id: str = Field(description="ID of the order")
31+
32+
33+
class CreateOrderTransactionParameters(BaseModel):
34+
srcChainId: str = Field(
35+
description=
36+
"An ID of a source chain, a chain where the cross-chain swap will start"
37+
)
38+
srcChainTokenIn: str = Field(
39+
description="An address (on a source chain) of an input token to swap")
40+
srcChainTokenInAmount: str = Field(
41+
description="An amount of input tokens to swap")
42+
dstChainId: str = Field(
43+
description=
44+
"An ID of a destination chain, a chain where the cross-chain swap will finish. Must differ from srcChainId!"
45+
)
46+
dstChainTokenOut: str = Field(
47+
description="An address (on a destination chain) of a target token")
48+
dstChainTokenOutAmount: Optional[str] = Field(
49+
default="auto",
50+
description=
51+
"Amount of the target asset the market maker expects to receive upon order fulfillment.",
52+
)
53+
additionalTakerRewardBps: Optional[int] = Field(
54+
description=
55+
"additionalTakerRewardBps is additionally laid in on top of default taker margin"
56+
)
57+
srcIntermediaryTokenAddress: Optional[str] = Field(
58+
description=
59+
"An address (on a source chain) of an intermediary token a user's input funds should be swapped to prior order creation"
60+
)
61+
dstIntermediaryTokenAddress: Optional[str] = Field(
62+
description=
63+
"An address (on a destination chain) of an intermediary token whose value assumed to be equal to the value of srcIntermediaryTokenAddress"
64+
)
65+
dstIntermediaryTokenSpenderAddress: Optional[str] = Field(
66+
description=
67+
"Applicable to a EVM-compatible destination chain. An address (on a EVM-compatible destination chain) assumed as a spender of the intermediary token (set as dstIntermediaryTokenAddress) during order fulfillment"
68+
)
69+
intermediaryTokenUSDPrice: Optional[float] = Field(
70+
description=
71+
"A value (a spot price) of the given intermediary token expressed in US dollars"
72+
)
73+
dstChainTokenOutRecipient: Optional[str] = Field(
74+
description=
75+
"Address (on the destination chain) where target tokens should be transferred to after the swap. Required for transaction construction, otherwise only the quote is returned!"
76+
)
77+
senderAddress: Optional[str] = Field(
78+
description=
79+
"Address (on the source chain) who submits input tokens for a cross-chain swap"
80+
)
81+
srcChainOrderAuthorityAddress: Optional[str] = Field(
82+
description=
83+
"Address (on the source chain) who submits input tokens for a cross-chain swap. Required for transaction construction, otherwise only the quote is returned!"
84+
)
85+
srcAllowedCancelBeneficiary: Optional[str] = Field(
86+
description=
87+
"Fixed recipient of the funds of an order in case it is being cancelled. If not set, the recipient could be set later upon order cancellation"
88+
)
89+
referralCode: Optional[float] = Field(
90+
default=31494,
91+
description=
92+
"Your referral code which can be generated here: https://app.debridge.finance/refer",
93+
)
94+
affiliateFeePercent: Optional[float] = Field(
95+
default=0,
96+
description=
97+
"The share of the input amount to be distributed to the affiliateFeeRecipient (if given) address as an affiliate fee",
98+
)
99+
affiliateFeeRecipient: Optional[str] = Field(
100+
description=
101+
"An address (on an origin chain) that will receive affiliate fees according to the affiliateFeePercent parameter"
102+
)
103+
srcChainTokenInSenderPermit: Optional[str] = Field(
104+
description=
105+
"Typically, a sender is required to approve token transfer to deBridge forwarder for further transfer and swap"
106+
)
107+
dstChainOrderAuthorityAddress: Optional[str] = Field(
108+
description=
109+
"Address on the destination chain whom should be granted the privileges to manage the order (patch, cancel, etc). Required for transaction construction, otherwise only the quote is returned!"
110+
)
111+
enableEstimate: Optional[bool] = Field(
112+
description=
113+
"This flag forces deSwap API to validate the resulting transaction and estimate its gas consumption"
114+
)
115+
allowedTaker: Optional[str] = Field(
116+
description="An address (on a destination chain) of a allowed taker")
117+
dlnHook: Optional[str] = Field(
118+
description="JSON representing a DLN Hook to be attached to an order")
119+
prependOperatingExpenses: Optional[bool] = Field(
120+
default=False,
121+
description=
122+
"Tells API server to prepend operating expenses to the input amount",
123+
)
124+
metadata: Optional[str] = Field(default=False, description="Metadata")
125+
ptp: Optional[bool] = Field(
126+
default=False,
127+
description=
128+
"Forces a P2P order where input and output tokens are left intact",
129+
)
130+
skipSolanaRecipientValidation: Optional[bool] = Field(
131+
default=False,
132+
description=
133+
"Skip system address validation dstChainTokenOutRecipient in Solana",
134+
)
135+
136+
137+
class SingleChainSwapEstimationParameters(BaseModel):
138+
chainId: str = Field(
139+
description="An ID of a chain, a chain where the swap must be performed"
140+
)
141+
tokenIn: str = Field(description="An address of an input token to swap")
142+
tokenInAmount: str = Field(description="An amount of input tokens to swap")
143+
slippage: Optional[str] = Field(
144+
default="auto",
145+
description=
146+
"A slippage constraint (in %) is a safeguard during swaps (on both source and destination chains, if applicable). It is also used to calculate the minimum possible outcome during estimation",
147+
)
148+
tokenOut: str = Field(description="An address of a target token")
149+
affiliateFeePercent: Optional[float] = Field(
150+
default=0,
151+
description=
152+
"The share of the input amount to be distributed to the affiliateFeeRecipient (if given) address as an affiliate fee",
153+
)
154+
affiliateFeeRecipient: Optional[str] = Field(
155+
description=
156+
"An address (on an origin chain) that will receive affiliate fees according to the affiliateFeePercent parameter"
157+
)
158+
159+
160+
class SingleChainSwapTransactionParameters(BaseModel):
161+
chainId: str = Field(
162+
description="An ID of a chain, a chain where the swap must be performed"
163+
)
164+
tokenIn: str = Field(description="An address of an input token to swap")
165+
tokenInAmount: str = Field(description="An amount of input tokens to swap")
166+
slippage: Optional[str] = Field(
167+
default="auto",
168+
description=
169+
"A slippage constraint (in %) is a safeguard during swaps (on both source and destination chains, if applicable). It is also used to calculate the minimum possible outcome during estimation",
170+
)
171+
tokenOut: str = Field(description="An address of a target token")
172+
tokenOutRecipient: str = Field(
173+
description="Address who receives the tokens from the swap")
174+
affiliateFeePercent: Optional[float] = Field(
175+
default=0,
176+
description=
177+
"The share of the input amount to be distributed to the affiliateFeeRecipient (if given) address as an affiliate fee",
178+
)
179+
affiliateFeeRecipient: Optional[str] = Field(
180+
description=
181+
"An address (on an origin chain) that will receive affiliate fees according to the affiliateFeePercent parameter"
182+
)
183+
senderAddress: Optional[str] = Field(
184+
description=
185+
"Address (on the source chain) who submits input tokens for a cross-chain swap"
186+
)

0 commit comments

Comments
 (0)