Skip to content

Commit

Permalink
fix: address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
robercano committed May 27, 2024
1 parent e2e9b4b commit e374960
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
22 changes: 14 additions & 8 deletions sdk/order-planner-common/src/implementation/OrderPlanner.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Order, type IPositionsManager, TransactionInfo } from '@summerfi/sdk-common/orders'
import { ISimulation, SimulationType, steps } from '@summerfi/sdk-common/simulation'
import {
ISimulation,
SimulationSteps,
SimulationType,
steps,
} from '@summerfi/sdk-common/simulation'
import { Maybe } from '@summerfi/sdk-common/common'
import {
ActionBuildersMap,
ActionCall,
FilterStep,
IActionBuilder,
IStepBuilderContext,
StepBuilderContext,
Expand Down Expand Up @@ -34,7 +40,7 @@ export class OrderPlanner implements IOrderPlanner {
context.startSubContext()

for (const step of simulation.steps) {
const stepBuilder = this._getActionBuilder(actionBuildersMap, step)
const stepBuilder = this._getActionBuilder(actionBuildersMap, step.type)
if (!stepBuilder) {
throw new Error(`No step builder found for step type ${step.type}`)
}
Expand Down Expand Up @@ -68,17 +74,17 @@ export class OrderPlanner implements IOrderPlanner {
})
}

private _getActionBuilder<StepType extends steps.Steps>(
actionBuildersMap: ActionBuildersMap,
step: StepType,
): Maybe<IActionBuilder<StepType>> {
const builder = actionBuildersMap[step.type]
private _getActionBuilder<
StepType extends SimulationSteps,
Step extends FilterStep<StepType, steps.Steps>,
>(actionBuildersMap: ActionBuildersMap, stepType: StepType): Maybe<IActionBuilder<Step>> {
const builder = actionBuildersMap[stepType]

if (!builder) {
return undefined
}

return new builder() as IActionBuilder<StepType>
return new builder()
}

private async _generateOrder(params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export abstract class BaseProtocolPlugin implements IProtocolPlugin {
return undefined
}

return new BuilderClass() as IActionBuilder<Step>
return new BuilderClass()
}

/** HELPERS */
Expand Down
6 changes: 3 additions & 3 deletions sdk/protocol-plugins/tests/utils/ProtocolPluginMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class ProtocolPluginMock implements IProtocolPlugin {
return undefined
}

return new builder() as IActionBuilder<Step>
return new builder()
}

async getImportPositionTransaction(params: {
Expand Down Expand Up @@ -167,7 +167,7 @@ export class EmptyProtocolPluginMock implements IProtocolPlugin {
return undefined
}

return new builder() as IActionBuilder<Step>
return new builder()
}

async getImportPositionTransaction(params: {
Expand Down Expand Up @@ -222,7 +222,7 @@ export class NoCheckpointProtocolPluginMock implements IProtocolPlugin {
return undefined
}

return new builder() as IActionBuilder<Step>
return new builder()
}

async getImportPositionTransaction(params: {
Expand Down

0 comments on commit e374960

Please sign in to comment.