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 748e737e..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", @@ -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/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 }; } 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/packages/lending/package.json b/packages/lending/package.json index 0feb2fb9..a7eacebf 100644 --- a/packages/lending/package.json +++ b/packages/lending/package.json @@ -24,10 +24,10 @@ }, "dependencies": { "@aave/math-utils": "^1.21.0", - "@protocolink/api": "0.4.8", - "@protocolink/common": "0.3.4", - "@protocolink/core": "0.4.4", - "@protocolink/logics": "^0.4.4", + "@protocolink/api": "^1.0.0", + "@protocolink/common": "^0.3.4", + "@protocolink/core": "^0.4.4", + "@protocolink/logics": "^1.0.0", "decimal.js-light": "^2.5.1" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index d4abc0d1..dd8d9df8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1085,10 +1085,12 @@ node-addon-api "^3.2.1" node-gyp-build "^4.3.0" -"@protocolink/logics@^0.4.4", "@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"