diff --git a/package-lock.json b/package-lock.json index 07a001a..24c9299 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@indigo-labs/dexter", - "version": "4.2.1", + "version": "5.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@indigo-labs/dexter", - "version": "4.2.1", + "version": "5.0.3", "license": "MIT", "dependencies": { "@types/crypto-js": "^4.1.1", @@ -15,7 +15,7 @@ "bottleneck": "^2.19.5", "crypto-js": "^4.1.1", "lodash": "^4.17.21", - "lucid-cardano": "^0.8.7" + "lucid-cardano": "^0.10.7" }, "devDependencies": { "@babel/core": "^7.21.4", @@ -5754,9 +5754,9 @@ } }, "node_modules/lucid-cardano": { - "version": "0.8.9", - "resolved": "https://registry.npmjs.org/lucid-cardano/-/lucid-cardano-0.8.9.tgz", - "integrity": "sha512-2deXHPB12/1yMSRFYk0qmiqazvN0V+HLeEFyYsUyIjuzwk8F72mC8ZsjUjPt9NeWgySuyPivPFjXt3jSrG+iIA==", + "version": "0.10.7", + "resolved": "https://registry.npmjs.org/lucid-cardano/-/lucid-cardano-0.10.7.tgz", + "integrity": "sha512-hxJRMWj8VH+SGFqsVMG6T3LSRuxzwFbWOQ5DTGQQUyR/20FL7bjiVL+2ivMJF52tAbFKcwqpRD4fddR7LbqcAw==", "dependencies": { "@peculiar/webcrypto": "^1.4.0", "node-fetch": "^3.2.3", diff --git a/package.json b/package.json index 2f57187..bad6db1 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "bottleneck": "^2.19.5", "crypto-js": "^4.1.1", "lodash": "^4.17.21", - "lucid-cardano": "^0.8.7" + "lucid-cardano": "^0.10.7" }, "devDependencies": { "@babel/core": "^7.21.4", diff --git a/src/dex/api/base-api.ts b/src/dex/api/base-api.ts index ba83043..f390c4f 100644 --- a/src/dex/api/base-api.ts +++ b/src/dex/api/base-api.ts @@ -11,6 +11,6 @@ export abstract class BaseApi { /** * Fetch all liquidity pools matching assetA & assetB. */ - abstract liquidityPools(assetA: Token, assetB?: Token): Promise; + abstract liquidityPools(assetA?: Token, assetB?: Token): Promise; -} \ No newline at end of file +} diff --git a/src/dex/api/vyfinance-api.ts b/src/dex/api/vyfinance-api.ts index 78cbcad..17c0852 100644 --- a/src/dex/api/vyfinance-api.ts +++ b/src/dex/api/vyfinance-api.ts @@ -24,15 +24,15 @@ export class VyfinanceApi extends BaseApi { }); } - liquidityPools(assetA: Token, assetB?: Token): Promise { - const assetAId: string = (assetA === 'lovelace') - ? 'lovelace' - : assetA.identifier(); + liquidityPools(assetA?: Token, assetB?: Token): Promise { + const assetAId: string = (assetA && assetA !== 'lovelace') + ? assetA.identifier() + : 'lovelace'; let assetBId: string = (assetB && assetB !== 'lovelace') ? assetB.identifier() : 'lovelace'; - const url: string = assetB + const url: string = assetA && assetB ? `/lp?networkId=1&v2=true&tokenAUnit=${assetAId}&tokenBUnit=${assetBId}` : '/lp?networkId=1&v2=true'; @@ -48,12 +48,13 @@ export class VyfinanceApi extends BaseApi { ? new Asset(poolDetails['bAsset']['currencySymbol'], Buffer.from(poolDetails['bAsset']['tokenName']).toString('hex')) : 'lovelace'; + let liquidityPool: LiquidityPool = new LiquidityPool( VyFinance.identifier, tokenA, tokenB, - BigInt(pool['tokenAQuantity']), - BigInt(pool['tokenBQuantity']), + BigInt(pool['tokenAQuantity'] ?? 0), + BigInt(pool['tokenBQuantity'] ?? 0), pool['poolValidatorUtxoAddress'], pool['orderValidatorUtxoAddress'], pool['orderValidatorUtxoAddress'], @@ -63,10 +64,12 @@ export class VyfinanceApi extends BaseApi { liquidityPool.lpToken = new Asset(lpTokenDetails[0], lpTokenDetails[1]); liquidityPool.poolFeePercent = (poolDetails['feesSettings']['barFee'] + poolDetails['feesSettings']['liqFee']) / 100; liquidityPool.identifier = liquidityPool.lpToken.identifier(); + liquidityPool.extra.nft = new Asset(poolDetails['mainNFT']['currencySymbol'], poolDetails['mainNFT']['tokenName']); return liquidityPool; }).filter((pool: LiquidityPool | undefined) => pool !== undefined) as LiquidityPool[]; - }).catch(() => { + }).catch((e) => { + console.error(e) return []; }); } diff --git a/src/dex/sundaeswap.ts b/src/dex/sundaeswap.ts index 231fb44..2159937 100644 --- a/src/dex/sundaeswap.ts +++ b/src/dex/sundaeswap.ts @@ -32,7 +32,7 @@ export class SundaeSwap extends BaseDex { public readonly orderAddress: string = 'addr1wxaptpmxcxawvr3pzlhgnpmzz3ql43n2tc8mn3av5kx0yzs09tqh8'; public readonly poolAddress: string = 'addr1w9qzpelu9hn45pefc0xr4ac4kdxeswq7pndul2vuj59u8tqaxdznu'; public readonly lpTokenPolicyId: string = '0029cb7c88c7567b63d1a512c0ed626aa169688ec980730c0473b913'; - public readonly cancelDatum: string = 'd8799f00000001ff'; + public readonly cancelDatum: string = 'd87a80'; public readonly orderScript: Script = { type: 'PlutusV1', script: '59084601000033233322232332232333222323332223322323332223233223233223332223333222233322233223322332233223332223322332233322232323232322222325335300b001103c13503d35303b3357389201035054350003c498ccc888c8c8c94cd4c05c0144d4c0680188888cd4c04c480048d4c0ed40188888888888cd4c078480048ccd5cd19b8f375c0020180440420066a6040006446a6048004446a605000444666aa60302400244a66a6a07c0044266a08c0020042002a0886466a002a088a08a2446600466a609000846a0820024a0806600400e00226a606ca002444444444466a6032240024646464666ae68cdc399991119191800802990009aa82c1119a9a826000a4000446a6aa08a00444a66a6050666ae68cdc78010048150148980380089803001990009aa82b9119a9a825800a4000446a6aa08800444a66a604e666ae68cdc7801003814814080089803001999aa81e3ae335503c75ceb4d4c084cccd5cd19b8735573aa006900011998119aba1500335742a00466a080eb8d5d09aba2500223505135304f33573892010350543100050499262220020183371491010270200035302801422220044800808007c4d5d1280089aab9e500113754002012264a66a6a070601a6aae78dd50008a81a910a99a9a81d0008a81b910a99a9a81e0008a81c910a99a9a81f0008a81d910a99a9a8200008a81e910a99a9a8210008a81f910a99a9a8220008a820910a99a9a8230008a821910a99a9a8240008a822910a99a9a8250008a823910a99a9a82600089999999999825981000a18100090080071810006181000500418100031810002001110a8259a980a1999ab9a3370e6aae754009200023301635742a0046ae84d5d1280111a8211a982019ab9c490103505431000414992622002135573ca00226ea8004cd40148c8c8c8c8cccd5cd19b8735573aa00890001199980d9bae35742a0086464646666ae68cdc39aab9d5002480008cc88cc08c008004c8c8c8cccd5cd19b8735573aa004900011991198148010009919191999ab9a3370e6aae754009200023302d304735742a00466a07a4646464646666ae68cdc3a800a4004466606a6eb4d5d0a8021bad35742a0066eb4d5d09aba2500323333573466e1d4009200023037304e357426aae7940188d4154d4c14ccd5ce2490350543100054499264984d55cea80189aba25001135573ca00226ea8004d5d09aba2500223504e35304c335738921035054310004d49926135573ca00226ea8004d5d0a80119a81cbae357426ae8940088d4128d4c120cd5ce249035054310004949926135573ca00226ea8004d5d0a80119a81abae357426ae8940088d4118d4c110cd5ce249035054310004549926135573ca00226ea8004d5d0a8019bad35742a00464646464646666ae68cdc3a800a40084605c646464646666ae68cdc3a800a40044606c6464646666ae68cdc39aab9d5002480008cc88cd40f8008004dd69aba15002375a6ae84d5d1280111a8289a982799ab9c491035054310005049926135573ca00226ea8004d5d09aab9e500423333573466e1d40092000233036304b35742a0086eb4d5d09aba2500423504e35304c335738921035054310004d499264984d55cea80109aab9e5001137540026ae84d55cf280291999ab9a3370ea0049001118169bad357426aae7940188cccd5cd19b875003480008ccc0bcc11cd5d0a8031bad35742a00a66a072eb4d5d09aba2500523504a353048335738920103505431000494992649926135573aa00626ae8940044d55cf280089baa001357426ae8940088d4108d4c100cd5ce249035054310004149926135744a00226ae8940044d55cf280089baa0010033350052323333573466e1d40052002201623333573466e1d40092000201623504035303e335738921035054310003f499264984d55ce9baa001002335005200100112001230023758002640026aa072446666aae7c004940c08cd40bcd5d080118019aba2002498c8004d540e088448894cd4d40bc0044008884cc014008ccd54c01c48004014010004c8004d540dc884894cd4d40b400440188854cd4c01cc01000840244cd4c01848004010004488008488004800488848ccc00401000c00880048848cc00400c00880044880084880048004888848cccc00401401000c00880048848cc00400c00880048848cc00400c00880048848cc00400c00880048488c00800c888488ccc00401401000c800484888c00c0108884888ccc00801801401084888c00401080048488c00800c88488cc00401000c800448848cc00400c008480044488c88c008dd5800990009aa80d11191999aab9f0022501223350113355008300635573aa004600a6aae794008c010d5d100180c09aba10011122123300100300211200112232323333573466e1d400520002350083005357426aae79400c8cccd5cd19b87500248008940208d405cd4c054cd5ce24810350543100016499264984d55cea80089baa00112122300200311220011200113500d35300b3357389211f556e6578706563746564205478496e666f20636f6e737472756374696f6e2e0000c498888888888848cccccccccc00402c02802402001c01801401000c00880044488008488488cc00401000c480048c8c8cccd5cd19b875001480088c018dd71aba135573ca00646666ae68cdc3a80124000460106eb8d5d09aab9e500423500c35300a3357389201035054310000b499264984d55cea80089baa001212230020032122300100320012323333573466e1d40052002200823333573466e1d40092000200a2350073530053357389210350543100006499264984d55ce9baa0011200120011261220021220012001112323001001223300330020020014891c0029cb7c88c7567b63d1a512c0ed626aa169688ec980730c0473b9130001', diff --git a/src/dex/vyfinance.ts b/src/dex/vyfinance.ts index 3d46631..ded5ce3 100644 --- a/src/dex/vyfinance.ts +++ b/src/dex/vyfinance.ts @@ -1,6 +1,6 @@ import { LiquidityPool } from './models/liquidity-pool'; import { BaseDataProvider } from '@providers/data/base-data-provider'; -import { Token } from './models/asset'; +import { Asset, Token } from './models/asset'; import { BaseDex } from './base-dex'; import { DatumParameters, PayToAddress, RequestConfig, SpendUTxO, SwapFee, UTxO } from '@app/types'; import { DefinitionBuilder } from '@app/definition-builder'; @@ -9,7 +9,7 @@ import { AddressType, DatumParameterKey } from '@app/constants'; import order from '@dex/definitions/vyfinance/order'; import { BaseApi } from '@dex/api/base-api'; import { VyfinanceApi } from '@dex/api/vyfinance-api'; -import { Script } from 'lucid-cardano'; +import { Data, Script } from 'lucid-cardano'; /** * VyFinance constants. @@ -28,7 +28,7 @@ export class VyFinance extends BaseDex { public readonly cancelDatum: string = 'd87a80'; public readonly orderScript: Script = { type: 'PlutusV1', - script: '590a8c010000332323232322232322322323253353330093333573466e1cd55cea803a40004646424660020060046464646666ae68cdc3a800a40184642444444460020106eb4d5d09aab9e500323333573466e1d4009200a232122222223002008375a6ae84d55cf280211999ab9a3370ea00690041190911111118018041bad357426aae7940148cccd5cd19b875004480188c848888888c010020dd69aba135573ca00c46666ae68cdc3a802a400842444444400a46666ae68cdc3a8032400446424444444600c0106464646666ae68cdc39aab9d5002480008cc8848cc00400c008dd69aba15002375a6ae84d5d1280111931a99ab9c01d01c01b01a135573ca00226ea8004d5d09aab9e500823333573466e1d401d2000232122222223007008375a6ae84d55cf280491931a99ab9c01a019018017016015014013012011135573aa00226ea8004d5d09aba25008375c6ae85401c8c98d4cd5ce0078070068061999ab9a3370ea0089001109100111999ab9a3370ea00a9000109100091931a99ab9c01000f00e00d00c3333573466e1cd55cea8012400046644246600200600464646464646464646464646666ae68cdc39aab9d500a480008cccccccccc888888888848cccccccccc00402c02802402001c01801401000c008d5d0a80519a80b90009aba1500935742a0106ae85401cd5d0a8031aba1500535742a00866a02eeb8d5d0a8019aba15002357426ae8940088c98d4cd5ce00d80d00c80c09aba25001135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aab9e5001137540026ae854008c8c8c8cccd5cd19b875001480188c848888c010014c8c8c8c8c8c8cccd5cd19b8750014803084888888800c8cccd5cd19b875002480288488888880108cccd5cd19b875003480208cc8848888888cc004024020dd71aba15005375a6ae84d5d1280291999ab9a3370ea00890031199109111111198010048041bae35742a00e6eb8d5d09aba2500723333573466e1d40152004233221222222233006009008301b35742a0126eb8d5d09aba2500923333573466e1d40192002232122222223007008301c357426aae79402c8cccd5cd19b875007480008c848888888c014020c074d5d09aab9e500c23263533573804003e03c03a03803603403203002e26aae7540104d55cf280189aab9e5002135573ca00226ea8004d5d09aab9e500323333573466e1d400920042321222230020053011357426aae7940108cccd5cd19b875003480088c848888c004014c8c8c8cccd5cd19b8735573aa004900011991091980080180119191999ab9a3370e6aae75400520002375c6ae84d55cf280111931a99ab9c01c01b01a019137540026ae854008dd69aba135744a004464c6a66ae7006406005c0584d55cf280089baa001357426aae7940148cccd5cd19b875004480008c848888c00c014dd71aba135573ca00c464c6a66ae7005805405004c0480440404d55cea80089baa001357426ae8940088c98d4cd5ce007807006806080689931a99ab9c4901035054350000d00c135573ca00226ea80044d55ce9baa001135573ca00226ea800448c88c008dd60009900099180080091191999aab9f0022122002233221223300100400330053574200660046ae8800c01cc0080088c8c8c8c8cccd5cd19b875001480088ccc888488ccc00401401000cdd69aba15004375a6ae85400cdd69aba135744a00646666ae68cdc3a8012400046424460040066464646666ae68cdc3a800a400446424460020066eb8d5d09aab9e500323333573466e1d400920002321223002003375c6ae84d55cf280211931a99ab9c00f00e00d00c00b135573aa00226ea8004d5d09aab9e500623263533573801401201000e00c26aae75400c4d5d1280089aab9e5001137540029309000a481035054310033232323322323232323232323232332223222253350021350012232350032222222222533533355301512001321233001225335002210031001002501e25335333573466e3c0300040540504d40800045407c00c84054404cd4c8c8d4cc8848cc00400c008ccdc624000030004a66a666ae68cdc7a800a4410000b00a150151350165001223355011002001133371802e02e0026a00a4400444004260086a6464646464a66a6666666ae900148cccd5cd19b8735573aa00a900011999aab9f500525019233335573ea00a4a03446666aae7d40149406c8cccd55cf9aba2500625335323232323333333574800846666ae68cdc39aab9d5004480008cccd55cfa8021281191999aab9f500425024233335573e6ae89401494cd4c088d5d0a80390a99a99a811119191919191999999aba400623333573466e1d40092002233335573ea00c4a05e46666aae7d4018940c08cccd55cfa8031281891999aab9f35744a00e4a66a605a6ae854028854cd4c0b8d5d0a80510a99a98179aba1500a21350361223330010050040031503415033150322503203303203103023333573466e1d400d2000233335573ea00e4a06046666aae7cd5d128041299a98171aba150092135033122300200315031250310320312502f02c02b2502d2502d2502d2502d02e135573aa00826ae8940044d5d1280089aab9e5001137540026ae85401c84d40a048cc00400c0085409854094940940980940909408807c940849408494084940840884d5d1280089aab9e5001137540026ae854024854cd4ccd54054070cd54054070060d5d0a80490a99a99a80d00e9aba150092135020123330010040030021501e1501d1501c2501c01d01c01b01a250180152501725017250172501701821001135626135744a00226ae8940044d55cf280089baa00135001223500222222222225335009132635335738921035054380001f01b22100222200232001355011225335001100422135002225335333573466e3c00801c02402040244c01800c488008488004c8004d5403488448894cd40044d400c88004884ccd401488008c010008ccd54c01c480040140100044488c88ccccccd5d2000aa8029299a98019bab002213500f0011500d55005550055500500e3200135500e223233335573e00446a01e2440044a66a600c6aae754008854cd4c018d55cf280190a99a98031aba200521350123212233001003004335500b003002150101500f1500e00f135742002224a0102244246600200600446666666ae900049401c9401c9401c8d4020dd6801128038040911919191999999aba400423333573466e1d40092000233335573ea0084a01846666aae7cd5d128029299a98049aba15006213500f3500f0011500d2500d00e00d23333573466e1d400d2002233335573ea00a46a01ca01a4a01a01c4a0180120104a0144a0144a0144a01401626aae7540084d55cf280089baa00123232323333333574800846666ae68cdc3a8012400446666aae7d4010940288cccd55cf9aba2500525335300a35742a00c426a01a24460020062a0164a01601801646666ae68cdc3a801a400046666aae7d40149402c8cccd55cf9aba2500625335300b35742a00e426a01c24460040062a0184a01801a0184a01400e00c4a0104a0104a0104a01001226aae7540084d55cf280089baa0014988ccccccd5d20009280192801928019280191a8021bae002004121223002003112200112001480e0448c8c00400488cc00cc00800800522011cca28be9e0d69a18f9cb8ae14b6807088321e7a4c5b21e572c00b389e0001', + script: '590a8c010000332323232322232322322323253353330093333573466e1cd55cea803a40004646424660020060046464646666ae68cdc3a800a40184642444444460020106eb4d5d09aab9e500323333573466e1d4009200a232122222223002008375a6ae84d55cf280211999ab9a3370ea00690041190911111118018041bad357426aae7940148cccd5cd19b875004480188c848888888c010020dd69aba135573ca00c46666ae68cdc3a802a400842444444400a46666ae68cdc3a8032400446424444444600c0106464646666ae68cdc39aab9d5002480008cc8848cc00400c008dd69aba15002375a6ae84d5d1280111931a99ab9c01d01c01b01a135573ca00226ea8004d5d09aab9e500823333573466e1d401d2000232122222223007008375a6ae84d55cf280491931a99ab9c01a019018017016015014013012011135573aa00226ea8004d5d09aba25008375c6ae85401c8c98d4cd5ce0078070068061999ab9a3370ea0089001109100111999ab9a3370ea00a9000109100091931a99ab9c01000f00e00d00c3333573466e1cd55cea8012400046644246600200600464646464646464646464646666ae68cdc39aab9d500a480008cccccccccc888888888848cccccccccc00402c02802402001c01801401000c008d5d0a80519a80b90009aba1500935742a0106ae85401cd5d0a8031aba1500535742a00866a02eeb8d5d0a8019aba15002357426ae8940088c98d4cd5ce00d80d00c80c09aba25001135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aab9e5001137540026ae854008c8c8c8cccd5cd19b875001480188c848888c010014c8c8c8c8c8c8cccd5cd19b8750014803084888888800c8cccd5cd19b875002480288488888880108cccd5cd19b875003480208cc8848888888cc004024020dd71aba15005375a6ae84d5d1280291999ab9a3370ea00890031199109111111198010048041bae35742a00e6eb8d5d09aba2500723333573466e1d40152004233221222222233006009008301b35742a0126eb8d5d09aba2500923333573466e1d40192002232122222223007008301c357426aae79402c8cccd5cd19b875007480008c848888888c014020c074d5d09aab9e500c23263533573804003e03c03a03803603403203002e26aae7540104d55cf280189aab9e5002135573ca00226ea8004d5d09aab9e500323333573466e1d400920042321222230020053011357426aae7940108cccd5cd19b875003480088c848888c004014c8c8c8cccd5cd19b8735573aa004900011991091980080180119191999ab9a3370e6aae75400520002375c6ae84d55cf280111931a99ab9c01c01b01a019137540026ae854008dd69aba135744a004464c6a66ae7006406005c0584d55cf280089baa001357426aae7940148cccd5cd19b875004480008c848888c00c014dd71aba135573ca00c464c6a66ae7005805405004c0480440404d55cea80089baa001357426ae8940088c98d4cd5ce007807006806080689931a99ab9c4901035054350000d00c135573ca00226ea80044d55ce9baa001135573ca00226ea800448c88c008dd60009900099180080091191999aab9f0022122002233221223300100400330053574200660046ae8800c01cc0080088c8c8c8c8cccd5cd19b875001480088ccc888488ccc00401401000cdd69aba15004375a6ae85400cdd69aba135744a00646666ae68cdc3a8012400046424460040066464646666ae68cdc3a800a400446424460020066eb8d5d09aab9e500323333573466e1d400920002321223002003375c6ae84d55cf280211931a99ab9c00f00e00d00c00b135573aa00226ea8004d5d09aab9e500623263533573801401201000e00c26aae75400c4d5d1280089aab9e5001137540029309000a481035054310033232323322323232323232323232332223222253350021350012232350032222222222533533355301512001321233001225335002210031001002501e25335333573466e3c0300040540504d40800045407c00c84054404cd4c8c8d4cc8848cc00400c008ccdc624000030004a66a666ae68cdc7a800a4410000b00a150151350165001223355011002001133371802e02e0026a00a4400444004260086a6464646464a66a6666666ae900148cccd5cd19b8735573aa00a900011999aab9f500525019233335573ea00a4a03446666aae7d40149406c8cccd55cf9aba2500625335323232323333333574800846666ae68cdc39aab9d5004480008cccd55cfa8021281191999aab9f500425024233335573e6ae89401494cd4c088d5d0a80390a99a99a811119191919191999999aba400623333573466e1d40092002233335573ea00c4a05e46666aae7d4018940c08cccd55cfa8031281891999aab9f35744a00e4a66a605a6ae854028854cd4c0b8d5d0a80510a99a98179aba1500a21350361223330010050040031503415033150322503203303203103023333573466e1d400d2000233335573ea00e4a06046666aae7cd5d128041299a98171aba150092135033122300200315031250310320312502f02c02b2502d2502d2502d2502d02e135573aa00826ae8940044d5d1280089aab9e5001137540026ae85401c84d40a048cc00400c0085409854094940940980940909408807c940849408494084940840884d5d1280089aab9e5001137540026ae854024854cd4ccd54054070cd54054070060d5d0a80490a99a99a80d00e9aba150092135020123330010040030021501e1501d1501c2501c01d01c01b01a250180152501725017250172501701821001135626135744a00226ae8940044d55cf280089baa00135001223500222222222225335009132635335738921035054380001f01b22100222200232001355011225335001100422135002225335333573466e3c00801c02402040244c01800c488008488004c8004d5403488448894cd40044d400c88004884ccd401488008c010008ccd54c01c480040140100044488c88ccccccd5d2000aa8029299a98019bab002213500f0011500d55005550055500500e3200135500e223233335573e00446a01e2440044a66a600c6aae754008854cd4c018d55cf280190a99a98031aba200521350123212233001003004335500b003002150101500f1500e00f135742002224a0102244246600200600446666666ae900049401c9401c9401c8d4020dd6801128038040911919191999999aba400423333573466e1d40092000233335573ea0084a01846666aae7cd5d128029299a98049aba15006213500f3500f0011500d2500d00e00d23333573466e1d400d2002233335573ea00a46a01ca01a4a01a01c4a0180120104a0144a0144a0144a01401626aae7540084d55cf280089baa00123232323333333574800846666ae68cdc3a8012400446666aae7d4010940288cccd55cf9aba2500525335300a35742a00c426a01a24460020062a0164a01601801646666ae68cdc3a801a400046666aae7d40149402c8cccd55cf9aba2500625335300b35742a00e426a01c24460040062a0184a01801a0184a01400e00c4a0104a0104a0104a01001226aae7540084d55cf280089baa0014988ccccccd5d20009280192801928019280191a8021bae002004121223002003112200112001480e0448c8c00400488cc00cc00800800522011c', }; constructor(requestConfig: RequestConfig = {}) { @@ -129,6 +129,16 @@ export class VyFinance extends BaseDex { return Promise.reject('Unable to find relevant UTxO for cancelling the swap order.'); } + const pool: LiquidityPool | undefined = (await this.api.liquidityPools()) + .find((pool: LiquidityPool) => [pool.marketOrderAddress, pool.limitOrderAddress].includes(relevantUtxo.address)); + + if (! pool) { + return Promise.reject('Unable to find relevant liquidity pool for cancelling the swap order.'); + } + + const script: Script = this.orderScript; + script.script += `${pool.extra.nft.policyId}0001`; + return [ { address: returnAddress, @@ -138,7 +148,7 @@ export class VyFinance extends BaseDex { spendUtxos: [{ utxo: relevantUtxo, redeemer: this.cancelDatum, - validator: this.orderScript, + validator: script, signer: returnAddress, }], } diff --git a/src/providers/data/blockfrost-provider.ts b/src/providers/data/blockfrost-provider.ts index 847e739..924d084 100644 --- a/src/providers/data/blockfrost-provider.ts +++ b/src/providers/data/blockfrost-provider.ts @@ -92,6 +92,7 @@ export class BlockfrostProvider extends BaseDataProvider { txHash: response.data.hash, address: utxo.address, datumHash: utxo.data_hash, + datum: utxo.inline_datum, outputIndex: utxo.output_index, assetBalances: utxo.amount.reduce((assets: AssetBalance[], amount: any) => { assets.push({ diff --git a/src/providers/wallet/lucid-provider.ts b/src/providers/wallet/lucid-provider.ts index 12bf868..f94354f 100644 --- a/src/providers/wallet/lucid-provider.ts +++ b/src/providers/wallet/lucid-provider.ts @@ -105,8 +105,9 @@ export class LucidProvider extends BaseWalletProvider { txHash: spendUtxo.utxo.txHash, outputIndex: spendUtxo.utxo.outputIndex, address: spendUtxo.utxo.address, - datumHash: spendUtxo.utxo.datumHash, - assets: this.paymentFromAssets(spendUtxo.utxo.assetBalances) + datumHash: spendUtxo.utxo.datum ? null : spendUtxo.utxo.datumHash, + datum: spendUtxo.utxo.datum, + assets: this.paymentFromAssets(spendUtxo.utxo.assetBalances), } ], spendUtxo.redeemer); diff --git a/src/requests/cancel-swap-request.ts b/src/requests/cancel-swap-request.ts index c0bdc14..97dcfaa 100644 --- a/src/requests/cancel-swap-request.ts +++ b/src/requests/cancel-swap-request.ts @@ -61,7 +61,9 @@ export class CancelSwapRequest { cancelTransaction.status = TransactionStatus.Building; cancelTransaction.attachMetadata(MetadataKey.Message, { - msg: `[${this._dexter.config.metadataMsgBranding}] ${this._dexName} Cancel Swap` + msg: [ + `[${this._dexter.config.metadataMsgBranding}] ${this._dexName} Cancel Swap` + ] }); // Build transaction diff --git a/src/types.ts b/src/types.ts index 7e3fe05..91fcea3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -48,6 +48,7 @@ export type UTxO = { txHash: string, address: string, datumHash: string, + datum?: string, outputIndex: number, assetBalances: AssetBalance[], };