Aftermath 文档
  • Aftermath
    • 关于 Aftermath Finance
      • 我们在构造什么?
  • 开始使用
    • 创建一个账户
      • zkLogin
        • 删除 zkLogin 账户
      • Sui Metamask Snap
      • Native Sui wallets
    • 动态气体
    • Aftermath导航
      • 与您的钱包互动
      • 查看您的投资组合
      • 更改您的设置
      • 桥
      • 推荐
  • 交易
    • 智能订单路由器
    • 进行交易
    • 费用
  • 池子
    • 恒定函数做市商
    • 教程
      • 存款
      • 撤出
      • 创建一个池
    • 费用
    • 合约
    • 审计报告
  • 农场
    • Afterburner保险库
    • 教程
      • 将资产抵押到农场
      • 索赔奖励
      • 解除质押
    • 架构
      • 保险库
      • 质押头寸
    • 费用
    • 常见问题
  • 流动质押
    • afSUI
    • 教程
      • 质押
      • 解除质押
    • 架构
      • 包和模块
      • 进入点
    • 费用
    • 常见问题
    • 合约
    • 审计报告
  • 我们的验证器
    • 关于我们
  • 开发人员
    • 入门
    • 路由器
    • 流动性质押
    • 池
  • Egg
    • 关于Egg
  • 官方链接
    • 推特
    • Discord
    • Github
    • Medium
    • Aftermath 的验证器
Powered by GitBook
On this page
  • 池子
  • 事件
  • Deposit
  • Withdraw
  • 交易
  • Deposit
  • Withdraw
  • 计算
  • Spot Price
  • Trade Amount Out
  • Trade Amount In
  • Deposit LP Amount Out
  • Withdraw Amounts Out
  1. 开发人员

池

稳定和不相关资产的可变权重 AMM 池,每个池最多 8 项资产。

const pools = new Aftermath("TESTNET").Pools();

池子

// single pool
const pool = await pools.getPool({
	objectId: "0x..",
});

// multiple pools
const somePools = await pools.getPools({
	objectIds: ["0x1..", "0x2.."],
});

// all pools
const allPools = await pools.getAllPools();

事件

Deposit

const eventData = await pool.getDepositEvents({
	// optional
	cursor: {
		txDigest: "0x..",
		eventSeq: "0x..",
	},
	limit: 10,
});

console.log(eventData);
/*
{
	events: [
		{
			poolId: "0x..",
			depositor: "0x.."
			types: ["0x1..", "0x2..", "0x3.."],
			deposits: [1_000n, 1_000_000n, 500n],
			lpMinted: 34_000_000n,
		},
		...
	],
	nextCursor: {...},
}
*/

Withdraw

const eventData = await pool.getWithdrawEvents({
	// optional
	cursor: {
		txDigest: "0x..",
		eventSeq: "0x..",
	},
	limit: 10,
});

console.log(eventData);
/*
{
	events: [
		{
			poolId: "0x..",
			withdrawer: "0x.."
			types: ["0x1..", "0x2..", "0x3.."],
			withdrawn: [1_000n, 1_000_000n, 500n],
			lpBurned: 34_000_000n,
		},
		...
	],
	nextCursor: {...},
}
*/

交易

Deposit

const tx = await pool.getDepositTransaction({
	walletAddress: "0x..",
	amountsIn: {
		"0x1..": 1_000_000_000n,
		"0x2..": 50_000_000n,
		"0x3..": 700_000n,
	},
	slippage: 0.01,	// 1% max slippage
	
	// optional
	referrer: "0x..",
});

Withdraw

const tx = await pool.getWithdrawTransaction({
	walletAddress: "0x..",
	// Amounts out approximation for coins wanting to withdraw
	amountsOutDirection: {
		"0x1..": 1_000_000_000n,
		"0x3..": 700_000n,
		"0x5..": 5_000_000n,
	},
	lpCoinAmount: 1_000_000_000n, // LP coin amount being sent
	slippage: 0.01,	// 1% max slippage
	
	// optional
	referrer: "0x..",
});

计算

Spot Price

const spotPrice = pool.getSpotPrice({
	coinInType: "0x1...",
	coinOutType: "0x2...",
	
	// optional
	withFees: true,
});

console.log(spotPrice); // in/out
// 1.22312342123412

Trade Amount Out

const amountOut = pool.getTradeAmountOut({
	coinInType: "0x1...",
	coinOutType: "0x2...",
	coinInAmount: 1_000_000n,
	
	// optional
	referral: true, // apply referral discount to calculation
});

console.log(amountOut);
// 1_200_000n

Trade Amount In

const amountIn = pool.getTradeAmountIn({
	coinInType: "0x1...",
	coinOutType: "0x2...",
	coinOutAmount: 1_200_000n,
	
	// optional
	referral: true, // apply referral discount to calculation
});

console.log(amountIn);
// 1_000_000n

Deposit LP Amount Out

const depositResult = pool.getDepositLpAmountOut({
	amountsIn: {
		"0x1..": 1_000_000_000n,
		"0x2..": 50_000_000n,
		"0x3..": 700_000n,
	},
	
	// optional
	referral: true, // apply referral discount to calculation
});

console.log(depositResult);
/*
{
	lpAmountOut: 6_500_000_000n, // 6.5 (9 decimals)
	lpRatio: 1.01342132, // LP ratio after deposit
}
*/

Withdraw Amounts Out

const amountsOut = pool.getWithdrawAmountsOut({
	lpRatio: 0.98988789, // LP ratio after withdraw
	// Amounts out approximation for coins wanting to withdraw
	amountsOutDirection: {
		"0x1..": 1_000_000_000n,
		"0x3..": 700_000n,
		"0x5..": 5_000_000n,
	},
	
	// optional
	referral: true, // apply referral discount to calculation
});

console.log(amountsOut);
/*
{
	"0x1..": 1_130_000_000n,
	"0x3..": 710_000n,
	"0x5..": 5_400_000n,
}
*/
Previous流动性质押Next关于Egg

Last updated 1 year ago