Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
shunjizhan committed Oct 23, 2024
2 parents 25883bc + b6b184e commit bd20d08
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 58 deletions.
105 changes: 53 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,59 @@ data: {
// similar to /routeXcm
```

### `/shouldRouteDropAndBootstrap`
checks if the relayer can route this request, returns router address
```
GET /shouldRouteDropAndBootstrap
params: {
recipient: string; // dest evm address
gasDrop: boolean; // whether to perform gas drop, only available when feeToken is 'jitosol'
feeToken: string; // token to pay for router fee, either 'jitosol' or 'ldot'
}
```

example
```
GET /shouldRouteDropAndBootstrap?recipient=0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6&gasDrop=1&feeToken=jitosol
=>
{
"data": {
"shouldRoute": true,
"routerAddr": "0xC3FaCa03c514C5e47cf267f971B50280E5ea780b"
}
}
```

### `/routeDropAndBootstrap`
- when calling for the first time: route and perform gas drop (if `gasDrop` is true)
- when calling for the second time: route only

returns the txhash

```
POST /routeDropAndBootstrap
params: {
recipient: string; // dest evm address
gasDrop: boolean; // whether to perform gas drop, only available when feeToken is 'jitosol'
feeToken: string; // token to pay for router fee, either 'jitosol' or 'ldot'
}
```

example
```
POST /routeDropAndBootstrap
{
"recipient":"0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6",
"gasDrop": true,
"feeToken": "jitosol"
}
=> tx hash
{
data: '0xede191f4de90057d320c0d06388e7357edb7bcd6b437a5035dd63dfc8809ce7e'
}
```

### `/shouldRouteSwapAndLp`
checks if the relayer can route this request, returns router address
```
Expand Down Expand Up @@ -649,58 +702,6 @@ data: {
// similar to /routeXcm
```

### `/shouldRouteDropAndBootstrap`
checks if the relayer can route this request, returns router address
```
GET /shouldRouteDropAndBootstrap
params: {
recipient: string; // dest evm address
gasDrop: boolean; // whether to perform gas drop, only available when feeToken is 'jitosol'
feeToken: string; // token to pay for router fee, either 'jitosol' or 'ldot'
}
```

example
```
GET /shouldRouteDropAndBootstrap?recipient=0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6&gasDrop=1&feeToken=jitosol
=>
{
"data": {
"shouldRoute": true,
"routerAddr": "0xC3FaCa03c514C5e47cf267f971B50280E5ea780b"
}
}
```

### `/routeDropAndBootstrap`
- when calling for the first time: route and perform gas drop (if `gasDrop` is true)
- when calling for the second time: route only

returns the txhash

```
POST /routeDropAndBootstrap
params: {
recipient: string; // dest evm address
gasDrop: boolean; // whether to perform gas drop, only available when feeToken is 'jitosol'
feeToken: string; // token to pay for router fee, either 'jitosol' or 'ldot'
}
```

example
```
POST /routeDropAndBootstrap
{
"recipient":"0x0085560b24769dAC4ed057F1B2ae40746AA9aAb6",
"gasDrop": true,
"feeToken": "jitosol"
}
=> tx hash
{
data: '0xede191f4de90057d320c0d06388e7357edb7bcd6b437a5035dd63dfc8809ce7e'
}
```

## Routing Process
A complete working flow can be found in [routing e2e tests](./src/__tests__/route.test.ts).
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ export const api = {
shouldRouteEuphrates: _axiosGet(apiUrl.shouldRouteEuphrates),
routeEuphrates: _axiosPost(apiUrl.routeEuphrates),

shouldRouteSwapAndLp: _axiosGet(apiUrl.shouldRouteSwapAndLp),
routeSwapAndLp: _axiosPost(apiUrl.routeSwapAndLp),

shouldRouteDropAndBootstrap: _axiosGet(apiUrl.shouldRouteDropAndBootstrap),
routeDropAndBootstrap: _axiosPost(apiUrl.routeDropAndBootstrap),

shouldRouteSwapAndLp: _axiosGet(apiUrl.shouldRouteSwapAndLp),
routeSwapAndLp: _axiosPost(apiUrl.routeSwapAndLp),

routerInfo: _axiosGet(apiUrl.routerInfo),
saveRouterInfo: _axiosPost(apiUrl.saveRouterInfo),

Expand Down
6 changes: 3 additions & 3 deletions src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ export const apiUrl = {
shouldRouteEuphrates: getRelayerUrl('/shouldRouteEuphrates'),
routeEuphrates: getRelayerUrl('/routeEuphrates'),

shouldRouteSwapAndLp: getRelayerUrl('/shouldRouteSwapAndLp'),
routeSwapAndLp: getRelayerUrl('/routeSwapAndLp'),

shouldRouteDropAndBootstrap: getRelayerUrl('/shouldRouteDropAndBootstrap'),
routeDropAndBootstrap: getRelayerUrl('/routeDropAndBootstrap'),

shouldRouteSwapAndLp: getRelayerUrl('/shouldRouteSwapAndLp'),
routeSwapAndLp: getRelayerUrl('/routeSwapAndLp'),

routerInfo: getRelayerUrl('/routerInfo'),
saveRouterInfo: getRelayerUrl('/saveRouterInfo'),

Expand Down
3 changes: 3 additions & 0 deletions src/middlewares/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ const ROUTER_CONFIGS: {
schema: swapAndRouteSchema,
handler: shouldSwapAndRoute,
},
<<<<<<< HEAD
'/shouldRouteSwapAndLp': {
schema: swapAndLpSchema,
handler: shouldRouteSwapAndLp,
},
=======
>>>>>>> master
'/shouldRouteDropAndBootstrap': {
schema: dropAndBootstrapSchema,
handler: shouldRouteDropAndBoostrap,
Expand Down
3 changes: 3 additions & 0 deletions src/utils/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const routeEuphratesSchema: ObjectSchema<RouteParamsEuphrates> = object({

export const swapAndRouteSchema = routeEuphratesSchema;

<<<<<<< HEAD
export const swapAndLpSchema: ObjectSchema<SwapAndLpParams> = object({
poolId: string().required(),
recipient: string().required(),
Expand All @@ -133,6 +134,8 @@ export const swapAndLpSchema: ObjectSchema<SwapAndLpParams> = object({
minShareAmount: string(),
});

=======
>>>>>>> master
export const dropAndBootstrapSchema: ObjectSchema<DropAndBootstrapParams> = object({
recipient: string().required(),
gasDrop: boolean().required(),
Expand Down

0 comments on commit bd20d08

Please sign in to comment.