mirror of
https://github.com/alexgo-io/alex-sdk.git
synced 2026-01-12 14:25:02 +08:00
feat: migrate to swap-helper-bridged-v1-1
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
"lint": "tsdx lint",
|
||||
"prepare": "tsdx build",
|
||||
"size": "size-limit",
|
||||
"gen:contract": "node -r esm ./scripts/gen-contract.ts",
|
||||
"gen:contract": "rm -rf src/generated/smartContract/*.ts && node -r esm ./scripts/gen-contract.ts",
|
||||
"analyze": "size-limit --why"
|
||||
},
|
||||
"husky": {
|
||||
|
||||
@@ -11,7 +11,7 @@ const contracts = [
|
||||
"amm-swap-pool-v1-1",
|
||||
"token-amm-swap-pool",
|
||||
|
||||
"swap-helper-bridged",
|
||||
"swap-helper-bridged-v1-1",
|
||||
]
|
||||
|
||||
;(async function main() {
|
||||
|
||||
@@ -8,8 +8,8 @@ responseSimpleT,
|
||||
listT
|
||||
} from "../smartContractHelpers/codegenImport"
|
||||
|
||||
export const swapHelperBridged = defineContract({
|
||||
"swap-helper-bridged": {
|
||||
export const swapHelperBridgedV11 = defineContract({
|
||||
"swap-helper-bridged-v1-1": {
|
||||
'swap-helper-from-amm': {
|
||||
input: [
|
||||
{ name: 'token-x-trait', type: principalT },
|
||||
@@ -4,7 +4,7 @@ import { swapHelperV103 } from "./contract_swap-helper-v1-03"
|
||||
import { ammSwapPool } from "./contract_amm-swap-pool"
|
||||
import { ammSwapPoolV11 } from "./contract_amm-swap-pool-v1-1"
|
||||
import { tokenAmmSwapPool } from "./contract_token-amm-swap-pool"
|
||||
import { swapHelperBridged } from "./contract_swap-helper-bridged"
|
||||
import { swapHelperBridgedV11 } from "./contract_swap-helper-bridged-v1-1"
|
||||
|
||||
export const AlexContracts = defineContract({
|
||||
...swapHelperV102,
|
||||
@@ -12,7 +12,7 @@ export const AlexContracts = defineContract({
|
||||
...ammSwapPool,
|
||||
...ammSwapPoolV11,
|
||||
...tokenAmmSwapPool,
|
||||
...swapHelperBridged
|
||||
...swapHelperBridgedV11
|
||||
});
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ export async function getLiquidityProviderFee(
|
||||
if (ammRoute.length === 0) {
|
||||
const reachableInAmm = AMMSwapPool.reachableInAMM(tokenX, tokenY, ammPools);
|
||||
if (reachableInAmm.type === 'fromAmm') {
|
||||
return await readonlyCall('swap-helper-bridged', 'fee-helper-from-amm', {
|
||||
return await readonlyCall('swap-helper-bridged-v1-1', 'fee-helper-from-amm', {
|
||||
'token-x': reachableInAmm.tokenX,
|
||||
'token-y': reachableInAmm.tokenY,
|
||||
'token-z': reachableInAmm.tokenZ,
|
||||
@@ -64,7 +64,7 @@ export async function getLiquidityProviderFee(
|
||||
}).then(unwrapResponse);
|
||||
}
|
||||
if (reachableInAmm.type === 'toAmm') {
|
||||
return await readonlyCall('swap-helper-bridged', 'fee-helper-to-amm', {
|
||||
return await readonlyCall('swap-helper-bridged-v1-1', 'fee-helper-to-amm', {
|
||||
'token-x': reachableInAmm.tokenX,
|
||||
'token-y': reachableInAmm.tokenY,
|
||||
'token-z': reachableInAmm.tokenZ,
|
||||
|
||||
@@ -60,7 +60,7 @@ export const getYAmountFromXAmount = async (
|
||||
if (ammRoute.length === 0) {
|
||||
const reachableInAMM = AMMSwapPool.reachableInAMM(tokenX, tokenY, ammPools);
|
||||
if (reachableInAMM.type === 'fromAmm') {
|
||||
return await readonlyCall('swap-helper-bridged', 'get-helper-from-amm', {
|
||||
return await readonlyCall('swap-helper-bridged-v1-1', 'get-helper-from-amm', {
|
||||
dx: fromAmount,
|
||||
'token-x': reachableInAMM.tokenX,
|
||||
'token-y': reachableInAMM.tokenY,
|
||||
@@ -69,7 +69,7 @@ export const getYAmountFromXAmount = async (
|
||||
}).then(unwrapResponse);
|
||||
}
|
||||
if (reachableInAMM.type === 'toAmm') {
|
||||
return await readonlyCall('swap-helper-bridged', 'get-helper-to-amm', {
|
||||
return await readonlyCall('swap-helper-bridged-v1-1', 'get-helper-to-amm', {
|
||||
dx: fromAmount,
|
||||
'token-x': reachableInAMM.tokenX,
|
||||
'token-y': reachableInAMM.tokenY,
|
||||
|
||||
@@ -21,7 +21,7 @@ export async function getRoute(
|
||||
const reachableInAmm = AMMSwapPool.reachableInAMM(from, to, ammPools);
|
||||
if (reachableInAmm.type === 'fromAmm') {
|
||||
const result = await readonlyCall(
|
||||
'swap-helper-bridged',
|
||||
'swap-helper-bridged-v1-1',
|
||||
'route-helper-from-amm',
|
||||
{
|
||||
'token-x': reachableInAmm.tokenX,
|
||||
@@ -34,7 +34,7 @@ export async function getRoute(
|
||||
}
|
||||
if (reachableInAmm.type === 'toAmm') {
|
||||
const result = await readonlyCall(
|
||||
'swap-helper-bridged',
|
||||
'swap-helper-bridged-v1-1',
|
||||
'route-helper-to-amm',
|
||||
{
|
||||
'token-x': reachableInAmm.tokenX,
|
||||
|
||||
@@ -248,7 +248,7 @@ export function runSpot(
|
||||
);
|
||||
if (reachableInAMM.type === 'fromAmm') {
|
||||
return composeTx(
|
||||
'swap-helper-bridged',
|
||||
'swap-helper-bridged-v1-1',
|
||||
'swap-helper-from-amm',
|
||||
{
|
||||
'token-x-trait': reachableInAMM.tokenX,
|
||||
@@ -285,7 +285,7 @@ export function runSpot(
|
||||
}
|
||||
if (reachableInAMM.type === 'toAmm') {
|
||||
return composeTx(
|
||||
'swap-helper-bridged',
|
||||
'swap-helper-bridged-v1-1',
|
||||
'swap-helper-to-amm',
|
||||
{
|
||||
'token-x-trait': reachableInAMM.tokenX,
|
||||
|
||||
Reference in New Issue
Block a user