@swapkit/plugins 1.0.0-beta.0 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chainflip/index.cjs +2 -2
- package/dist/chainflip/index.cjs.map +4 -4
- package/dist/chainflip/index.js +2 -2
- package/dist/chainflip/index.js.map +4 -4
- package/dist/evm/index.cjs +2 -2
- package/dist/evm/index.cjs.map +3 -3
- package/dist/evm/index.js +2 -2
- package/dist/evm/index.js.map +3 -3
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +4 -3
- package/dist/index.js +2 -1
- package/dist/index.js.map +4 -3
- package/dist/kado/index.cjs +2 -2
- package/dist/kado/index.cjs.map +3 -3
- package/dist/kado/index.js +3 -3
- package/dist/kado/index.js.map +3 -3
- package/dist/radix/index.cjs.map +1 -1
- package/dist/radix/index.js.map +1 -1
- package/dist/solana/index.cjs +3 -0
- package/dist/solana/index.cjs.map +10 -0
- package/dist/solana/index.js +3 -0
- package/dist/solana/index.js.map +10 -0
- package/dist/thorchain/index.cjs +2 -2
- package/dist/thorchain/index.cjs.map +3 -3
- package/dist/thorchain/index.js +2 -2
- package/dist/thorchain/index.js.map +3 -3
- package/package.json +17 -8
- package/src/chainflip/broker.ts +12 -11
- package/src/chainflip/plugin.ts +3 -8
- package/src/evm/index.ts +1 -1
- package/src/index.ts +2 -3
- package/src/kado/helpers.ts +3 -3
- package/src/solana/index.ts +1 -0
- package/src/solana/plugin.ts +36 -0
- package/src/thorchain/plugin.ts +10 -11
- package/src/thorchain/types.ts +1 -16
- package/src/types.ts +19 -0
- package/src/utils.ts +34 -0
package/dist/chainflip/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var F={};
|
|
1
|
+
var F={};R(F,{assetIdentifierToChainflipTicker:()=>T,ChainflipPlugin:()=>E,ChainflipBroker:()=>D});module.exports=k(F);var g=require("@polkadot/keyring"),h=require("@polkadot/util"),s=require("@swapkit/helpers"),T=new Map([["ARB.ETH","ArbEth"],["ARB.USDC-0XAF88D065E77C8CC2239327C5EDB3A432268E5831","ArbUsdc"],["BTC.BTC","Btc"],["DOT.DOT","Dot"],["ETH.ETH","Eth"],["ETH.FLIP-0X826180541412D574CF1336D22C0C0A287822678A","Flip"],["ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48","Usdc"],["ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7","Usdt"],["SOL.SOL","Sol"],["SOL.USDC-EPJFWDD5AUFQSSQEM2QN1XZYBAPC8G4WEGGKZWYTDT1V","SolUsdc"]]),b=(e)=>()=>{let i=e.api.tx.swapping?.registerAsBroker?.();if(!i)throw new s.SwapKitError("chainflip_broker_register");return e.signAndBroadcast({tx:i,address:e.getAddress()})},y=(e)=>({feeAsset:i,recipient:r})=>{let n=i.chain===s.Chain.Polkadot,p=s.wrapWithThrow(()=>{return n?e.encodeAddress(e.decodeAddress(r),"hex"):r},"chainflip_broker_recipient_error");return new Promise((o)=>{let a=e.api.tx?.swapping?.withdraw?.(i.ticker.toLowerCase(),{[i.chain.toLowerCase()]:p});if(!a)throw new s.SwapKitError("chainflip_broker_withdraw");e.signAndBroadcast({tx:a,callback:async(f)=>{if(!f.status?.isFinalized)return;let d=f.events.find((w)=>w.event.method==="WithdrawalRequested");if(!d)throw new s.SwapKitError("chainflip_channel_error","Could not find 'WithdrawalRequested' event");let{event:{data:{egressId:A,egressAsset:u,egressAmount:c,egressFee:m,destinationAddress:C}}}=d.toHuman();o({egressId:A,egressAsset:u,egressAmount:c,egressFee:m,destinationAddress:C})}})})},B=(e)=>async({evmToolbox:i,stateChainAccount:r,assetValue:n})=>{let{chainflipGateway:p}=await import("@swapkit/helpers/contracts"),o=s.AssetValue.from({asset:"ETH.FLIP"});if(!n.eqAsset(o))throw new s.SwapKitError("chainflip_broker_fund_only_flip_supported");if(!e.validateAddress(r))throw new s.SwapKitError("chainflip_broker_fund_invalid_address");let a=h.isHex(r)?r:h.u8aToHex(g.decodeAddress(r));return i.call({abi:p,contractAddress:"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd",funcName:"fundStateChainAccount",funcParams:[a,n.getBaseValue("string")]})},D=(e)=>({registerAsBroker:b(e),fundStateChainAccount:B(e),withdrawFee:y(e)});var t=require("@swapkit/helpers"),l=require("@swapkit/helpers/api"),E=t.createPlugin({name:"chainflip",methods:({getWallet:e})=>({swap:async function i(r){let n=t.SKConfig.get("integrations").chainflip?.brokerUrl;if(!(r?.route?.buyAsset&&n&&r.route.meta.chainflip))throw new t.SwapKitError("core_swap_invalid_params",{...r,chainflipBrokerUrl:n});let{route:{buyAsset:p,sellAsset:o,sellAmount:a,destinationAddress:f,meta:{chainflip:d}},maxBoostFeeBps:A=0}=r;if(!(o&&p))throw new t.SwapKitError("core_swap_asset_not_recognized");let u=await t.AssetValue.from({asyncTokenLookup:!0,asset:o,value:a}),c=e(u.chain);if(!c)throw new t.SwapKitError("core_wallet_connection_not_found");let{depositAddress:m}=await l.SwapKitApi.getChainflipDepositChannel({...d,destinationAddress:f||d.destinationAddress,maxBoostFeeBps:A||d.maxBoostFeeBps});return await c.transfer({assetValue:u,sender:c.address,recipient:m,isProgramDerivedAddress:!0})}}),properties:{supportedSwapkitProviders:[t.ProviderName.CHAINFLIP,t.ProviderName.CHAINFLIP_STREAMING]}});
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=E9F48CA793E45EBF64756E2164756E21
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/chainflip/broker.ts", "../src/chainflip/plugin.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { decodeAddress } from \"@polkadot/keyring\";\nimport { isHex, u8aToHex } from \"@polkadot/util\";\nimport { AssetValue, Chain, SwapKitError, wrapWithThrow } from \"@swapkit/helpers\";\nimport
|
|
6
|
-
"import {\n AssetValue,\n type
|
|
5
|
+
"import { decodeAddress } from \"@polkadot/keyring\";\nimport { isHex, u8aToHex } from \"@polkadot/util\";\nimport { AssetValue, Chain, SwapKitError, wrapWithThrow } from \"@swapkit/helpers\";\nimport type { getEvmToolbox } from \"@swapkit/toolboxes/evm\";\nimport type { getSubstrateToolbox } from \"@swapkit/toolboxes/substrate\";\n\nimport type { WithdrawFeeResponse } from \"./types\";\n\ntype ChainflipToolbox = Awaited<ReturnType<typeof getSubstrateToolbox<Chain.Chainflip>>>;\n\nexport const assetIdentifierToChainflipTicker = new Map<string, string>([\n [\"ARB.ETH\", \"ArbEth\"],\n [\"ARB.USDC-0XAF88D065E77C8CC2239327C5EDB3A432268E5831\", \"ArbUsdc\"],\n [\"BTC.BTC\", \"Btc\"],\n [\"DOT.DOT\", \"Dot\"],\n [\"ETH.ETH\", \"Eth\"],\n [\"ETH.FLIP-0X826180541412D574CF1336D22C0C0A287822678A\", \"Flip\"],\n [\"ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48\", \"Usdc\"],\n [\"ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7\", \"Usdt\"],\n [\"SOL.SOL\", \"Sol\"],\n [\"SOL.USDC-EPJFWDD5AUFQSSQEM2QN1XZYBAPC8G4WEGGKZWYTDT1V\", \"SolUsdc\"],\n]);\n\nconst registerAsBroker = (toolbox: ChainflipToolbox) => () => {\n const extrinsic = toolbox.api.tx.swapping?.registerAsBroker?.();\n\n if (!extrinsic) {\n throw new SwapKitError(\"chainflip_broker_register\");\n }\n\n return toolbox.signAndBroadcast({ tx: extrinsic, address: toolbox.getAddress() });\n};\n\nconst withdrawFee =\n (toolbox: ChainflipToolbox) =>\n ({ feeAsset, recipient }: { feeAsset: AssetValue; recipient: string }) => {\n const isFeeChainPolkadot = feeAsset.chain === Chain.Polkadot;\n\n const recipientAddress = wrapWithThrow(() => {\n return isFeeChainPolkadot\n ? toolbox.encodeAddress(toolbox.decodeAddress(recipient), \"hex\")\n : recipient;\n }, \"chainflip_broker_recipient_error\");\n\n return new Promise<WithdrawFeeResponse>((resolve) => {\n const extrinsic = toolbox.api.tx?.swapping?.withdraw?.(feeAsset.ticker.toLowerCase(), {\n [feeAsset.chain.toLowerCase()]: recipientAddress,\n });\n\n if (!extrinsic) {\n throw new SwapKitError(\"chainflip_broker_withdraw\");\n }\n\n toolbox.signAndBroadcast({\n tx: extrinsic,\n callback: async (result) => {\n if (!result.status?.isFinalized) {\n return;\n }\n\n const withdrawEvent = result.events.find(\n (event) => event.event.method === \"WithdrawalRequested\",\n );\n\n if (!withdrawEvent) {\n throw new SwapKitError(\n \"chainflip_channel_error\",\n \"Could not find 'WithdrawalRequested' event\",\n );\n }\n const {\n event: {\n data: { egressId, egressAsset, egressAmount, egressFee, destinationAddress },\n },\n } = withdrawEvent.toHuman() as any;\n resolve({\n egressId,\n egressAsset,\n egressAmount,\n egressFee,\n destinationAddress,\n });\n },\n });\n });\n };\n\nconst fundStateChainAccount =\n (chainflipToolbox: ChainflipToolbox) =>\n async ({\n evmToolbox,\n stateChainAccount,\n assetValue,\n }: {\n evmToolbox: Awaited<ReturnType<typeof getEvmToolbox>>;\n stateChainAccount: string;\n assetValue: AssetValue;\n }) => {\n const { chainflipGateway } = await import(\"@swapkit/helpers/contracts\");\n\n const flipAssetValue = AssetValue.from({ asset: \"ETH.FLIP\" });\n\n if (!assetValue.eqAsset(flipAssetValue)) {\n throw new SwapKitError(\"chainflip_broker_fund_only_flip_supported\");\n }\n\n if (!chainflipToolbox.validateAddress(stateChainAccount)) {\n throw new SwapKitError(\"chainflip_broker_fund_invalid_address\");\n }\n\n const hexAddress = isHex(stateChainAccount)\n ? stateChainAccount\n : u8aToHex(decodeAddress(stateChainAccount));\n\n return evmToolbox.call<string>({\n abi: chainflipGateway,\n contractAddress: \"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd\",\n funcName: \"fundStateChainAccount\",\n funcParams: [hexAddress, assetValue.getBaseValue(\"string\")],\n });\n };\n\nexport const ChainflipBroker = (chainflipToolbox: ChainflipToolbox) => ({\n registerAsBroker: registerAsBroker(chainflipToolbox),\n fundStateChainAccount: fundStateChainAccount(chainflipToolbox),\n withdrawFee: withdrawFee(chainflipToolbox),\n});\n",
|
|
6
|
+
"import {\n AssetValue,\n type CryptoChain,\n ProviderName,\n SKConfig,\n SwapKitError,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport { SwapKitApi } from \"@swapkit/helpers/api\";\nimport type { RequestSwapDepositAddressParams } from \"./types\";\n\nexport const ChainflipPlugin = createPlugin({\n name: \"chainflip\",\n methods: ({ getWallet }) => ({\n swap: async function chainflipSwap(swapParams: RequestSwapDepositAddressParams) {\n const brokerUrl = SKConfig.get(\"integrations\").chainflip?.brokerUrl;\n\n if (!(swapParams?.route?.buyAsset && brokerUrl && swapParams.route.meta.chainflip)) {\n throw new SwapKitError(\"core_swap_invalid_params\", {\n ...swapParams,\n chainflipBrokerUrl: brokerUrl,\n });\n }\n\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n destinationAddress: recipient,\n meta: { chainflip },\n },\n maxBoostFeeBps = 0,\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString)) {\n throw new SwapKitError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({\n asyncTokenLookup: true,\n asset: sellAssetString,\n value: sellAmount,\n });\n\n const wallet = getWallet(sellAsset.chain as CryptoChain);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await SwapKitApi.getChainflipDepositChannel({\n ...chainflip,\n destinationAddress: recipient || chainflip.destinationAddress,\n maxBoostFeeBps: maxBoostFeeBps || chainflip.maxBoostFeeBps,\n });\n\n // @ts-expect-error TODO: right now it's inferred from toolboxes\n // we need to simplify this to one object params\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n sender: wallet.address,\n recipient: depositAddress,\n isProgramDerivedAddress: true,\n });\n\n return tx as string;\n },\n }),\n properties: {\n supported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,KAAK,CACtC,iBAAkB,GAClB,MAAO,EACP,MAAO,CACT,CAAC,EAEK,EAAS,EAAU,EAAU,KAAoB,EAEvD,IAAK,EACH,MAAM,IAAI,eAAa,kCAAkC,EAG3D,IAAQ,kBAAmB,MAAM,aAAW,2BAA2B,IAClE,EACH,mBAAoB,GAAa,EAAU,mBAC3C,eAAgB,GAAkB,EAAU,cAC9C,CAAC,EAWD,OAPW,MAAM,EAAO,SAAS,CAC/B,WAAY,EACZ,OAAQ,EAAO,QACf,UAAW,EACX,wBAAyB,EAC3B,CAAC,EAIL,GACA,WAAY,CACV,0BAA2B,CAAC,eAAa,UAAW,eAAa,mBAAmB,CACtF,CACF,CAAC",
|
|
9
|
+
"debugId": "E9F48CA793E45EBF64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/chainflip/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"../chunk-tvrdndbw.js";import{decodeAddress as
|
|
1
|
+
import{a as l,b as w}from"../chunk-tvrdndbw.js";import{decodeAddress as x}from"@polkadot/keyring";import{isHex as T,u8aToHex as b}from"@polkadot/util";import{AssetValue as y,Chain as B,SwapKitError as p,wrapWithThrow as D}from"@swapkit/helpers";var L=new Map([["ARB.ETH","ArbEth"],["ARB.USDC-0XAF88D065E77C8CC2239327C5EDB3A432268E5831","ArbUsdc"],["BTC.BTC","Btc"],["DOT.DOT","Dot"],["ETH.ETH","Eth"],["ETH.FLIP-0X826180541412D574CF1336D22C0C0A287822678A","Flip"],["ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48","Usdc"],["ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7","Usdt"],["SOL.SOL","Sol"],["SOL.USDC-EPJFWDD5AUFQSSQEM2QN1XZYBAPC8G4WEGGKZWYTDT1V","SolUsdc"]]),E=(e)=>()=>{let r=e.api.tx.swapping?.registerAsBroker?.();if(!r)throw new p("chainflip_broker_register");return e.signAndBroadcast({tx:r,address:e.getAddress()})},k=(e)=>({feeAsset:r,recipient:t})=>{let s=r.chain===B.Polkadot,a=D(()=>{return s?e.encodeAddress(e.decodeAddress(t),"hex"):t},"chainflip_broker_recipient_error");return new Promise((i)=>{let n=e.api.tx?.swapping?.withdraw?.(r.ticker.toLowerCase(),{[r.chain.toLowerCase()]:a});if(!n)throw new p("chainflip_broker_withdraw");e.signAndBroadcast({tx:n,callback:async(c)=>{if(!c.status?.isFinalized)return;let o=c.events.find((g)=>g.event.method==="WithdrawalRequested");if(!o)throw new p("chainflip_channel_error","Could not find 'WithdrawalRequested' event");let{event:{data:{egressId:u,egressAsset:f,egressAmount:d,egressFee:h,destinationAddress:m}}}=o.toHuman();i({egressId:u,egressAsset:f,egressAmount:d,egressFee:h,destinationAddress:m})}})})},R=(e)=>async({evmToolbox:r,stateChainAccount:t,assetValue:s})=>{let{chainflipGateway:a}=await import("@swapkit/helpers/contracts"),i=y.from({asset:"ETH.FLIP"});if(!s.eqAsset(i))throw new p("chainflip_broker_fund_only_flip_supported");if(!e.validateAddress(t))throw new p("chainflip_broker_fund_invalid_address");let n=T(t)?t:b(x(t));return r.call({abi:a,contractAddress:"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd",funcName:"fundStateChainAccount",funcParams:[n,s.getBaseValue("string")]})},U=(e)=>({registerAsBroker:E(e),fundStateChainAccount:R(e),withdrawFee:k(e)});import{AssetValue as F,ProviderName as C,SKConfig as _,SwapKitError as A,createPlugin as S}from"@swapkit/helpers";import{SwapKitApi as H}from"@swapkit/helpers/api";var M=S({name:"chainflip",methods:({getWallet:e})=>({swap:async function r(t){let s=_.get("integrations").chainflip?.brokerUrl;if(!(t?.route?.buyAsset&&s&&t.route.meta.chainflip))throw new A("core_swap_invalid_params",{...t,chainflipBrokerUrl:s});let{route:{buyAsset:a,sellAsset:i,sellAmount:n,destinationAddress:c,meta:{chainflip:o}},maxBoostFeeBps:u=0}=t;if(!(i&&a))throw new A("core_swap_asset_not_recognized");let f=await F.from({asyncTokenLookup:!0,asset:i,value:n}),d=e(f.chain);if(!d)throw new A("core_wallet_connection_not_found");let{depositAddress:h}=await H.getChainflipDepositChannel({...o,destinationAddress:c||o.destinationAddress,maxBoostFeeBps:u||o.maxBoostFeeBps});return await d.transfer({assetValue:f,sender:d.address,recipient:h,isProgramDerivedAddress:!0})}}),properties:{supportedSwapkitProviders:[C.CHAINFLIP,C.CHAINFLIP_STREAMING]}});export{L as assetIdentifierToChainflipTicker,M as ChainflipPlugin,U as ChainflipBroker};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=8EB8AC0447903D3764756E2164756E21
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/chainflip/broker.ts", "../src/chainflip/plugin.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { decodeAddress } from \"@polkadot/keyring\";\nimport { isHex, u8aToHex } from \"@polkadot/util\";\nimport { AssetValue, Chain, SwapKitError, wrapWithThrow } from \"@swapkit/helpers\";\nimport
|
|
6
|
-
"import {\n AssetValue,\n type
|
|
5
|
+
"import { decodeAddress } from \"@polkadot/keyring\";\nimport { isHex, u8aToHex } from \"@polkadot/util\";\nimport { AssetValue, Chain, SwapKitError, wrapWithThrow } from \"@swapkit/helpers\";\nimport type { getEvmToolbox } from \"@swapkit/toolboxes/evm\";\nimport type { getSubstrateToolbox } from \"@swapkit/toolboxes/substrate\";\n\nimport type { WithdrawFeeResponse } from \"./types\";\n\ntype ChainflipToolbox = Awaited<ReturnType<typeof getSubstrateToolbox<Chain.Chainflip>>>;\n\nexport const assetIdentifierToChainflipTicker = new Map<string, string>([\n [\"ARB.ETH\", \"ArbEth\"],\n [\"ARB.USDC-0XAF88D065E77C8CC2239327C5EDB3A432268E5831\", \"ArbUsdc\"],\n [\"BTC.BTC\", \"Btc\"],\n [\"DOT.DOT\", \"Dot\"],\n [\"ETH.ETH\", \"Eth\"],\n [\"ETH.FLIP-0X826180541412D574CF1336D22C0C0A287822678A\", \"Flip\"],\n [\"ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48\", \"Usdc\"],\n [\"ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7\", \"Usdt\"],\n [\"SOL.SOL\", \"Sol\"],\n [\"SOL.USDC-EPJFWDD5AUFQSSQEM2QN1XZYBAPC8G4WEGGKZWYTDT1V\", \"SolUsdc\"],\n]);\n\nconst registerAsBroker = (toolbox: ChainflipToolbox) => () => {\n const extrinsic = toolbox.api.tx.swapping?.registerAsBroker?.();\n\n if (!extrinsic) {\n throw new SwapKitError(\"chainflip_broker_register\");\n }\n\n return toolbox.signAndBroadcast({ tx: extrinsic, address: toolbox.getAddress() });\n};\n\nconst withdrawFee =\n (toolbox: ChainflipToolbox) =>\n ({ feeAsset, recipient }: { feeAsset: AssetValue; recipient: string }) => {\n const isFeeChainPolkadot = feeAsset.chain === Chain.Polkadot;\n\n const recipientAddress = wrapWithThrow(() => {\n return isFeeChainPolkadot\n ? toolbox.encodeAddress(toolbox.decodeAddress(recipient), \"hex\")\n : recipient;\n }, \"chainflip_broker_recipient_error\");\n\n return new Promise<WithdrawFeeResponse>((resolve) => {\n const extrinsic = toolbox.api.tx?.swapping?.withdraw?.(feeAsset.ticker.toLowerCase(), {\n [feeAsset.chain.toLowerCase()]: recipientAddress,\n });\n\n if (!extrinsic) {\n throw new SwapKitError(\"chainflip_broker_withdraw\");\n }\n\n toolbox.signAndBroadcast({\n tx: extrinsic,\n callback: async (result) => {\n if (!result.status?.isFinalized) {\n return;\n }\n\n const withdrawEvent = result.events.find(\n (event) => event.event.method === \"WithdrawalRequested\",\n );\n\n if (!withdrawEvent) {\n throw new SwapKitError(\n \"chainflip_channel_error\",\n \"Could not find 'WithdrawalRequested' event\",\n );\n }\n const {\n event: {\n data: { egressId, egressAsset, egressAmount, egressFee, destinationAddress },\n },\n } = withdrawEvent.toHuman() as any;\n resolve({\n egressId,\n egressAsset,\n egressAmount,\n egressFee,\n destinationAddress,\n });\n },\n });\n });\n };\n\nconst fundStateChainAccount =\n (chainflipToolbox: ChainflipToolbox) =>\n async ({\n evmToolbox,\n stateChainAccount,\n assetValue,\n }: {\n evmToolbox: Awaited<ReturnType<typeof getEvmToolbox>>;\n stateChainAccount: string;\n assetValue: AssetValue;\n }) => {\n const { chainflipGateway } = await import(\"@swapkit/helpers/contracts\");\n\n const flipAssetValue = AssetValue.from({ asset: \"ETH.FLIP\" });\n\n if (!assetValue.eqAsset(flipAssetValue)) {\n throw new SwapKitError(\"chainflip_broker_fund_only_flip_supported\");\n }\n\n if (!chainflipToolbox.validateAddress(stateChainAccount)) {\n throw new SwapKitError(\"chainflip_broker_fund_invalid_address\");\n }\n\n const hexAddress = isHex(stateChainAccount)\n ? stateChainAccount\n : u8aToHex(decodeAddress(stateChainAccount));\n\n return evmToolbox.call<string>({\n abi: chainflipGateway,\n contractAddress: \"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd\",\n funcName: \"fundStateChainAccount\",\n funcParams: [hexAddress, assetValue.getBaseValue(\"string\")],\n });\n };\n\nexport const ChainflipBroker = (chainflipToolbox: ChainflipToolbox) => ({\n registerAsBroker: registerAsBroker(chainflipToolbox),\n fundStateChainAccount: fundStateChainAccount(chainflipToolbox),\n withdrawFee: withdrawFee(chainflipToolbox),\n});\n",
|
|
6
|
+
"import {\n AssetValue,\n type CryptoChain,\n ProviderName,\n SKConfig,\n SwapKitError,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport { SwapKitApi } from \"@swapkit/helpers/api\";\nimport type { RequestSwapDepositAddressParams } from \"./types\";\n\nexport const ChainflipPlugin = createPlugin({\n name: \"chainflip\",\n methods: ({ getWallet }) => ({\n swap: async function chainflipSwap(swapParams: RequestSwapDepositAddressParams) {\n const brokerUrl = SKConfig.get(\"integrations\").chainflip?.brokerUrl;\n\n if (!(swapParams?.route?.buyAsset && brokerUrl && swapParams.route.meta.chainflip)) {\n throw new SwapKitError(\"core_swap_invalid_params\", {\n ...swapParams,\n chainflipBrokerUrl: brokerUrl,\n });\n }\n\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n destinationAddress: recipient,\n meta: { chainflip },\n },\n maxBoostFeeBps = 0,\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString)) {\n throw new SwapKitError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({\n asyncTokenLookup: true,\n asset: sellAssetString,\n value: sellAmount,\n });\n\n const wallet = getWallet(sellAsset.chain as CryptoChain);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await SwapKitApi.getChainflipDepositChannel({\n ...chainflip,\n destinationAddress: recipient || chainflip.destinationAddress,\n maxBoostFeeBps: maxBoostFeeBps || chainflip.maxBoostFeeBps,\n });\n\n // @ts-expect-error TODO: right now it's inferred from toolboxes\n // we need to simplify this to one object params\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n sender: wallet.address,\n recipient: depositAddress,\n isProgramDerivedAddress: true,\n });\n\n return tx as string;\n },\n }),\n properties: {\n supportedSwapkitProviders: [ProviderName.CHAINFLIP, ProviderName.CHAINFLIP_STREAMING],\n },\n});\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": "
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": "gDAAA,wBAAS,0BACT,gBAAS,cAAO,uBAChB,qBAAS,WAAY,kBAAO,mBAAc,yBAQnC,IAAM,EAAmC,IAAI,IAAoB,CACtE,CAAC,UAAW,QAAQ,EACpB,CAAC,sDAAuD,SAAS,EACjE,CAAC,UAAW,KAAK,EACjB,CAAC,UAAW,KAAK,EACjB,CAAC,UAAW,KAAK,EACjB,CAAC,sDAAuD,MAAM,EAC9D,CAAC,sDAAuD,MAAM,EAC9D,CAAC,sDAAuD,MAAM,EAC9D,CAAC,UAAW,KAAK,EACjB,CAAC,wDAAyD,SAAS,CACrE,CAAC,EAE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E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/evm/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var E={};V(E,{EVMPlugin:()=>l});module.exports=m(E);var e=require("@swapkit/helpers");function v({approveMode:a,getWallet:c}){return function n({assetValue:s,spenderAddress:t}){let p=s.chain,r=e.EVMChains.includes(p);if(r&&s.isGasAsset||!r||s.isSynthetic){let d=a==="checkOnly"||"approved";return Promise.resolve(d)}let o=c(p),i=a==="checkOnly"?o.isApproved:o.approve;if(!(s.address&&o.address))throw new e.SwapKitError("core_approve_asset_address_or_from_not_found");return i({amount:s.getBaseValue("bigint"),assetAddress:s.address,from:o.address,spenderAddress:t})}}var l=e.createPlugin({name:"evm",properties:{supportedSwapkitProviders:[e.ProviderName.CAMELOT_V3,e.ProviderName.OPENOCEAN_V2,e.ProviderName.ONEINCH,e.ProviderName.PANCAKESWAP,e.ProviderName.PANGOLIN_V1,e.ProviderName.SUSHISWAP_V2,e.ProviderName.TRADERJOE_V2,e.ProviderName.UNISWAP_V2,e.ProviderName.UNISWAP_V3]},methods:({getWallet:a})=>({approveAssetValue:v({approveMode:e.ApproveMode.Approve,getWallet:a}),isAssetValueApproved:v({approveMode:e.ApproveMode.CheckOnly,getWallet:a}),swap:async function c({route:{tx:n,sellAsset:s},feeOptionKey:t}){let r=(await e.AssetValue.from({asset:s,asyncTokenLookup:!0})).chain,u=a(r);if(!(e.EVMChains.includes(r)&&n))throw new e.SwapKitError("core_swap_invalid_params");let{from:o,to:i,data:d,value:A}=n;return u.sendTransaction({from:o,to:i,data:d,value:BigInt(A)
|
|
1
|
+
var E={};V(E,{EVMPlugin:()=>l});module.exports=m(E);var e=require("@swapkit/helpers");function v({approveMode:a,getWallet:c}){return function n({assetValue:s,spenderAddress:t}){let p=s.chain,r=e.EVMChains.includes(p);if(r&&s.isGasAsset||!r||s.isSynthetic){let d=a==="checkOnly"||"approved";return Promise.resolve(d)}let o=c(p),i=a==="checkOnly"?o.isApproved:o.approve;if(!(s.address&&o.address))throw new e.SwapKitError("core_approve_asset_address_or_from_not_found");return i({amount:s.getBaseValue("bigint"),assetAddress:s.address,from:o.address,spenderAddress:t})}}var l=e.createPlugin({name:"evm",properties:{supportedSwapkitProviders:[e.ProviderName.CAMELOT_V3,e.ProviderName.OPENOCEAN_V2,e.ProviderName.ONEINCH,e.ProviderName.PANCAKESWAP,e.ProviderName.PANGOLIN_V1,e.ProviderName.SUSHISWAP_V2,e.ProviderName.TRADERJOE_V2,e.ProviderName.UNISWAP_V2,e.ProviderName.UNISWAP_V3]},methods:({getWallet:a})=>({approveAssetValue:v({approveMode:e.ApproveMode.Approve,getWallet:a}),isAssetValueApproved:v({approveMode:e.ApproveMode.CheckOnly,getWallet:a}),swap:async function c({route:{tx:n,sellAsset:s},feeOptionKey:t}){let r=(await e.AssetValue.from({asset:s,asyncTokenLookup:!0})).chain,u=a(r);if(!(e.EVMChains.includes(r)&&n))throw new e.SwapKitError("core_swap_invalid_params");let{from:o,to:i,data:d,value:A}=n;return u.sendTransaction({from:o,to:i,data:d,value:BigInt(A),feeOptionKey:t})}})});
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=FDF9BDCE1CF4B05064756E2164756E21
|
package/dist/evm/index.cjs.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/evm/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import {\n ApproveMode,\n type ApproveReturnType,\n AssetValue,\n type EVMChain,\n EVMChains,\n ProviderName,\n SwapKitError,\n type SwapKitPluginParams,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@swapkit/helpers/api\";\n\nfunction approve<T extends ApproveMode>({\n approveMode,\n getWallet,\n}: { approveMode: T } & SwapKitPluginParams) {\n return function approveEVM({\n assetValue,\n spenderAddress,\n }: { spenderAddress: string; assetValue: AssetValue }) {\n const evmChain = assetValue.chain as EVMChain;\n const isEVMChain = EVMChains.includes(evmChain);\n const isNativeEVM = isEVMChain && assetValue.isGasAsset;\n\n if (isNativeEVM || !isEVMChain || assetValue.isSynthetic) {\n const isApproved = approveMode === \"checkOnly\" || \"approved\";\n return Promise.resolve(isApproved) as ApproveReturnType<T>;\n }\n\n const wallet = getWallet(evmChain);\n const walletAction = approveMode === \"checkOnly\" ? wallet.isApproved : wallet.approve;\n\n if (!(assetValue.address && wallet.address)) {\n throw new SwapKitError(\"core_approve_asset_address_or_from_not_found\");\n }\n\n return walletAction({\n amount: assetValue.getBaseValue(\"bigint\"),\n assetAddress: assetValue.address,\n from: wallet.address,\n spenderAddress,\n });\n };\n}\n\nexport const EVMPlugin = createPlugin({\n name: \"evm\",\n properties: {\n supportedSwapkitProviders: [\n ProviderName.CAMELOT_V3,\n ProviderName.OPENOCEAN_V2,\n ProviderName.ONEINCH,\n ProviderName.PANCAKESWAP,\n ProviderName.PANGOLIN_V1,\n ProviderName.SUSHISWAP_V2,\n ProviderName.TRADERJOE_V2,\n ProviderName.UNISWAP_V2,\n ProviderName.UNISWAP_V3,\n ],\n },\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: async function evmSwap({\n route: { tx, sellAsset },\n feeOptionKey,\n }: SwapParams<\"evm\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({ asset: sellAsset, asyncTokenLookup: true });\n const evmChain = assetValue.chain as EVMChain;\n const wallet = getWallet(evmChain);\n\n if (!(EVMChains.includes(evmChain) && tx)) {\n throw new SwapKitError(\"core_swap_invalid_params\");\n }\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ from, to, data, value: BigInt(value)
|
|
5
|
+
"import {\n ApproveMode,\n type ApproveReturnType,\n AssetValue,\n type EVMChain,\n EVMChains,\n ProviderName,\n SwapKitError,\n type SwapKitPluginParams,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@swapkit/helpers/api\";\n\nfunction approve<T extends ApproveMode>({\n approveMode,\n getWallet,\n}: { approveMode: T } & SwapKitPluginParams) {\n return function approveEVM({\n assetValue,\n spenderAddress,\n }: { spenderAddress: string; assetValue: AssetValue }) {\n const evmChain = assetValue.chain as EVMChain;\n const isEVMChain = EVMChains.includes(evmChain);\n const isNativeEVM = isEVMChain && assetValue.isGasAsset;\n\n if (isNativeEVM || !isEVMChain || assetValue.isSynthetic) {\n const isApproved = approveMode === \"checkOnly\" || \"approved\";\n return Promise.resolve(isApproved) as ApproveReturnType<T>;\n }\n\n const wallet = getWallet(evmChain);\n const walletAction = approveMode === \"checkOnly\" ? wallet.isApproved : wallet.approve;\n\n if (!(assetValue.address && wallet.address)) {\n throw new SwapKitError(\"core_approve_asset_address_or_from_not_found\");\n }\n\n return walletAction({\n amount: assetValue.getBaseValue(\"bigint\"),\n assetAddress: assetValue.address,\n from: wallet.address,\n spenderAddress,\n });\n };\n}\n\nexport const EVMPlugin = createPlugin({\n name: \"evm\",\n properties: {\n supportedSwapkitProviders: [\n ProviderName.CAMELOT_V3,\n ProviderName.OPENOCEAN_V2,\n ProviderName.ONEINCH,\n ProviderName.PANCAKESWAP,\n ProviderName.PANGOLIN_V1,\n ProviderName.SUSHISWAP_V2,\n ProviderName.TRADERJOE_V2,\n ProviderName.UNISWAP_V2,\n ProviderName.UNISWAP_V3,\n ],\n },\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: async function evmSwap({\n route: { tx, sellAsset },\n feeOptionKey,\n }: SwapParams<\"evm\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({ asset: sellAsset, asyncTokenLookup: true });\n const evmChain = assetValue.chain as EVMChain;\n const wallet = getWallet(evmChain);\n\n if (!(EVMChains.includes(evmChain) && tx)) {\n throw new SwapKitError(\"core_swap_invalid_params\");\n }\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ from, to, data, value: BigInt(value), feeOptionKey });\n },\n }),\n});\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "oDAWO,IAXP,8BAcA,SAAS,CAA8B,EACrC,cACA,aAC2C,CAC3C,
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "oDAWO,IAXP,8BAcA,SAAS,CAA8B,EACrC,cACA,aAC2C,CAC3C,OAAO,SAAS,CAAU,EACxB,aACA,kBACqD,CACrD,IAAM,EAAW,EAAW,MACtB,EAAa,YAAU,SAAS,CAAQ,EAG9C,GAFoB,GAAc,EAAW,aAEzB,GAAc,EAAW,YAAa,CACxD,IAAM,EAAa,IAAgB,aAAe,WAClD,OAAO,QAAQ,QAAQ,CAAU,EAGnC,IAAM,EAAS,EAAU,CAAQ,EAC3B,EAAe,IAAgB,YAAc,EAAO,WAAa,EAAO,QAE9E,KAAM,EAAW,SAAW,EAAO,SACjC,MAAM,IAAI,eAAa,8CAA8C,EAGvE,OAAO,EAAa,CAClB,OAAQ,EAAW,aAAa,QAAQ,EACxC,aAAc,EAAW,QACzB,KAAM,EAAO,QACb,gBACF,CAAC,GAIE,IAAM,EAAY,eAAa,CACpC,KAAM,MACN,WAAY,CACV,0BAA2B,CACzB,eAAa,WACb,eAAa,aACb,eAAa,QACb,eAAa,YACb,eAAa,YACb,eAAa,aACb,eAAa,aACb,eAAa,WACb,eAAa,UACf,CACF,EACA,QAAS,EAAG,gBAAiB,CAC3B,kBAAmB,EAAQ,CAAE,YAAa,cAAY,QAAS,WAAU,CAAC,EAC1E,qBAAsB,EAAQ,CAAE,YAAa,cAAY,UAAW,WAAU,CAAC,EAC/E,KAAM,eAAe,CAAO,EAC1B,OAAS,KAAI,aACb,gBACwC,CAExC,IAAM,GADa,MAAM,aAAW,KAAK,CAAE,MAAO,EAAW,iBAAkB,EAAK,CAAC,GACzD,MACtB,EAAS,EAAU,CAAQ,EAEjC,KAAM,YAAU,SAAS,CAAQ,GAAK,GACpC,MAAM,IAAI,eAAa,0BAA0B,EAGnD,IAAQ,OAAM,KAAI,OAAM,SAAU,EAClC,OAAO,EAAO,gBAAgB,CAAE,OAAM,KAAI,OAAM,MAAO,OAAO,CAAK,EAAG,cAAa,CAAC,EAExF,EACF,CAAC",
|
|
8
|
+
"debugId": "FDF9BDCE1CF4B05064756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/evm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"../chunk-tvrdndbw.js";import{ApproveMode as v,AssetValue as E,EVMChains as m,ProviderName as e,SwapKitError as V,createPlugin as w}from"@swapkit/helpers";function A({approveMode:a,getWallet:c}){return function n({assetValue:s,spenderAddress:t}){let p=s.chain,r=m.includes(p);if(r&&s.isGasAsset||!r||s.isSynthetic){let d=a==="checkOnly"||"approved";return Promise.resolve(d)}let o=c(p),i=a==="checkOnly"?o.isApproved:o.approve;if(!(s.address&&o.address))throw new V("core_approve_asset_address_or_from_not_found");return i({amount:s.getBaseValue("bigint"),assetAddress:s.address,from:o.address,spenderAddress:t})}}var h=w({name:"evm",properties:{supportedSwapkitProviders:[e.CAMELOT_V3,e.OPENOCEAN_V2,e.ONEINCH,e.PANCAKESWAP,e.PANGOLIN_V1,e.SUSHISWAP_V2,e.TRADERJOE_V2,e.UNISWAP_V2,e.UNISWAP_V3]},methods:({getWallet:a})=>({approveAssetValue:A({approveMode:v.Approve,getWallet:a}),isAssetValueApproved:A({approveMode:v.CheckOnly,getWallet:a}),swap:async function c({route:{tx:n,sellAsset:s},feeOptionKey:t}){let r=(await E.from({asset:s,asyncTokenLookup:!0})).chain,u=a(r);if(!(m.includes(r)&&n))throw new V("core_swap_invalid_params");let{from:o,to:i,data:d,value:l}=n;return u.sendTransaction({from:o,to:i,data:d,value:BigInt(l)
|
|
1
|
+
import"../chunk-tvrdndbw.js";import{ApproveMode as v,AssetValue as E,EVMChains as m,ProviderName as e,SwapKitError as V,createPlugin as w}from"@swapkit/helpers";function A({approveMode:a,getWallet:c}){return function n({assetValue:s,spenderAddress:t}){let p=s.chain,r=m.includes(p);if(r&&s.isGasAsset||!r||s.isSynthetic){let d=a==="checkOnly"||"approved";return Promise.resolve(d)}let o=c(p),i=a==="checkOnly"?o.isApproved:o.approve;if(!(s.address&&o.address))throw new V("core_approve_asset_address_or_from_not_found");return i({amount:s.getBaseValue("bigint"),assetAddress:s.address,from:o.address,spenderAddress:t})}}var h=w({name:"evm",properties:{supportedSwapkitProviders:[e.CAMELOT_V3,e.OPENOCEAN_V2,e.ONEINCH,e.PANCAKESWAP,e.PANGOLIN_V1,e.SUSHISWAP_V2,e.TRADERJOE_V2,e.UNISWAP_V2,e.UNISWAP_V3]},methods:({getWallet:a})=>({approveAssetValue:A({approveMode:v.Approve,getWallet:a}),isAssetValueApproved:A({approveMode:v.CheckOnly,getWallet:a}),swap:async function c({route:{tx:n,sellAsset:s},feeOptionKey:t}){let r=(await E.from({asset:s,asyncTokenLookup:!0})).chain,u=a(r);if(!(m.includes(r)&&n))throw new V("core_swap_invalid_params");let{from:o,to:i,data:d,value:l}=n;return u.sendTransaction({from:o,to:i,data:d,value:BigInt(l),feeOptionKey:t})}})});export{h as EVMPlugin};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=E47DB87BB400068364756E2164756E21
|
package/dist/evm/index.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/evm/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import {\n ApproveMode,\n type ApproveReturnType,\n AssetValue,\n type EVMChain,\n EVMChains,\n ProviderName,\n SwapKitError,\n type SwapKitPluginParams,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@swapkit/helpers/api\";\n\nfunction approve<T extends ApproveMode>({\n approveMode,\n getWallet,\n}: { approveMode: T } & SwapKitPluginParams) {\n return function approveEVM({\n assetValue,\n spenderAddress,\n }: { spenderAddress: string; assetValue: AssetValue }) {\n const evmChain = assetValue.chain as EVMChain;\n const isEVMChain = EVMChains.includes(evmChain);\n const isNativeEVM = isEVMChain && assetValue.isGasAsset;\n\n if (isNativeEVM || !isEVMChain || assetValue.isSynthetic) {\n const isApproved = approveMode === \"checkOnly\" || \"approved\";\n return Promise.resolve(isApproved) as ApproveReturnType<T>;\n }\n\n const wallet = getWallet(evmChain);\n const walletAction = approveMode === \"checkOnly\" ? wallet.isApproved : wallet.approve;\n\n if (!(assetValue.address && wallet.address)) {\n throw new SwapKitError(\"core_approve_asset_address_or_from_not_found\");\n }\n\n return walletAction({\n amount: assetValue.getBaseValue(\"bigint\"),\n assetAddress: assetValue.address,\n from: wallet.address,\n spenderAddress,\n });\n };\n}\n\nexport const EVMPlugin = createPlugin({\n name: \"evm\",\n properties: {\n supportedSwapkitProviders: [\n ProviderName.CAMELOT_V3,\n ProviderName.OPENOCEAN_V2,\n ProviderName.ONEINCH,\n ProviderName.PANCAKESWAP,\n ProviderName.PANGOLIN_V1,\n ProviderName.SUSHISWAP_V2,\n ProviderName.TRADERJOE_V2,\n ProviderName.UNISWAP_V2,\n ProviderName.UNISWAP_V3,\n ],\n },\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: async function evmSwap({\n route: { tx, sellAsset },\n feeOptionKey,\n }: SwapParams<\"evm\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({ asset: sellAsset, asyncTokenLookup: true });\n const evmChain = assetValue.chain as EVMChain;\n const wallet = getWallet(evmChain);\n\n if (!(EVMChains.includes(evmChain) && tx)) {\n throw new SwapKitError(\"core_swap_invalid_params\");\n }\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ from, to, data, value: BigInt(value)
|
|
5
|
+
"import {\n ApproveMode,\n type ApproveReturnType,\n AssetValue,\n type EVMChain,\n EVMChains,\n ProviderName,\n SwapKitError,\n type SwapKitPluginParams,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@swapkit/helpers/api\";\n\nfunction approve<T extends ApproveMode>({\n approveMode,\n getWallet,\n}: { approveMode: T } & SwapKitPluginParams) {\n return function approveEVM({\n assetValue,\n spenderAddress,\n }: { spenderAddress: string; assetValue: AssetValue }) {\n const evmChain = assetValue.chain as EVMChain;\n const isEVMChain = EVMChains.includes(evmChain);\n const isNativeEVM = isEVMChain && assetValue.isGasAsset;\n\n if (isNativeEVM || !isEVMChain || assetValue.isSynthetic) {\n const isApproved = approveMode === \"checkOnly\" || \"approved\";\n return Promise.resolve(isApproved) as ApproveReturnType<T>;\n }\n\n const wallet = getWallet(evmChain);\n const walletAction = approveMode === \"checkOnly\" ? wallet.isApproved : wallet.approve;\n\n if (!(assetValue.address && wallet.address)) {\n throw new SwapKitError(\"core_approve_asset_address_or_from_not_found\");\n }\n\n return walletAction({\n amount: assetValue.getBaseValue(\"bigint\"),\n assetAddress: assetValue.address,\n from: wallet.address,\n spenderAddress,\n });\n };\n}\n\nexport const EVMPlugin = createPlugin({\n name: \"evm\",\n properties: {\n supportedSwapkitProviders: [\n ProviderName.CAMELOT_V3,\n ProviderName.OPENOCEAN_V2,\n ProviderName.ONEINCH,\n ProviderName.PANCAKESWAP,\n ProviderName.PANGOLIN_V1,\n ProviderName.SUSHISWAP_V2,\n ProviderName.TRADERJOE_V2,\n ProviderName.UNISWAP_V2,\n ProviderName.UNISWAP_V3,\n ],\n },\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: async function evmSwap({\n route: { tx, sellAsset },\n feeOptionKey,\n }: SwapParams<\"evm\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({ asset: sellAsset, asyncTokenLookup: true });\n const evmChain = assetValue.chain as EVMChain;\n const wallet = getWallet(evmChain);\n\n if (!(EVMChains.includes(evmChain) && tx)) {\n throw new SwapKitError(\"core_swap_invalid_params\");\n }\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ from, to, data, value: BigInt(value), feeOptionKey });\n },\n }),\n});\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "6BAAA,sBACE,gBAEA,eAEA,kBACA,kBACA,kBAGA,yBAIF,SAAS,CAA8B,EACrC,cACA,aAC2C,CAC3C,
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "6BAAA,sBACE,gBAEA,eAEA,kBACA,kBACA,kBAGA,yBAIF,SAAS,CAA8B,EACrC,cACA,aAC2C,CAC3C,OAAO,SAAS,CAAU,EACxB,aACA,kBACqD,CACrD,IAAM,EAAW,EAAW,MACtB,EAAa,EAAU,SAAS,CAAQ,EAG9C,GAFoB,GAAc,EAAW,aAEzB,GAAc,EAAW,YAAa,CACxD,IAAM,EAAa,IAAgB,aAAe,WAClD,OAAO,QAAQ,QAAQ,CAAU,EAGnC,IAAM,EAAS,EAAU,CAAQ,EAC3B,EAAe,IAAgB,YAAc,EAAO,WAAa,EAAO,QAE9E,KAAM,EAAW,SAAW,EAAO,SACjC,MAAM,IAAI,EAAa,8CAA8C,EAGvE,OAAO,EAAa,CAClB,OAAQ,EAAW,aAAa,QAAQ,EACxC,aAAc,EAAW,QACzB,KAAM,EAAO,QACb,gBACF,CAAC,GAIE,IAAM,EAAY,EAAa,CACpC,KAAM,MACN,WAAY,CACV,0BAA2B,CACzB,EAAa,WACb,EAAa,aACb,EAAa,QACb,EAAa,YACb,EAAa,YACb,EAAa,aACb,EAAa,aACb,EAAa,WACb,EAAa,UACf,CACF,EACA,QAAS,EAAG,gBAAiB,CAC3B,kBAAmB,EAAQ,CAAE,YAAa,EAAY,QAAS,WAAU,CAAC,EAC1E,qBAAsB,EAAQ,CAAE,YAAa,EAAY,UAAW,WAAU,CAAC,EAC/E,KAAM,eAAe,CAAO,EAC1B,OAAS,KAAI,aACb,gBACwC,CAExC,IAAM,GADa,MAAM,EAAW,KAAK,CAAE,MAAO,EAAW,iBAAkB,EAAK,CAAC,GACzD,MACtB,EAAS,EAAU,CAAQ,EAEjC,KAAM,EAAU,SAAS,CAAQ,GAAK,GACpC,MAAM,IAAI,EAAa,0BAA0B,EAGnD,IAAQ,OAAM,KAAI,OAAM,SAAU,EAClC,OAAO,EAAO,gBAAgB,CAAE,OAAM,KAAI,OAAM,MAAO,OAAO,CAAK,EAAG,cAAa,CAAC,EAExF,EACF,CAAC",
|
|
8
|
+
"debugId": "E47DB87BB400068364756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var e={};p(e,{loadPlugin:()=>a});module.exports=r(e);async function a(n){let{match:o}=await import("ts-pattern");return await o(n).with("chainflip",async()=>{let{ChainflipPlugin:i}=await import("./chainflip/index.cjs");return i}).with("thorchain",async()=>{let{ThorchainPlugin:i}=await import("./thorchain/index.cjs");return i}).with("kado",async()=>{let{KadoPlugin:i}=await import("./kado/index.cjs");return i}).with("radix",async()=>{let{RadixPlugin:i}=await import("./radix/index.cjs");return i}).with("evm",async()=>{let{EVMPlugin:i}=await import("./evm/index.cjs");return i}).with("solana",async()=>{let{SolanaPlugin:i}=await import("./solana/index.cjs");return i}).exhaustive()}
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=5E5900B00E90B40864756E2164756E21
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
3
|
+
"sources": ["../src/utils.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"import type { PluginName, SKPlugins } from \"./types\";\n\nexport async function loadPlugin<P extends PluginName>(pluginName: P) {\n const { match } = await import(\"ts-pattern\");\n\n const plugin = await match(pluginName as PluginName)\n .with(\"chainflip\", async () => {\n const { ChainflipPlugin } = await import(\"./chainflip\");\n return ChainflipPlugin;\n })\n .with(\"thorchain\", async () => {\n const { ThorchainPlugin } = await import(\"./thorchain\");\n return ThorchainPlugin;\n })\n .with(\"kado\", async () => {\n const { KadoPlugin } = await import(\"./kado\");\n return KadoPlugin;\n })\n .with(\"radix\", async () => {\n const { RadixPlugin } = await import(\"./radix\");\n return RadixPlugin;\n })\n .with(\"evm\", async () => {\n const { EVMPlugin } = await import(\"./evm\");\n return EVMPlugin;\n })\n .with(\"solana\", async () => {\n const { SolanaPlugin } = await import(\"./solana\");\n return SolanaPlugin;\n })\n .exhaustive();\n\n return plugin as unknown as SKPlugins[P];\n}\n"
|
|
5
6
|
],
|
|
6
|
-
"mappings": "",
|
|
7
|
-
"debugId": "
|
|
7
|
+
"mappings": "qDAEA,eAAsB,CAAgC,CAAC,EAAe,CACpE,IAAQ,SAAU,KAAa,sBA6B/B,OA3Be,MAAM,EAAM,CAAwB,EAChD,KAAK,YAAa,SAAY,CAC7B,IAAQ,mBAAoB,KAAa,iCACzC,OAAO,EACR,EACA,KAAK,YAAa,SAAY,CAC7B,IAAQ,mBAAoB,KAAa,iCACzC,OAAO,EACR,EACA,KAAK,OAAQ,SAAY,CACxB,IAAQ,cAAe,KAAa,4BACpC,OAAO,EACR,EACA,KAAK,QAAS,SAAY,CACzB,IAAQ,eAAgB,KAAa,6BACrC,OAAO,EACR,EACA,KAAK,MAAO,SAAY,CACvB,IAAQ,aAAc,KAAa,2BACnC,OAAO,EACR,EACA,KAAK,SAAU,SAAY,CAC1B,IAAQ,gBAAiB,KAAa,8BACtC,OAAO,EACR,EACA,WAAW",
|
|
8
|
+
"debugId": "5E5900B00E90B40864756E2164756E21",
|
|
8
9
|
"names": []
|
|
9
10
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import{a as t,b as n}from"./chunk-tvrdndbw.js";async function p(o){let{match:a}=await import("ts-pattern");return await a(o).with("chainflip",async()=>{let{ChainflipPlugin:i}=await import("./chainflip/index.js");return i}).with("thorchain",async()=>{let{ThorchainPlugin:i}=await import("./thorchain/index.js");return i}).with("kado",async()=>{let{KadoPlugin:i}=await import("./kado/index.js");return i}).with("radix",async()=>{let{RadixPlugin:i}=await import("./radix/index.js");return i}).with("evm",async()=>{let{EVMPlugin:i}=await import("./evm/index.js");return i}).with("solana",async()=>{let{SolanaPlugin:i}=await import("./solana/index.js");return i}).exhaustive()}export{p as loadPlugin};
|
|
1
2
|
|
|
2
|
-
//# debugId=
|
|
3
|
+
//# debugId=228B6887332A42FE64756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
3
|
+
"sources": ["../src/utils.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"import type { PluginName, SKPlugins } from \"./types\";\n\nexport async function loadPlugin<P extends PluginName>(pluginName: P) {\n const { match } = await import(\"ts-pattern\");\n\n const plugin = await match(pluginName as PluginName)\n .with(\"chainflip\", async () => {\n const { ChainflipPlugin } = await import(\"./chainflip\");\n return ChainflipPlugin;\n })\n .with(\"thorchain\", async () => {\n const { ThorchainPlugin } = await import(\"./thorchain\");\n return ThorchainPlugin;\n })\n .with(\"kado\", async () => {\n const { KadoPlugin } = await import(\"./kado\");\n return KadoPlugin;\n })\n .with(\"radix\", async () => {\n const { RadixPlugin } = await import(\"./radix\");\n return RadixPlugin;\n })\n .with(\"evm\", async () => {\n const { EVMPlugin } = await import(\"./evm\");\n return EVMPlugin;\n })\n .with(\"solana\", async () => {\n const { SolanaPlugin } = await import(\"./solana\");\n return SolanaPlugin;\n })\n .exhaustive();\n\n return plugin as unknown as SKPlugins[P];\n}\n"
|
|
5
6
|
],
|
|
6
|
-
"mappings": "",
|
|
7
|
-
"debugId": "
|
|
7
|
+
"mappings": "+CAEA,eAAsB,CAAgC,CAAC,EAAe,CACpE,IAAQ,SAAU,KAAa,sBA6B/B,OA3Be,MAAM,EAAM,CAAwB,EAChD,KAAK,YAAa,SAAY,CAC7B,IAAQ,mBAAoB,KAAa,gCACzC,OAAO,EACR,EACA,KAAK,YAAa,SAAY,CAC7B,IAAQ,mBAAoB,KAAa,gCACzC,OAAO,EACR,EACA,KAAK,OAAQ,SAAY,CACxB,IAAQ,cAAe,KAAa,2BACpC,OAAO,EACR,EACA,KAAK,QAAS,SAAY,CACzB,IAAQ,eAAgB,KAAa,4BACrC,OAAO,EACR,EACA,KAAK,MAAO,SAAY,CACvB,IAAQ,aAAc,KAAa,0BACnC,OAAO,EACR,EACA,KAAK,SAAU,SAAY,CAC1B,IAAQ,gBAAiB,KAAa,6BACtC,OAAO,EACR,EACA,WAAW",
|
|
8
|
+
"debugId": "228B6887332A42FE64756E2164756E21",
|
|
8
9
|
"names": []
|
|
9
10
|
}
|
package/dist/kado/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var k={};P(k,{mapKadoQuoteToQuoteResponse:()=>f,SupportedKadoChain:()=>b,KadoSupportedFiatCurrencies:()=>E,KadoPlugin:()=>O,KadoChainToChain:()=>I,ChainToKadoChain:()=>h});module.exports=N(k);var t=require("@swapkit/helpers"),b={thorchain:t.Chain.THORChain,solana:t.Chain.Solana,polygon:t.Chain.Polygon,Optimism:t.Chain.Optimism,litecoin:t.Chain.Litecoin,kujira:t.Chain.Kujira,ethereum:t.Chain.Ethereum,"cosmos hub":t.Chain.Cosmos,bitcoin:t.Chain.Bitcoin,base:t.Chain.Base,Avalanche:t.Chain.Avalanche,Arbitrum:t.Chain.Arbitrum};function h(n){let r=Object.entries(b).find(([e,a])=>a===n);if(!r)throw new Error(`Chain ${n} not supported`);return r[0]}function I(n){if(!Object.keys(b).includes(n))throw new Error(`KadoChain ${n} not supported`);return b[n]}function f({quote:n,sellAsset:o,buyAsset:r}){let e=o.chain,a=r.chain,c=e===t.Chain.Fiat,{receive:u,price:p,baseAmount:s,totalFee:m,processingFee:d,networkFee:g}=n.data.quote,y=r.set(c?u.unitCount.toString():u.amount.toString()),x=c?Math.round(m.amount/u.amount*1e4):Math.round(m.amount/(p.price*s.amount)*1e4),l=Math.ceil(t.
|
|
1
|
+
var k={};P(k,{mapKadoQuoteToQuoteResponse:()=>f,SupportedKadoChain:()=>b,KadoSupportedFiatCurrencies:()=>E,KadoPlugin:()=>O,KadoChainToChain:()=>I,ChainToKadoChain:()=>h});module.exports=N(k);var t=require("@swapkit/helpers"),b={thorchain:t.Chain.THORChain,solana:t.Chain.Solana,polygon:t.Chain.Polygon,Optimism:t.Chain.Optimism,litecoin:t.Chain.Litecoin,kujira:t.Chain.Kujira,ethereum:t.Chain.Ethereum,"cosmos hub":t.Chain.Cosmos,bitcoin:t.Chain.Bitcoin,base:t.Chain.Base,Avalanche:t.Chain.Avalanche,Arbitrum:t.Chain.Arbitrum};function h(n){let r=Object.entries(b).find(([e,a])=>a===n);if(!r)throw new Error(`Chain ${n} not supported`);return r[0]}function I(n){if(!Object.keys(b).includes(n))throw new Error(`KadoChain ${n} not supported`);return b[n]}function f({quote:n,sellAsset:o,buyAsset:r}){let e=o.chain,a=r.chain,c=e===t.Chain.Fiat,{receive:u,price:p,baseAmount:s,totalFee:m,processingFee:d,networkFee:g}=n.data.quote,y=r.set(c?u.unitCount.toString():u.amount.toString()),x=c?Math.round(m.amount/u.amount*1e4):Math.round(m.amount/(p.price*s.amount)*1e4),l=Math.ceil(t.BlockTimes[e]*3),C=Math.ceil(60),K=Math.ceil(t.BlockTimes[a]),S=[{buyAsset:r.toString(),destinationAddress:"{destinationAddress}",estimatedTime:{inbound:l,swap:C,outbound:K,total:l+C+K},expectedBuyAmount:y.getValue("string"),expectedBuyAmountMaxSlippage:y.getValue("string"),providers:[t.ProviderName.KADO],sellAmount:o.getValue("string"),sellAsset:o.toString(),sourceAddress:"{sourceAddress}",totalSlippageBps:x,fees:[{asset:d.currency,amount:d.amount.toString(),type:t.FeeTypeEnum.LIQUIDITY,protocol:t.ProviderName.KADO,chain:t.Chain.Fiat},{asset:g.currency,amount:g.amount.toString(),type:t.FeeTypeEnum.NETWORK,protocol:t.ProviderName.KADO,chain:r.chain}],legs:[{provider:t.ProviderName.KADO,sellAsset:o.toString(),sellAmount:o.getValue("string"),buyAsset:r.toString(),buyAmount:u.unitCount.toString(),buyAmountMaxSlippage:u.unitCount.toString(),fees:[{asset:d.currency,amount:d.amount.toString(),type:t.FeeTypeEnum.LIQUIDITY,protocol:t.ProviderName.KADO,chain:t.Chain.Fiat},{asset:g.currency,amount:g.amount.toString(),type:t.FeeTypeEnum.NETWORK,protocol:t.ProviderName.KADO,chain:r.chain}]}],warnings:[],meta:{tags:[]}}];return{quoteId:crypto.randomUUID(),routes:S,error:n.success?void 0:n.message}}var i=require("@swapkit/helpers");var O=i.createPlugin({name:"kado",methods:()=>({createPopover:R,getAssets:T,getBlockchains:v,getKadoWidgetUrl:F,getOrderStatus:M,fetchProviderQuote:D,swap:_}),properties:{supportedSwapkitProviders:[i.ProviderName.KADO]}});function _({route:n}){if(!(n.sourceAddress&&n.destinationAddress))throw new Error("Source and destination addresses are required");let o=i.AssetValue.from({asset:n.sellAsset}),r=i.AssetValue.from({asset:n.buyAsset}),e=o.chain===i.Chain.Fiat?"buy":"sell",a=F({sellAsset:o,buyAsset:r,recipient:n.destinationAddress,sender:n.sourceAddress,type:e,mode:"minimal"});return R(a),{status:"pending",txHash:null}}async function D({sellAsset:n,buyAsset:o,fiatMethod:r="credit_card"}){try{let e=n.chain===i.Chain.Fiat,[a,c]=e?[o,n]:[n,o],u=e?"buy":"sell",p={amount:a.getValue("string"),asset:a.symbol,blockchain:h(a.chain),currency:c.symbol,fiatMethod:r,partner:"fortress",transactionType:u},s=i.SKConfig.get("apiKeys").kado;i.warnOnce(!s,"plugin(kado): No Kado API key found");let m=await i.RequestClient.get("https://api.kado.money/v2/ramp/quote",{searchParams:p,headers:{"X-Widget-Id":s}});if(!m.success)throw new Error(m.message);return f({quote:m,sellAsset:n,buyAsset:o})}catch(e){throw new Error("core_swap_quote_error")}}async function v(){let n=await i.RequestClient.get("https://api.kado.money/v1/ramp/blockchains");if(!n.success)throw new Error(n.message);return n.data.blockchains}async function T(){let n=await i.RequestClient.get("https://api.kado.money/v1/ramp/supported-assets");if(!n.success)throw new Error(n.message);return n.data.assets}async function M(n){let o=i.SKConfig.get("apiKeys").kado;i.warnOnce(!o,"plugin(kado): No Kado API key found");try{let r=await i.RequestClient.get(`https://api.kado.money/v2/public/orders/${n}`,{headers:{"X-Widget-Id":o}});if(!r.success)throw new Error(r.message);return r.data.order}catch(r){throw new Error("Failed to get order status")}}function F({sellAsset:n,buyAsset:o,recipient:r,type:e,sender:a,mode:c}){let u=i.SKConfig.get("apiKeys").kado;i.warnOnce(!u,"plugin(kado): No Kado API key found");let p=e==="buy"?{onPayAmount:n.getValue("string"),onPayCurrency:n.symbol,onRevCurrency:o.symbol,...r?{onToAddress:r}:{}}:{offPayAmount:n.getValue("string"),offPayCurrency:n.symbol,offRevCurrency:o.symbol,...a?{offFromAddress:a}:{}},s=h(e==="buy"?o.chain:n.chain).toUpperCase();return`https://app.kado.money/?${new URLSearchParams({...p,apiKey:u,network:s,product:e.toUpperCase(),mode:c}).toString()}`}function R(n){let o=document.createElement("div");o.style.cssText=`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -17,4 +17,4 @@ var k={};P(k,{mapKadoQuoteToQuoteResponse:()=>f,SupportedKadoChain:()=>b,KadoSup
|
|
|
17
17
|
background: white;
|
|
18
18
|
`,o.appendChild(r),document.body.appendChild(o),o.addEventListener("click",(e)=>{if(e.target===o)document.body.removeChild(o)}),o}var E=["USD","CAD","GBP","EUR","MXN","COP","INR","CHF","AUD","ARS","BRL","CLP","JPY","KRW","PEN","PHP","SGD","TRY","UYU","TWD","VND","CRC","SEK","PLN","DKK","NOK","NZD"];
|
|
19
19
|
|
|
20
|
-
//# debugId=
|
|
20
|
+
//# debugId=3680F2EEFA51A34064756E2164756E21
|
package/dist/kado/index.cjs.map
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/kado/helpers.ts", "../src/kado/plugin.ts", "../src/kado/types.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { type AssetValue, Chain, FeeTypeEnum, ProviderName
|
|
5
|
+
"import { type AssetValue, BlockTimes, Chain, FeeTypeEnum, ProviderName } from \"@swapkit/helpers\";\nimport type { QuoteResponse, QuoteResponseRoute } from \"@swapkit/helpers/api\";\nimport type { KadoQuoteResponse } from \"./types\";\n\nexport const SupportedKadoChain = {\n thorchain: Chain.THORChain,\n solana: Chain.Solana,\n polygon: Chain.Polygon,\n Optimism: Chain.Optimism,\n litecoin: Chain.Litecoin,\n kujira: Chain.Kujira,\n ethereum: Chain.Ethereum,\n \"cosmos hub\": Chain.Cosmos,\n bitcoin: Chain.Bitcoin,\n base: Chain.Base,\n Avalanche: Chain.Avalanche,\n Arbitrum: Chain.Arbitrum,\n};\n\nexport function ChainToKadoChain(chain: Chain) {\n const entries = Object.entries(SupportedKadoChain);\n const found = entries.find(([_, value]) => value === chain);\n if (!found) throw new Error(`Chain ${chain} not supported`);\n return found[0];\n}\n\nexport function KadoChainToChain(kadoChain: string) {\n const found = Object.keys(SupportedKadoChain).includes(kadoChain);\n if (!found) throw new Error(`KadoChain ${kadoChain} not supported`);\n return SupportedKadoChain[kadoChain as keyof typeof SupportedKadoChain];\n}\n\nexport function mapKadoQuoteToQuoteResponse({\n quote,\n sellAsset,\n buyAsset,\n}: { quote: KadoQuoteResponse; sellAsset: AssetValue; buyAsset: AssetValue }): QuoteResponse {\n const sellAssetChain = sellAsset.chain;\n const buyAssetChain = buyAsset.chain;\n const isOnRamp = sellAssetChain === Chain.Fiat;\n const { receive, price, baseAmount, totalFee, processingFee, networkFee } = quote.data.quote;\n\n const buyAssetAmount = buyAsset.set(\n isOnRamp ? receive.unitCount.toString() : receive.amount.toString(),\n );\n const totalSlippageBps = isOnRamp\n ? Math.round((totalFee.amount / receive.amount) * 10_000)\n : Math.round((totalFee.amount / (price.price * baseAmount.amount)) * 10_000);\n\n const inbound = Math.ceil(BlockTimes[sellAssetChain] * 3);\n const swap = Math.ceil(60);\n const outbound = Math.ceil(BlockTimes[buyAssetChain]);\n const routes: QuoteResponseRoute[] = [\n {\n buyAsset: buyAsset.toString(),\n destinationAddress: \"{destinationAddress}\",\n estimatedTime: { inbound, swap, outbound, total: inbound + swap + outbound },\n expectedBuyAmount: buyAssetAmount.getValue(\"string\"),\n expectedBuyAmountMaxSlippage: buyAssetAmount.getValue(\"string\"),\n providers: [ProviderName.KADO],\n sellAmount: sellAsset.getValue(\"string\"),\n sellAsset: sellAsset.toString(),\n sourceAddress: \"{sourceAddress}\",\n totalSlippageBps,\n fees: [\n {\n asset: processingFee.currency,\n amount: processingFee.amount.toString(),\n type: FeeTypeEnum.LIQUIDITY,\n protocol: ProviderName.KADO,\n chain: Chain.Fiat,\n },\n {\n asset: networkFee.currency,\n amount: networkFee.amount.toString(),\n type: FeeTypeEnum.NETWORK,\n protocol: ProviderName.KADO,\n chain: buyAsset.chain,\n },\n ],\n legs: [\n {\n provider: ProviderName.KADO,\n sellAsset: sellAsset.toString(),\n sellAmount: sellAsset.getValue(\"string\"),\n buyAsset: buyAsset.toString(),\n buyAmount: receive.unitCount.toString(),\n buyAmountMaxSlippage: receive.unitCount.toString(),\n fees: [\n {\n asset: processingFee.currency,\n amount: processingFee.amount.toString(),\n type: FeeTypeEnum.LIQUIDITY,\n protocol: ProviderName.KADO,\n chain: Chain.Fiat,\n },\n {\n asset: networkFee.currency,\n amount: networkFee.amount.toString(),\n type: FeeTypeEnum.NETWORK,\n protocol: ProviderName.KADO,\n chain: buyAsset.chain,\n },\n ],\n },\n ],\n warnings: [],\n meta: { tags: [] },\n },\n ];\n\n return {\n quoteId: crypto.randomUUID(),\n routes,\n error: quote.success ? undefined : quote.message,\n };\n}\n",
|
|
6
6
|
"import {\n AssetValue,\n Chain,\n ProviderName,\n RequestClient,\n SKConfig,\n type SwapParams,\n createPlugin,\n warnOnce,\n} from \"@swapkit/helpers\";\nimport type { QuoteResponse, QuoteResponseRoute } from \"@swapkit/helpers/api\";\nimport { ChainToKadoChain, mapKadoQuoteToQuoteResponse } from \"./helpers\";\nimport type {\n KadoAssetsResponse,\n KadoBlockchainsResponse,\n KadoFiatCurrency,\n KadoFiatMethod,\n KadoQuoteRequest,\n KadoQuoteResponse,\n} from \"./types\";\n\nexport const KadoPlugin = createPlugin({\n name: \"kado\",\n methods: () => ({\n createPopover,\n getAssets,\n getBlockchains,\n getKadoWidgetUrl,\n getOrderStatus,\n fetchProviderQuote,\n swap,\n }),\n properties: {\n supportedSwapkitProviders: [ProviderName.KADO],\n },\n});\n\nfunction swap({ route }: SwapParams<\"evm\", QuoteResponseRoute>) {\n if (!(route.sourceAddress && route.destinationAddress)) {\n throw new Error(\"Source and destination addresses are required\");\n }\n\n const sellAsset = AssetValue.from({ asset: route.sellAsset });\n const buyAsset = AssetValue.from({ asset: route.buyAsset });\n\n // Determine if this is a buy or sell operation\n const type = sellAsset.chain === Chain.Fiat ? \"buy\" : \"sell\";\n\n const url = getKadoWidgetUrl({\n sellAsset,\n buyAsset,\n recipient: route.destinationAddress,\n sender: route.sourceAddress,\n type,\n mode: \"minimal\",\n });\n\n createPopover(url);\n\n return {\n status: \"pending\",\n txHash: null,\n };\n}\n\nasync function fetchProviderQuote({\n sellAsset,\n buyAsset,\n fiatMethod = \"credit_card\",\n}: {\n sellAsset: AssetValue;\n buyAsset: AssetValue;\n fiatMethod: KadoFiatMethod;\n}): Promise<QuoteResponse> {\n try {\n const isOnRamp = sellAsset.chain === Chain.Fiat;\n const [paymentAsset, receiveAsset] = isOnRamp ? [buyAsset, sellAsset] : [sellAsset, buyAsset];\n const transactionType = isOnRamp ? \"buy\" : \"sell\";\n\n const quoteRequest: KadoQuoteRequest = {\n amount: paymentAsset.getValue(\"string\"),\n asset: paymentAsset.symbol,\n blockchain: ChainToKadoChain(paymentAsset.chain),\n currency: receiveAsset.symbol as KadoFiatCurrency,\n fiatMethod,\n partner: \"fortress\",\n transactionType,\n };\n\n const kadoApiKey = SKConfig.get(\"apiKeys\").kado;\n warnOnce(!kadoApiKey, \"plugin(kado): No Kado API key found\");\n\n const quote = await RequestClient.get<KadoQuoteResponse>(\n \"https://api.kado.money/v2/ramp/quote\",\n { searchParams: quoteRequest, headers: { \"X-Widget-Id\": kadoApiKey } },\n );\n\n if (!quote.success) {\n throw new Error(quote.message);\n }\n\n return mapKadoQuoteToQuoteResponse({ quote, sellAsset, buyAsset });\n } catch (_) {\n throw new Error(\"core_swap_quote_error\");\n }\n}\n\nasync function getBlockchains() {\n const response = await RequestClient.get<KadoBlockchainsResponse>(\n \"https://api.kado.money/v1/ramp/blockchains\",\n );\n\n if (!response.success) {\n throw new Error(response.message);\n }\n\n return response.data.blockchains;\n}\n\nasync function getAssets() {\n const response = await RequestClient.get<KadoAssetsResponse>(\n \"https://api.kado.money/v1/ramp/supported-assets\",\n );\n\n if (!response.success) {\n throw new Error(response.message);\n }\n\n return response.data.assets;\n}\n\nasync function getOrderStatus(orderId: string) {\n const kadoApiKey = SKConfig.get(\"apiKeys\").kado;\n warnOnce(!kadoApiKey, \"plugin(kado): No Kado API key found\");\n\n try {\n const response = await RequestClient.get<{\n success: boolean;\n message: string;\n data: { order: { status: string } };\n }>(`https://api.kado.money/v2/public/orders/${orderId}`, {\n headers: { \"X-Widget-Id\": kadoApiKey },\n });\n\n if (!response.success) {\n throw new Error(response.message);\n }\n\n return response.data.order;\n } catch (_error) {\n throw new Error(\"Failed to get order status\");\n }\n}\n\nfunction getKadoWidgetUrl({\n sellAsset,\n buyAsset,\n recipient,\n type,\n sender,\n mode,\n}: {\n sellAsset: AssetValue;\n buyAsset: AssetValue;\n recipient?: string;\n sender?: string;\n type: \"buy\" | \"sell\";\n mode: \"minimal\" | \"full\";\n}) {\n const kadoApiKey = SKConfig.get(\"apiKeys\").kado;\n warnOnce(!kadoApiKey, \"plugin(kado): No Kado API key found\");\n\n const buySellParams =\n type === \"buy\"\n ? {\n onPayAmount: sellAsset.getValue(\"string\"),\n onPayCurrency: sellAsset.symbol,\n onRevCurrency: buyAsset.symbol,\n ...(recipient ? { onToAddress: recipient } : {}),\n }\n : {\n offPayAmount: sellAsset.getValue(\"string\"),\n offPayCurrency: sellAsset.symbol,\n offRevCurrency: buyAsset.symbol,\n ...(sender ? { offFromAddress: sender } : {}),\n };\n const network = ChainToKadoChain(type === \"buy\" ? buyAsset.chain : sellAsset.chain).toUpperCase();\n const urlParams = new URLSearchParams({\n ...buySellParams,\n apiKey: kadoApiKey,\n network,\n product: type.toUpperCase(),\n mode,\n });\n\n return `https://app.kado.money/?${urlParams.toString()}`;\n}\n\nfunction createPopover(url: string) {\n const overlay = document.createElement(\"div\");\n overlay.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n justify-content: center;\n align-items: center;\n z-index: 9999;\n `;\n\n const iframe = document.createElement(\"iframe\");\n iframe.src = url;\n iframe.style.cssText = `\n width: 440px;\n height: 700px;\n border: none;\n border-radius: 12px;\n background: white;\n `;\n\n overlay.appendChild(iframe);\n document.body.appendChild(overlay);\n\n overlay.addEventListener(\"click\", (e) => {\n if (e.target === overlay) {\n document.body.removeChild(overlay);\n }\n });\n\n return overlay;\n}\n",
|
|
7
7
|
"import type { SupportedKadoChain } from \"./helpers\";\n\nexport const KadoSupportedFiatCurrencies = [\n \"USD\",\n \"CAD\",\n \"GBP\",\n \"EUR\",\n \"MXN\",\n \"COP\",\n \"INR\",\n \"CHF\",\n \"AUD\",\n \"ARS\",\n \"BRL\",\n \"CLP\",\n \"JPY\",\n \"KRW\",\n \"PEN\",\n \"PHP\",\n \"SGD\",\n \"TRY\",\n \"UYU\",\n \"TWD\",\n \"VND\",\n \"CRC\",\n \"SEK\",\n \"PLN\",\n \"DKK\",\n \"NOK\",\n \"NZD\",\n] as const;\n\nexport type KadoFiatCurrency = (typeof KadoSupportedFiatCurrencies)[number];\n\nexport type KadoFiatMethod =\n | \"ach\"\n | \"debit_card\"\n | \"credit_card\"\n | \"apple_pay_credit\"\n | \"apple_pay_debit\"\n | \"wire\"\n | \"sepa\"\n | \"pix\"\n | \"koywe\";\n\nexport type KadoQuoteRequest = {\n transactionType: \"buy\" | \"sell\";\n fiatMethod: KadoFiatMethod;\n partner: \"fortress\";\n amount: string;\n asset: string;\n blockchain: string;\n currency: KadoFiatCurrency;\n};\n\nexport type KadoAsset = {\n _id: string;\n name: string;\n description: string;\n label: string;\n symbol: string;\n supportedProviders: string[];\n stablecoin: boolean;\n liveOnRamp: boolean;\n createdAt: string;\n updatedAt: string;\n __v: number;\n priority: number;\n displayPrecision: number;\n usesAvaxRouter: boolean;\n squidChainId: string;\n coingeckoId: string;\n usesAxelarBridge: boolean;\n squidAssetId: string;\n address: string;\n blockExplorerURI: string;\n decimals: number;\n officialChainId: keyof typeof SupportedKadoChain;\n precision: number;\n rampProducts: string[];\n wallets: string[];\n rpcURI: string;\n usesPolygonFulfillment: boolean;\n usesOsmoRouter: boolean;\n ibcChannelIdOffRamp: number;\n ibcChannelIdOnRamp: number;\n osmoPfmChannel: number;\n osmoPfmReceiver: string;\n ibcDenom: string;\n isNative: boolean;\n avgOffRampTimeInSeconds: number;\n avgOnRampTimeInSeconds: number;\n providers: string[];\n trustekAssetId: string;\n trustekNetworkId: string;\n kycLevels: string[];\n};\n\nexport type KadoBlockchainsResponse = {\n success: boolean;\n message: string;\n data: {\n blockchains: {\n _id: string;\n supportedEnvironment: string;\n network: string;\n origin: string;\n label: string;\n associatedAssets: KadoAsset[];\n avgTransactionTimeSeconds: number;\n usesAvaxRouter: boolean;\n liveOnRamp: boolean;\n createdAt: string;\n updatedAt: string;\n __v: number;\n priority: number;\n }[];\n };\n};\n\nexport type KadoAssetsResponse = {\n success: boolean;\n message: string;\n data: {\n assets: {\n _id: string;\n name: string;\n description: string;\n label: string;\n symbol: string;\n supportedProviders: string[];\n stablecoin: boolean;\n liveOnRamp: boolean;\n createdAt: string;\n updatedAt: string;\n __v: number;\n priority: number;\n }[];\n };\n};\n\nexport type KadoQuoteResponse = {\n success: boolean;\n message: string;\n data: {\n request: {\n transactionType: string;\n fiatMethod: KadoFiatMethod;\n partner: string;\n amount: number;\n asset: string;\n blockchain: keyof typeof SupportedKadoChain;\n currency: KadoFiatCurrency;\n reverse: false;\n ipCountry: string;\n };\n quote: {\n asset: string;\n baseAmount: {\n amount: number;\n currency: KadoFiatCurrency;\n };\n price: {\n amount: number;\n price: number;\n symbol: string;\n unit: string;\n };\n bridgeFee: {\n amount: number;\n currency: KadoFiatCurrency;\n originalAmount: number;\n promotionModifier: number;\n };\n receiveAmountAfterFees: {\n originalAmount: number;\n amount: number;\n currency: KadoFiatCurrency;\n };\n receiveUnitCountAfterFees: {\n amount: number;\n currency: KadoFiatCurrency;\n };\n feeType: string;\n minValue: {\n amount: number;\n unit: string;\n };\n maxValue: {\n amount: number;\n unit: string;\n };\n receive: {\n amount: number;\n originalAmount: number;\n symbol: string;\n unit: string;\n unitCount: number;\n };\n networkFee: {\n amount: number;\n currency: KadoFiatCurrency;\n originalAmount: number;\n promotionModifier: number;\n };\n processingFee: {\n amount: number;\n currency: KadoFiatCurrency;\n originalAmount: number;\n promotionModifier: number;\n };\n totalFee: {\n amount: number;\n currency: KadoFiatCurrency;\n originalAmount: number;\n };\n smartContractFee: {\n amount: number;\n currency: KadoFiatCurrency;\n originalAmount: number;\n promotionModifier: number;\n };\n };\n };\n};\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": "gM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F",
|
|
10
|
+
"debugId": "3680F2EEFA51A34064756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/dist/kado/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../chunk-tvrdndbw.js";import{Chain as i,FeeTypeEnum as b,ProviderName as s
|
|
1
|
+
import"../chunk-tvrdndbw.js";import{BlockTimes as S,Chain as i,FeeTypeEnum as b,ProviderName as s}from"@swapkit/helpers";var f={thorchain:i.THORChain,solana:i.Solana,polygon:i.Polygon,Optimism:i.Optimism,litecoin:i.Litecoin,kujira:i.Kujira,ethereum:i.Ethereum,"cosmos hub":i.Cosmos,bitcoin:i.Bitcoin,base:i.Base,Avalanche:i.Avalanche,Arbitrum:i.Arbitrum};function y(n){let o=Object.entries(f).find(([r,e])=>e===n);if(!o)throw new Error(`Chain ${n} not supported`);return o[0]}function A(n){if(!Object.keys(f).includes(n))throw new Error(`KadoChain ${n} not supported`);return f[n]}function I({quote:n,sellAsset:t,buyAsset:o}){let r=t.chain,e=o.chain,m=r===i.Fiat,{receive:a,price:p,baseAmount:c,totalFee:u,processingFee:d,networkFee:g}=n.data.quote,K=o.set(m?a.unitCount.toString():a.amount.toString()),T=m?Math.round(u.amount/a.amount*1e4):Math.round(u.amount/(p.price*c.amount)*1e4),F=Math.ceil(S[r]*3),R=Math.ceil(60),x=Math.ceil(S[e]),M=[{buyAsset:o.toString(),destinationAddress:"{destinationAddress}",estimatedTime:{inbound:F,swap:R,outbound:x,total:F+R+x},expectedBuyAmount:K.getValue("string"),expectedBuyAmountMaxSlippage:K.getValue("string"),providers:[s.KADO],sellAmount:t.getValue("string"),sellAsset:t.toString(),sourceAddress:"{sourceAddress}",totalSlippageBps:T,fees:[{asset:d.currency,amount:d.amount.toString(),type:b.LIQUIDITY,protocol:s.KADO,chain:i.Fiat},{asset:g.currency,amount:g.amount.toString(),type:b.NETWORK,protocol:s.KADO,chain:o.chain}],legs:[{provider:s.KADO,sellAsset:t.toString(),sellAmount:t.getValue("string"),buyAsset:o.toString(),buyAmount:a.unitCount.toString(),buyAmountMaxSlippage:a.unitCount.toString(),fees:[{asset:d.currency,amount:d.amount.toString(),type:b.LIQUIDITY,protocol:s.KADO,chain:i.Fiat},{asset:g.currency,amount:g.amount.toString(),type:b.NETWORK,protocol:s.KADO,chain:o.chain}]}],warnings:[],meta:{tags:[]}}];return{quoteId:crypto.randomUUID(),routes:M,error:n.success?void 0:n.message}}import{AssetValue as O,Chain as _,ProviderName as E,RequestClient as h,SKConfig as l,createPlugin as N,warnOnce as C}from"@swapkit/helpers";var j=N({name:"kado",methods:()=>({createPopover:v,getAssets:B,getBlockchains:U,getKadoWidgetUrl:D,getOrderStatus:Q,fetchProviderQuote:k,swap:P}),properties:{supportedSwapkitProviders:[E.KADO]}});function P({route:n}){if(!(n.sourceAddress&&n.destinationAddress))throw new Error("Source and destination addresses are required");let t=O.from({asset:n.sellAsset}),o=O.from({asset:n.buyAsset}),r=t.chain===_.Fiat?"buy":"sell",e=D({sellAsset:t,buyAsset:o,recipient:n.destinationAddress,sender:n.sourceAddress,type:r,mode:"minimal"});return v(e),{status:"pending",txHash:null}}async function k({sellAsset:n,buyAsset:t,fiatMethod:o="credit_card"}){try{let r=n.chain===_.Fiat,[e,m]=r?[t,n]:[n,t],a=r?"buy":"sell",p={amount:e.getValue("string"),asset:e.symbol,blockchain:y(e.chain),currency:m.symbol,fiatMethod:o,partner:"fortress",transactionType:a},c=l.get("apiKeys").kado;C(!c,"plugin(kado): No Kado API key found");let u=await h.get("https://api.kado.money/v2/ramp/quote",{searchParams:p,headers:{"X-Widget-Id":c}});if(!u.success)throw new Error(u.message);return I({quote:u,sellAsset:n,buyAsset:t})}catch(r){throw new Error("core_swap_quote_error")}}async function U(){let n=await h.get("https://api.kado.money/v1/ramp/blockchains");if(!n.success)throw new Error(n.message);return n.data.blockchains}async function B(){let n=await h.get("https://api.kado.money/v1/ramp/supported-assets");if(!n.success)throw new Error(n.message);return n.data.assets}async function Q(n){let t=l.get("apiKeys").kado;C(!t,"plugin(kado): No Kado API key found");try{let o=await h.get(`https://api.kado.money/v2/public/orders/${n}`,{headers:{"X-Widget-Id":t}});if(!o.success)throw new Error(o.message);return o.data.order}catch(o){throw new Error("Failed to get order status")}}function D({sellAsset:n,buyAsset:t,recipient:o,type:r,sender:e,mode:m}){let a=l.get("apiKeys").kado;C(!a,"plugin(kado): No Kado API key found");let p=r==="buy"?{onPayAmount:n.getValue("string"),onPayCurrency:n.symbol,onRevCurrency:t.symbol,...o?{onToAddress:o}:{}}:{offPayAmount:n.getValue("string"),offPayCurrency:n.symbol,offRevCurrency:t.symbol,...e?{offFromAddress:e}:{}},c=y(r==="buy"?t.chain:n.chain).toUpperCase();return`https://app.kado.money/?${new URLSearchParams({...p,apiKey:a,network:c,product:r.toUpperCase(),mode:m}).toString()}`}function v(n){let t=document.createElement("div");t.style.cssText=`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -15,6 +15,6 @@ import"../chunk-tvrdndbw.js";import{Chain as i,FeeTypeEnum as b,ProviderName as
|
|
|
15
15
|
border: none;
|
|
16
16
|
border-radius: 12px;
|
|
17
17
|
background: white;
|
|
18
|
-
`,t.appendChild(o),document.body.appendChild(t),t.addEventListener("click",(r)=>{if(r.target===t)document.body.removeChild(t)}),t}var G=["USD","CAD","GBP","EUR","MXN","COP","INR","CHF","AUD","ARS","BRL","CLP","JPY","KRW","PEN","PHP","SGD","TRY","UYU","TWD","VND","CRC","SEK","PLN","DKK","NOK","NZD"];export{I as mapKadoQuoteToQuoteResponse,f as SupportedKadoChain,G as KadoSupportedFiatCurrencies,j as KadoPlugin,
|
|
18
|
+
`,t.appendChild(o),document.body.appendChild(t),t.addEventListener("click",(r)=>{if(r.target===t)document.body.removeChild(t)}),t}var G=["USD","CAD","GBP","EUR","MXN","COP","INR","CHF","AUD","ARS","BRL","CLP","JPY","KRW","PEN","PHP","SGD","TRY","UYU","TWD","VND","CRC","SEK","PLN","DKK","NOK","NZD"];export{I as mapKadoQuoteToQuoteResponse,f as SupportedKadoChain,G as KadoSupportedFiatCurrencies,j as KadoPlugin,A as KadoChainToChain,y as ChainToKadoChain};
|
|
19
19
|
|
|
20
|
-
//# debugId=
|
|
20
|
+
//# debugId=9108B788624D163064756E2164756E21
|
package/dist/kado/index.js.map
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/kado/helpers.ts", "../src/kado/plugin.ts", "../src/kado/types.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { type AssetValue, Chain, FeeTypeEnum, ProviderName
|
|
5
|
+
"import { type AssetValue, BlockTimes, Chain, FeeTypeEnum, ProviderName } from \"@swapkit/helpers\";\nimport type { QuoteResponse, QuoteResponseRoute } from \"@swapkit/helpers/api\";\nimport type { KadoQuoteResponse } from \"./types\";\n\nexport const SupportedKadoChain = {\n thorchain: Chain.THORChain,\n solana: Chain.Solana,\n polygon: Chain.Polygon,\n Optimism: Chain.Optimism,\n litecoin: Chain.Litecoin,\n kujira: Chain.Kujira,\n ethereum: Chain.Ethereum,\n \"cosmos hub\": Chain.Cosmos,\n bitcoin: Chain.Bitcoin,\n base: Chain.Base,\n Avalanche: Chain.Avalanche,\n Arbitrum: Chain.Arbitrum,\n};\n\nexport function ChainToKadoChain(chain: Chain) {\n const entries = Object.entries(SupportedKadoChain);\n const found = entries.find(([_, value]) => value === chain);\n if (!found) throw new Error(`Chain ${chain} not supported`);\n return found[0];\n}\n\nexport function KadoChainToChain(kadoChain: string) {\n const found = Object.keys(SupportedKadoChain).includes(kadoChain);\n if (!found) throw new Error(`KadoChain ${kadoChain} not supported`);\n return SupportedKadoChain[kadoChain as keyof typeof SupportedKadoChain];\n}\n\nexport function mapKadoQuoteToQuoteResponse({\n quote,\n sellAsset,\n buyAsset,\n}: { quote: KadoQuoteResponse; sellAsset: AssetValue; buyAsset: AssetValue }): QuoteResponse {\n const sellAssetChain = sellAsset.chain;\n const buyAssetChain = buyAsset.chain;\n const isOnRamp = sellAssetChain === Chain.Fiat;\n const { receive, price, baseAmount, totalFee, processingFee, networkFee } = quote.data.quote;\n\n const buyAssetAmount = buyAsset.set(\n isOnRamp ? receive.unitCount.toString() : receive.amount.toString(),\n );\n const totalSlippageBps = isOnRamp\n ? Math.round((totalFee.amount / receive.amount) * 10_000)\n : Math.round((totalFee.amount / (price.price * baseAmount.amount)) * 10_000);\n\n const inbound = Math.ceil(BlockTimes[sellAssetChain] * 3);\n const swap = Math.ceil(60);\n const outbound = Math.ceil(BlockTimes[buyAssetChain]);\n const routes: QuoteResponseRoute[] = [\n {\n buyAsset: buyAsset.toString(),\n destinationAddress: \"{destinationAddress}\",\n estimatedTime: { inbound, swap, outbound, total: inbound + swap + outbound },\n expectedBuyAmount: buyAssetAmount.getValue(\"string\"),\n expectedBuyAmountMaxSlippage: buyAssetAmount.getValue(\"string\"),\n providers: [ProviderName.KADO],\n sellAmount: sellAsset.getValue(\"string\"),\n sellAsset: sellAsset.toString(),\n sourceAddress: \"{sourceAddress}\",\n totalSlippageBps,\n fees: [\n {\n asset: processingFee.currency,\n amount: processingFee.amount.toString(),\n type: FeeTypeEnum.LIQUIDITY,\n protocol: ProviderName.KADO,\n chain: Chain.Fiat,\n },\n {\n asset: networkFee.currency,\n amount: networkFee.amount.toString(),\n type: FeeTypeEnum.NETWORK,\n protocol: ProviderName.KADO,\n chain: buyAsset.chain,\n },\n ],\n legs: [\n {\n provider: ProviderName.KADO,\n sellAsset: sellAsset.toString(),\n sellAmount: sellAsset.getValue(\"string\"),\n buyAsset: buyAsset.toString(),\n buyAmount: receive.unitCount.toString(),\n buyAmountMaxSlippage: receive.unitCount.toString(),\n fees: [\n {\n asset: processingFee.currency,\n amount: processingFee.amount.toString(),\n type: FeeTypeEnum.LIQUIDITY,\n protocol: ProviderName.KADO,\n chain: Chain.Fiat,\n },\n {\n asset: networkFee.currency,\n amount: networkFee.amount.toString(),\n type: FeeTypeEnum.NETWORK,\n protocol: ProviderName.KADO,\n chain: buyAsset.chain,\n },\n ],\n },\n ],\n warnings: [],\n meta: { tags: [] },\n },\n ];\n\n return {\n quoteId: crypto.randomUUID(),\n routes,\n error: quote.success ? undefined : quote.message,\n };\n}\n",
|
|
6
6
|
"import {\n AssetValue,\n Chain,\n ProviderName,\n RequestClient,\n SKConfig,\n type SwapParams,\n createPlugin,\n warnOnce,\n} from \"@swapkit/helpers\";\nimport type { QuoteResponse, QuoteResponseRoute } from \"@swapkit/helpers/api\";\nimport { ChainToKadoChain, mapKadoQuoteToQuoteResponse } from \"./helpers\";\nimport type {\n KadoAssetsResponse,\n KadoBlockchainsResponse,\n KadoFiatCurrency,\n KadoFiatMethod,\n KadoQuoteRequest,\n KadoQuoteResponse,\n} from \"./types\";\n\nexport const KadoPlugin = createPlugin({\n name: \"kado\",\n methods: () => ({\n createPopover,\n getAssets,\n getBlockchains,\n getKadoWidgetUrl,\n getOrderStatus,\n fetchProviderQuote,\n swap,\n }),\n properties: {\n supportedSwapkitProviders: [ProviderName.KADO],\n },\n});\n\nfunction swap({ route }: SwapParams<\"evm\", QuoteResponseRoute>) {\n if (!(route.sourceAddress && route.destinationAddress)) {\n throw new Error(\"Source and destination addresses are required\");\n }\n\n const sellAsset = AssetValue.from({ asset: route.sellAsset });\n const buyAsset = AssetValue.from({ asset: route.buyAsset });\n\n // Determine if this is a buy or sell operation\n const type = sellAsset.chain === Chain.Fiat ? \"buy\" : \"sell\";\n\n const url = getKadoWidgetUrl({\n sellAsset,\n buyAsset,\n recipient: route.destinationAddress,\n sender: route.sourceAddress,\n type,\n mode: \"minimal\",\n });\n\n createPopover(url);\n\n return {\n status: \"pending\",\n txHash: null,\n };\n}\n\nasync function fetchProviderQuote({\n sellAsset,\n buyAsset,\n fiatMethod = \"credit_card\",\n}: {\n sellAsset: AssetValue;\n buyAsset: AssetValue;\n fiatMethod: KadoFiatMethod;\n}): Promise<QuoteResponse> {\n try {\n const isOnRamp = sellAsset.chain === Chain.Fiat;\n const [paymentAsset, receiveAsset] = isOnRamp ? [buyAsset, sellAsset] : [sellAsset, buyAsset];\n const transactionType = isOnRamp ? \"buy\" : \"sell\";\n\n const quoteRequest: KadoQuoteRequest = {\n amount: paymentAsset.getValue(\"string\"),\n asset: paymentAsset.symbol,\n blockchain: ChainToKadoChain(paymentAsset.chain),\n currency: receiveAsset.symbol as KadoFiatCurrency,\n fiatMethod,\n partner: \"fortress\",\n transactionType,\n };\n\n const kadoApiKey = SKConfig.get(\"apiKeys\").kado;\n warnOnce(!kadoApiKey, \"plugin(kado): No Kado API key found\");\n\n const quote = await RequestClient.get<KadoQuoteResponse>(\n \"https://api.kado.money/v2/ramp/quote\",\n { searchParams: quoteRequest, headers: { \"X-Widget-Id\": kadoApiKey } },\n );\n\n if (!quote.success) {\n throw new Error(quote.message);\n }\n\n return mapKadoQuoteToQuoteResponse({ quote, sellAsset, buyAsset });\n } catch (_) {\n throw new Error(\"core_swap_quote_error\");\n }\n}\n\nasync function getBlockchains() {\n const response = await RequestClient.get<KadoBlockchainsResponse>(\n \"https://api.kado.money/v1/ramp/blockchains\",\n );\n\n if (!response.success) {\n throw new Error(response.message);\n }\n\n return response.data.blockchains;\n}\n\nasync function getAssets() {\n const response = await RequestClient.get<KadoAssetsResponse>(\n \"https://api.kado.money/v1/ramp/supported-assets\",\n );\n\n if (!response.success) {\n throw new Error(response.message);\n }\n\n return response.data.assets;\n}\n\nasync function getOrderStatus(orderId: string) {\n const kadoApiKey = SKConfig.get(\"apiKeys\").kado;\n warnOnce(!kadoApiKey, \"plugin(kado): No Kado API key found\");\n\n try {\n const response = await RequestClient.get<{\n success: boolean;\n message: string;\n data: { order: { status: string } };\n }>(`https://api.kado.money/v2/public/orders/${orderId}`, {\n headers: { \"X-Widget-Id\": kadoApiKey },\n });\n\n if (!response.success) {\n throw new Error(response.message);\n }\n\n return response.data.order;\n } catch (_error) {\n throw new Error(\"Failed to get order status\");\n }\n}\n\nfunction getKadoWidgetUrl({\n sellAsset,\n buyAsset,\n recipient,\n type,\n sender,\n mode,\n}: {\n sellAsset: AssetValue;\n buyAsset: AssetValue;\n recipient?: string;\n sender?: string;\n type: \"buy\" | \"sell\";\n mode: \"minimal\" | \"full\";\n}) {\n const kadoApiKey = SKConfig.get(\"apiKeys\").kado;\n warnOnce(!kadoApiKey, \"plugin(kado): No Kado API key found\");\n\n const buySellParams =\n type === \"buy\"\n ? {\n onPayAmount: sellAsset.getValue(\"string\"),\n onPayCurrency: sellAsset.symbol,\n onRevCurrency: buyAsset.symbol,\n ...(recipient ? { onToAddress: recipient } : {}),\n }\n : {\n offPayAmount: sellAsset.getValue(\"string\"),\n offPayCurrency: sellAsset.symbol,\n offRevCurrency: buyAsset.symbol,\n ...(sender ? { offFromAddress: sender } : {}),\n };\n const network = ChainToKadoChain(type === \"buy\" ? buyAsset.chain : sellAsset.chain).toUpperCase();\n const urlParams = new URLSearchParams({\n ...buySellParams,\n apiKey: kadoApiKey,\n network,\n product: type.toUpperCase(),\n mode,\n });\n\n return `https://app.kado.money/?${urlParams.toString()}`;\n}\n\nfunction createPopover(url: string) {\n const overlay = document.createElement(\"div\");\n overlay.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n justify-content: center;\n align-items: center;\n z-index: 9999;\n `;\n\n const iframe = document.createElement(\"iframe\");\n iframe.src = url;\n iframe.style.cssText = `\n width: 440px;\n height: 700px;\n border: none;\n border-radius: 12px;\n background: white;\n `;\n\n overlay.appendChild(iframe);\n document.body.appendChild(overlay);\n\n overlay.addEventListener(\"click\", (e) => {\n if (e.target === overlay) {\n document.body.removeChild(overlay);\n }\n });\n\n return overlay;\n}\n",
|
|
7
7
|
"import type { SupportedKadoChain } from \"./helpers\";\n\nexport const KadoSupportedFiatCurrencies = [\n \"USD\",\n \"CAD\",\n \"GBP\",\n \"EUR\",\n \"MXN\",\n \"COP\",\n \"INR\",\n \"CHF\",\n \"AUD\",\n \"ARS\",\n \"BRL\",\n \"CLP\",\n \"JPY\",\n \"KRW\",\n \"PEN\",\n \"PHP\",\n \"SGD\",\n \"TRY\",\n \"UYU\",\n \"TWD\",\n \"VND\",\n \"CRC\",\n \"SEK\",\n \"PLN\",\n \"DKK\",\n \"NOK\",\n \"NZD\",\n] as const;\n\nexport type KadoFiatCurrency = (typeof KadoSupportedFiatCurrencies)[number];\n\nexport type KadoFiatMethod =\n | \"ach\"\n | \"debit_card\"\n | \"credit_card\"\n | \"apple_pay_credit\"\n | \"apple_pay_debit\"\n | \"wire\"\n | \"sepa\"\n | \"pix\"\n | \"koywe\";\n\nexport type KadoQuoteRequest = {\n transactionType: \"buy\" | \"sell\";\n fiatMethod: KadoFiatMethod;\n partner: \"fortress\";\n amount: string;\n asset: string;\n blockchain: string;\n currency: KadoFiatCurrency;\n};\n\nexport type KadoAsset = {\n _id: string;\n name: string;\n description: string;\n label: string;\n symbol: string;\n supportedProviders: string[];\n stablecoin: boolean;\n liveOnRamp: boolean;\n createdAt: string;\n updatedAt: string;\n __v: number;\n priority: number;\n displayPrecision: number;\n usesAvaxRouter: boolean;\n squidChainId: string;\n coingeckoId: string;\n usesAxelarBridge: boolean;\n squidAssetId: string;\n address: string;\n blockExplorerURI: string;\n decimals: number;\n officialChainId: keyof typeof SupportedKadoChain;\n precision: number;\n rampProducts: string[];\n wallets: string[];\n rpcURI: string;\n usesPolygonFulfillment: boolean;\n usesOsmoRouter: boolean;\n ibcChannelIdOffRamp: number;\n ibcChannelIdOnRamp: number;\n osmoPfmChannel: number;\n osmoPfmReceiver: string;\n ibcDenom: string;\n isNative: boolean;\n avgOffRampTimeInSeconds: number;\n avgOnRampTimeInSeconds: number;\n providers: string[];\n trustekAssetId: string;\n trustekNetworkId: string;\n kycLevels: string[];\n};\n\nexport type KadoBlockchainsResponse = {\n success: boolean;\n message: string;\n data: {\n blockchains: {\n _id: string;\n supportedEnvironment: string;\n network: string;\n origin: string;\n label: string;\n associatedAssets: KadoAsset[];\n avgTransactionTimeSeconds: number;\n usesAvaxRouter: boolean;\n liveOnRamp: boolean;\n createdAt: string;\n updatedAt: string;\n __v: number;\n priority: number;\n }[];\n };\n};\n\nexport type KadoAssetsResponse = {\n success: boolean;\n message: string;\n data: {\n assets: {\n _id: string;\n name: string;\n description: string;\n label: string;\n symbol: string;\n supportedProviders: string[];\n stablecoin: boolean;\n liveOnRamp: boolean;\n createdAt: string;\n updatedAt: string;\n __v: number;\n priority: number;\n }[];\n };\n};\n\nexport type KadoQuoteResponse = {\n success: boolean;\n message: string;\n data: {\n request: {\n transactionType: string;\n fiatMethod: KadoFiatMethod;\n partner: string;\n amount: number;\n asset: string;\n blockchain: keyof typeof SupportedKadoChain;\n currency: KadoFiatCurrency;\n reverse: false;\n ipCountry: string;\n };\n quote: {\n asset: string;\n baseAmount: {\n amount: number;\n currency: KadoFiatCurrency;\n };\n price: {\n amount: number;\n price: number;\n symbol: string;\n unit: string;\n };\n bridgeFee: {\n amount: number;\n currency: KadoFiatCurrency;\n originalAmount: number;\n promotionModifier: number;\n };\n receiveAmountAfterFees: {\n originalAmount: number;\n amount: number;\n currency: KadoFiatCurrency;\n };\n receiveUnitCountAfterFees: {\n amount: number;\n currency: KadoFiatCurrency;\n };\n feeType: string;\n minValue: {\n amount: number;\n unit: string;\n };\n maxValue: {\n amount: number;\n unit: string;\n };\n receive: {\n amount: number;\n originalAmount: number;\n symbol: string;\n unit: string;\n unitCount: number;\n };\n networkFee: {\n amount: number;\n currency: KadoFiatCurrency;\n originalAmount: number;\n promotionModifier: number;\n };\n processingFee: {\n amount: number;\n currency: KadoFiatCurrency;\n originalAmount: number;\n promotionModifier: number;\n };\n totalFee: {\n amount: number;\n currency: KadoFiatCurrency;\n originalAmount: number;\n };\n smartContractFee: {\n amount: number;\n currency: KadoFiatCurrency;\n originalAmount: number;\n promotionModifier: number;\n };\n };\n };\n};\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": "6BAAA,
|
|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AO,IAAM,EACb,EAAO,MAAM,QAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQvB,EAAQ,YAAY,CAAM,EAC1B,SAAS,KAAK,YAAY,CAAO,EAEjC,EAAQ,iBAAiB,QAAS,CAAC,IAAM,CACvC,GAAI,EAAE,SAAW,EACf,SAAS,KAAK,YAAY,CAAO,EAEpC,EAEM,ECtOF,IAAM,EAA8B,CACzC,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,KACF",
|
|
10
|
+
"debugId": "9108B788624D163064756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/dist/radix/index.cjs.map
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import {\n AssetValue,\n Chain,\n ProviderName,\n SwapKitError,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport type { QuoteResponseRoute } from \"@swapkit/helpers/api\";\n\nexport const RadixPlugin = createPlugin({\n name: \"radix\",\n properties: { supportedSwapkitProviders: [ProviderName.CAVIAR_V1] },\n methods: ({ getWallet }) => ({\n swap: async function radixSwap({\n route: { tx, sellAmount, sellAsset },\n }: SwapParams<\"radix\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({\n asyncTokenLookup: true,\n value: sellAmount,\n asset: sellAsset,\n });\n\n if (Chain.Radix !== assetValue.chain) {\n throw new SwapKitError(\"core_swap_invalid_params\");\n }\n\n const wallet = getWallet(assetValue.chain);\n try {\n return wallet.signAndBroadcast({ manifest: tx as string });\n } catch (error) {\n throw new SwapKitError(\"core_swap_invalid_params\", error);\n }\n },\n }),\n});\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "sDAOO,IAPP,8BAUa,EAAc,eAAa,CACtC,KAAM,QACN,WAAY,CAAE,0BAA2B,CAAC,eAAa,SAAS,CAAE,EAClE,QAAS,EAAG,gBAAiB,CAC3B,KAAM,eAAe,CAAS,EAC5B,OAAS,KAAI,aAAY,cACiB,CAC1C,IAAM,EAAa,MAAM,aAAW,KAAK,CACvC,iBAAkB,GAClB,MAAO,EACP,MAAO,CACT,CAAC,EAED,GAAI,QAAM,QAAU,EAAW,MAC7B,MAAM,IAAI,eAAa,0BAA0B,EAGnD,IAAM,EAAS,EAAU,EAAW,KAAK,EACzC,GAAI,CACF,OAAO,EAAO,iBAAiB,CAAE,SAAU,CAAa,CAAC,
|
|
7
|
+
"mappings": "sDAOO,IAPP,8BAUa,EAAc,eAAa,CACtC,KAAM,QACN,WAAY,CAAE,0BAA2B,CAAC,eAAa,SAAS,CAAE,EAClE,QAAS,EAAG,gBAAiB,CAC3B,KAAM,eAAe,CAAS,EAC5B,OAAS,KAAI,aAAY,cACiB,CAC1C,IAAM,EAAa,MAAM,aAAW,KAAK,CACvC,iBAAkB,GAClB,MAAO,EACP,MAAO,CACT,CAAC,EAED,GAAI,QAAM,QAAU,EAAW,MAC7B,MAAM,IAAI,eAAa,0BAA0B,EAGnD,IAAM,EAAS,EAAU,EAAW,KAAK,EACzC,GAAI,CACF,OAAO,EAAO,iBAAiB,CAAE,SAAU,CAAa,CAAC,EACzD,MAAO,EAAO,CACd,MAAM,IAAI,eAAa,2BAA4B,CAAK,GAG9D,EACF,CAAC",
|
|
8
8
|
"debugId": "0E4076998B38FA0B64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/radix/index.js.map
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import {\n AssetValue,\n Chain,\n ProviderName,\n SwapKitError,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport type { QuoteResponseRoute } from \"@swapkit/helpers/api\";\n\nexport const RadixPlugin = createPlugin({\n name: \"radix\",\n properties: { supportedSwapkitProviders: [ProviderName.CAVIAR_V1] },\n methods: ({ getWallet }) => ({\n swap: async function radixSwap({\n route: { tx, sellAmount, sellAsset },\n }: SwapParams<\"radix\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({\n asyncTokenLookup: true,\n value: sellAmount,\n asset: sellAsset,\n });\n\n if (Chain.Radix !== assetValue.chain) {\n throw new SwapKitError(\"core_swap_invalid_params\");\n }\n\n const wallet = getWallet(assetValue.chain);\n try {\n return wallet.signAndBroadcast({ manifest: tx as string });\n } catch (error) {\n throw new SwapKitError(\"core_swap_invalid_params\", error);\n }\n },\n }),\n});\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "6BAAA,qBACE,WACA,kBACA,kBACA,kBAEA,yBAIK,IAAM,EAAc,EAAa,CACtC,KAAM,QACN,WAAY,CAAE,0BAA2B,CAAC,EAAa,SAAS,CAAE,EAClE,QAAS,EAAG,gBAAiB,CAC3B,KAAM,eAAe,CAAS,EAC5B,OAAS,KAAI,aAAY,cACiB,CAC1C,IAAM,EAAa,MAAM,EAAW,KAAK,CACvC,iBAAkB,GAClB,MAAO,EACP,MAAO,CACT,CAAC,EAED,GAAI,EAAM,QAAU,EAAW,MAC7B,MAAM,IAAI,EAAa,0BAA0B,EAGnD,IAAM,EAAS,EAAU,EAAW,KAAK,EACzC,GAAI,CACF,OAAO,EAAO,iBAAiB,CAAE,SAAU,CAAa,CAAC,
|
|
7
|
+
"mappings": "6BAAA,qBACE,WACA,kBACA,kBACA,kBAEA,yBAIK,IAAM,EAAc,EAAa,CACtC,KAAM,QACN,WAAY,CAAE,0BAA2B,CAAC,EAAa,SAAS,CAAE,EAClE,QAAS,EAAG,gBAAiB,CAC3B,KAAM,eAAe,CAAS,EAC5B,OAAS,KAAI,aAAY,cACiB,CAC1C,IAAM,EAAa,MAAM,EAAW,KAAK,CACvC,iBAAkB,GAClB,MAAO,EACP,MAAO,CACT,CAAC,EAED,GAAI,EAAM,QAAU,EAAW,MAC7B,MAAM,IAAI,EAAa,0BAA0B,EAGnD,IAAM,EAAS,EAAU,EAAW,KAAK,EACzC,GAAI,CACF,OAAO,EAAO,iBAAiB,CAAE,SAAU,CAAa,CAAC,EACzD,MAAO,EAAO,CACd,MAAM,IAAI,EAAa,2BAA4B,CAAK,GAG9D,EACF,CAAC",
|
|
8
8
|
"debugId": "1CB0136C68E6C70064756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|