99 type NoirAndBackend ,
1010 type PoolErc20Service ,
1111} from "./RollupService.js" ;
12- import { prove , toNoirU256 } from "./utils.js" ;
12+ import { prove } from "./utils.js" ;
1313
1414export class LobService {
1515 constructor (
@@ -24,10 +24,10 @@ export class LobService {
2424 async swap ( params : {
2525 sellerSecretKey : string ;
2626 sellerNote : Erc20Note ;
27- sellerAmount : bigint ;
27+ sellerAmount : TokenAmount ;
2828 buyerSecretKey : string ;
2929 buyerNote : Erc20Note ;
30- buyerAmount : bigint ;
30+ buyerAmount : TokenAmount ;
3131 } ) {
3232 const { Fr } = await import ( "@aztec/aztec.js" ) ;
3333
@@ -37,34 +37,22 @@ export class LobService {
3737
3838 const sellerChangeNote = await Erc20Note . from ( {
3939 owner : await CompleteWaAddress . fromSecretKey ( params . sellerSecretKey ) ,
40- amount : await TokenAmount . from ( {
41- token : params . sellerNote . amount . token ,
42- amount : params . sellerNote . amount . amount - params . sellerAmount ,
43- } ) ,
40+ amount : params . sellerNote . amount . sub ( params . sellerAmount ) ,
4441 randomness : sellerRandomness ,
4542 } ) ;
4643 const buyerChangeNote = await Erc20Note . from ( {
4744 owner : await CompleteWaAddress . fromSecretKey ( params . buyerSecretKey ) ,
48- amount : await TokenAmount . from ( {
49- token : params . buyerNote . amount . token ,
50- amount : params . buyerNote . amount . amount - params . buyerAmount ,
51- } ) ,
45+ amount : params . buyerNote . amount . sub ( params . buyerAmount ) ,
5246 randomness : buyerRandomness ,
5347 } ) ;
5448 const sellerSwapNote = await Erc20Note . from ( {
5549 owner : await CompleteWaAddress . fromSecretKey ( params . sellerSecretKey ) ,
56- amount : await TokenAmount . from ( {
57- token : params . buyerNote . amount . token ,
58- amount : params . buyerAmount ,
59- } ) ,
50+ amount : params . buyerAmount ,
6051 randomness : sellerRandomness ,
6152 } ) ;
6253 const buyerSwapNote = await Erc20Note . from ( {
6354 owner : await CompleteWaAddress . fromSecretKey ( params . buyerSecretKey ) ,
64- amount : await TokenAmount . from ( {
65- token : params . sellerNote . amount . token ,
66- amount : params . sellerAmount ,
67- } ) ,
55+ amount : params . sellerAmount ,
6856 randomness : buyerRandomness ,
6957 } ) ;
7058
@@ -75,15 +63,15 @@ export class LobService {
7563 params . sellerSecretKey ,
7664 params . sellerNote ,
7765 ) ,
78- seller_amount : toNoirU256 ( params . sellerAmount ) ,
66+ seller_amount : await params . sellerAmount . toNoir ( ) ,
7967 seller_randomness : sellerRandomness ,
8068
8169 buyer_secret_key : params . buyerSecretKey ,
8270 buyer_note : await this . poolErc20 . toNoteConsumptionInputs (
8371 params . buyerSecretKey ,
8472 params . buyerNote ,
8573 ) ,
86- buyer_amount : toNoirU256 ( params . buyerAmount ) ,
74+ buyer_amount : await params . buyerAmount . toNoir ( ) ,
8775 buyer_randomness : buyerRandomness ,
8876 } ;
8977 const { proof } = await prove ( "swap" , swapCircuit , input ) ;
0 commit comments