Skip to content

Commit

Permalink
feat: supporting types (#124)
Browse files Browse the repository at this point in the history
* feat: supporting types

* refactor: call action

* feat: redefined steps

* chore: removed cleanup script

* fix: changed build script

* revert: changes to build script

* chore: included all files in package

* chore: restored local config

* chore: restored local config

* chore: added dist folder

* chore: new dist

* chore: new dist

* chore: dist

* Revert "chore: dist"

This reverts commit 654ed81.

* Revert "Revert "chore: dist""

This reverts commit c077f44.

* chore: removed dist for merge
  • Loading branch information
H3xept committed Mar 22, 2023
1 parent 88c9ecf commit 9fc1fa7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
4 changes: 4 additions & 0 deletions src/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,10 @@ const basicCoins: BasicCoin[] = [
address: '0x07de306ff27a2b630b1141956844eb1552b956b5',
decimals: 6,
},
[ChainId.GOR]: {
address: '0x509ee0d083ddf8ac028f2a56731412edd63223b9',
decimals: 6,
},
},
},
// USDC
Expand Down
34 changes: 13 additions & 21 deletions src/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface FeeCost {

export interface GasCost {
type: 'SUM' | 'APPROVE' | 'SEND' | 'FEE'
price?: string // suggested current standard price for chain
price: string // suggested current standard price for chain
estimate?: string // estimate how much gas will be needed
limit?: string // suggested gas limit (estimate +25%)
amount: string // estimate * price = amount of tokens that will be needed
Expand All @@ -41,6 +41,7 @@ export interface Action {

// ESTIMATE
export interface Estimate {
tool: string
fromAmount: string
fromAmountUSD?: string
toAmount: string
Expand All @@ -52,8 +53,6 @@ export interface Estimate {
gasCosts?: GasCost[] // This is a list to account for approval gas costs and transaction gas costs. However, approval gas costs are not used at the moment

executionDuration: number // estimated duration in seconds

data?: any // differs by tool
}

// EXECUTION
Expand Down Expand Up @@ -160,29 +159,19 @@ export function isCrossStep(step: Step): step is CrossStep {
return step.type === 'cross'
}

export interface LifiStep extends StepBase {
type: 'lifi'
action: Action
estimate: Estimate
includedSteps: Step[]
export interface DestinationCallInfo {
toContractAddress: string
toContractCallData: string
toFallbackAddress: string
callDataGasLimit: string
}

export function isLifiStep(step: Step): step is LifiStep {
return (
step.type === 'lifi' && step.includedSteps && step.includedSteps.length > 0
)
}
export type CallAction = Action & DestinationCallInfo

export interface CustomStep extends StepBase {
type: 'custom'
action: Action
action: CallAction
estimate: Estimate
destinationCallInfo: {
toContractAddress: string
toContractCallData: string
toFallbackAddress: string
callDataGasLimit: string
}
}

export function isCustomStep(step: Step): step is CustomStep {
Expand All @@ -193,4 +182,7 @@ export function isProtocolStep(step: Step): step is ProtocolStep {
return step.type === 'protocol'
}

export type Step = SwapStep | CrossStep | LifiStep | CustomStep | ProtocolStep
export type Step = SwapStep | CrossStep | CustomStep | ProtocolStep
export type LifiStep = Omit<Step, 'type'> & { includedSteps: Step[] } & {
type: 'lifi'
}
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1506,9 +1506,9 @@ __metadata:
linkType: hard

"@sinclair/typebox@npm:^0.25.16":
version: 0.25.22
resolution: "@sinclair/typebox@npm:0.25.22"
checksum: 82bea74649dd9e4ac81e14815d7e04fc70847065666c3af2023e478a40097a5345fbbaf526f9df4cdafad5f014b3c6060ce0777a7fd2e086a33b972b3322eb88
version: 0.25.24
resolution: "@sinclair/typebox@npm:0.25.24"
checksum: 10219c58f40b8414c50b483b0550445e9710d4fe7b2c4dccb9b66533dd90ba8e024acc776026cebe81e87f06fa24b07fdd7bc30dd277eb9cc386ec50151a3026
languageName: node
linkType: hard

Expand Down

0 comments on commit 9fc1fa7

Please sign in to comment.