forked from AngleProtocol/merkl-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
1,265 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"recommendations": [], | ||
"unwantedRecommendations": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports.biome": "explicit" | ||
}, | ||
"editor.defaultFormatter": "biomejs.biome", | ||
"[typescript]": { | ||
"editor.defaultFormatter": "biomejs.biome" | ||
}, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "biomejs.biome" | ||
}, | ||
"editor.formatOnSave": true, | ||
"editor.formatOnType": false, | ||
"editor.foldingImportsByDefault": true, | ||
"editor.foldingHighlight": true, | ||
"editor.foldingStrategy": "auto", | ||
"files.eol": "\n" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule dappkit
updated
12 files
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { api } from "../index.server"; | ||
import { fetchWithLogs } from "../utils"; | ||
|
||
export abstract class ClaimsService { | ||
static async #fetch<R, T extends { data: R; status: number; response: Response }>( | ||
call: () => Promise<T>, | ||
resource = "Claims", | ||
): Promise<NonNullable<T["data"]>> { | ||
const { data, status } = await fetchWithLogs(call); | ||
|
||
if (status === 404) throw new Response(`${resource} not found`, { status }); | ||
if (status === 500) throw new Response(`${resource} unavailable`, { status }); | ||
if (data == null) throw new Response(`${resource} unavailable`, { status }); | ||
return data; | ||
} | ||
|
||
static async getForUser(address: string) { | ||
return await ClaimsService.#fetch(async () => api.v4.claims({ address }).get()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { api as clientApi } from "src/api/index.client"; | ||
import { fetchWithLogs } from "../utils"; | ||
|
||
export abstract class InteractionService { | ||
static async #fetch<R, T extends { data: R; status: number; response: Response }>( | ||
call: () => Promise<T>, | ||
resource = "Chain", | ||
): Promise<NonNullable<T["data"]>> { | ||
const { data, status } = await fetchWithLogs(call); | ||
|
||
if (status === 404) throw new Response(`${resource} not found`, { status }); | ||
if (status === 500) throw new Response(`${resource} unavailable`, { status }); | ||
if (data == null) throw new Response(`${resource} unavailable`, { status }); | ||
return data; | ||
} | ||
|
||
/** | ||
* Client side | ||
* @param chainId | ||
* @param protocolId | ||
* @param identifier | ||
*/ | ||
static async getTarget(chainId: number, protocolId: string, identifier: string) { | ||
const targets = await InteractionService.#fetch(() => | ||
clientApi.v4.interaction.targets.get({ | ||
query: { chainId, protocolId, identifier }, | ||
}), | ||
); | ||
|
||
//TODO: opportunity/:id/target instead of taking the first result and expecting unique | ||
return targets?.[0]; | ||
} | ||
|
||
/** | ||
* Client side | ||
*/ | ||
static async getTransaction(payload: Parameters<typeof clientApi.v4.interaction.transaction.get>[0]["query"]) { | ||
const transaction = await InteractionService.#fetch(() => | ||
clientApi.v4.interaction.transaction.get({ | ||
query: payload, | ||
}), | ||
); | ||
|
||
return transaction; | ||
} | ||
|
||
static async getBalances(chainId: number, address: string) { | ||
const tokens = await InteractionService.#fetch(() => | ||
clientApi.v4.tokens.balances.get({ | ||
query: { chainId: chainId, userAddress: address }, | ||
}), | ||
); | ||
|
||
return tokens; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { api } from "../index.server"; | ||
import { fetchWithLogs } from "../utils"; | ||
|
||
export abstract class LiquidityService { | ||
static async #fetch<R, T extends { data: R; status: number; response: Response }>( | ||
call: () => Promise<T>, | ||
resource = "Positions", | ||
): Promise<NonNullable<T["data"]>> { | ||
const { data, status } = await fetchWithLogs(call); | ||
|
||
if (status === 404) throw new Response(`${resource} not found`, { status }); | ||
if (status === 500) throw new Response(`${resource} unavailable`, { status }); | ||
if (data == null) throw new Response(`${resource} unavailable`, { status }); | ||
return data; | ||
} | ||
|
||
static async getForUser(query: Parameters<typeof api.v4.liquidity.index.get>["0"]["query"]) { | ||
return await LiquidityService.#fetch(async () => api.v4.liquidity.index.get({ query })); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.