Skip to content

Commit

Permalink
Merge branch 'master' into feature/add_lending_sdk_20231108
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Lu committed Nov 27, 2023
2 parents d5ee967 + d156957 commit adab5f1
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 10 deletions.
10 changes: 10 additions & 0 deletions packages/api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@protocolink/api",
"version": "0.4.8",
"version": "1.0.0",
"description": "Protocolink API SDK",
"keywords": [
"furucombo",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/protocols/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
5 changes: 5 additions & 0 deletions packages/api/src/protocols/permit2/pull-token.ts
Original file line number Diff line number Diff line change
@@ -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<logics.permit2.PullTokenLogicFields>;

export type PullTokenLogic = Logic<PullTokenFields>;

export async function getPullTokenTokenList(chainId: number): Promise<logics.permit2.PullTokenLogicTokenList> {
return getProtocolTokenList(chainId, logics.permit2.PullTokenLogic.rid);
}

export function newPullTokenLogic(fields: PullTokenFields): PullTokenLogic {
return { rid: logics.permit2.PullTokenLogic.rid, fields };
}
16 changes: 16 additions & 0 deletions packages/api/src/protocols/spark/borrow.ts
Original file line number Diff line number Diff line change
@@ -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<logics.spark.BorrowLogicFields>;

export type BorrowLogic = Logic<BorrowFields>;

export async function getBorrowTokenList(chainId: number): Promise<logics.spark.BorrowLogicTokenList> {
return getProtocolTokenList(chainId, logics.spark.BorrowLogic.rid);
}

export function newBorrowLogic(fields: BorrowFields): BorrowLogic {
return { rid: logics.spark.BorrowLogic.rid, fields };
}
27 changes: 27 additions & 0 deletions packages/api/src/protocols/spark/flash-loan.ts
Original file line number Diff line number Diff line change
@@ -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<logics.spark.FlashLoanLogicParams>;

export async function getFlashLoanTokenList(chainId: number): Promise<logics.spark.FlashLoanLogicTokenList> {
return getProtocolTokenList(chainId, logics.spark.FlashLoanLogic.rid);
}

export async function getFlashLoanQuotation(
chainId: number,
params: FlashLoanParams
): Promise<logics.spark.FlashLoanLogicQuotation> {
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 })];
}
5 changes: 5 additions & 0 deletions packages/api/src/protocols/spark/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './borrow';
export * from './supply';
export * from './flash-loan';
export * from './repay';
export * from './withdraw';
22 changes: 22 additions & 0 deletions packages/api/src/protocols/spark/repay.ts
Original file line number Diff line number Diff line change
@@ -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<logics.spark.RepayLogicParams>;

export type RepayFields = common.Declasifying<logics.spark.RepayLogicFields>;

export type RepayLogic = Logic<RepayFields>;

export async function getRepayTokenList(chainId: number): Promise<logics.spark.RepayLogicTokenList> {
return getProtocolTokenList(chainId, logics.spark.RepayLogic.rid);
}

export async function getRepayQuotation(chainId: number, params: RepayParams): Promise<logics.spark.RepayLogicFields> {
return quote(chainId, logics.spark.RepayLogic.rid, params);
}

export function newRepayLogic(fields: RepayFields): RepayLogic {
return { rid: logics.spark.RepayLogic.rid, fields };
}
25 changes: 25 additions & 0 deletions packages/api/src/protocols/spark/supply.ts
Original file line number Diff line number Diff line change
@@ -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<logics.spark.SupplyLogicParams>;

export type SupplyFields = common.Declasifying<logics.spark.SupplyLogicFields>;

export type SupplyLogic = Logic<SupplyFields>;

export async function getSupplyTokenList(chainId: number): Promise<logics.spark.SupplyLogicTokenList> {
return getProtocolTokenList(chainId, logics.spark.SupplyLogic.rid);
}

export async function getSupplyQuotation(
chainId: number,
params: SupplyParams
): Promise<logics.spark.SupplyLogicFields> {
return quote(chainId, logics.spark.SupplyLogic.rid, params);
}

export function newSupplyLogic(fields: SupplyFields): SupplyLogic {
return { rid: logics.spark.SupplyLogic.rid, fields };
}
25 changes: 25 additions & 0 deletions packages/api/src/protocols/spark/withdraw.ts
Original file line number Diff line number Diff line change
@@ -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<logics.spark.WithdrawLogicParams>;

export type WithdrawFields = common.Declasifying<logics.spark.WithdrawLogicFields>;

export type WithdrawLogic = Logic<WithdrawFields>;

export async function getWithdrawTokenList(chainId: number): Promise<logics.spark.WithdrawLogicTokenList> {
return getProtocolTokenList(chainId, logics.spark.WithdrawLogic.rid);
}

export async function getWithdrawQuotation(
chainId: number,
params: WithdrawParams
): Promise<logics.spark.WithdrawLogicFields> {
return quote(chainId, logics.spark.WithdrawLogic.rid, params);
}

export function newWithdrawLogic(fields: WithdrawFields): WithdrawLogic {
return { rid: logics.spark.WithdrawLogic.rid, fields };
}
8 changes: 4 additions & 4 deletions packages/lending/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 6 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit adab5f1

Please sign in to comment.