Merge remote-tracking branch 'origin/main' into feat/OP-3702-add-governance-pools

This commit is contained in:
Dmitry Leleko
2023-04-12 17:00:49 +03:00
15 changed files with 137 additions and 318 deletions

302
package-lock.json generated
View File

@@ -1,18 +1,18 @@
{
"name": "@orionprotocol/sdk",
"version": "0.18.13-rc3",
"version": "0.18.15-rc7",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@orionprotocol/sdk",
"version": "0.18.13-rc3",
"version": "0.18.15-rc7",
"license": "ISC",
"dependencies": {
"@babel/runtime": "^7.21.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@orionprotocol/contracts": "0.7.0",
"@orionprotocol/contracts": "0.8.0",
"bignumber.js": "^9.1.1",
"bson-objectid": "^2.0.4",
"buffer": "^6.0.3",
@@ -40,7 +40,6 @@
"@types/express": "^4.17.17",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.11",
"@types/socket.io-client": "1.4.33",
"@types/uuid": "^9.0.1",
"@types/ws": "^8.5.4",
"@typescript-eslint/eslint-plugin": "^5.57.1",
@@ -58,7 +57,7 @@
"husky": "^8.0.3",
"is-ci": "^3.0.1",
"jest": "^29.5.0",
"ts-jest": "^29.0.5",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.2",
"tsup": "^6.7.0",
"typescript": "^5.0.4"
@@ -2680,9 +2679,9 @@
}
},
"node_modules/@orionprotocol/contracts": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@orionprotocol/contracts/-/contracts-0.7.0.tgz",
"integrity": "sha512-JOFfAMpw3alfvLWZORruxAKWFR6MPdz0IhSqGRHmgokg0XD42p3EhUFQujzPAY8R2bNnCw7PLlatuY90OEQ3Lw=="
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/@orionprotocol/contracts/-/contracts-0.8.0.tgz",
"integrity": "sha512-oYyP6JKDm3D71nswvA9x46hTurYetjxsn9zio/dHn0pHE2YDgziub0LeFeRjgz8RcANUOs/8qq53cNIiPseU7Q=="
},
"node_modules/@sinclair/typebox": {
"version": "0.25.23",
@@ -2952,12 +2951,6 @@
"@types/node": "*"
}
},
"node_modules/@types/socket.io-client": {
"version": "1.4.33",
"resolved": "https://registry.npmjs.org/@types/socket.io-client/-/socket.io-client-1.4.33.tgz",
"integrity": "sha512-m4LnxkljsI9fMsjwpW5QhRpMixo2BeeLpFmg0AE+sS4H1pzAd/cs/ftTiL60FLZgfFa8PFRPx5KsHu8O0bADKQ==",
"dev": true
},
"node_modules/@types/stack-utils": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz",
@@ -2995,15 +2988,15 @@
"dev": true
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.57.1.tgz",
"integrity": "sha512-1MeobQkQ9tztuleT3v72XmY0XuKXVXusAhryoLuU5YZ+mXoYKZP9SQ7Flulh1NX4DTjpGTc2b/eMu4u7M7dhnQ==",
"version": "5.58.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.58.0.tgz",
"integrity": "sha512-vxHvLhH0qgBd3/tW6/VccptSfc8FxPQIkmNTVLWcCOVqSBvqpnKkBTYrhcGlXfSnd78azwe+PsjYFj0X34/njA==",
"dev": true,
"dependencies": {
"@eslint-community/regexpp": "^4.4.0",
"@typescript-eslint/scope-manager": "5.57.1",
"@typescript-eslint/type-utils": "5.57.1",
"@typescript-eslint/utils": "5.57.1",
"@typescript-eslint/scope-manager": "5.58.0",
"@typescript-eslint/type-utils": "5.58.0",
"@typescript-eslint/utils": "5.58.0",
"debug": "^4.3.4",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
@@ -3028,53 +3021,6 @@
}
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.57.1.tgz",
"integrity": "sha512-N/RrBwEUKMIYxSKl0oDK5sFVHd6VI7p9K5MyUlVYAY6dyNb/wHUqndkTd3XhpGlXgnQsBkRZuu4f9kAHghvgPw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/visitor-keys": "5.57.1"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.57.1.tgz",
"integrity": "sha512-bSs4LOgyV3bJ08F5RDqO2KXqg3WAdwHCu06zOqcQ6vqbTJizyBhuh1o1ImC69X4bV2g1OJxbH71PJqiO7Y1RuA==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.1.tgz",
"integrity": "sha512-RjQrAniDU0CEk5r7iphkm731zKlFiUjvcBS2yHAg8WWqFMCaCrD0rKEVOMUyMMcbGPZ0bPp56srkGWrgfZqLRA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.57.1",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
@@ -3091,14 +3037,14 @@
}
},
"node_modules/@typescript-eslint/parser": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.57.1.tgz",
"integrity": "sha512-hlA0BLeVSA/wBPKdPGxoVr9Pp6GutGoY380FEhbVi0Ph4WNe8kLvqIRx76RSQt1lynZKfrXKs0/XeEk4zZycuA==",
"version": "5.58.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.58.0.tgz",
"integrity": "sha512-ixaM3gRtlfrKzP8N6lRhBbjTow1t6ztfBvQNGuRM8qH1bjFFXIJ35XY+FC0RRBKn3C6cT+7VW1y8tNm7DwPHDQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.57.1",
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/typescript-estree": "5.57.1",
"@typescript-eslint/scope-manager": "5.58.0",
"@typescript-eslint/types": "5.58.0",
"@typescript-eslint/typescript-estree": "5.58.0",
"debug": "^4.3.4"
},
"engines": {
@@ -3117,14 +3063,14 @@
}
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.57.1.tgz",
"integrity": "sha512-N/RrBwEUKMIYxSKl0oDK5sFVHd6VI7p9K5MyUlVYAY6dyNb/wHUqndkTd3XhpGlXgnQsBkRZuu4f9kAHghvgPw==",
"node_modules/@typescript-eslint/scope-manager": {
"version": "5.58.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.58.0.tgz",
"integrity": "sha512-b+w8ypN5CFvrXWQb9Ow9T4/6LC2MikNf1viLkYTiTbkQl46CnR69w7lajz1icW0TBsYmlpg+mRzFJ4LEJ8X9NA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/visitor-keys": "5.57.1"
"@typescript-eslint/types": "5.58.0",
"@typescript-eslint/visitor-keys": "5.58.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -3134,86 +3080,14 @@
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.57.1.tgz",
"integrity": "sha512-bSs4LOgyV3bJ08F5RDqO2KXqg3WAdwHCu06zOqcQ6vqbTJizyBhuh1o1ImC69X4bV2g1OJxbH71PJqiO7Y1RuA==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.57.1.tgz",
"integrity": "sha512-A2MZqD8gNT0qHKbk2wRspg7cHbCDCk2tcqt6ScCFLr5Ru8cn+TCfM786DjPhqwseiS+PrYwcXht5ztpEQ6TFTw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/visitor-keys": "5.57.1",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.1.tgz",
"integrity": "sha512-RjQrAniDU0CEk5r7iphkm731zKlFiUjvcBS2yHAg8WWqFMCaCrD0rKEVOMUyMMcbGPZ0bPp56srkGWrgfZqLRA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.57.1",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/parser/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
},
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.57.1.tgz",
"integrity": "sha512-/RIPQyx60Pt6ga86hKXesXkJ2WOS4UemFrmmq/7eOyiYjYv/MUSHPlkhU6k9T9W1ytnTJueqASW+wOmW4KrViw==",
"version": "5.58.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.58.0.tgz",
"integrity": "sha512-FF5vP/SKAFJ+LmR9PENql7fQVVgGDOS+dq3j+cKl9iW/9VuZC/8CFmzIP0DLKXfWKpRHawJiG70rVH+xZZbp8w==",
"dev": true,
"dependencies": {
"@typescript-eslint/typescript-estree": "5.57.1",
"@typescript-eslint/utils": "5.57.1",
"@typescript-eslint/typescript-estree": "5.58.0",
"@typescript-eslint/utils": "5.58.0",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
},
@@ -3305,53 +3179,10 @@
"node": ">=10"
}
},
"node_modules/@typescript-eslint/utils": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.57.1.tgz",
"integrity": "sha512-kN6vzzf9NkEtawECqze6v99LtmDiUJCVpvieTFA1uL7/jDghiJGubGZ5csicYHU1Xoqb3oH/R5cN5df6W41Nfg==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@types/json-schema": "^7.0.9",
"@types/semver": "^7.3.12",
"@typescript-eslint/scope-manager": "5.57.1",
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/typescript-estree": "5.57.1",
"eslint-scope": "^5.1.1",
"semver": "^7.3.7"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/scope-manager": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.57.1.tgz",
"integrity": "sha512-N/RrBwEUKMIYxSKl0oDK5sFVHd6VI7p9K5MyUlVYAY6dyNb/wHUqndkTd3XhpGlXgnQsBkRZuu4f9kAHghvgPw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/visitor-keys": "5.57.1"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/types": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.57.1.tgz",
"integrity": "sha512-bSs4LOgyV3bJ08F5RDqO2KXqg3WAdwHCu06zOqcQ6vqbTJizyBhuh1o1ImC69X4bV2g1OJxbH71PJqiO7Y1RuA==",
"node_modules/@typescript-eslint/types": {
"version": "5.58.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.58.0.tgz",
"integrity": "sha512-JYV4eITHPzVQMnHZcYJXl2ZloC7thuUHrcUmxtzvItyKPvQ50kb9QXBkgNAt90OYMqwaodQh2kHutWZl1fc+1g==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -3361,14 +3192,14 @@
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.57.1.tgz",
"integrity": "sha512-A2MZqD8gNT0qHKbk2wRspg7cHbCDCk2tcqt6ScCFLr5Ru8cn+TCfM786DjPhqwseiS+PrYwcXht5ztpEQ6TFTw==",
"node_modules/@typescript-eslint/typescript-estree": {
"version": "5.58.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.58.0.tgz",
"integrity": "sha512-cRACvGTodA+UxnYM2uwA2KCwRL7VAzo45syNysqlMyNyjw0Z35Icc9ihPJZjIYuA5bXJYiJ2YGUB59BqlOZT1Q==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/visitor-keys": "5.57.1",
"@typescript-eslint/types": "5.58.0",
"@typescript-eslint/visitor-keys": "5.58.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@@ -3388,14 +3219,35 @@
}
}
},
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/visitor-keys": {
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.1.tgz",
"integrity": "sha512-RjQrAniDU0CEk5r7iphkm731zKlFiUjvcBS2yHAg8WWqFMCaCrD0rKEVOMUyMMcbGPZ0bPp56srkGWrgfZqLRA==",
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.4.0.tgz",
"integrity": "sha512-RgOxM8Mw+7Zus0+zcLEUn8+JfoLpj/huFTItQy2hsM4khuC1HYRDp0cU482Ewn/Fcy6bCjufD8vAj7voC66KQw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.57.1",
"eslint-visitor-keys": "^3.3.0"
"lru-cache": "^6.0.0"
},
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/@typescript-eslint/utils": {
"version": "5.58.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.58.0.tgz",
"integrity": "sha512-gAmLOTFXMXOC+zP1fsqm3VceKSBQJNzV385Ok3+yzlavNHZoedajjS4UyS21gabJYcobuigQPs/z71A9MdJFqQ==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@types/json-schema": "^7.0.9",
"@types/semver": "^7.3.12",
"@typescript-eslint/scope-manager": "5.58.0",
"@typescript-eslint/types": "5.58.0",
"@typescript-eslint/typescript-estree": "5.58.0",
"eslint-scope": "^5.1.1",
"semver": "^7.3.7"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -3403,6 +3255,9 @@
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/@typescript-eslint/utils/node_modules/semver": {
@@ -3420,6 +3275,23 @@
"node": ">=10"
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "5.58.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.58.0.tgz",
"integrity": "sha512-/fBraTlPj0jwdyTwLyrRTxv/3lnU2H96pNTVM6z3esTWLtA5MZ9ghSMJ7Rb+TtUAdtEw9EyJzJ0EydIMKxQ9gA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.58.0",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@webassemblyjs/ast": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz",

