mirror of
https://github.com/alexgo-io/alex-sdk.git
synced 2026-01-12 14:25:02 +08:00
feat: add run swap
This commit is contained in:
3
jest.config.js
Normal file
3
jest.config.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
@@ -17,6 +17,7 @@
|
||||
"lint": "tsdx lint",
|
||||
"prepare": "tsdx build",
|
||||
"size": "size-limit",
|
||||
"gen:contract": "node -r esm ./scripts/gen-contract.ts",
|
||||
"analyze": "size-limit --why"
|
||||
},
|
||||
"peerDependencies": {},
|
||||
@@ -44,9 +45,15 @@
|
||||
"limit": "10 KB"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"@stacks/transactions": "^6.2.0",
|
||||
"clarity-codegen": "^0.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@size-limit/preset-small-lib": "^8.2.4",
|
||||
"esm": "^3.2.25",
|
||||
"husky": "^8.0.3",
|
||||
"prettier": "^2.8.4",
|
||||
"size-limit": "^8.2.4",
|
||||
"tsdx": "^0.14.1",
|
||||
"tslib": "^2.5.0",
|
||||
|
||||
25
scripts/gen-contract.ts
Normal file
25
scripts/gen-contract.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { generateContracts } from "clarity-codegen/lib/generate"
|
||||
import * as path from "path"
|
||||
|
||||
const API_HOST = "https://stacks-node-api.alexlab.co"
|
||||
const CONTRACT_DEPLOYER = "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9"
|
||||
|
||||
const contracts = [
|
||||
"swap-helper-v1-02",
|
||||
"swap-helper-v1-03",
|
||||
"amm-swap-pool",
|
||||
"token-amm-swap-pool",
|
||||
|
||||
"swap-helper-bridged",
|
||||
]
|
||||
|
||||
;(async function main() {
|
||||
await generateContracts(
|
||||
API_HOST,
|
||||
CONTRACT_DEPLOYER,
|
||||
contracts,
|
||||
path.resolve(__dirname, "../src/generated/smartContract/"),
|
||||
"Alex",
|
||||
"../smartContractHelpers/codegenImport",
|
||||
)
|
||||
})().catch(console.error)
|
||||
2
src/config.ts
Normal file
2
src/config.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const CONTRACT_DEPLOYER = 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9';
|
||||
export const API_HOST = "https://stacks-node-api.alexlab.co"
|
||||
685
src/generated/smartContract/contract_amm-swap-pool.ts
Normal file
685
src/generated/smartContract/contract_amm-swap-pool.ts
Normal file
@@ -0,0 +1,685 @@
|
||||
|
||||
import {
|
||||
defineContract,
|
||||
principalT,
|
||||
numberT,
|
||||
optionalT,
|
||||
responseSimpleT,
|
||||
tupleT,
|
||||
booleanT,
|
||||
noneT
|
||||
} from "../smartContractHelpers/codegenImport"
|
||||
|
||||
export const ammSwapPool = defineContract({
|
||||
"amm-swap-pool": {
|
||||
'add-to-position': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'max-dy', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(tupleT({ dx: numberT, dy: numberT, supply: numberT }, ), ),
|
||||
mode: 'public'
|
||||
},
|
||||
'create-pool': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'pool-owner', type: principalT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'dy', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
pause: {
|
||||
input: [ { name: 'new-paused', type: booleanT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'reduce-position': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'percent', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(tupleT({ dx: numberT, dy: numberT }, ), ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-contract-owner': {
|
||||
input: [ { name: 'owner', type: principalT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-end-block': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'new-end-block', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-fee-rate-x': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'fee-rate-x', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-fee-rate-y': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'fee-rate-y', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-fee-rebate': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'fee-rebate', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-max-in-ratio': {
|
||||
input: [ { name: 'new-max-in-ratio', type: numberT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-max-out-ratio': {
|
||||
input: [ { name: 'new-max-out-ratio', type: numberT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-oracle-average': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'new-oracle-average', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-oracle-enabled': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'enabled', type: booleanT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-pool-owner': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'pool-owner', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-start-block': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'new-start-block', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-switch-threshold': {
|
||||
input: [ { name: 'new-threshold', type: numberT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-threshold-x': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'new-threshold', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-threshold-y': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'new-threshold', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'swap-helper': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'min-dy', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'swap-helper-a': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'token-z-trait', type: principalT },
|
||||
{ name: 'factor-x', type: numberT },
|
||||
{ name: 'factor-y', type: numberT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'min-dz', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'swap-helper-b': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'token-z-trait', type: principalT },
|
||||
{ name: 'token-w-trait', type: principalT },
|
||||
{ name: 'factor-x', type: numberT },
|
||||
{ name: 'factor-y', type: numberT },
|
||||
{ name: 'factor-z', type: numberT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'min-dw', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'swap-helper-c': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'token-z-trait', type: principalT },
|
||||
{ name: 'token-w-trait', type: principalT },
|
||||
{ name: 'token-v-trait', type: principalT },
|
||||
{ name: 'factor-x', type: numberT },
|
||||
{ name: 'factor-y', type: numberT },
|
||||
{ name: 'factor-z', type: numberT },
|
||||
{ name: 'factor-w', type: numberT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'min-dv', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'swap-x-for-y': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'min-dy', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(tupleT({ dx: numberT, dy: numberT }, ), ),
|
||||
mode: 'public'
|
||||
},
|
||||
'swap-y-for-x': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'dy', type: numberT },
|
||||
{ name: 'min-dx', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(tupleT({ dx: numberT, dy: numberT }, ), ),
|
||||
mode: 'public'
|
||||
},
|
||||
'check-pool-status': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'fee-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'fee-helper-a': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-x', type: numberT },
|
||||
{ name: 'factor-y', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'fee-helper-b': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'token-w', type: principalT },
|
||||
{ name: 'factor-x', type: numberT },
|
||||
{ name: 'factor-y', type: numberT },
|
||||
{ name: 'factor-z', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'fee-helper-c': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'token-w', type: principalT },
|
||||
{ name: 'token-v', type: principalT },
|
||||
{ name: 'factor-x', type: numberT },
|
||||
{ name: 'factor-y', type: numberT },
|
||||
{ name: 'factor-z', type: numberT },
|
||||
{ name: 'factor-w', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-balances': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(tupleT({ 'balance-x': numberT, 'balance-y': numberT }, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-contract-owner': {
|
||||
input: [],
|
||||
output: responseSimpleT(principalT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-end-block': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-fee-rate-x': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-fee-rate-y': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-fee-rebate': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'dx', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-helper-a': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-x', type: numberT },
|
||||
{ name: 'factor-y', type: numberT },
|
||||
{ name: 'dx', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-helper-b': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'token-w', type: principalT },
|
||||
{ name: 'factor-x', type: numberT },
|
||||
{ name: 'factor-y', type: numberT },
|
||||
{ name: 'factor-z', type: numberT },
|
||||
{ name: 'dx', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-helper-c': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'token-w', type: principalT },
|
||||
{ name: 'token-v', type: principalT },
|
||||
{ name: 'factor-x', type: numberT },
|
||||
{ name: 'factor-y', type: numberT },
|
||||
{ name: 'factor-z', type: numberT },
|
||||
{ name: 'factor-w', type: numberT },
|
||||
{ name: 'dx', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-invariant': {
|
||||
input: [
|
||||
{ name: 'balance-x', type: numberT },
|
||||
{ name: 'balance-y', type: numberT },
|
||||
{ name: 't', type: numberT }
|
||||
],
|
||||
output: numberT,
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-max-in-ratio': { input: [], output: numberT, mode: 'readonly' },
|
||||
'get-max-out-ratio': { input: [], output: numberT, mode: 'readonly' },
|
||||
'get-oracle-average': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-oracle-enabled': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-oracle-instant': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-oracle-resilient': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-pool-details': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(tupleT({
|
||||
'balance-x': numberT,
|
||||
'balance-y': numberT,
|
||||
'end-block': numberT,
|
||||
'fee-rate-x': numberT,
|
||||
'fee-rate-y': numberT,
|
||||
'fee-rebate': numberT,
|
||||
'oracle-average': numberT,
|
||||
'oracle-enabled': booleanT,
|
||||
'oracle-resilient': numberT,
|
||||
'pool-id': numberT,
|
||||
'pool-owner': principalT,
|
||||
'start-block': numberT,
|
||||
'threshold-x': numberT,
|
||||
'threshold-y': numberT,
|
||||
'total-supply': numberT
|
||||
}, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-pool-details-by-id': {
|
||||
input: [ { name: 'pool-id', type: numberT } ],
|
||||
output: responseSimpleT(tupleT({ factor: numberT, 'token-x': principalT, 'token-y': principalT }, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-pool-exists': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: optionalT(tupleT({
|
||||
'balance-x': numberT,
|
||||
'balance-y': numberT,
|
||||
'end-block': numberT,
|
||||
'fee-rate-x': numberT,
|
||||
'fee-rate-y': numberT,
|
||||
'fee-rebate': numberT,
|
||||
'oracle-average': numberT,
|
||||
'oracle-enabled': booleanT,
|
||||
'oracle-resilient': numberT,
|
||||
'pool-id': numberT,
|
||||
'pool-owner': principalT,
|
||||
'start-block': numberT,
|
||||
'threshold-x': numberT,
|
||||
'threshold-y': numberT,
|
||||
'total-supply': numberT
|
||||
}, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-pool-owner': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(principalT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-position-given-burn': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'token', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(tupleT({ dx: numberT, dy: numberT }, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-position-given-mint': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'token', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(tupleT({ dx: numberT, dy: numberT }, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-price': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-start-block': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-switch-threshold': { input: [], output: numberT, mode: 'readonly' },
|
||||
'get-threshold-x': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-threshold-y': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-token-given-position': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'max-dy', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(tupleT({ dy: numberT, token: numberT }, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-x-given-price': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'price', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-x-given-y': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'dy', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-x-in-given-y-out': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'dy', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-y-given-price': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'price', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-y-given-x': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'dx', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-y-in-given-x-out': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'factor', type: numberT },
|
||||
{ name: 'dx', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'is-paused': { input: [], output: booleanT, mode: 'readonly' },
|
||||
'pools-data-map': {
|
||||
input: tupleT({ factor: numberT, 'token-x': principalT, 'token-y': principalT }, ),
|
||||
output: optionalT(tupleT({
|
||||
'balance-x': numberT,
|
||||
'balance-y': numberT,
|
||||
'end-block': numberT,
|
||||
'fee-rate-x': numberT,
|
||||
'fee-rate-y': numberT,
|
||||
'fee-rebate': numberT,
|
||||
'oracle-average': numberT,
|
||||
'oracle-enabled': booleanT,
|
||||
'oracle-resilient': numberT,
|
||||
'pool-id': numberT,
|
||||
'pool-owner': principalT,
|
||||
'start-block': numberT,
|
||||
'threshold-x': numberT,
|
||||
'threshold-y': numberT,
|
||||
'total-supply': numberT
|
||||
}, ), ),
|
||||
mode: 'mapEntry'
|
||||
},
|
||||
'pools-id-map': {
|
||||
input: numberT,
|
||||
output: optionalT(tupleT({ factor: numberT, 'token-x': principalT, 'token-y': principalT }, ), ),
|
||||
mode: 'mapEntry'
|
||||
},
|
||||
'MAX-IN-RATIO': { input: noneT, output: numberT, mode: 'variable' },
|
||||
'MAX-OUT-RATIO': { input: noneT, output: numberT, mode: 'variable' },
|
||||
'contract-owner': { input: noneT, output: principalT, mode: 'variable' },
|
||||
paused: { input: noneT, output: booleanT, mode: 'variable' },
|
||||
'pool-nonce': { input: noneT, output: numberT, mode: 'variable' },
|
||||
'switch-threshold': { input: noneT, output: numberT, mode: 'variable' }
|
||||
}
|
||||
} as const)
|
||||
|
||||
|
||||
142
src/generated/smartContract/contract_swap-helper-bridged.ts
Normal file
142
src/generated/smartContract/contract_swap-helper-bridged.ts
Normal file
@@ -0,0 +1,142 @@
|
||||
|
||||
import {
|
||||
defineContract,
|
||||
principalT,
|
||||
numberT,
|
||||
optionalT,
|
||||
responseSimpleT,
|
||||
listT
|
||||
} from "../smartContractHelpers/codegenImport"
|
||||
|
||||
export const swapHelperBridged = defineContract({
|
||||
"swap-helper-bridged": {
|
||||
'swap-helper-from-amm': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'token-z-trait', type: principalT },
|
||||
{ name: 'factor-x', type: numberT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'min-dz', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'swap-helper-to-amm': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'token-z-trait', type: principalT },
|
||||
{ name: 'factor-y', type: numberT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'min-dz', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'fee-helper-from-amm': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-x', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'fee-helper-to-amm': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-y', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-helper-from-amm': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-x', type: numberT },
|
||||
{ name: 'dx', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-helper-to-amm': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-y', type: numberT },
|
||||
{ name: 'dx', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'oracle-instant-helper-from-amm': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-x', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'oracle-instant-helper-to-amm': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-y', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'oracle-resilient-helper-from-amm': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-x', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'oracle-resilient-helper-to-amm': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-y', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'route-helper-from-amm': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-x', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(listT(principalT, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'route-helper-to-amm': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'token-z', type: principalT },
|
||||
{ name: 'factor-y', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(listT(principalT, ), ),
|
||||
mode: 'readonly'
|
||||
}
|
||||
}
|
||||
} as const)
|
||||
|
||||
|
||||
82
src/generated/smartContract/contract_swap-helper-v1-02.ts
Normal file
82
src/generated/smartContract/contract_swap-helper-v1-02.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
import {
|
||||
defineContract,
|
||||
principalT,
|
||||
numberT,
|
||||
optionalT,
|
||||
responseSimpleT,
|
||||
listT,
|
||||
tupleT
|
||||
} from "../smartContractHelpers/codegenImport"
|
||||
|
||||
export const swapHelperV102 = defineContract({
|
||||
"swap-helper-v1-02": {
|
||||
'swap-helper': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'min-dy', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'fee-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-given-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'dy', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'dx', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'oracle-instant-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'oracle-resilient-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'route-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(listT(principalT, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'fwp-oracle-resilient-map': {
|
||||
input: tupleT({ 'token-x': principalT, 'token-y': principalT }, ),
|
||||
output: optionalT(numberT, ),
|
||||
mode: 'mapEntry'
|
||||
}
|
||||
}
|
||||
} as const)
|
||||
|
||||
|
||||
87
src/generated/smartContract/contract_swap-helper-v1-03.ts
Normal file
87
src/generated/smartContract/contract_swap-helper-v1-03.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
|
||||
import {
|
||||
defineContract,
|
||||
principalT,
|
||||
numberT,
|
||||
optionalT,
|
||||
responseSimpleT,
|
||||
listT,
|
||||
tupleT
|
||||
} from "../smartContractHelpers/codegenImport"
|
||||
|
||||
export const swapHelperV103 = defineContract({
|
||||
"swap-helper-v1-03": {
|
||||
'swap-helper': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
{ name: 'token-y-trait', type: principalT },
|
||||
{ name: 'dx', type: numberT },
|
||||
{ name: 'min-dy', type: optionalT(numberT, ) }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'fee-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-given-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'dy', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT },
|
||||
{ name: 'dx', type: numberT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'oracle-instant-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'oracle-resilient-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'route-helper': {
|
||||
input: [
|
||||
{ name: 'token-x', type: principalT },
|
||||
{ name: 'token-y', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(listT(principalT, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'fwp-oracle-resilient-map': {
|
||||
input: tupleT({ 'token-x': principalT, 'token-y': principalT }, ),
|
||||
output: optionalT(numberT, ),
|
||||
mode: 'mapEntry'
|
||||
},
|
||||
'simple-oracle-resilient-map': {
|
||||
input: tupleT({ 'token-x': principalT, 'token-y': principalT }, ),
|
||||
output: optionalT(numberT, ),
|
||||
mode: 'mapEntry'
|
||||
}
|
||||
}
|
||||
} as const)
|
||||
|
||||
|
||||
305
src/generated/smartContract/contract_token-amm-swap-pool.ts
Normal file
305
src/generated/smartContract/contract_token-amm-swap-pool.ts
Normal file
@@ -0,0 +1,305 @@
|
||||
|
||||
import {
|
||||
defineContract,
|
||||
principalT,
|
||||
responseSimpleT,
|
||||
booleanT,
|
||||
numberT,
|
||||
stringT,
|
||||
optionalT,
|
||||
listT,
|
||||
tupleT,
|
||||
bufferT,
|
||||
noneT
|
||||
} from "../smartContractHelpers/codegenImport"
|
||||
|
||||
export const tokenAmmSwapPool = defineContract({
|
||||
"token-amm-swap-pool": {
|
||||
'add-approved-contract': {
|
||||
input: [ { name: 'new-approved-contract', type: principalT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
burn: {
|
||||
input: [
|
||||
{ name: 'token-id', type: numberT },
|
||||
{ name: 'amount', type: numberT },
|
||||
{ name: 'sender', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'burn-fixed': {
|
||||
input: [
|
||||
{ name: 'token-id', type: numberT },
|
||||
{ name: 'amount', type: numberT },
|
||||
{ name: 'sender', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
mint: {
|
||||
input: [
|
||||
{ name: 'token-id', type: numberT },
|
||||
{ name: 'amount', type: numberT },
|
||||
{ name: 'recipient', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'mint-fixed': {
|
||||
input: [
|
||||
{ name: 'token-id', type: numberT },
|
||||
{ name: 'amount', type: numberT },
|
||||
{ name: 'recipient', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-approved-contract': {
|
||||
input: [
|
||||
{ name: 'owner', type: principalT },
|
||||
{ name: 'approved', type: booleanT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-contract-owner': {
|
||||
input: [ { name: 'owner', type: principalT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-decimals': {
|
||||
input: [ { name: 'new-decimals', type: numberT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-name': {
|
||||
input: [ { name: 'new-name', type: stringT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-symbol': {
|
||||
input: [ { name: 'new-symbol', type: stringT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-token-uri': {
|
||||
input: [ { name: 'new-uri', type: optionalT(stringT, ) } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-transferrable': {
|
||||
input: [ { name: 'new-transferrable', type: booleanT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
transfer: {
|
||||
input: [
|
||||
{ name: 'token-id', type: numberT },
|
||||
{ name: 'amount', type: numberT },
|
||||
{ name: 'sender', type: principalT },
|
||||
{ name: 'recipient', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'transfer-fixed': {
|
||||
input: [
|
||||
{ name: 'token-id', type: numberT },
|
||||
{ name: 'amount', type: numberT },
|
||||
{ name: 'sender', type: principalT },
|
||||
{ name: 'recipient', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'transfer-many': {
|
||||
input: [
|
||||
{
|
||||
name: 'transfers',
|
||||
type: listT(tupleT({
|
||||
amount: numberT,
|
||||
recipient: principalT,
|
||||
sender: principalT,
|
||||
'token-id': numberT
|
||||
}, ), )
|
||||
}
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'transfer-many-fixed': {
|
||||
input: [
|
||||
{
|
||||
name: 'transfers',
|
||||
type: listT(tupleT({
|
||||
amount: numberT,
|
||||
recipient: principalT,
|
||||
sender: principalT,
|
||||
'token-id': numberT
|
||||
}, ), )
|
||||
}
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'transfer-many-memo': {
|
||||
input: [
|
||||
{
|
||||
name: 'transfers',
|
||||
type: listT(tupleT({
|
||||
amount: numberT,
|
||||
memo: bufferT,
|
||||
recipient: principalT,
|
||||
sender: principalT,
|
||||
'token-id': numberT
|
||||
}, ), )
|
||||
}
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'transfer-many-memo-fixed': {
|
||||
input: [
|
||||
{
|
||||
name: 'transfers',
|
||||
type: listT(tupleT({
|
||||
amount: numberT,
|
||||
memo: bufferT,
|
||||
recipient: principalT,
|
||||
sender: principalT,
|
||||
'token-id': numberT
|
||||
}, ), )
|
||||
}
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'transfer-memo': {
|
||||
input: [
|
||||
{ name: 'token-id', type: numberT },
|
||||
{ name: 'amount', type: numberT },
|
||||
{ name: 'sender', type: principalT },
|
||||
{ name: 'recipient', type: principalT },
|
||||
{ name: 'memo', type: bufferT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'transfer-memo-fixed': {
|
||||
input: [
|
||||
{ name: 'token-id', type: numberT },
|
||||
{ name: 'amount', type: numberT },
|
||||
{ name: 'sender', type: principalT },
|
||||
{ name: 'recipient', type: principalT },
|
||||
{ name: 'memo', type: bufferT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'fixed-to-decimals': {
|
||||
input: [ { name: 'amount', type: numberT } ],
|
||||
output: numberT,
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-balance': {
|
||||
input: [
|
||||
{ name: 'token-id', type: numberT },
|
||||
{ name: 'who', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-balance-fixed': {
|
||||
input: [
|
||||
{ name: 'token-id', type: numberT },
|
||||
{ name: 'who', type: principalT }
|
||||
],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-contract-owner': {
|
||||
input: [],
|
||||
output: responseSimpleT(principalT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-decimals': {
|
||||
input: [ { name: 'token-id', type: numberT } ],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-name': {
|
||||
input: [ { name: 'token-id', type: numberT } ],
|
||||
output: responseSimpleT(stringT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-overall-balance': {
|
||||
input: [ { name: 'who', type: principalT } ],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-overall-balance-fixed': {
|
||||
input: [ { name: 'who', type: principalT } ],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-overall-supply': { input: [], output: responseSimpleT(numberT, ), mode: 'readonly' },
|
||||
'get-overall-supply-fixed': { input: [], output: responseSimpleT(numberT, ), mode: 'readonly' },
|
||||
'get-symbol': {
|
||||
input: [ { name: 'token-id', type: numberT } ],
|
||||
output: responseSimpleT(stringT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-token-balance-owned-in-fixed': {
|
||||
input: [ { name: 'owner', type: principalT } ],
|
||||
output: listT(tupleT({ balance: numberT, 'token-id': numberT }, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-token-owned': {
|
||||
input: [ { name: 'owner', type: principalT } ],
|
||||
output: listT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-token-uri': {
|
||||
input: [ { name: 'token-id', type: numberT } ],
|
||||
output: responseSimpleT(optionalT(stringT, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-total-supply': {
|
||||
input: [ { name: 'token-id', type: numberT } ],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-total-supply-fixed': {
|
||||
input: [ { name: 'token-id', type: numberT } ],
|
||||
output: responseSimpleT(numberT, ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-transferrable': { input: [], output: responseSimpleT(booleanT, ), mode: 'readonly' },
|
||||
'approved-contracts': {
|
||||
input: principalT,
|
||||
output: optionalT(booleanT, ),
|
||||
mode: 'mapEntry'
|
||||
},
|
||||
'token-balances': {
|
||||
input: tupleT({ owner: principalT, 'token-id': numberT }, ),
|
||||
output: optionalT(numberT, ),
|
||||
mode: 'mapEntry'
|
||||
},
|
||||
'token-owned': {
|
||||
input: principalT,
|
||||
output: optionalT(listT(numberT, ), ),
|
||||
mode: 'mapEntry'
|
||||
},
|
||||
'token-supplies': { input: numberT, output: optionalT(numberT, ), mode: 'mapEntry' },
|
||||
'contract-owner': { input: noneT, output: principalT, mode: 'variable' },
|
||||
'token-decimals': { input: noneT, output: numberT, mode: 'variable' },
|
||||
'token-name': { input: noneT, output: stringT, mode: 'variable' },
|
||||
'token-symbol': { input: noneT, output: stringT, mode: 'variable' },
|
||||
'token-uri': { input: noneT, output: optionalT(stringT, ), mode: 'variable' },
|
||||
transferrable: { input: noneT, output: booleanT, mode: 'variable' }
|
||||
}
|
||||
} as const)
|
||||
|
||||
|
||||
16
src/generated/smartContract/contracts_Alex.ts
Normal file
16
src/generated/smartContract/contracts_Alex.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { defineContract } from "../smartContractHelpers/codegenImport";
|
||||
import { swapHelperV102 } from "./contract_swap-helper-v1-02"
|
||||
import { swapHelperV103 } from "./contract_swap-helper-v1-03"
|
||||
import { ammSwapPool } from "./contract_amm-swap-pool"
|
||||
import { tokenAmmSwapPool } from "./contract_token-amm-swap-pool"
|
||||
import { swapHelperBridged } from "./contract_swap-helper-bridged"
|
||||
|
||||
export const AlexContracts = defineContract({
|
||||
...swapHelperV102,
|
||||
...swapHelperV103,
|
||||
...ammSwapPool,
|
||||
...tokenAmmSwapPool,
|
||||
...swapHelperBridged
|
||||
});
|
||||
|
||||
|
||||
36
src/generated/smartContractHelpers/codegenImport.ts
Normal file
36
src/generated/smartContractHelpers/codegenImport.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
ClarityType,
|
||||
contractPrincipalCV,
|
||||
PrincipalCV,
|
||||
standardPrincipalCV,
|
||||
} from '@stacks/transactions';
|
||||
import { addressResult, contractResult, transcoders } from 'clarity-codegen';
|
||||
import type { Decoder } from 'clarity-codegen/lib/runtime/types';
|
||||
import { CONTRACT_DEPLOYER } from '../../config';
|
||||
|
||||
export * from 'clarity-codegen';
|
||||
|
||||
export function principalCV(principal: string): PrincipalCV {
|
||||
if (principal.includes('.')) {
|
||||
const [address, contractName] = principal.split('.');
|
||||
return contractPrincipalCV(address!, contractName!);
|
||||
}
|
||||
if (principal.startsWith('SP') || principal.startsWith('ST')) {
|
||||
return standardPrincipalCV(principal);
|
||||
}
|
||||
return contractPrincipalCV(CONTRACT_DEPLOYER, principal);
|
||||
}
|
||||
|
||||
export const principleResult: Decoder<string> = (result) => {
|
||||
if (result.type === ClarityType.PrincipalStandard) {
|
||||
return addressResult(result);
|
||||
} else if (result.type === ClarityType.PrincipalContract) {
|
||||
return contractResult(result).split('.')[1];
|
||||
}
|
||||
throw new Error(`Expected principal, got ${result.type}`);
|
||||
};
|
||||
|
||||
export const principalT = transcoders({
|
||||
encode: principalCV,
|
||||
decode: principleResult,
|
||||
});
|
||||
676
src/generated/smartContractHelpers/errorCodes.json
Normal file
676
src/generated/smartContractHelpers/errorCodes.json
Normal file
@@ -0,0 +1,676 @@
|
||||
{
|
||||
"ERR-NOT-AUTHORIZED": [
|
||||
{
|
||||
"code": 1000,
|
||||
"comment": "token-xbtc.clar:12"
|
||||
}
|
||||
],
|
||||
"ERR-TRANSFER-FAILED": [
|
||||
{
|
||||
"code": 3000,
|
||||
"comment": "token-apower.clar:5"
|
||||
}
|
||||
],
|
||||
"ERR-NO-ARB-EXISTS": [
|
||||
{
|
||||
"code": 9000,
|
||||
"comment": "flash-loan-user-autoalex-to-alex.clar:5"
|
||||
}
|
||||
],
|
||||
"ERR-GET-BALANCE-FIXED-FAIL": [
|
||||
{
|
||||
"code": 6001,
|
||||
"comment": "flash-loan-user-autoalex-to-alex.clar:6"
|
||||
}
|
||||
],
|
||||
"ERR-EXCEEDS-MAX-USE": [
|
||||
{
|
||||
"code": 9000,
|
||||
"comment": "faucet.clar:8"
|
||||
}
|
||||
],
|
||||
"ERR-UNKNOWN-TOKEN": [
|
||||
{
|
||||
"code": 1001,
|
||||
"comment": "faucet.clar:9"
|
||||
}
|
||||
],
|
||||
"ERR-EXPIRY-IS-NONE": [
|
||||
{
|
||||
"code": 2027,
|
||||
"comment": "flash-loan-user-margin-usda-wbtc.clar:5"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-TOKEN": [
|
||||
{
|
||||
"code": 2026,
|
||||
"comment": "flash-loan-user-margin-usda-wbtc.clar:6"
|
||||
}
|
||||
],
|
||||
"ERR-TOO-MANY-POOLS": [
|
||||
{
|
||||
"code": 2004,
|
||||
"comment": "staked-fwp-wstx-alex-50-50-v1-01.clar:6"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-BALANCE": [
|
||||
{
|
||||
"code": 2008,
|
||||
"comment": "staked-fwp-wstx-alex-50-50-v1-01.clar:7"
|
||||
},
|
||||
{
|
||||
"code": 1001,
|
||||
"comment": "yield-token-equation.clar:13"
|
||||
}
|
||||
],
|
||||
"ERR-TOKEN-NOT-AUTHORIZED": [
|
||||
{
|
||||
"code": 1001,
|
||||
"comment": "bridge-endpoint.clar:5"
|
||||
}
|
||||
],
|
||||
"ERR-RECIPIENT-NOT-AUTHORIZED": [
|
||||
{
|
||||
"code": 1002,
|
||||
"comment": "bridge-endpoint.clar:6"
|
||||
}
|
||||
],
|
||||
"ERR-WRAPPER-NOT-AUTHORIZED": [
|
||||
{
|
||||
"code": 1004,
|
||||
"comment": "bridge-endpoint.clar:7"
|
||||
}
|
||||
],
|
||||
"ERR-UNKNOWN-USER-ID": [
|
||||
{
|
||||
"code": 1005,
|
||||
"comment": "bridge-endpoint.clar:8"
|
||||
}
|
||||
],
|
||||
"ERR-UNKNOWN-VALIDATOR-ID": [
|
||||
{
|
||||
"code": 1006,
|
||||
"comment": "bridge-endpoint.clar:9"
|
||||
}
|
||||
],
|
||||
"ERR-USER-ALREADY-REGISTERED": [
|
||||
{
|
||||
"code": 1007,
|
||||
"comment": "bridge-endpoint.clar:10"
|
||||
},
|
||||
{
|
||||
"code": 10001,
|
||||
"comment": "alex-reserve-pool.clar:8"
|
||||
}
|
||||
],
|
||||
"ERR-VALIDATOR-ALREADY-REGISTERED": [
|
||||
{
|
||||
"code": 1008,
|
||||
"comment": "bridge-endpoint.clar:11"
|
||||
}
|
||||
],
|
||||
"ERR-DUPLICATE-SIGNATURE": [
|
||||
{
|
||||
"code": 1009,
|
||||
"comment": "bridge-endpoint.clar:12"
|
||||
}
|
||||
],
|
||||
"ERR-ORDER-HASH-MISMATCH": [
|
||||
{
|
||||
"code": 1010,
|
||||
"comment": "bridge-endpoint.clar:13"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-SIGNATURE": [
|
||||
{
|
||||
"code": 1011,
|
||||
"comment": "bridge-endpoint.clar:14"
|
||||
}
|
||||
],
|
||||
"ERR-UKNOWN-RELAYER": [
|
||||
{
|
||||
"code": 1012,
|
||||
"comment": "bridge-endpoint.clar:15"
|
||||
}
|
||||
],
|
||||
"ERR-REQUIRED-VALIDATORS": [
|
||||
{
|
||||
"code": 1013,
|
||||
"comment": "bridge-endpoint.clar:16"
|
||||
}
|
||||
],
|
||||
"ERR-ORDER-ALREADY-SENT": [
|
||||
{
|
||||
"code": 1014,
|
||||
"comment": "bridge-endpoint.clar:17"
|
||||
}
|
||||
],
|
||||
"ERR-PAUSED": [
|
||||
{
|
||||
"code": 1015,
|
||||
"comment": "bridge-endpoint.clar:18"
|
||||
},
|
||||
{
|
||||
"code": 1001,
|
||||
"comment": "amm-swap-pool.clar:19"
|
||||
}
|
||||
],
|
||||
"ERR-USER-NOT-WHITELISTED": [
|
||||
{
|
||||
"code": 1016,
|
||||
"comment": "bridge-endpoint.clar:19"
|
||||
}
|
||||
],
|
||||
"ERR-AMOUNT-LESS-THAN-MIN-FEE": [
|
||||
{
|
||||
"code": 1017,
|
||||
"comment": "bridge-endpoint.clar:20"
|
||||
}
|
||||
],
|
||||
"ERR-UNKNOWN-CHAIN-ID": [
|
||||
{
|
||||
"code": 1018,
|
||||
"comment": "bridge-endpoint.clar:21"
|
||||
}
|
||||
],
|
||||
"ERR-NO-LIQUIDITY": [
|
||||
{
|
||||
"code": 2002,
|
||||
"comment": "weighted-equation-v1-01.clar:10"
|
||||
}
|
||||
],
|
||||
"ERR-WEIGHT-SUM": [
|
||||
{
|
||||
"code": 4000,
|
||||
"comment": "weighted-equation-v1-01.clar:11"
|
||||
}
|
||||
],
|
||||
"ERR-MAX-IN-RATIO": [
|
||||
{
|
||||
"code": 4001,
|
||||
"comment": "weighted-equation-v1-01.clar:12"
|
||||
}
|
||||
],
|
||||
"ERR-MAX-OUT-RATIO": [
|
||||
{
|
||||
"code": 4002,
|
||||
"comment": "weighted-equation-v1-01.clar:13"
|
||||
}
|
||||
],
|
||||
"ERR-X-OUT-OF-BOUNDS": [
|
||||
{
|
||||
"code": 5009,
|
||||
"comment": "weighted-equation-v1-01.clar:485"
|
||||
}
|
||||
],
|
||||
"ERR-Y-OUT-OF-BOUNDS": [
|
||||
{
|
||||
"code": 5010,
|
||||
"comment": "weighted-equation-v1-01.clar:486"
|
||||
}
|
||||
],
|
||||
"ERR-PRODUCT-OUT-OF-BOUNDS": [
|
||||
{
|
||||
"code": 5011,
|
||||
"comment": "weighted-equation-v1-01.clar:487"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-EXPONENT": [
|
||||
{
|
||||
"code": 5012,
|
||||
"comment": "weighted-equation-v1-01.clar:488"
|
||||
}
|
||||
],
|
||||
"ERR-OUT-OF-BOUNDS": [
|
||||
{
|
||||
"code": 5013,
|
||||
"comment": "weighted-equation-v1-01.clar:489"
|
||||
}
|
||||
],
|
||||
"ERR-NO-FEE-CHANGE": [
|
||||
{
|
||||
"code": 8001,
|
||||
"comment": "multisig-fwp-alex-autoalex.clar:6"
|
||||
}
|
||||
],
|
||||
"ERR-BLOCK-HEIGHT-NOT-REACHED": [
|
||||
{
|
||||
"code": 8003,
|
||||
"comment": "multisig-fwp-alex-autoalex.clar:8"
|
||||
},
|
||||
{
|
||||
"code": 2042,
|
||||
"comment": "alex-lottery.clar:5"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-LIQUIDITY": [
|
||||
{
|
||||
"code": 2003,
|
||||
"comment": "auto-fwp-alex-usda.clar:227"
|
||||
}
|
||||
],
|
||||
"ERR-REWARD-CYCLE-NOT-COMPLETED": [
|
||||
{
|
||||
"code": 10017,
|
||||
"comment": "auto-fwp-alex-usda.clar:228"
|
||||
}
|
||||
],
|
||||
"ERR-STAKING-NOT-AVAILABLE": [
|
||||
{
|
||||
"code": 10015,
|
||||
"comment": "auto-fwp-alex-usda.clar:229"
|
||||
},
|
||||
{
|
||||
"code": 2027,
|
||||
"comment": "yield-vault-alex.clar:13"
|
||||
}
|
||||
],
|
||||
"ERR-NOT-ACTIVATED": [
|
||||
{
|
||||
"code": 2043,
|
||||
"comment": "auto-fwp-alex-usda.clar:231"
|
||||
}
|
||||
],
|
||||
"ERR-ACTIVATED": [
|
||||
{
|
||||
"code": 2044,
|
||||
"comment": "auto-fwp-alex-usda.clar:232"
|
||||
}
|
||||
],
|
||||
"ERR-USER-ID-NOT-FOUND": [
|
||||
{
|
||||
"code": 10003,
|
||||
"comment": "auto-fwp-alex-usda.clar:233"
|
||||
}
|
||||
],
|
||||
"ERR-INSUFFICIENT-BALANCE": [
|
||||
{
|
||||
"code": 2045,
|
||||
"comment": "auto-fwp-alex-usda.clar:234"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-PERCENT": [
|
||||
{
|
||||
"code": 5000,
|
||||
"comment": "auto-fwp-alex-usda.clar:235"
|
||||
}
|
||||
],
|
||||
"ERR-AVAILABLE-ALEX": [
|
||||
{
|
||||
"code": 20000,
|
||||
"comment": "auto-fwp-alex-usda-100x.clar:6"
|
||||
}
|
||||
],
|
||||
"ERR-BLOCK-HEIGHT": [
|
||||
{
|
||||
"code": 2043,
|
||||
"comment": "auto-fwp-alex-autoalex-x-v1-01.clar:9"
|
||||
}
|
||||
],
|
||||
"ERR-NOT-ENOUGH-ALEX": [
|
||||
{
|
||||
"code": 20001,
|
||||
"comment": "auto-fwp-alex-autoalex-x-v1-01.clar:10"
|
||||
}
|
||||
],
|
||||
"ERR-X-OUT-OF-BOUNDS-MANTISSA": [
|
||||
{
|
||||
"code": 50091,
|
||||
"comment": "math-fixed-point-v2.clar:116"
|
||||
}
|
||||
],
|
||||
"ERR-X-OUT-OF-BOUNDS-EXP": [
|
||||
{
|
||||
"code": 50092,
|
||||
"comment": "math-fixed-point-v2.clar:117"
|
||||
}
|
||||
],
|
||||
"ERR-Y-OUT-OF-BOUNDS-MANTISSA": [
|
||||
{
|
||||
"code": 50101,
|
||||
"comment": "math-fixed-point-v2.clar:119"
|
||||
}
|
||||
],
|
||||
"ERR-Y-OUT-OF-BOUNDS-EXP": [
|
||||
{
|
||||
"code": 50102,
|
||||
"comment": "math-fixed-point-v2.clar:120"
|
||||
}
|
||||
],
|
||||
"ERR-NOT-POSITIVE": [
|
||||
{
|
||||
"code": 5014,
|
||||
"comment": "math-fixed-point-v2.clar:124"
|
||||
}
|
||||
],
|
||||
"ERR-MINT-FAILED": [
|
||||
{
|
||||
"code": 6002,
|
||||
"comment": "token-wxusd.clar:16"
|
||||
}
|
||||
],
|
||||
"ERR-BURN-FAILED": [
|
||||
{
|
||||
"code": 6003,
|
||||
"comment": "token-wxusd.clar:17"
|
||||
}
|
||||
],
|
||||
"ERR-NOT-SUPPORTED": [
|
||||
{
|
||||
"code": 6004,
|
||||
"comment": "token-wxusd.clar:19"
|
||||
}
|
||||
],
|
||||
"ERR-CONTRACT-NOT-ACTIVATED": [
|
||||
{
|
||||
"code": 10005,
|
||||
"comment": "alex-reserve-pool.clar:10"
|
||||
}
|
||||
],
|
||||
"ERR-CANNOT-STAKE": [
|
||||
{
|
||||
"code": 10016,
|
||||
"comment": "alex-reserve-pool.clar:12"
|
||||
}
|
||||
],
|
||||
"ERR-AMOUNT-EXCEED-RESERVE": [
|
||||
{
|
||||
"code": 2024,
|
||||
"comment": "alex-reserve-pool.clar:14"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-POOL": [
|
||||
{
|
||||
"code": 2001,
|
||||
"comment": "collateral-rebalancing-pool.clar:9"
|
||||
}
|
||||
],
|
||||
"ERR-POOL-ALREADY-EXISTS": [
|
||||
{
|
||||
"code": 2000,
|
||||
"comment": "collateral-rebalancing-pool.clar:12"
|
||||
}
|
||||
],
|
||||
"ERR-GET-WEIGHT-FAIL": [
|
||||
{
|
||||
"code": 2012,
|
||||
"comment": "collateral-rebalancing-pool.clar:15"
|
||||
}
|
||||
],
|
||||
"ERR-EXPIRY": [
|
||||
{
|
||||
"code": 2017,
|
||||
"comment": "collateral-rebalancing-pool.clar:16"
|
||||
}
|
||||
],
|
||||
"ERR-LTV-TOO-HIGH": [
|
||||
{
|
||||
"code": 2019,
|
||||
"comment": "collateral-rebalancing-pool.clar:19"
|
||||
}
|
||||
],
|
||||
"ERR-EXCEEDS-MAX-SLIPPAGE": [
|
||||
{
|
||||
"code": 2020,
|
||||
"comment": "collateral-rebalancing-pool.clar:20"
|
||||
}
|
||||
],
|
||||
"ERR-POOL-AT-CAPACITY": [
|
||||
{
|
||||
"code": 2027,
|
||||
"comment": "collateral-rebalancing-pool.clar:22"
|
||||
}
|
||||
],
|
||||
"ERR-ROLL-FLASH-LOAN-FEE": [
|
||||
{
|
||||
"code": 2028,
|
||||
"comment": "collateral-rebalancing-pool.clar:23"
|
||||
}
|
||||
],
|
||||
"ERR-ORACLE-NOT-ENABLED": [
|
||||
{
|
||||
"code": 7002,
|
||||
"comment": "collateral-rebalancing-pool.clar:24"
|
||||
}
|
||||
],
|
||||
"ERR-PERCENT-GREATER-THAN-ONE": [
|
||||
{
|
||||
"code": 5000,
|
||||
"comment": "fixed-weight-pool-alex.clar:14"
|
||||
}
|
||||
],
|
||||
"ERR-ORACLE-ALREADY-ENABLED": [
|
||||
{
|
||||
"code": 7003,
|
||||
"comment": "fixed-weight-pool-alex.clar:17"
|
||||
}
|
||||
],
|
||||
"ERR-ORACLE-AVERAGE-BIGGER-THAN-ONE": [
|
||||
{
|
||||
"code": 7004,
|
||||
"comment": "fixed-weight-pool-alex.clar:18"
|
||||
}
|
||||
],
|
||||
"ERR-UNKNOWN-LOTTERY": [
|
||||
{
|
||||
"code": 2045,
|
||||
"comment": "alex-lottery.clar:3"
|
||||
}
|
||||
],
|
||||
"ERR-UNKNOWN-LOTTERY-ROUND": [
|
||||
{
|
||||
"code": 2047,
|
||||
"comment": "alex-lottery.clar:4"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-SEQUENCE": [
|
||||
{
|
||||
"code": 2046,
|
||||
"comment": "alex-lottery.clar:6"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-LOTTERY-TOKEN": [
|
||||
{
|
||||
"code": 2026,
|
||||
"comment": "alex-lottery.clar:7"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-LOTTERY-SETTING": [
|
||||
{
|
||||
"code": 110,
|
||||
"comment": "alex-lottery.clar:8"
|
||||
}
|
||||
],
|
||||
"ERR-ALREADY-REGISTERED": [
|
||||
{
|
||||
"code": 10001,
|
||||
"comment": "alex-lottery.clar:9"
|
||||
}
|
||||
],
|
||||
"ERR-LOTTERY-ROUND-ALREADY-CLAIMED": [
|
||||
{
|
||||
"code": 2048,
|
||||
"comment": "alex-lottery.clar:11"
|
||||
}
|
||||
],
|
||||
"ERR-BONUS-TICKETS-EXCEED-MAX": [
|
||||
{
|
||||
"code": 2049,
|
||||
"comment": "alex-lottery.clar:12"
|
||||
}
|
||||
],
|
||||
"ERR-NOT-REGISTERED": [
|
||||
{
|
||||
"code": 2050,
|
||||
"comment": "alex-lottery.clar:13"
|
||||
}
|
||||
],
|
||||
"ERR-SWITCH-THRESHOLD-BIGGER-THAN-ONE": [
|
||||
{
|
||||
"code": 7005,
|
||||
"comment": "amm-swap-pool.clar:20"
|
||||
}
|
||||
],
|
||||
"ERR-STAKING-IN-PROGRESS": [
|
||||
{
|
||||
"code": 2018,
|
||||
"comment": "yield-vault-alex.clar:12"
|
||||
}
|
||||
],
|
||||
"ERR-ALREADY-EXPIRED": [
|
||||
{
|
||||
"code": 2011,
|
||||
"comment": "liquidity-bootstrapping-pool.clar:16"
|
||||
}
|
||||
],
|
||||
"ERR-PRICE-LOWER-THAN-MIN": [
|
||||
{
|
||||
"code": 2021,
|
||||
"comment": "liquidity-bootstrapping-pool.clar:18"
|
||||
}
|
||||
],
|
||||
"ERR-PRICE-GREATER-THAN-MAX": [
|
||||
{
|
||||
"code": 2022,
|
||||
"comment": "liquidity-bootstrapping-pool.clar:19"
|
||||
}
|
||||
],
|
||||
"ERR-NO-FEE": [
|
||||
{
|
||||
"code": 2005,
|
||||
"comment": "yield-token-pool.clar:14"
|
||||
}
|
||||
],
|
||||
"ERR-NO-FEE-Y": [
|
||||
{
|
||||
"code": 2006,
|
||||
"comment": "yield-token-pool.clar:15"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-EXPIRY": [
|
||||
{
|
||||
"code": 2009,
|
||||
"comment": "yield-token-pool.clar:16"
|
||||
}
|
||||
],
|
||||
"ERR-GET-EXPIRY-FAIL-ERR": [
|
||||
{
|
||||
"code": 2013,
|
||||
"comment": "yield-token-pool.clar:17"
|
||||
}
|
||||
],
|
||||
"ERR-DY-BIGGER-THAN-AVAILABLE": [
|
||||
{
|
||||
"code": 2016,
|
||||
"comment": "yield-token-pool.clar:18"
|
||||
}
|
||||
],
|
||||
"ERR-NOT-FOUND": [
|
||||
{
|
||||
"code": 1003,
|
||||
"comment": "dual-farming-pool.clar:8"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-TICKET": [
|
||||
{
|
||||
"code": 2028,
|
||||
"comment": "alex-launchpad.clar:12"
|
||||
}
|
||||
],
|
||||
"ERR-NO-VRF-SEED-FOUND": [
|
||||
{
|
||||
"code": 2030,
|
||||
"comment": "alex-launchpad.clar:13"
|
||||
}
|
||||
],
|
||||
"ERR-CLAIM-NOT-AVAILABLE": [
|
||||
{
|
||||
"code": 2031,
|
||||
"comment": "alex-launchpad.clar:14"
|
||||
}
|
||||
],
|
||||
"ERR-REGISTRATION-STARTED": [
|
||||
{
|
||||
"code": 2033,
|
||||
"comment": "alex-launchpad.clar:15"
|
||||
}
|
||||
],
|
||||
"ERR-REGISTRATION-NOT-STARTED": [
|
||||
{
|
||||
"code": 2034,
|
||||
"comment": "alex-launchpad.clar:16"
|
||||
}
|
||||
],
|
||||
"ERR-LISTING-ACTIVATED": [
|
||||
{
|
||||
"code": 2035,
|
||||
"comment": "alex-launchpad.clar:17"
|
||||
}
|
||||
],
|
||||
"ERR-LISTING-NOT-ACTIVATED": [
|
||||
{
|
||||
"code": 2036,
|
||||
"comment": "alex-launchpad.clar:18"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-REGISTRATION-PERIOD": [
|
||||
{
|
||||
"code": 2037,
|
||||
"comment": "alex-launchpad.clar:19"
|
||||
}
|
||||
],
|
||||
"ERR-REGISTRATION-ENDED": [
|
||||
{
|
||||
"code": 2038,
|
||||
"comment": "alex-launchpad.clar:20"
|
||||
}
|
||||
],
|
||||
"ERR-REGISTRATION-NOT-ENDED": [
|
||||
{
|
||||
"code": 2039,
|
||||
"comment": "alex-launchpad.clar:21"
|
||||
}
|
||||
],
|
||||
"ERR-CLAIM-ENDED": [
|
||||
{
|
||||
"code": 2040,
|
||||
"comment": "alex-launchpad.clar:22"
|
||||
}
|
||||
],
|
||||
"ERR-CLAIM-NOT-ENDED": [
|
||||
{
|
||||
"code": 2041,
|
||||
"comment": "alex-launchpad.clar:23"
|
||||
}
|
||||
],
|
||||
"ERR-INVALID-CLAIM-PERIOD": [
|
||||
{
|
||||
"code": 2042,
|
||||
"comment": "alex-launchpad.clar:24"
|
||||
}
|
||||
],
|
||||
"ERR-REFUND-NOT-AVAILABLE": [
|
||||
{
|
||||
"code": 2043,
|
||||
"comment": "alex-launchpad.clar:25"
|
||||
}
|
||||
],
|
||||
"ERR-ALREADY-PROCESSED": [
|
||||
{
|
||||
"code": 1409,
|
||||
"comment": "fwp-wstx-alex-tranched-64.clar:15"
|
||||
}
|
||||
],
|
||||
"ERR-DISTRIBUTION": [
|
||||
{
|
||||
"code": 1410,
|
||||
"comment": "fwp-wstx-alex-tranched-64.clar:16"
|
||||
}
|
||||
],
|
||||
"ERR-CHAIN-NOT-AUTHORIZED": [
|
||||
{
|
||||
"code": 1003,
|
||||
"comment": "bridge-helper.clar:7"
|
||||
}
|
||||
]
|
||||
}
|
||||
90
src/helpers/FeeHelper.ts
Normal file
90
src/helpers/FeeHelper.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import { AlexSDK, Currency } from '../index';
|
||||
import { AMMSwapPool } from '../utils/ammPool';
|
||||
import { unwrapResponse } from 'clarity-codegen';
|
||||
|
||||
export async function getLiquidityProviderFee(
|
||||
sdk: AlexSDK,
|
||||
tokenX: Currency,
|
||||
tokenY: Currency,
|
||||
ammPools: AMMSwapPool.PoolTokens[]
|
||||
): Promise<bigint> {
|
||||
const ammRoute = AMMSwapPool.getRoute(tokenX, tokenY, ammPools);
|
||||
if (ammRoute.length === 0) {
|
||||
const reachableInAmm = AMMSwapPool.reachableInAMM(tokenX, tokenY, ammPools);
|
||||
if (reachableInAmm.type === 'fromAmm') {
|
||||
return await sdk
|
||||
.readonlyCall('swap-helper-bridged', 'fee-helper-from-amm', {
|
||||
'token-x': reachableInAmm.tokenX,
|
||||
'token-y': reachableInAmm.tokenY,
|
||||
'token-z': reachableInAmm.tokenZ,
|
||||
'factor-x': reachableInAmm.factorX,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
if (reachableInAmm.type === 'toAmm') {
|
||||
return await sdk
|
||||
.readonlyCall('swap-helper-bridged', 'fee-helper-to-amm', {
|
||||
'token-x': reachableInAmm.tokenX,
|
||||
'token-y': reachableInAmm.tokenY,
|
||||
'token-z': reachableInAmm.tokenZ,
|
||||
'factor-y': reachableInAmm.factorY,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
return await sdk
|
||||
.readonlyCall('swap-helper-v1-03', 'fee-helper', {
|
||||
'token-x': tokenX,
|
||||
'token-y': tokenY,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
if (ammRoute.length === 1) {
|
||||
return await sdk
|
||||
.readonlyCall('amm-swap-pool', 'fee-helper', {
|
||||
'token-x': tokenX,
|
||||
'token-y': tokenY,
|
||||
factor: AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
if (ammRoute.length === 2) {
|
||||
return await sdk
|
||||
.readonlyCall('amm-swap-pool', 'fee-helper-a', {
|
||||
'token-x': tokenX,
|
||||
'token-y': ammRoute[0]!.neighbour,
|
||||
'token-z': ammRoute[1]!.neighbour,
|
||||
'factor-x': AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
'factor-y': AMMSwapPool.getFactor(ammRoute[1]!.pool),
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
if (ammRoute.length === 3) {
|
||||
return await sdk
|
||||
.readonlyCall('amm-swap-pool', 'fee-helper-b', {
|
||||
'token-x': tokenX,
|
||||
'token-y': ammRoute[0]!.neighbour,
|
||||
'token-z': ammRoute[1]!.neighbour,
|
||||
'token-w': ammRoute[2]!.neighbour,
|
||||
'factor-x': AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
'factor-y': AMMSwapPool.getFactor(ammRoute[1]!.pool),
|
||||
'factor-z': AMMSwapPool.getFactor(ammRoute[2]!.pool),
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
if (ammRoute.length === 4) {
|
||||
return await sdk
|
||||
.readonlyCall('amm-swap-pool', 'fee-helper-c', {
|
||||
'token-x': tokenX,
|
||||
'token-y': ammRoute[0]!.neighbour,
|
||||
'token-z': ammRoute[1]!.neighbour,
|
||||
'token-w': ammRoute[2]!.neighbour,
|
||||
'token-v': ammRoute[3]!.neighbour,
|
||||
'factor-x': AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
'factor-y': AMMSwapPool.getFactor(ammRoute[1]!.pool),
|
||||
'factor-z': AMMSwapPool.getFactor(ammRoute[2]!.pool),
|
||||
'factor-w': AMMSwapPool.getFactor(ammRoute[3]!.pool),
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
throw new Error('Too many AMM pools in route');
|
||||
}
|
||||
98
src/helpers/RateHelper.ts
Normal file
98
src/helpers/RateHelper.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
import { AlexSDK, Currency } from '../index';
|
||||
import { AMMSwapPool } from '../utils/ammPool';
|
||||
import { unwrapResponse } from 'clarity-codegen';
|
||||
|
||||
export const getYAmountFromXAmount = async (
|
||||
sdk: AlexSDK,
|
||||
tokenX: Currency,
|
||||
tokenY: Currency,
|
||||
fromAmount: bigint,
|
||||
ammPools: AMMSwapPool.PoolTokens[]
|
||||
): Promise<bigint> => {
|
||||
const ammRoute = AMMSwapPool.getRoute(tokenX, tokenY, ammPools);
|
||||
if (ammRoute.length === 0) {
|
||||
const reachableInAMM = AMMSwapPool.reachableInAMM(tokenX, tokenY, ammPools);
|
||||
if (reachableInAMM.type === 'fromAmm') {
|
||||
return await sdk
|
||||
.readonlyCall('swap-helper-bridged', 'get-helper-from-amm', {
|
||||
dx: fromAmount,
|
||||
'token-x': reachableInAMM.tokenX,
|
||||
'token-y': reachableInAMM.tokenY,
|
||||
'token-z': reachableInAMM.tokenZ,
|
||||
'factor-x': reachableInAMM.factorX,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
if (reachableInAMM.type === 'toAmm') {
|
||||
return await sdk
|
||||
.readonlyCall('swap-helper-bridged', 'get-helper-to-amm', {
|
||||
dx: fromAmount,
|
||||
'token-x': reachableInAMM.tokenX,
|
||||
'token-y': reachableInAMM.tokenY,
|
||||
'token-z': reachableInAMM.tokenZ,
|
||||
'factor-y': reachableInAMM.factorY,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
return await sdk
|
||||
.readonlyCall('swap-helper-v1-03', 'get-helper', {
|
||||
'token-x': tokenX,
|
||||
'token-y': tokenY,
|
||||
dx: fromAmount,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
if (ammRoute.length === 1) {
|
||||
return await sdk
|
||||
.readonlyCall('amm-swap-pool', 'get-helper', {
|
||||
'token-x': tokenX,
|
||||
'token-y': ammRoute[0]!.neighbour,
|
||||
dx: fromAmount,
|
||||
factor: AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
if (ammRoute.length === 2) {
|
||||
return await sdk
|
||||
.readonlyCall('amm-swap-pool', 'get-helper-a', {
|
||||
'token-x': tokenX,
|
||||
'token-y': ammRoute[0]!.neighbour,
|
||||
'token-z': ammRoute[1]!.neighbour,
|
||||
'factor-x': AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
'factor-y': AMMSwapPool.getFactor(ammRoute[1]!.pool),
|
||||
dx: fromAmount,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
if (ammRoute.length === 3) {
|
||||
return await sdk
|
||||
.readonlyCall('amm-swap-pool', 'get-helper-b', {
|
||||
'token-x': tokenX,
|
||||
'token-y': ammRoute[0]!.neighbour,
|
||||
'token-z': ammRoute[1]!.neighbour,
|
||||
'token-w': ammRoute[2]!.neighbour,
|
||||
'factor-x': AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
'factor-y': AMMSwapPool.getFactor(ammRoute[1]!.pool),
|
||||
'factor-z': AMMSwapPool.getFactor(ammRoute[2]!.pool),
|
||||
dx: fromAmount,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
if (ammRoute.length === 4) {
|
||||
return await sdk
|
||||
.readonlyCall('amm-swap-pool', 'get-helper-c', {
|
||||
'token-x': tokenX,
|
||||
'token-y': ammRoute[0]!.neighbour,
|
||||
'token-z': ammRoute[1]!.neighbour,
|
||||
'token-w': ammRoute[2]!.neighbour,
|
||||
'token-v': ammRoute[3]!.neighbour,
|
||||
'factor-x': AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
'factor-y': AMMSwapPool.getFactor(ammRoute[1]!.pool),
|
||||
'factor-z': AMMSwapPool.getFactor(ammRoute[2]!.pool),
|
||||
'factor-w': AMMSwapPool.getFactor(ammRoute[3]!.pool),
|
||||
dx: fromAmount,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
}
|
||||
throw new Error('Too many AMM pools in route');
|
||||
};
|
||||
45
src/helpers/RouteHelper.ts
Normal file
45
src/helpers/RouteHelper.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { AlexSDK, Currency } from '../index';
|
||||
import { AMMSwapPool } from '../utils/ammPool';
|
||||
import { unwrapResponse } from 'clarity-codegen';
|
||||
|
||||
export async function getRoute(
|
||||
sdk: AlexSDK,
|
||||
from: Currency,
|
||||
to: Currency,
|
||||
pools: AMMSwapPool.PoolTokens[]
|
||||
): Promise<Currency[]> {
|
||||
const ammRoute = AMMSwapPool.getRoute(from, to, pools);
|
||||
if (ammRoute.length > 0) {
|
||||
return [from, ...ammRoute.map((a) => a.neighbour)];
|
||||
}
|
||||
const reachableInAmm = AMMSwapPool.reachableInAMM(from, to, pools);
|
||||
if (reachableInAmm.type === 'fromAmm') {
|
||||
const result = await sdk
|
||||
.readonlyCall('swap-helper-bridged', 'route-helper-from-amm', {
|
||||
'token-x': reachableInAmm.tokenX,
|
||||
'token-y': reachableInAmm.tokenY,
|
||||
'token-z': reachableInAmm.tokenZ,
|
||||
'factor-x': reachableInAmm.factorX,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
return result.map((x) => x as Currency);
|
||||
}
|
||||
if (reachableInAmm.type === 'toAmm') {
|
||||
const result = await sdk
|
||||
.readonlyCall('swap-helper-bridged', 'route-helper-to-amm', {
|
||||
'token-x': reachableInAmm.tokenX,
|
||||
'token-y': reachableInAmm.tokenY,
|
||||
'token-z': reachableInAmm.tokenZ,
|
||||
'factor-y': reachableInAmm.factorY,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
return result.map((x) => x as Currency);
|
||||
}
|
||||
const result = await sdk
|
||||
.readonlyCall('swap-helper-v1-03', 'route-helper', {
|
||||
'token-x': from,
|
||||
'token-y': to,
|
||||
})
|
||||
.then(unwrapResponse);
|
||||
return result.map((x) => x as Currency);
|
||||
}
|
||||
352
src/helpers/SwapHelper.ts
Normal file
352
src/helpers/SwapHelper.ts
Normal file
@@ -0,0 +1,352 @@
|
||||
import { Contracts, Currency } from '../index';
|
||||
import { AMMSwapPool } from '../utils/ammPool';
|
||||
import { AlexVault, transfer } from '../utils/postConditions';
|
||||
import {
|
||||
ClarityValue,
|
||||
FungibleConditionCode,
|
||||
FungiblePostCondition,
|
||||
STXPostCondition,
|
||||
} from '@stacks/transactions';
|
||||
import {
|
||||
OpenCallFunctionDescriptor,
|
||||
ParameterObjOfDescriptor,
|
||||
ReadonlyFunctionDescriptor,
|
||||
ReturnTypeOfDescriptor,
|
||||
} from 'clarity-codegen';
|
||||
import { AlexContracts } from '../generated/smartContract/contracts_Alex';
|
||||
import { CONTRACT_DEPLOYER } from '../config';
|
||||
|
||||
export type TxToBroadCast = {
|
||||
contractAddress: string;
|
||||
contractName: string;
|
||||
functionName: string;
|
||||
functionArgs: ClarityValue[];
|
||||
postConditions: Array<FungiblePostCondition | STXPostCondition>;
|
||||
};
|
||||
|
||||
const composeTx: <
|
||||
T extends keyof Contracts,
|
||||
F extends keyof Contracts[T],
|
||||
Descriptor extends Contracts[T][F]
|
||||
>(
|
||||
contractName: T,
|
||||
functionName: F,
|
||||
args: Descriptor extends OpenCallFunctionDescriptor
|
||||
? ParameterObjOfDescriptor<Descriptor>
|
||||
: never,
|
||||
postConditions: (FungiblePostCondition | STXPostCondition)[]
|
||||
) => TxToBroadCast = (contractName, functionName, args, postConditions) => {
|
||||
const functionDescriptor = AlexContracts[contractName][
|
||||
functionName
|
||||
] as any as OpenCallFunctionDescriptor;
|
||||
const clarityArgs = functionDescriptor.input.map((arg) =>
|
||||
arg.type.encode(args[arg.name])
|
||||
);
|
||||
return {
|
||||
contractName,
|
||||
functionName: String(functionName),
|
||||
functionArgs: clarityArgs,
|
||||
contractAddress: CONTRACT_DEPLOYER,
|
||||
postConditions,
|
||||
};
|
||||
};
|
||||
|
||||
export function runSpot(
|
||||
stxAddress: string,
|
||||
currencyX: Currency,
|
||||
currencyY: Currency,
|
||||
fromAmount: bigint,
|
||||
minDy: bigint,
|
||||
middleSteps: Currency[],
|
||||
ammPools: AMMSwapPool.PoolTokens[]
|
||||
): TxToBroadCast {
|
||||
const ammRoute = AMMSwapPool.getRoute(currencyX, currencyY, ammPools);
|
||||
if (ammRoute.length === 0) {
|
||||
const reachableInAMM = AMMSwapPool.reachableInAMM(
|
||||
currencyX,
|
||||
currencyY,
|
||||
ammPools
|
||||
);
|
||||
if (reachableInAMM.type === 'fromAmm') {
|
||||
return composeTx(
|
||||
'swap-helper-bridged',
|
||||
'swap-helper-from-amm',
|
||||
{
|
||||
'token-x-trait': reachableInAMM.tokenX,
|
||||
'token-y-trait': reachableInAMM.tokenY,
|
||||
'token-z-trait': reachableInAMM.tokenZ,
|
||||
dx: fromAmount,
|
||||
'min-dz': minDy,
|
||||
'factor-x': reachableInAMM.factorX,
|
||||
},
|
||||
[
|
||||
transfer(stxAddress, currencyX, fromAmount),
|
||||
...middleSteps.flatMap((middle) => [
|
||||
transfer(
|
||||
AlexVault,
|
||||
middle,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
stxAddress,
|
||||
middle,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
]),
|
||||
transfer(
|
||||
AlexVault,
|
||||
currencyY,
|
||||
minDy,
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
if (reachableInAMM.type === 'toAmm') {
|
||||
return composeTx(
|
||||
'swap-helper-bridged',
|
||||
'swap-helper-to-amm',
|
||||
{
|
||||
'token-x-trait': reachableInAMM.tokenX,
|
||||
'token-y-trait': reachableInAMM.tokenY,
|
||||
'token-z-trait': reachableInAMM.tokenZ,
|
||||
dx: fromAmount,
|
||||
'min-dz': minDy,
|
||||
'factor-y': reachableInAMM.factorY,
|
||||
},
|
||||
[
|
||||
transfer(stxAddress, currencyX, fromAmount),
|
||||
...middleSteps.flatMap((middle) => [
|
||||
transfer(
|
||||
AlexVault,
|
||||
middle,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
stxAddress,
|
||||
middle,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
]),
|
||||
transfer(
|
||||
AlexVault,
|
||||
currencyY,
|
||||
minDy,
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
return composeTx(
|
||||
'swap-helper-v1-03',
|
||||
'swap-helper',
|
||||
{
|
||||
'token-x-trait': currencyX,
|
||||
'token-y-trait': currencyY,
|
||||
dx: fromAmount,
|
||||
'min-dy': minDy,
|
||||
},
|
||||
[
|
||||
transfer(stxAddress, currencyX, fromAmount),
|
||||
...middleSteps.flatMap((middle) => [
|
||||
transfer(
|
||||
AlexVault,
|
||||
middle,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
stxAddress,
|
||||
middle,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
]),
|
||||
transfer(
|
||||
AlexVault,
|
||||
currencyY,
|
||||
minDy,
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
if (ammRoute.length === 1) {
|
||||
return composeTx(
|
||||
'amm-swap-pool',
|
||||
'swap-helper',
|
||||
{
|
||||
'token-x-trait': currencyX,
|
||||
'token-y-trait': ammRoute[0]!.neighbour,
|
||||
factor: AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
dx: fromAmount,
|
||||
'min-dy': minDy,
|
||||
},
|
||||
[
|
||||
transfer(stxAddress, currencyX, fromAmount),
|
||||
transfer(
|
||||
AlexVault,
|
||||
currencyY,
|
||||
minDy,
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
if (ammRoute.length === 2) {
|
||||
return composeTx(
|
||||
'amm-swap-pool',
|
||||
'swap-helper-a',
|
||||
{
|
||||
'token-x-trait': currencyX,
|
||||
'token-y-trait': ammRoute[0]!.neighbour,
|
||||
'token-z-trait': ammRoute[1]!.neighbour,
|
||||
'factor-x': AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
'factor-y': AMMSwapPool.getFactor(ammRoute[1]!.pool),
|
||||
dx: fromAmount,
|
||||
'min-dz': minDy,
|
||||
},
|
||||
[
|
||||
transfer(stxAddress, currencyX, fromAmount),
|
||||
transfer(
|
||||
AlexVault,
|
||||
ammRoute[0]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
stxAddress,
|
||||
ammRoute[0]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
AlexVault,
|
||||
currencyY,
|
||||
minDy,
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
if (ammRoute.length === 3) {
|
||||
return composeTx(
|
||||
'amm-swap-pool',
|
||||
'swap-helper-b',
|
||||
{
|
||||
'token-x-trait': currencyX,
|
||||
'token-y-trait': ammRoute[0]!.neighbour,
|
||||
'token-z-trait': ammRoute[1]!.neighbour,
|
||||
'token-w-trait': ammRoute[2]!.neighbour,
|
||||
'factor-x': AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
'factor-y': AMMSwapPool.getFactor(ammRoute[1]!.pool),
|
||||
'factor-z': AMMSwapPool.getFactor(ammRoute[2]!.pool),
|
||||
dx: fromAmount,
|
||||
'min-dw': minDy,
|
||||
},
|
||||
[
|
||||
transfer(stxAddress, currencyX, fromAmount),
|
||||
transfer(
|
||||
AlexVault,
|
||||
ammRoute[0]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
stxAddress,
|
||||
ammRoute[0]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
AlexVault,
|
||||
ammRoute[1]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
stxAddress,
|
||||
ammRoute[1]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
AlexVault,
|
||||
currencyY,
|
||||
minDy,
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
if (ammRoute.length === 4) {
|
||||
return composeTx(
|
||||
'amm-swap-pool',
|
||||
'swap-helper-c',
|
||||
{
|
||||
'token-x-trait': currencyX,
|
||||
'token-y-trait': ammRoute[0]!.neighbour,
|
||||
'token-z-trait': ammRoute[1]!.neighbour,
|
||||
'token-w-trait': ammRoute[2]!.neighbour,
|
||||
'token-v-trait': ammRoute[3]!.neighbour,
|
||||
'factor-x': AMMSwapPool.getFactor(ammRoute[0]!.pool),
|
||||
'factor-y': AMMSwapPool.getFactor(ammRoute[1]!.pool),
|
||||
'factor-z': AMMSwapPool.getFactor(ammRoute[2]!.pool),
|
||||
'factor-w': AMMSwapPool.getFactor(ammRoute[3]!.pool),
|
||||
dx: fromAmount,
|
||||
'min-dv': minDy,
|
||||
},
|
||||
[
|
||||
transfer(stxAddress, currencyX, fromAmount),
|
||||
transfer(
|
||||
AlexVault,
|
||||
ammRoute[0]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
stxAddress,
|
||||
ammRoute[0]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
AlexVault,
|
||||
ammRoute[1]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
stxAddress,
|
||||
ammRoute[1]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
AlexVault,
|
||||
ammRoute[2]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
stxAddress,
|
||||
ammRoute[2]!.neighbour,
|
||||
BigInt(0),
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
transfer(
|
||||
AlexVault,
|
||||
currencyY,
|
||||
minDy,
|
||||
FungibleConditionCode.GreaterEqual
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
throw new Error('Too many AMM pools in route');
|
||||
}
|
||||
115
src/index.ts
115
src/index.ts
@@ -1,6 +1,111 @@
|
||||
export const sum = (a: number, b: number) => {
|
||||
if ('development' === process.env.NODE_ENV) {
|
||||
console.log('boop');
|
||||
import { ReadOnlyFunctionOptions } from '@stacks/transactions/src/builders';
|
||||
import { ClarityValue } from '@stacks/transactions';
|
||||
import { AlexContracts } from './generated/smartContract/contracts_Alex';
|
||||
import {
|
||||
ParameterObjOfDescriptor,
|
||||
ReadonlyFunctionDescriptor,
|
||||
ReturnTypeOfDescriptor,
|
||||
} from 'clarity-codegen';
|
||||
import { CONTRACT_DEPLOYER } from './config';
|
||||
import { getLiquidityProviderFee } from './helpers/FeeHelper';
|
||||
import { AMMSwapPool } from './utils/ammPool';
|
||||
import { defaultReadonlyCallExecutor } from './utils/readonlyCallExecutor';
|
||||
import { getRoute } from './helpers/RouteHelper';
|
||||
import { getYAmountFromXAmount } from './helpers/RateHelper';
|
||||
import { runSpot, TxToBroadCast } from './helpers/SwapHelper';
|
||||
|
||||
export type Contracts = typeof AlexContracts;
|
||||
|
||||
export enum Currency {
|
||||
ALEX = 'age000-governance-token',
|
||||
USDA = 'token-wusda',
|
||||
STX = 'token-wstx',
|
||||
BANANA = 'token-wban',
|
||||
XBTC = 'token-wbtc',
|
||||
DIKO = 'token-wdiko',
|
||||
SLIME = 'token-wslm',
|
||||
XUSD = 'token-wxusd',
|
||||
MIA = 'token-wmia',
|
||||
NYCC = 'token-wnycc',
|
||||
CORGI = 'token-wcorgi',
|
||||
}
|
||||
|
||||
export type ReadonlyCallExecutor = (
|
||||
options: Pick<
|
||||
ReadOnlyFunctionOptions,
|
||||
'functionArgs' | 'functionName' | 'contractName' | 'contractAddress'
|
||||
>
|
||||
) => Promise<ClarityValue>;
|
||||
|
||||
export class AlexSDK {
|
||||
private readonly readonlyCallExecutor: ReadonlyCallExecutor;
|
||||
constructor(options?: { readonlyCallExecutor?: ReadonlyCallExecutor }) {
|
||||
this.readonlyCallExecutor =
|
||||
options?.readonlyCallExecutor ?? defaultReadonlyCallExecutor;
|
||||
}
|
||||
return a + b;
|
||||
};
|
||||
|
||||
readonlyCall: <
|
||||
T extends keyof Contracts,
|
||||
F extends keyof Contracts[T],
|
||||
Descriptor extends Contracts[T][F]
|
||||
>(
|
||||
contractName: T,
|
||||
functionName: F,
|
||||
args: Descriptor extends ReadonlyFunctionDescriptor
|
||||
? ParameterObjOfDescriptor<Descriptor>
|
||||
: never
|
||||
) => Promise<
|
||||
Descriptor extends ReadonlyFunctionDescriptor
|
||||
? ReturnTypeOfDescriptor<Descriptor>
|
||||
: never
|
||||
> = async (contractName, functionName, args) => {
|
||||
const functionDescriptor = AlexContracts[contractName][
|
||||
functionName
|
||||
] as any as ReadonlyFunctionDescriptor;
|
||||
const clarityArgs = functionDescriptor.input.map((arg) =>
|
||||
arg.type.encode(args[arg.name])
|
||||
);
|
||||
const result = await this.readonlyCallExecutor({
|
||||
contractName,
|
||||
functionName: String(functionName),
|
||||
functionArgs: clarityArgs,
|
||||
contractAddress: CONTRACT_DEPLOYER,
|
||||
});
|
||||
return functionDescriptor.output.decode(result);
|
||||
};
|
||||
|
||||
getFee(from: Currency, to: Currency): Promise<bigint> {
|
||||
return getLiquidityProviderFee(this, from, to, AMMSwapPool.ammTokens);
|
||||
}
|
||||
getRouter(from: Currency, to: Currency): Promise<Currency[]> {
|
||||
return getRoute(this, from, to, AMMSwapPool.ammTokens);
|
||||
}
|
||||
getRate(from: Currency, fromAmount: bigint, to: Currency): Promise<bigint> {
|
||||
return getYAmountFromXAmount(
|
||||
this,
|
||||
from,
|
||||
to,
|
||||
fromAmount,
|
||||
AMMSwapPool.ammTokens
|
||||
);
|
||||
}
|
||||
runSwap(
|
||||
stxAddress: string,
|
||||
currencyX: Currency,
|
||||
currencyY: Currency,
|
||||
fromAmount: bigint,
|
||||
minDy: bigint,
|
||||
middleSteps: Currency[],
|
||||
ammPools: AMMSwapPool.PoolTokens[]
|
||||
): TxToBroadCast {
|
||||
return runSpot(
|
||||
stxAddress,
|
||||
currencyX,
|
||||
currencyY,
|
||||
fromAmount,
|
||||
minDy,
|
||||
middleSteps,
|
||||
ammPools
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
103
src/utils/ammPool.ts
Normal file
103
src/utils/ammPool.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
import { Currency } from '../index';
|
||||
import { AMMSwapRoute, resolveAmmRoute } from './ammRouteResolver';
|
||||
import { bridgeHelperResolver } from './bridgeHelperResolver';
|
||||
import { assertNever } from './utils';
|
||||
|
||||
export namespace AMMSwapPool {
|
||||
export enum Pool {
|
||||
// AMM_SWAP_POOL
|
||||
AMM_SWAP_POOL_WXUSD_WUSDA = 'token-amm-swap-pool:token-wxusd,token-wusda,0.0001e8',
|
||||
AMM_SWAP_POOL_WXUSD_WUSDA_2 = 'token-amm-swap-pool:token-wxusd,token-wusda,0.005e8',
|
||||
// not yet available
|
||||
// AMM_SWAP_POOL_WSTX_ALEX = 'token-amm-swap-pool:token-wstx,age000-governance-token,1e8',
|
||||
// AMM_SWAP_POOL_WSTX_XBTC = 'token-amm-swap-pool:token-wstx,token-wbtc,1e8',
|
||||
// AMM_SWAP_POOL_ALEX_WBAN = 'token-amm-swap-pool:age000-governance-token,token-wban,1e8',
|
||||
// AMM_SWAP_POOL_ALEX_WUSDA = 'token-amm-swap-pool:age000-governance-token,token-wusda,1e8',
|
||||
AMM_SWAP_POOL_ALEX_WDIKO = 'token-amm-swap-pool:age000-governance-token,token-wdiko,1e8',
|
||||
AMM_SWAP_POOL_WSTX_WCORGI = 'token-amm-swap-pool:token-wstx,token-wcorgi,1e8',
|
||||
}
|
||||
|
||||
export type SwapTokens = Currency;
|
||||
|
||||
export const getRoute = (
|
||||
tokenX: Currency,
|
||||
tokenY: Currency,
|
||||
ammPools: PoolTokens[]
|
||||
): AMMSwapRoute[] =>
|
||||
resolveAmmRoute(
|
||||
tokenX,
|
||||
tokenY,
|
||||
// AMM_SWAP_POOL_WXUSD_WUSDA is deprecated now, don't use it if we have AMM_SWAP_POOL_WXUSD_WUSDA_2 is available
|
||||
ammPools.includes(Pool.AMM_SWAP_POOL_WXUSD_WUSDA_2)
|
||||
? ammPools.filter((a) => a !== Pool.AMM_SWAP_POOL_WXUSD_WUSDA)
|
||||
: ammPools
|
||||
);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export const reachableInAMM: typeof bridgeHelperResolver = (...args) =>
|
||||
bridgeHelperResolver(...args);
|
||||
|
||||
export const ammTokens = [
|
||||
Pool.AMM_SWAP_POOL_WXUSD_WUSDA,
|
||||
Pool.AMM_SWAP_POOL_WXUSD_WUSDA_2,
|
||||
Pool.AMM_SWAP_POOL_ALEX_WDIKO,
|
||||
Pool.AMM_SWAP_POOL_WSTX_WCORGI,
|
||||
];
|
||||
|
||||
export type PoolTokens = (typeof ammTokens)[number];
|
||||
export const isPoolToken = (token: string): token is PoolTokens =>
|
||||
ammTokens.includes(token as PoolTokens);
|
||||
|
||||
export const fromXY = (
|
||||
x: Currency,
|
||||
y: Currency,
|
||||
factor: number
|
||||
): PoolTokens => {
|
||||
if (x === Currency.XUSD && y === Currency.USDA && factor === 0.0001e8) {
|
||||
return Pool.AMM_SWAP_POOL_WXUSD_WUSDA;
|
||||
}
|
||||
throw new Error(`Invalid AMM token: ${x} ${y}`);
|
||||
};
|
||||
|
||||
export function breakDown(
|
||||
poolToken: AMMSwapPool.PoolTokens
|
||||
): [Currency.STX | Currency.ALEX | Currency.XUSD, AMMSwapPool.SwapTokens] {
|
||||
switch (poolToken) {
|
||||
case Pool.AMM_SWAP_POOL_WXUSD_WUSDA:
|
||||
case Pool.AMM_SWAP_POOL_WXUSD_WUSDA_2:
|
||||
return [Currency.XUSD, Currency.USDA];
|
||||
// case Pool.AMM_SWAP_POOL_WSTX_ALEX:
|
||||
// return [Currency.STX, Currency.ALEX];
|
||||
// case Pool.AMM_SWAP_POOL_WSTX_XBTC:
|
||||
// return [Currency.STX, Currency.XBTC];
|
||||
// case Pool.AMM_SWAP_POOL_ALEX_WBAN:
|
||||
// return [Currency.ALEX, Currency.BANANA];
|
||||
// case Pool.AMM_SWAP_POOL_ALEX_WUSDA:
|
||||
// return [Currency.ALEX, Currency.USDA];
|
||||
case Pool.AMM_SWAP_POOL_ALEX_WDIKO:
|
||||
return [Currency.ALEX, Currency.DIKO];
|
||||
case Pool.AMM_SWAP_POOL_WSTX_WCORGI:
|
||||
return [Currency.STX, Currency.CORGI];
|
||||
default:
|
||||
assertNever(poolToken);
|
||||
}
|
||||
}
|
||||
|
||||
export function getFactor(poolToken: PoolTokens): bigint {
|
||||
switch (poolToken) {
|
||||
case Pool.AMM_SWAP_POOL_WXUSD_WUSDA:
|
||||
return BigInt(0.0001e8);
|
||||
case Pool.AMM_SWAP_POOL_WXUSD_WUSDA_2:
|
||||
return BigInt(0.005e8);
|
||||
// case Pool.AMM_SWAP_POOL_WSTX_ALEX:
|
||||
// case Pool.AMM_SWAP_POOL_WSTX_XBTC:
|
||||
// case Pool.AMM_SWAP_POOL_ALEX_WBAN:
|
||||
// case Pool.AMM_SWAP_POOL_ALEX_WUSDA:
|
||||
case Pool.AMM_SWAP_POOL_ALEX_WDIKO:
|
||||
case Pool.AMM_SWAP_POOL_WSTX_WCORGI:
|
||||
return BigInt(1e8);
|
||||
default:
|
||||
assertNever(poolToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
54
src/utils/ammRouteResolver.ts
Normal file
54
src/utils/ammRouteResolver.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { isNotNull } from './utils';
|
||||
import { AMMSwapPool } from './ammPool';
|
||||
|
||||
export type AMMSwapRoute = {
|
||||
neighbour: AMMSwapPool.SwapTokens;
|
||||
pool: AMMSwapPool.PoolTokens;
|
||||
};
|
||||
|
||||
function neighbours(
|
||||
token: AMMSwapPool.SwapTokens,
|
||||
pools: AMMSwapPool.PoolTokens[]
|
||||
): AMMSwapRoute[] {
|
||||
return pools
|
||||
.map((pool) => {
|
||||
const [x, y] = AMMSwapPool.breakDown(pool);
|
||||
if (x === token) return { neighbour: y, pool };
|
||||
if (y === token) return { neighbour: x, pool };
|
||||
return null;
|
||||
})
|
||||
.filter(isNotNull);
|
||||
}
|
||||
|
||||
export function resolveAmmRoute(
|
||||
tokenX: AMMSwapPool.SwapTokens,
|
||||
tokenY: AMMSwapPool.SwapTokens,
|
||||
pools: AMMSwapPool.PoolTokens[]
|
||||
): AMMSwapRoute[] {
|
||||
if (pools.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const visited: { [key in AMMSwapPool.SwapTokens]?: AMMSwapRoute[] } = {
|
||||
[tokenX]: [],
|
||||
};
|
||||
// contract only support up to 4 segments
|
||||
for (let i = 0; i < 4; i++) {
|
||||
Object.keys(visited)
|
||||
.map((a) => a as AMMSwapPool.SwapTokens)
|
||||
.forEach((a) => {
|
||||
neighbours(a, pools).forEach((b) => {
|
||||
if (
|
||||
b.neighbour === tokenX ||
|
||||
visited[a]?.some((c) => c.neighbour === b.neighbour)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
visited[b.neighbour] = [...(visited[a] ?? []), b];
|
||||
});
|
||||
});
|
||||
if (tokenY in visited) {
|
||||
return visited[tokenY]!;
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
44
src/utils/bridgeHelperResolver.ts
Normal file
44
src/utils/bridgeHelperResolver.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
import { Currency } from '../index';
|
||||
import { AMMSwapPool } from './ammPool';
|
||||
|
||||
export function bridgeHelperResolver(
|
||||
from: Currency,
|
||||
to: Currency,
|
||||
ammPools: AMMSwapPool.PoolTokens[]
|
||||
) {
|
||||
const bridgingToken = [Currency.STX, Currency.ALEX];
|
||||
const fromPool = ammPools.find((a) => {
|
||||
if (!AMMSwapPool.breakDown(a).includes(from)) return false;
|
||||
const [x, y] = AMMSwapPool.breakDown(a);
|
||||
return bridgingToken.includes(x === from ? y : x);
|
||||
});
|
||||
if (fromPool) {
|
||||
const [x, y] = AMMSwapPool.breakDown(fromPool);
|
||||
return {
|
||||
pool: fromPool,
|
||||
type: 'fromAmm' as const,
|
||||
tokenX: from,
|
||||
tokenY: x === from ? y : x,
|
||||
factorX: AMMSwapPool.getFactor(fromPool),
|
||||
tokenZ: to,
|
||||
};
|
||||
}
|
||||
const toPool = ammPools.find((a) => {
|
||||
if (!AMMSwapPool.breakDown(a).includes(to)) return false;
|
||||
const [x, y] = AMMSwapPool.breakDown(a);
|
||||
return bridgingToken.includes(x === to ? y : x);
|
||||
});
|
||||
if (toPool) {
|
||||
const [x, y] = AMMSwapPool.breakDown(toPool);
|
||||
return {
|
||||
pool: toPool,
|
||||
type: 'toAmm' as const,
|
||||
tokenX: from,
|
||||
tokenY: x === to ? y : x,
|
||||
factorY: AMMSwapPool.getFactor(toPool),
|
||||
tokenZ: to,
|
||||
};
|
||||
}
|
||||
return { type: 'none' as const };
|
||||
}
|
||||
66
src/utils/currency.ts
Normal file
66
src/utils/currency.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { Currency } from '../index';
|
||||
|
||||
const tokenNativeAddressDefinition = {
|
||||
'age000-governance-token':
|
||||
'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.age000-governance-token::alex',
|
||||
'token-wxusd':
|
||||
'SP2TZK01NKDC89J6TA56SA47SDF7RTHYEQ79AAB9A.Wrapped-USD::wrapped-usd',
|
||||
'token-wbtc':
|
||||
'SP3DX3H4FEYZJZ586MFBS25ZW3HZDMEW92260R2PR.Wrapped-Bitcoin::wrapped-bitcoin',
|
||||
'token-wdiko': {
|
||||
assetIdentifier:
|
||||
'SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.arkadiko-token::diko',
|
||||
decimals: 1e6,
|
||||
},
|
||||
'token-wusda': {
|
||||
assetIdentifier:
|
||||
'SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.usda-token::usda',
|
||||
decimals: 1e6,
|
||||
},
|
||||
'token-wban': {
|
||||
assetIdentifier:
|
||||
'SP2KAF9RF86PVX3NEE27DFV1CQX0T4WGR41X3S45C.btc-monkeys-bananas::BANANA',
|
||||
decimals: 1e6,
|
||||
},
|
||||
'token-wslm': {
|
||||
assetIdentifier:
|
||||
'SP125J1ADVYWGWB9NQRCVGKYAG73R17ZNMV17XEJ7.slime-token::SLIME',
|
||||
decimals: 1e6,
|
||||
},
|
||||
'token-wmia': {
|
||||
assetIdentifier:
|
||||
'SP1H1733V5MZ3SZ9XRW9FKYGEZT0JDGEB8Y634C7R.miamicoin-token-v2::miamicoin',
|
||||
decimals: 1e6,
|
||||
},
|
||||
'token-wnycc': {
|
||||
assetIdentifier:
|
||||
'SPSCWDV3RKV5ZRN1FQD84YE1NQFEDJ9R1F4DYQ11.newyorkcitycoin-token-v2::newyorkcitycoin',
|
||||
decimals: 1e6,
|
||||
},
|
||||
'token-wcorgi': {
|
||||
decimals: 1e6,
|
||||
assetIdentifier: `SP3NE50GEXFG9SZGTT51P40X2CKYSZ5CC4ZTZ7A2G.welshcorgicoin-token::welshcorgicoin`,
|
||||
},
|
||||
};
|
||||
|
||||
export function getCurrencyNativeScale(currency: Currency) {
|
||||
if (currency === Currency.STX) {
|
||||
return 1e6;
|
||||
}
|
||||
const address = tokenNativeAddressDefinition[currency];
|
||||
if (typeof address === 'string') {
|
||||
return 1e8;
|
||||
}
|
||||
return address.decimals;
|
||||
}
|
||||
|
||||
export function getCurrencyNativeAddress(currency: Currency) {
|
||||
if (currency === Currency.STX) {
|
||||
throw new Error('STX is not a token');
|
||||
}
|
||||
const address = tokenNativeAddressDefinition[currency];
|
||||
if (typeof address === 'string') {
|
||||
return address;
|
||||
}
|
||||
return address.assetIdentifier;
|
||||
}
|
||||
32
src/utils/postConditions.ts
Normal file
32
src/utils/postConditions.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
createFungiblePostCondition,
|
||||
createSTXPostCondition,
|
||||
FungibleConditionCode,
|
||||
FungiblePostCondition,
|
||||
STXPostCondition,
|
||||
} from '@stacks/transactions';
|
||||
import { CONTRACT_DEPLOYER } from '../config';
|
||||
import { Currency } from '../index';
|
||||
import { getCurrencyNativeAddress, getCurrencyNativeScale } from './currency';
|
||||
|
||||
export const AlexVault = `${CONTRACT_DEPLOYER}.alex-vault`;
|
||||
|
||||
export function transfer(
|
||||
senderAddress: string,
|
||||
currency: Currency,
|
||||
amount: bigint,
|
||||
compare: FungibleConditionCode = FungibleConditionCode.Equal
|
||||
): FungiblePostCondition | STXPostCondition {
|
||||
const scale = getCurrencyNativeScale(currency);
|
||||
const nativeAmount = (amount * BigInt(scale)) / BigInt(1e8);
|
||||
if (currency === Currency.STX) {
|
||||
return createSTXPostCondition(senderAddress, compare, nativeAmount);
|
||||
}
|
||||
const assetIdentifier = getCurrencyNativeAddress(currency);
|
||||
return createFungiblePostCondition(
|
||||
senderAddress,
|
||||
compare,
|
||||
nativeAmount,
|
||||
assetIdentifier
|
||||
);
|
||||
}
|
||||
16
src/utils/readonlyCallExecutor.ts
Normal file
16
src/utils/readonlyCallExecutor.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { ReadonlyCallExecutor } from '../index';
|
||||
import { callReadOnlyFunction } from '@stacks/transactions';
|
||||
import { API_HOST, CONTRACT_DEPLOYER } from '../config';
|
||||
import { StacksMainnet } from '@stacks/network';
|
||||
|
||||
export const defaultReadonlyCallExecutor: ReadonlyCallExecutor = async (
|
||||
options
|
||||
) => {
|
||||
return callReadOnlyFunction({
|
||||
...options,
|
||||
senderAddress: CONTRACT_DEPLOYER,
|
||||
network: new StacksMainnet({
|
||||
url: API_HOST,
|
||||
}),
|
||||
});
|
||||
};
|
||||
7
src/utils/utils.ts
Normal file
7
src/utils/utils.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function isNotNull<T>(input: T | undefined | null): input is T {
|
||||
return input != null;
|
||||
}
|
||||
|
||||
export function assertNever(x: never): never {
|
||||
throw new Error('Unexpected object: ' + x);
|
||||
}
|
||||
14
test/alexSDK.test.ts
Normal file
14
test/alexSDK.test.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { AlexSDK, Currency } from '../src';
|
||||
|
||||
describe('AlexSDK', () => {
|
||||
it('Get fee', async () => {
|
||||
const sdk = new AlexSDK();
|
||||
const result = await sdk.getFee(Currency.ALEX, Currency.STX);
|
||||
console.log(result);
|
||||
});
|
||||
it('Get Route', async () => {
|
||||
const sdk = new AlexSDK();
|
||||
const result = await sdk.getRouter(Currency.STX, Currency.DIKO);
|
||||
console.log(result);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
import { sum } from '../src';
|
||||
|
||||
describe('blah', () => {
|
||||
it('works', () => {
|
||||
expect(sum(1, 1)).toEqual(2);
|
||||
});
|
||||
});
|
||||
@@ -17,7 +17,7 @@
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
// noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": true,
|
||||
// use Node's module resolution algorithm, instead of the legacy TS one
|
||||
"moduleResolution": "node",
|
||||
|
||||
204
yarn.lock
204
yarn.lock
@@ -1285,6 +1285,21 @@
|
||||
"@jridgewell/resolve-uri" "3.1.0"
|
||||
"@jridgewell/sourcemap-codec" "1.4.14"
|
||||
|
||||
"@noble/hashes@1.1.5":
|
||||
version "1.1.5"
|
||||
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.5.tgz#1a0377f3b9020efe2fae03290bd2a12140c95c11"
|
||||
integrity sha512-LTMZiiLc+V4v1Yi16TD6aX2gmtKszNye0pQgbaLqkvhIqP7nVsSaJsWloGQjJfJ8offaoP5GtX3yY5swbcJxxQ==
|
||||
|
||||
"@noble/hashes@^1.1.2":
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.2.0.tgz#a3150eeb09cc7ab207ebf6d7b9ad311a9bdbed12"
|
||||
integrity sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ==
|
||||
|
||||
"@noble/secp256k1@1.7.1":
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c"
|
||||
integrity sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==
|
||||
|
||||
"@nodelib/fs.scandir@2.1.5":
|
||||
version "2.1.5"
|
||||
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
|
||||
@@ -1393,6 +1408,39 @@
|
||||
"@size-limit/esbuild" "8.2.4"
|
||||
"@size-limit/file" "8.2.4"
|
||||
|
||||
"@stacks/common@^6.0.0":
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@stacks/common/-/common-6.0.0.tgz#ce80a11ca5d16db8276891db3ecc8e4f2eb1b43a"
|
||||
integrity sha512-tETwccvbYvaZ7u3ZucWNMOIPN97r6IPeZXKIFhLc1KSVaWSGEPTtZcwVp+Rz3mu2XgI2pg37SUrOWXSL7OOkDw==
|
||||
dependencies:
|
||||
"@types/bn.js" "^5.1.0"
|
||||
"@types/node" "^18.0.4"
|
||||
|
||||
"@stacks/network@^6.1.1":
|
||||
version "6.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@stacks/network/-/network-6.1.1.tgz#b6b01a8045375a055bb6e5598f4ff68da2d722a8"
|
||||
integrity sha512-FXOujmszG/NkYKDVDRmPLmfSQJvcSfvucXLOq6SkkTOohxFgQrT7cgAydmEwBWDiEoPsuYPlE0grppcUYIO8rQ==
|
||||
dependencies:
|
||||
"@stacks/common" "^6.0.0"
|
||||
cross-fetch "^3.1.5"
|
||||
|
||||
"@stacks/stacks-blockchain-api-types@^5.0.1":
|
||||
version "5.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@stacks/stacks-blockchain-api-types/-/stacks-blockchain-api-types-5.0.3.tgz#aff730e109b7c514a528b9f3304f9dfc36ad1045"
|
||||
integrity sha512-8vL+bPLTK0Sio3aJyIYITmdkwCCj01C5MqOQisC/GwthQvqf53uceAIsSsSQmVpFwvL5rqG0KGAu4rosW7QUwQ==
|
||||
|
||||
"@stacks/transactions@^6.2.0":
|
||||
version "6.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@stacks/transactions/-/transactions-6.2.0.tgz#cd7a68c32d4f361e358bca4fa6f424680fa84caf"
|
||||
integrity sha512-FUqcCNhCC5VlPvfUeeC6TB0gUifFj06E9xlWKbi2jB+oObh6XNBu4fS6I4EKxF1tEtUX9RNXcVbKDgMlX38syw==
|
||||
dependencies:
|
||||
"@noble/hashes" "1.1.5"
|
||||
"@noble/secp256k1" "1.7.1"
|
||||
"@stacks/common" "^6.0.0"
|
||||
"@stacks/network" "^6.1.1"
|
||||
c32check "^2.0.0"
|
||||
lodash.clonedeep "^4.5.0"
|
||||
|
||||
"@types/babel__core@^7.1.7":
|
||||
version "7.20.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.0.tgz#61bc5a4cae505ce98e1e36c5445e4bee060d8891"
|
||||
@@ -1426,6 +1474,13 @@
|
||||
dependencies:
|
||||
"@babel/types" "^7.3.0"
|
||||
|
||||
"@types/bn.js@^5.1.0":
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.1.tgz#b51e1b55920a4ca26e9285ff79936bbdec910682"
|
||||
integrity sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/eslint-visitor-keys@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
|
||||
@@ -1486,7 +1541,7 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
|
||||
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
|
||||
|
||||
"@types/node@*":
|
||||
"@types/node@*", "@types/node@^18.0.4":
|
||||
version "18.14.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.14.6.tgz#ae1973dd2b1eeb1825695bb11ebfb746d27e3e93"
|
||||
integrity sha512-93+VvleD3mXwlLI/xASjw0FzKcwzl3OdTCzm1LaRfqgS21gfFtK3zDXM5Op9TeeMsJVOaJ2VRDpT9q4Y3d0AvA==
|
||||
@@ -1831,6 +1886,14 @@ axe-core@^4.6.2:
|
||||
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.6.3.tgz#fc0db6fdb65cc7a80ccf85286d91d64ababa3ece"
|
||||
integrity sha512-/BQzOX780JhsxDnPpH4ZiyrJAzcd8AfzFPkv+89veFSr1rcMjuq2JDCwypKaPeB6ljHp9KjXhPpjgCvQlWYuqg==
|
||||
|
||||
axios@^0.27.2:
|
||||
version "0.27.2"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
|
||||
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
|
||||
dependencies:
|
||||
follow-redirects "^1.14.9"
|
||||
form-data "^4.0.0"
|
||||
|
||||
axobject-query@^3.1.1:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-3.1.1.tgz#3b6e5c6d4e43ca7ba51c5babf99d22a9c68485e1"
|
||||
@@ -1969,6 +2032,11 @@ balanced-match@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
|
||||
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
|
||||
|
||||
base-x@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.0.tgz#d0e3b7753450c73f8ad2389b5c018a4af7b2224a"
|
||||
integrity sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==
|
||||
|
||||
base@^0.11.1:
|
||||
version "0.11.2"
|
||||
resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f"
|
||||
@@ -2076,6 +2144,14 @@ bytes-iec@^3.1.1:
|
||||
resolved "https://registry.yarnpkg.com/bytes-iec/-/bytes-iec-3.1.1.tgz#94cd36bf95c2c22a82002c247df8772d1d591083"
|
||||
integrity sha512-fey6+4jDK7TFtFg/klGSvNKJctyU7n2aQdnM+CO0ruLPbqqMOM8Tio0Pc+deqUeVKX1tL5DQep1zQ7+37aTAsA==
|
||||
|
||||
c32check@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/c32check/-/c32check-2.0.0.tgz#b9365618b2fb135c0783d03f00605b7b0f90c659"
|
||||
integrity sha512-rpwfAcS/CMqo0oCqDf3r9eeLgScRE3l/xHDCXhM3UyrfvIn7PrLq63uHh7yYbv8NzaZn5MVsVhIRpQ+5GZ5HyA==
|
||||
dependencies:
|
||||
"@noble/hashes" "^1.1.2"
|
||||
base-x "^4.0.0"
|
||||
|
||||
cache-base@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2"
|
||||
@@ -2181,6 +2257,17 @@ ci-info@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46"
|
||||
integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==
|
||||
|
||||
clarity-codegen@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/clarity-codegen/-/clarity-codegen-0.2.0.tgz#4694f427074de0f995da2c947b7a9fbbe29abae0"
|
||||
integrity sha512-puhmo5pzCAGI8dBjt87jaM4fTuZHMLLxb9Se+lcAS+scfzkHa3NA91dpX+Vgv1bm3iFl/V8m8DvREKLhflXXVw==
|
||||
dependencies:
|
||||
"@stacks/stacks-blockchain-api-types" "^5.0.1"
|
||||
axios "^0.27.2"
|
||||
lodash "^4.17.21"
|
||||
yargs "^17.6.0"
|
||||
yqueue "^1.0.1"
|
||||
|
||||
class-utils@^0.3.5:
|
||||
version "0.3.6"
|
||||
resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463"
|
||||
@@ -2229,6 +2316,15 @@ cliui@^6.0.0:
|
||||
strip-ansi "^6.0.0"
|
||||
wrap-ansi "^6.2.0"
|
||||
|
||||
cliui@^8.0.1:
|
||||
version "8.0.1"
|
||||
resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa"
|
||||
integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==
|
||||
dependencies:
|
||||
string-width "^4.2.0"
|
||||
strip-ansi "^6.0.1"
|
||||
wrap-ansi "^7.0.0"
|
||||
|
||||
clone@^1.0.2:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
|
||||
@@ -2276,7 +2372,7 @@ color-name@~1.1.4:
|
||||
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
|
||||
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
|
||||
|
||||
combined-stream@^1.0.6, combined-stream@~1.0.6:
|
||||
combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6:
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
|
||||
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
|
||||
@@ -2341,6 +2437,13 @@ cosmiconfig@^6.0.0:
|
||||
path-type "^4.0.0"
|
||||
yaml "^1.7.2"
|
||||
|
||||
cross-fetch@^3.1.5:
|
||||
version "3.1.5"
|
||||
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f"
|
||||
integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==
|
||||
dependencies:
|
||||
node-fetch "2.6.7"
|
||||
|
||||
cross-spawn@^6.0.0, cross-spawn@^6.0.5:
|
||||
version "6.0.5"
|
||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
|
||||
@@ -2909,6 +3012,11 @@ eslint@^6.1.0:
|
||||
text-table "^0.2.0"
|
||||
v8-compile-cache "^2.0.3"
|
||||
|
||||
esm@^3.2.25:
|
||||
version "3.2.25"
|
||||
resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10"
|
||||
integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==
|
||||
|
||||
espree@^6.1.2:
|
||||
version "6.2.1"
|
||||
resolved "https://registry.yarnpkg.com/espree/-/espree-6.2.1.tgz#77fc72e1fd744a2052c20f38a5b575832e82734a"
|
||||
@@ -3201,6 +3309,11 @@ flatted@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
|
||||
integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==
|
||||
|
||||
follow-redirects@^1.14.9:
|
||||
version "1.15.2"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
|
||||
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
|
||||
|
||||
for-each@^0.3.3:
|
||||
version "0.3.3"
|
||||
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"
|
||||
@@ -3218,6 +3331,15 @@ forever-agent@~0.6.1:
|
||||
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
|
||||
integrity sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==
|
||||
|
||||
form-data@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
|
||||
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
|
||||
dependencies:
|
||||
asynckit "^0.4.0"
|
||||
combined-stream "^1.0.8"
|
||||
mime-types "^2.1.12"
|
||||
|
||||
form-data@~2.3.2:
|
||||
version "2.3.3"
|
||||
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6"
|
||||
@@ -3293,7 +3415,7 @@ gensync@^1.0.0-beta.2:
|
||||
resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0"
|
||||
integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==
|
||||
|
||||
get-caller-file@^2.0.1:
|
||||
get-caller-file@^2.0.1, get-caller-file@^2.0.5:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
|
||||
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
|
||||
@@ -4634,6 +4756,11 @@ locate-path@^5.0.0:
|
||||
dependencies:
|
||||
p-locate "^4.1.0"
|
||||
|
||||
lodash.clonedeep@^4.5.0:
|
||||
version "4.5.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
|
||||
integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==
|
||||
|
||||
lodash.debounce@^4.0.8:
|
||||
version "4.0.8"
|
||||
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
|
||||
@@ -4654,7 +4781,7 @@ lodash.sortby@^4.7.0:
|
||||
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
|
||||
integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==
|
||||
|
||||
lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19:
|
||||
lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21:
|
||||
version "4.17.21"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||
@@ -4906,6 +5033,13 @@ no-case@^3.0.4:
|
||||
lower-case "^2.0.2"
|
||||
tslib "^2.0.3"
|
||||
|
||||
node-fetch@2.6.7:
|
||||
version "2.6.7"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
|
||||
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
|
||||
dependencies:
|
||||
whatwg-url "^5.0.0"
|
||||
|
||||
node-int64@^0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
|
||||
@@ -5269,6 +5403,11 @@ prettier@^1.19.1:
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
|
||||
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
|
||||
|
||||
prettier@^2.8.4:
|
||||
version "2.8.4"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.4.tgz#34dd2595629bfbb79d344ac4a91ff948694463c3"
|
||||
integrity sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==
|
||||
|
||||
pretty-format@^25.2.1, pretty-format@^25.5.0:
|
||||
version "25.5.0"
|
||||
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-25.5.0.tgz#7873c1d774f682c34b8d48b6743a2bf2ac55791a"
|
||||
@@ -6052,7 +6191,7 @@ string-width@^3.0.0:
|
||||
is-fullwidth-code-point "^2.0.0"
|
||||
strip-ansi "^5.1.0"
|
||||
|
||||
string-width@^4.1.0, string-width@^4.2.0:
|
||||
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
@@ -6310,6 +6449,11 @@ tr46@^1.0.1:
|
||||
dependencies:
|
||||
punycode "^2.1.0"
|
||||
|
||||
tr46@~0.0.3:
|
||||
version "0.0.3"
|
||||
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
|
||||
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==
|
||||
|
||||
ts-jest@^25.3.1:
|
||||
version "25.5.1"
|
||||
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-25.5.1.tgz#2913afd08f28385d54f2f4e828be4d261f4337c7"
|
||||
@@ -6637,6 +6781,11 @@ wcwidth@^1.0.1:
|
||||
dependencies:
|
||||
defaults "^1.0.3"
|
||||
|
||||
webidl-conversions@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
|
||||
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==
|
||||
|
||||
webidl-conversions@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
|
||||
@@ -6654,6 +6803,14 @@ whatwg-mimetype@^2.2.0, whatwg-mimetype@^2.3.0:
|
||||
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf"
|
||||
integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==
|
||||
|
||||
whatwg-url@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
|
||||
integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==
|
||||
dependencies:
|
||||
tr46 "~0.0.3"
|
||||
webidl-conversions "^3.0.0"
|
||||
|
||||
whatwg-url@^7.0.0:
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-7.1.0.tgz#c2c492f1eca612988efd3d2266be1b9fc6170d06"
|
||||
@@ -6737,6 +6894,15 @@ wrap-ansi@^6.2.0:
|
||||
string-width "^4.1.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
wrap-ansi@^7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
||||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
||||
dependencies:
|
||||
ansi-styles "^4.0.0"
|
||||
string-width "^4.1.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
wrappy@1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
||||
@@ -6779,6 +6945,11 @@ y18n@^4.0.0:
|
||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf"
|
||||
integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==
|
||||
|
||||
y18n@^5.0.5:
|
||||
version "5.0.8"
|
||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
|
||||
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==
|
||||
|
||||
yallist@^3.0.2:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"
|
||||
@@ -6802,6 +6973,11 @@ yargs-parser@18.x, yargs-parser@^18.1.2:
|
||||
camelcase "^5.0.0"
|
||||
decamelize "^1.2.0"
|
||||
|
||||
yargs-parser@^21.1.1:
|
||||
version "21.1.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
|
||||
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==
|
||||
|
||||
yargs@^15.3.1:
|
||||
version "15.4.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
|
||||
@@ -6818,3 +6994,21 @@ yargs@^15.3.1:
|
||||
which-module "^2.0.0"
|
||||
y18n "^4.0.0"
|
||||
yargs-parser "^18.1.2"
|
||||
|
||||
yargs@^17.6.0:
|
||||
version "17.7.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.1.tgz#34a77645201d1a8fc5213ace787c220eabbd0967"
|
||||
integrity sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==
|
||||
dependencies:
|
||||
cliui "^8.0.1"
|
||||
escalade "^3.1.1"
|
||||
get-caller-file "^2.0.5"
|
||||
require-directory "^2.1.1"
|
||||
string-width "^4.2.3"
|
||||
y18n "^5.0.5"
|
||||
yargs-parser "^21.1.1"
|
||||
|
||||
yqueue@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/yqueue/-/yqueue-1.0.1.tgz#3b4f17344f2481350577f0fd29146556439f542b"
|
||||
integrity sha512-DBxJZBRafFLA/tCc5uO8ZTGFr+sQgn1FRJkZ4cVrIQIk6bv2bInraE3mbpLAJw9z93JGrLkqDoyTLrrZaCNq5w==
|
||||
|
||||
Reference in New Issue
Block a user