-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from LuPoYi/feature/add_radiant_v2_logic_20230914
feat: add radiant v2 api
- Loading branch information
Showing
11 changed files
with
174 additions
and
44 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,5 @@ | ||
--- | ||
'@protocolink/api': patch | ||
--- | ||
|
||
add radiant v2, skip radiant v2 test |
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
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,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.radiantv2.BorrowLogicFields>; | ||
|
||
export type BorrowLogic = Logic<BorrowFields>; | ||
|
||
export async function getBorrowTokenList(chainId: number): Promise<logics.radiantv2.BorrowLogicTokenList> { | ||
return getProtocolTokenList(chainId, logics.radiantv2.BorrowLogic.rid); | ||
} | ||
|
||
export function newBorrowLogic(fields: BorrowFields): BorrowLogic { | ||
return { rid: logics.radiantv2.BorrowLogic.rid, fields }; | ||
} |
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,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 DepositParams = common.Declasifying<logics.radiantv2.DepositLogicParams>; | ||
|
||
export type DepositFields = common.Declasifying<logics.radiantv2.DepositLogicFields>; | ||
|
||
export type DepositLogic = Logic<DepositFields>; | ||
|
||
export async function getDepositTokenList(chainId: number): Promise<logics.radiantv2.DepositLogicTokenList> { | ||
return getProtocolTokenList(chainId, logics.radiantv2.DepositLogic.rid); | ||
} | ||
|
||
export async function getDepositQuotation( | ||
chainId: number, | ||
params: DepositParams | ||
): Promise<logics.radiantv2.DepositLogicFields> { | ||
return quote(chainId, logics.radiantv2.DepositLogic.rid, params); | ||
} | ||
|
||
export function newDepositLogic(fields: DepositFields): DepositLogic { | ||
return { rid: logics.radiantv2.DepositLogic.rid, fields }; | ||
} |
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,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.radiantv2.FlashLoanLogicParams>; | ||
|
||
export async function getFlashLoanTokenList(chainId: number): Promise<logics.radiantv2.FlashLoanLogicTokenList> { | ||
return getProtocolTokenList(chainId, logics.radiantv2.FlashLoanLogic.rid); | ||
} | ||
|
||
export async function getFlashLoanQuotation( | ||
chainId: number, | ||
params: FlashLoanParams | ||
): Promise<logics.radiantv2.FlashLoanLogicQuotation> { | ||
return quote(chainId, logics.radiantv2.FlashLoanLogic.rid, params); | ||
} | ||
|
||
export function newFlashLoanLogic(fields: FlashLoanFields): FlashLoanLogic { | ||
return { rid: logics.radiantv2.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 })]; | ||
} |
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,5 @@ | ||
export * from './borrow'; | ||
export * from './deposit'; | ||
export * from './flash-loan'; | ||
export * from './repay'; | ||
export * from './withdraw'; |
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,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 RepayParams = common.Declasifying<logics.radiantv2.RepayLogicParams>; | ||
|
||
export type RepayFields = common.Declasifying<logics.radiantv2.RepayLogicFields>; | ||
|
||
export type RepayLogic = Logic<RepayFields>; | ||
|
||
export async function getRepayTokenList(chainId: number): Promise<logics.radiantv2.RepayLogicTokenList> { | ||
return getProtocolTokenList(chainId, logics.radiantv2.RepayLogic.rid); | ||
} | ||
|
||
export async function getRepayQuotation( | ||
chainId: number, | ||
params: RepayParams | ||
): Promise<logics.radiantv2.RepayLogicFields> { | ||
return quote(chainId, logics.radiantv2.RepayLogic.rid, params); | ||
} | ||
|
||
export function newRepayLogic(fields: RepayFields): RepayLogic { | ||
return { rid: logics.radiantv2.RepayLogic.rid, fields }; | ||
} |
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,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.radiantv2.WithdrawLogicParams>; | ||
|
||
export type WithdrawFields = common.Declasifying<logics.radiantv2.WithdrawLogicFields>; | ||
|
||
export type WithdrawLogic = Logic<WithdrawFields>; | ||
|
||
export async function getWithdrawTokenList(chainId: number): Promise<logics.radiantv2.WithdrawLogicTokenList> { | ||
return getProtocolTokenList(chainId, logics.radiantv2.WithdrawLogic.rid); | ||
} | ||
|
||
export async function getWithdrawQuotation( | ||
chainId: number, | ||
params: WithdrawParams | ||
): Promise<logics.radiantv2.WithdrawLogicFields> { | ||
return quote(chainId, logics.radiantv2.WithdrawLogic.rid, params); | ||
} | ||
|
||
export function newWithdrawLogic(fields: WithdrawFields): WithdrawLogic { | ||
return { rid: logics.radiantv2.WithdrawLogic.rid, fields }; | ||
} |
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