View File

@@ -56,7 +56,6 @@
"@types/express": "^4.17.17",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.11",
"@types/socket.io-client": "1.4.33",
"@types/uuid": "^9.0.1",
"@types/ws": "^8.5.4",
"@typescript-eslint/eslint-plugin": "^5.57.1",
@@ -74,7 +73,7 @@
"husky": "^8.0.3",
"is-ci": "^3.0.1",
"jest": "^29.5.0",
"ts-jest": "^29.0.5",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.2",
"tsup": "^6.7.0",
"typescript": "^5.0.4"
@@ -83,7 +82,7 @@
"@babel/runtime": "^7.21.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@orionprotocol/contracts": "0.7.0",
"@orionprotocol/contracts": "0.8.0",
"bignumber.js": "^9.1.1",
"bson-objectid": "^2.0.4",
"buffer": "^6.0.3",

View File

@@ -11,7 +11,7 @@ import {
REDEEMATOMIC_GAS_LIMIT,
WITHDRAW_GAS_LIMIT
} from '../../constants/index.js';
import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js';
import getNativeCryptocurrencyName from '../../utils/getNativeCryptocurrencyName.js';
import { denormalizeNumber, generateSecret, normalizeNumber, toUpperCase } from '../../utils/index.js';
import type { SupportedChainId } from '../../types.js';
import type Orion from '../index.js';
@@ -100,7 +100,7 @@ export default async function swap({
assetToAddress: sourceAssetToAddress,
} = await simpleFetch(sourceOrionBlockchain.getInfo)();
const sourceChainNativeCryptocurrency = getNativeCryptocurrency(sourceAssetToAddress);
const sourceChainNativeCryptocurrency = getNativeCryptocurrencyName(sourceAssetToAddress);
const sourceExchangeContract = Exchange__factory.connect(sourceExchangeContractAddress, sourceProvider);
// const sourceChainGasPriceWei = await simpleFetch(sourceOrionBlockchain.getGasPriceWei)();
@@ -114,7 +114,7 @@ export default async function swap({
const targetChainAssetAddress = targetAssetToAddress[assetName];
if (targetChainAssetAddress === undefined) throw new Error(`Asset '${assetName}' not found in target chain`);
const targetChainNativeCryptocurrency = getNativeCryptocurrency(targetAssetToAddress);
const targetChainNativeCryptocurrency = getNativeCryptocurrencyName(targetAssetToAddress);
const targetExchangeContract = Exchange__factory.connect(targetExchangeContractAddress, targetProvider);
const sourceChainBalances = await getBalances(

View File

@@ -8,7 +8,7 @@ import {
DEPOSIT_ERC20_GAS_LIMIT, DEPOSIT_ETH_GAS_LIMIT, INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION,
} from '../../constants/index.js';
import { denormalizeNumber, normalizeNumber } from '../../utils/index.js';
import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js';
import getNativeCryptocurrencyName from '../../utils/getNativeCryptocurrencyName.js';
import { simpleFetch } from 'simple-typed-fetch';
export type DepositParams = {
@@ -40,7 +40,7 @@ export default async function deposit({
assetToAddress,
} = await simpleFetch(orionBlockchain.getInfo)();
const nativeCryptocurrency = getNativeCryptocurrency(assetToAddress);
const nativeCryptocurrency = getNativeCryptocurrencyName(assetToAddress);
const exchangeContract = Exchange__factory.connect(exchangeContractAddress, provider);
const gasPriceWei = await simpleFetch(orionBlockchain.getGasPriceWei)();

View File

@@ -5,7 +5,7 @@ import { NATIVE_CURRENCY_PRECISION, SWAP_THROUGH_ORION_POOL_GAS_LIMIT } from '..
import type { OrionAggregator } from '../../services/OrionAggregator/index.js';
import type { OrionBlockchain } from '../../services/OrionBlockchain/index.js';
import { calculateFeeInFeeAsset, denormalizeNumber, getNativeCryptocurrency } from '../../utils/index.js';
import { calculateFeeInFeeAsset, denormalizeNumber, getNativeCryptocurrencyName } from '../../utils/index.js';
export type GetSwapInfoParams = {
type: 'exactSpend' | 'exactReceive'
@@ -43,7 +43,7 @@ export default async function getSwapInfo({
const {
assetToAddress,
} = await simpleFetch(orionBlockchain.getInfo)();
const nativeCryptocurrency = getNativeCryptocurrency(assetToAddress);
const nativeCryptocurrencyName = getNativeCryptocurrencyName(assetToAddress);
const feeAssets = await simpleFetch(orionBlockchain.getTokensFee)();
const pricesInOrn = await simpleFetch(orionBlockchain.getPrices)();
@@ -106,7 +106,7 @@ export default async function getSwapInfo({
route,
swapInfo,
fee: {
assetName: nativeCryptocurrency,
assetName: nativeCryptocurrencyName,
assetAddress: ethers.constants.AddressZero,
networkFeeInFeeAsset: denormalizedTransactionCost.toString(),
protocolFeeInFeeAsset: undefined,

View File

@@ -6,7 +6,7 @@ import BalanceGuard from '../../BalanceGuard.js';
import getAvailableSources from '../../utils/getAvailableFundsSources.js';
import type OrionUnit from '../index.js';
import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION, SWAP_THROUGH_ORION_POOL_GAS_LIMIT } from '../../constants/index.js';
import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js';
import getNativeCryptocurrencyName from '../../utils/getNativeCryptocurrencyName.js';
import { calculateFeeInFeeAsset, denormalizeNumber, normalizeNumber } from '../../utils/index.js';
import { signOrder } from '../../crypt/index.js';
import type orderSchema from '../../services/OrionAggregator/schemas/orderSchema.js';
@@ -86,7 +86,7 @@ export default async function swapLimit({
matcherAddress,
assetToAddress,
} = await simpleFetch(orionBlockchain.getInfo)();
const nativeCryptocurrency = getNativeCryptocurrency(assetToAddress);
const nativeCryptocurrency = getNativeCryptocurrencyName(assetToAddress);
const exchangeContract = Exchange__factory.connect(exchangeContractAddress, provider);
const feeAssets = await simpleFetch(orionBlockchain.getTokensFee)();

View File

@@ -5,7 +5,7 @@ import getBalances from '../../utils/getBalances.js';
import BalanceGuard from '../../BalanceGuard.js';
import getAvailableSources from '../../utils/getAvailableFundsSources.js';
import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION, SWAP_THROUGH_ORION_POOL_GAS_LIMIT } from '../../constants/index.js';
import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js';
import getNativeCryptocurrencyName from '../../utils/getNativeCryptocurrencyName.js';
import { calculateFeeInFeeAsset, denormalizeNumber, normalizeNumber } from '../../utils/index.js';
import { signOrder } from '../../crypt/index.js';
import type orderSchema from '../../services/OrionAggregator/schemas/orderSchema.js';
@@ -71,7 +71,7 @@ export default async function swapMarket({
matcherAddress,
assetToAddress,
} = await simpleFetch(orionBlockchain.getInfo)();
const nativeCryptocurrency = getNativeCryptocurrency(assetToAddress);
const nativeCryptocurrency = getNativeCryptocurrencyName(assetToAddress);
const exchangeContract = Exchange__factory.connect(exchangeContractAddress, provider);
const feeAssets = await simpleFetch(orionBlockchain.getTokensFee)();

View File

@@ -8,7 +8,7 @@ import {
INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION, WITHDRAW_GAS_LIMIT,
} from '../../constants/index.js';
import { denormalizeNumber, normalizeNumber } from '../../utils/index.js';
import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js';
import getNativeCryptocurrencyName from '../../utils/getNativeCryptocurrencyName.js';
import { simpleFetch } from 'simple-typed-fetch';
export type WithdrawParams = {
@@ -40,7 +40,7 @@ export default async function withdraw({
assetToAddress,
} = await simpleFetch(orionBlockchain.getInfo)();
const nativeCryptocurrency = getNativeCryptocurrency(assetToAddress);
const nativeCryptocurrency = getNativeCryptocurrencyName(assetToAddress);
const exchangeContract = Exchange__factory.connect(exchangeContractAddress, provider);
const gasPriceWei = await simpleFetch(orionBlockchain.getGasPriceWei)();

View File

@@ -7,7 +7,7 @@ import BalanceGuard from '../../BalanceGuard.js';
import { ADD_LIQUIDITY_GAS_LIMIT, INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION } from '../../constants/index.js';
import { denormalizeNumber, normalizeNumber } from '../../utils/index.js';
import getBalances from '../../utils/getBalances.js';
import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js';
import getNativeCryptocurrencyName from '../../utils/getNativeCryptocurrencyName.js';
const ADD_LIQUIDITY_SLIPPAGE = 0.05;
@@ -66,7 +66,7 @@ export default class FarmingManager {
const assetBDecimals = assetToDecimals[assetB];
if (assetBDecimals === undefined) throw new Error(`Decimals for asset '${assetB}' not found`);
const nativeCryptocurrency = getNativeCryptocurrency(assetToAddress);
const nativeCryptocurrency = getNativeCryptocurrencyName(assetToAddress);
const balances = await getBalances(
{
[assetA]: assetAAddress,
@@ -248,7 +248,7 @@ export default class FarmingManager {
const exchangeContract = Exchange__factory
.connect(exchangeContractAddress, this.orionUnit.provider);
const nativeCryptocurrency = getNativeCryptocurrency(assetToAddress);
const nativeCryptocurrency = getNativeCryptocurrencyName(assetToAddress);
const balances = await getBalances(
{
[assetA]: assetAAddress,

View File

@@ -1,6 +1,6 @@
import { ERC20__factory, type Exchange } from '@orionprotocol/contracts';
import type { BigNumber } from 'bignumber.js';
import type { BigNumber } from 'bignumber.js';
import { ethers } from 'ethers';
import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION } from '../constants/index.js';
import type { OrionAggregator } from '../services/OrionAggregator/index.js';
@@ -8,7 +8,7 @@ import denormalizeNumber from './denormalizeNumber.js';
export default async function getBalance(
orionAggregator: OrionAggregator,
asset: string,
assetName: string,
assetAddress: string,
walletAddress: string,
exchangeContract: Exchange,
@@ -32,13 +32,13 @@ export default async function getBalance(
}
const assetContractBalance = await exchangeContract.getBalance(assetAddress, walletAddress);
const denormalizedAssetInContractBalance = denormalizeNumber(assetContractBalance, INTERNAL_ORION_PRECISION);
const denormalizedAssetLockedBalanceResult = await orionAggregator.getLockedBalance(walletAddress, asset);
const denormalizedAssetLockedBalanceResult = await orionAggregator.getLockedBalance(walletAddress, assetName);
if (denormalizedAssetLockedBalanceResult.isErr()) {
throw new Error(denormalizedAssetLockedBalanceResult.error.message);
}
return {
exchange: denormalizedAssetInContractBalance.minus(denormalizedAssetLockedBalanceResult.value[asset] ?? 0),
exchange: denormalizedAssetInContractBalance.minus(denormalizedAssetLockedBalanceResult.value[assetName] ?? 0),
wallet: denormalizedAssetInWalletBalance,
};
}

View File

@@ -13,18 +13,18 @@ export default async (
) => {
const balances = await Promise.all(
Object.entries(balancesRequired)
.map(async ([asset, assetAddress]) => {
if (assetAddress === undefined) throw new Error(`Asset address of ${asset} not found`);
.map(async ([assetName, assetAddress]) => {
if (assetAddress === undefined) throw new Error(`Asset address of ${assetName} not found`);
const balance = await getBalance(
orionAggregator,
asset,
assetName,
assetAddress,
walletAddress,
exchangeContract,
provider,
);
return {
asset,
assetName,
amount: balance,
};
}),
@@ -35,6 +35,6 @@ export default async (
wallet: BigNumber
}>>>((prev, curr) => ({
...prev,
[curr.asset]: curr.amount,
[curr.assetName]: curr.amount,
}), {});
};

View File

@@ -1,19 +0,0 @@
import { ethers } from 'ethers';
const getNativeCryptocurrency = (assetToAddress: Partial<Record<string, string>>) => {
const addressToAsset = Object
.entries(assetToAddress)
.reduce<Partial<Record<string, string>>>((prev, [asset, address]) => {
if (address === undefined) return prev;
return {
...prev,
[address]: asset,
};
}, {});
const nativeCryptocurrency = addressToAsset[ethers.constants.AddressZero];
if (nativeCryptocurrency === undefined) throw new Error('Native cryptocurrency asset is not found');
return nativeCryptocurrency;
};
export default getNativeCryptocurrency;

View File

@@ -0,0 +1,21 @@
import { ethers } from 'ethers';
const getNativeCryptocurrencyName = (assetToAddress: Partial<Record<string, string>>) => {
const addressToAssetName = Object
.entries(assetToAddress)
.reduce<Partial<Record<string, string>>>((prev, [assetName, address]) => {
if (address === undefined) return prev;
return {
...prev,
[address]: assetName,
};
}, {});
const nativeCryptocurrencyName = addressToAssetName[ethers.constants.AddressZero];
if (nativeCryptocurrencyName === undefined) {
throw new Error('Native cryptocurrency asset name is not found');
}
return nativeCryptocurrencyName;
};
export default getNativeCryptocurrencyName;

View File

@@ -11,7 +11,7 @@ export { default as parseExchangeTradeTransaction } from './parseExchangeTradeTr
export { default as toUpperCase } from './toUpperCase.js';
export { default as toLowerCase } from './toLowerCase.js';
export { default as isUppercasedNetworkCode } from './isUppercasedNetworkCode.js';
export { default as getNativeCryptocurrency } from './getNativeCryptocurrency.js';
export { default as getNativeCryptocurrencyName } from './getNativeCryptocurrencyName.js';
export { default as isValidChainId } from './isValidChainId.js';
export { default as isKnownEnv } from './isKnownEnv.js';

View File

@@ -1,54 +0,0 @@
const path = require("path");
module.exports = (env, argv) => {
return {
mode: "production",
entry: {
index: path.resolve(__dirname, "./lib/esm/index.js")
},
externals: [
'node:util',
'node:zlib',
'node:url',
'node:stream',
'node:stream/web',
'node:process',
'node:path',
'node:net',
'node:http',
'node:https',
'node:fs',
'node:buffer',
'worker_threads',
'unfetch'
],
output: {
path: path.resolve(__dirname, "./lib/umd"), // builds to ./lib/umd/
filename: "[name].js", // index.js
library: "orionprotocol", // aka window.myLibrary
libraryTarget: "umd", // supports commonjs, amd and web browsers
globalObject: "this"
},
module: {
rules: [{
test: /\.t|js$/,
use: {
loader: "babel-loader",
options: {
plugins: [
"@babel/plugin-syntax-import-assertions",
],
}
}
}]
},
resolve: {
extensions: ['.ts', '.js'],
fallback: {
"crypto": require.resolve("crypto-browserify"),
"buffer": require.resolve("buffer/"),
"stream": require.resolve("stream-browserify"),
}
}
};
};