Aftermath 문서조사
  • Aftermath
    • Aftermath Finance 대해
      • 우리는 무엇을 구축하고 있나요?
  • 시작
    • 계정 만들기
      • zkLogin
        • zkLogin 계정 제거하기
      • Sui Metamask Snap
      • Native Sui wallets
    • Dynamic Gas
    • Aftermath 탐색하기
      • 지갑 상호작용하기
      • 포트폴리오 보기
      • 설정 변경하기
      • 브리지
      • 추천
  • Trade
    • 스마트 오더 라우터
    • 거래하기
    • 수수료
  • Pools
    • 상수 함수 시장 메이커
    • 자습서
      • 예치하기
      • 출금하기
      • 풀 생성하기
    • 수수료
    • Contracts
    • Audit
  • Farms
    • Afterburner Vaults
    • 자습서
      • 농장에 스테이킹하기
      • Claiming Rewards
      • Unstaking
    • 아키텍처
      • 볼트
      • 스테이크 포지션 패키지
    • 수수료
    • FAQs
  • Liquid Staking
    • afSUI
    • 자습서
      • 스테이킹
      • 스테이킹 해제하기
    • Architecture
      • Packages & Modules
      • 진입점
    • 수수료
    • FAQs
    • Contracts
    • Audit
  • Our validator
    • About us
  • Developers
    • Getting Started
    • Router
    • Liquid Staking
    • Pools
  • Egg
    • About Egg
  • Links
    • Twitter
    • Discord
    • Github
    • Medium
    • Aftermath Validator
Powered by GitBook
On this page
  • Pools
  • Events
  • Deposit
  • Withdraw
  • Transactions
  • Deposit
  • Withdraw
  • Calculations
  • Spot Price
  • Trade Amount Out
  • Trade Amount In
  • Deposit LP Amount Out
  • Withdraw Amounts Out
  1. Developers

Pools

AMM pools for both stable and uncorrelated assets of variable weights with up to 8 assets per pool.

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

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();

Events

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: {...},
}
*/

Transactions

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..",
});

Calculations

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,
}
*/
PreviousLiquid StakingNextAbout Egg