@@ -224,13 +224,35 @@ export class PoolService extends SDKConstruct implements IPoolsService {
224224
225225 if ( result . size === 0 ) {
226226 throw new Error (
227- `No tokensOut found for tokenIn ${ this . labelAddress ( tokenIn ) } on pool ${ this . labelAddress ( poolAddr ) } ` ,
227+ `No tokensOut found for tokenIn ${ this . labelAddress (
228+ tokenIn ,
229+ ) } on pool ${ this . labelAddress ( poolAddr ) } `,
228230 ) ;
229231 }
230232
231233 return result . asArray ( ) ;
232234 }
233235
236+ #getDepositZapper(
237+ poolAddr : Address ,
238+ tokenIn : Address ,
239+ tokenOut : Address ,
240+ ) : ZapperData | undefined {
241+ const zappers = this . sdk . marketRegister
242+ . getZapper ( poolAddr , tokenIn , tokenOut )
243+ ?. filter ( z => z . type !== "migration" ) ;
244+ if ( zappers && zappers . length > 1 ) {
245+ throw new Error (
246+ `Multiple zappers found for tokenIn ${ this . labelAddress (
247+ tokenIn ,
248+ ) } and tokenOut ${ this . labelAddress (
249+ tokenOut ,
250+ ) } on pool ${ this . labelAddress ( poolAddr ) } `,
251+ ) ;
252+ }
253+
254+ return zappers ?. [ 0 ] ;
255+ }
234256 #depositMetadata(
235257 poolAddr : Address ,
236258 tokenIn : Address ,
@@ -242,14 +264,14 @@ export class PoolService extends SDKConstruct implements IPoolsService {
242264 }
243265 const { pool } = this . sdk . marketRegister . findByPool ( poolAddr ) ;
244266
245- const zapper = this . sdk . marketRegister . getZapper (
246- poolAddr ,
247- tokenIn ,
248- tokenOut ,
249- ) ;
267+ const zapper = this . #getDepositZapper( poolAddr , tokenIn , tokenOut ) ;
250268 if ( ! zapper && ! allowDirectDeposit ) {
251269 throw new Error (
252- `No zapper found for tokenIn ${ this . labelAddress ( tokenIn ) } and tokenOut ${ this . labelAddress ( tokenOut ) } on pool ${ this . labelAddress ( poolAddr ) } ` ,
270+ `No zapper found for tokenIn ${ this . labelAddress (
271+ tokenIn ,
272+ ) } and tokenOut ${ this . labelAddress (
273+ tokenOut ,
274+ ) } on pool ${ this . labelAddress ( poolAddr ) } `,
253275 ) ;
254276 }
255277
0 commit comments