From d9410788e45f6e51dfc4e2726f4513aee8093b06 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Thu, 23 Nov 2023 17:47:36 +0800 Subject: [PATCH 1/3] feat: api package add Permit2 getPullTokenTokenList --- .changeset/great-kings-tickle.md | 5 +++++ packages/api/src/protocols/permit2/pull-token.ts | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/great-kings-tickle.md diff --git a/.changeset/great-kings-tickle.md b/.changeset/great-kings-tickle.md new file mode 100644 index 00000000..692475bb --- /dev/null +++ b/.changeset/great-kings-tickle.md @@ -0,0 +1,5 @@ +--- +'@protocolink/api': patch +--- + +add Permit2 getPullTokenTokenList diff --git a/packages/api/src/protocols/permit2/pull-token.ts b/packages/api/src/protocols/permit2/pull-token.ts index 05fd028b..5c88c7e4 100644 --- a/packages/api/src/protocols/permit2/pull-token.ts +++ b/packages/api/src/protocols/permit2/pull-token.ts @@ -1,11 +1,16 @@ import { Logic } from 'src/types'; import * as common from '@protocolink/common'; +import { getProtocolTokenList } from 'src/api'; import * as logics from '@protocolink/logics'; export type PullTokenFields = common.Declasifying; export type PullTokenLogic = Logic; +export async function getPullTokenTokenList(chainId: number): Promise { + return getProtocolTokenList(chainId, logics.permit2.PullTokenLogic.rid); +} + export function newPullTokenLogic(fields: PullTokenFields): PullTokenLogic { return { rid: logics.permit2.PullTokenLogic.rid, fields }; } From 4c9759088a426a618bddc20ab071f38549e7f83c Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Thu, 23 Nov 2023 17:49:38 +0800 Subject: [PATCH 2/3] feat: api package add Spark api --- .changeset/smart-berries-end.md | 5 ++++ packages/api/package.json | 2 +- packages/api/src/protocols/index.ts | 1 + packages/api/src/protocols/spark/borrow.ts | 16 +++++++++++ .../api/src/protocols/spark/flash-loan.ts | 27 +++++++++++++++++++ packages/api/src/protocols/spark/index.ts | 5 ++++ packages/api/src/protocols/spark/repay.ts | 22 +++++++++++++++ packages/api/src/protocols/spark/supply.ts | 25 +++++++++++++++++ packages/api/src/protocols/spark/withdraw.ts | 25 +++++++++++++++++ yarn.lock | 8 +++--- 10 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 .changeset/smart-berries-end.md create mode 100644 packages/api/src/protocols/spark/borrow.ts create mode 100644 packages/api/src/protocols/spark/flash-loan.ts create mode 100644 packages/api/src/protocols/spark/index.ts create mode 100644 packages/api/src/protocols/spark/repay.ts create mode 100644 packages/api/src/protocols/spark/supply.ts create mode 100644 packages/api/src/protocols/spark/withdraw.ts diff --git a/.changeset/smart-berries-end.md b/.changeset/smart-berries-end.md new file mode 100644 index 00000000..af51500d --- /dev/null +++ b/.changeset/smart-berries-end.md @@ -0,0 +1,5 @@ +--- +'@protocolink/api': major +--- + +add Spark api, skip Spark test diff --git a/packages/api/package.json b/packages/api/package.json index 748e737e..0ccaae94 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -28,7 +28,7 @@ "dependencies": { "@protocolink/common": "^0.3.4", "@protocolink/core": "^0.4.4", - "@protocolink/logics": "^0.4.7", + "@protocolink/logics": "^1.0.0", "@types/lodash": "^4.14.195", "@types/uuid": "^9.0.2", "@uniswap/permit2-sdk": "^1.2.0", diff --git a/packages/api/src/protocols/index.ts b/packages/api/src/protocols/index.ts index 7d42fb9e..7cb65ca0 100644 --- a/packages/api/src/protocols/index.ts +++ b/packages/api/src/protocols/index.ts @@ -6,6 +6,7 @@ export * as openoceanv2 from './openocean-v2'; export * as paraswapv5 from './paraswap-v5'; export * as permit2 from './permit2'; export * as radiantv2 from './radiant-v2'; +export * as spark from './spark'; export * as syncswap from './syncswap'; export * as uniswapv3 from './uniswap-v3'; export * as utility from './utility'; diff --git a/packages/api/src/protocols/spark/borrow.ts b/packages/api/src/protocols/spark/borrow.ts new file mode 100644 index 00000000..ebc8d8f9 --- /dev/null +++ b/packages/api/src/protocols/spark/borrow.ts @@ -0,0 +1,16 @@ +import { Logic } from 'src/types'; +import * as common from '@protocolink/common'; +import { getProtocolTokenList } from 'src/api'; +import * as logics from '@protocolink/logics'; + +export type BorrowFields = common.Declasifying; + +export type BorrowLogic = Logic; + +export async function getBorrowTokenList(chainId: number): Promise { + return getProtocolTokenList(chainId, logics.spark.BorrowLogic.rid); +} + +export function newBorrowLogic(fields: BorrowFields): BorrowLogic { + return { rid: logics.spark.BorrowLogic.rid, fields }; +} diff --git a/packages/api/src/protocols/spark/flash-loan.ts b/packages/api/src/protocols/spark/flash-loan.ts new file mode 100644 index 00000000..d73f71b1 --- /dev/null +++ b/packages/api/src/protocols/spark/flash-loan.ts @@ -0,0 +1,27 @@ +import { FlashLoanFields, FlashLoanLogic } from 'src/types'; +import * as common from '@protocolink/common'; +import { getProtocolTokenList, quote } from 'src/api'; +import * as logics from '@protocolink/logics'; +import { v4 as uuid } from 'uuid'; + +export type FlashLoanParams = common.Declasifying; + +export async function getFlashLoanTokenList(chainId: number): Promise { + return getProtocolTokenList(chainId, logics.spark.FlashLoanLogic.rid); +} + +export async function getFlashLoanQuotation( + chainId: number, + params: FlashLoanParams +): Promise { + return quote(chainId, logics.spark.FlashLoanLogic.rid, params); +} + +export function newFlashLoanLogic(fields: FlashLoanFields): FlashLoanLogic { + return { rid: logics.spark.FlashLoanLogic.rid, fields }; +} + +export function newFlashLoanLogicPair(loans: FlashLoanFields['loans']): [FlashLoanLogic, FlashLoanLogic] { + const id = uuid(); + return [newFlashLoanLogic({ id, loans, isLoan: true }), newFlashLoanLogic({ id, loans, isLoan: false })]; +} diff --git a/packages/api/src/protocols/spark/index.ts b/packages/api/src/protocols/spark/index.ts new file mode 100644 index 00000000..c58ec09e --- /dev/null +++ b/packages/api/src/protocols/spark/index.ts @@ -0,0 +1,5 @@ +export * from './borrow'; +export * from './supply'; +export * from './flash-loan'; +export * from './repay'; +export * from './withdraw'; diff --git a/packages/api/src/protocols/spark/repay.ts b/packages/api/src/protocols/spark/repay.ts new file mode 100644 index 00000000..59d15880 --- /dev/null +++ b/packages/api/src/protocols/spark/repay.ts @@ -0,0 +1,22 @@ +import { Logic } from 'src/types'; +import * as common from '@protocolink/common'; +import { getProtocolTokenList, quote } from 'src/api'; +import * as logics from '@protocolink/logics'; + +export type RepayParams = common.Declasifying; + +export type RepayFields = common.Declasifying; + +export type RepayLogic = Logic; + +export async function getRepayTokenList(chainId: number): Promise { + return getProtocolTokenList(chainId, logics.spark.RepayLogic.rid); +} + +export async function getRepayQuotation(chainId: number, params: RepayParams): Promise { + return quote(chainId, logics.spark.RepayLogic.rid, params); +} + +export function newRepayLogic(fields: RepayFields): RepayLogic { + return { rid: logics.spark.RepayLogic.rid, fields }; +} diff --git a/packages/api/src/protocols/spark/supply.ts b/packages/api/src/protocols/spark/supply.ts new file mode 100644 index 00000000..10e0770e --- /dev/null +++ b/packages/api/src/protocols/spark/supply.ts @@ -0,0 +1,25 @@ +import { Logic } from 'src/types'; +import * as common from '@protocolink/common'; +import { getProtocolTokenList, quote } from 'src/api'; +import * as logics from '@protocolink/logics'; + +export type SupplyParams = common.Declasifying; + +export type SupplyFields = common.Declasifying; + +export type SupplyLogic = Logic; + +export async function getSupplyTokenList(chainId: number): Promise { + return getProtocolTokenList(chainId, logics.spark.SupplyLogic.rid); +} + +export async function getSupplyQuotation( + chainId: number, + params: SupplyParams +): Promise { + return quote(chainId, logics.spark.SupplyLogic.rid, params); +} + +export function newSupplyLogic(fields: SupplyFields): SupplyLogic { + return { rid: logics.spark.SupplyLogic.rid, fields }; +} diff --git a/packages/api/src/protocols/spark/withdraw.ts b/packages/api/src/protocols/spark/withdraw.ts new file mode 100644 index 00000000..0fb136ff --- /dev/null +++ b/packages/api/src/protocols/spark/withdraw.ts @@ -0,0 +1,25 @@ +import { Logic } from 'src/types'; +import * as common from '@protocolink/common'; +import { getProtocolTokenList, quote } from 'src/api'; +import * as logics from '@protocolink/logics'; + +export type WithdrawParams = common.Declasifying; + +export type WithdrawFields = common.Declasifying; + +export type WithdrawLogic = Logic; + +export async function getWithdrawTokenList(chainId: number): Promise { + return getProtocolTokenList(chainId, logics.spark.WithdrawLogic.rid); +} + +export async function getWithdrawQuotation( + chainId: number, + params: WithdrawParams +): Promise { + return quote(chainId, logics.spark.WithdrawLogic.rid, params); +} + +export function newWithdrawLogic(fields: WithdrawFields): WithdrawLogic { + return { rid: logics.spark.WithdrawLogic.rid, fields }; +} diff --git a/yarn.lock b/yarn.lock index f93bfa00..257f9d92 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1080,10 +1080,10 @@ node-addon-api "^3.2.1" node-gyp-build "^4.3.0" -"@protocolink/logics@^0.4.7": - version "0.4.7" - resolved "https://registry.yarnpkg.com/@protocolink/logics/-/logics-0.4.7.tgz#74e146eba180a86774427fb9a5d79693061ce2ff" - integrity sha512-d82jyN0RVJtTtZohTURmZY4RL0ReUPbp6Ir746sM42u2gr9d8PYuDkbFir0mS43FHqAiKUKrTGfCvDProJ9NJw== +"@protocolink/logics@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@protocolink/logics/-/logics-1.0.0.tgz#6b4a229d11ad4ab1bd35f20eaeaf25b0574621ea" + integrity sha512-tXm2V4e6o67V7A8pvBi4mVvp78jrSGHCFpsFpPHxguRHlWEFDm80MsbrhFh7NPnrbQvXwMtoIVK48hygSeXhnQ== dependencies: "@paraswap/sdk" "^6.2.2" "@protocolink/common" "^0.3.4" From d156957612d672186350d866eff45bcd23a907ce Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Fri, 24 Nov 2023 11:36:11 +0800 Subject: [PATCH 3/3] chore: version package @protocolink/api@1.0.0 --- .changeset/great-kings-tickle.md | 5 ----- .changeset/smart-berries-end.md | 5 ----- packages/api/CHANGELOG.md | 10 ++++++++++ packages/api/package.json | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 .changeset/great-kings-tickle.md delete mode 100644 .changeset/smart-berries-end.md diff --git a/.changeset/great-kings-tickle.md b/.changeset/great-kings-tickle.md deleted file mode 100644 index 692475bb..00000000 --- a/.changeset/great-kings-tickle.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@protocolink/api': patch ---- - -add Permit2 getPullTokenTokenList diff --git a/.changeset/smart-berries-end.md b/.changeset/smart-berries-end.md deleted file mode 100644 index af51500d..00000000 --- a/.changeset/smart-berries-end.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@protocolink/api': major ---- - -add Spark api, skip Spark test diff --git a/packages/api/CHANGELOG.md b/packages/api/CHANGELOG.md index b56a36a0..aabeee53 100644 --- a/packages/api/CHANGELOG.md +++ b/packages/api/CHANGELOG.md @@ -1,5 +1,15 @@ # @furucombo/composable-router-api +## 1.0.0 + +### Major Changes + +- 4c97590: add Spark api, skip Spark test + +### Patch Changes + +- d941078: add Permit2 getPullTokenTokenList + ## 0.4.8 ### Patch Changes diff --git a/packages/api/package.json b/packages/api/package.json index 0ccaae94..cbd6f77f 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@protocolink/api", - "version": "0.4.8", + "version": "1.0.0", "description": "Protocolink API SDK", "keywords": [ "furucombo",