If you want to add some JS code, like some kind of snippet to your pages with libraries.yml, add it as any other library item but don't use jquery or drupal behaviours in .js code, add some plain JS code like
document.addEventListener("DOMContentLoaded", function() {
so to wrap some JS snippet for it, do it like below.
document.addEventListener("DOMContentLoaded", function() {
const config = {
sourceAssetAddress: null,
sourceAmountDecimal: null,
destinationAssetAddress: null,
destinationAmountDecimal: null,
apiKey: null,
partnerContractAddress: null,
};
const nodeId = 'totle-widget';
!function(){const t=document.createElement("script");t.type="text/javascript";const e=()=>{TotleWidget.default.run(config,document.getElementById(nodeId))};t.readyState?t.onreadystatechange=function(){"loaded"!=t.readyState&&"complete"!=t.readyState||(t.onreadystatechange=null,e())}:t.onload=function(){e()},t.src="https://widget.totle.com/latest/dist.js",document.getElementsByTagName("head")[0].appendChild(t)}();
});