Skip to content

Commit

Permalink
fix: provider injecting in order decoding (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
krboktv authored Apr 19, 2024
1 parent be4d884 commit ce165e3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
52 changes: 52 additions & 0 deletions src/fusion-order/fusion-order.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,58 @@ describe('Fusion Order', () => {
).toStrictEqual(order)
})

it('should decode fusion order from order + extension with provided source', () => {
const extensionContract = new Address(
'0x8273f37417da37c4a6c3995e82cf442f87a25d9c'
)

const order = FusionOrder.new(
extensionContract,
{
makerAsset: new Address(
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
),
takerAsset: new Address(
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
),
makingAmount: 1000000000000000000n,
takingAmount: 1420000000n,
maker: new Address(
'0x00000000219ab540356cbb839cbe05303d7705fa'
),
salt: 10n
},
{
auction: new AuctionDetails({
duration: 180n,
startTime: 1673548149n,
initialRateBump: 50000,
points: [
{
coefficient: 20000,
delay: 12
}
]
}),
whitelist: [
{
address: new Address(
'0x00000000219ab540356cbb839cbe05303d7705fa'
),
allowFrom: 0n
}
]
},
{
source: 'test'
}
)

expect(
FusionOrder.fromDataAndExtension(order.build(), order.extension)
).toStrictEqual(order)
})

it('Should calculate taking amount', () => {
const now = 10000n
const order = FusionOrder.new(
Expand Down
6 changes: 5 additions & 1 deletion src/fusion-order/fusion-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,15 @@ export class FusionOrder {

const builtExtension = extension.build()
const salt = LimitOrder.buildSalt(builtExtension, orderInfo.salt)
const saltWithInjectedTrackCode = orderInfo.salt
? salt
: injectTrackCode(salt, extra.source)

this.inner = new LimitOrder(
{
...orderInfo,
receiver,
salt: injectTrackCode(salt, extra.source)
salt: saltWithInjectedTrackCode
},
makerTraits,
builtExtension
Expand Down

0 comments on commit ce165e3

Please sign in to comment.