Add Liquidity

Package:

  • v1.0.0

  • v1.1.0

  • v1.1.1

CALL_METHOD
	Address("${account_address}")
		"withdraw"
		Address("${token1_resource_adddress}")
		Decimal("${token1_amount}");
TAKE_FROM_WORKTOP
	Address("${token1_resource_adddress}")
	Decimal("${token1_amount}")
	Bucket("bucket1");

CALL_METHOD
	Address("${account_address}")
		"withdraw"
		Address("${token2_resource_adddress}")
		Decimal("${token2_amount}");
		
TAKE_FROM_WORKTOP
	Address("${token2_resource_adddress}")
	Decimal("${token2_amount}")
	Bucket("bucket2");

# If adding to current liquidity position
# CALL_METHOD Address("${account_address}") "create_proof_of_non_fungibles" Address("${lp_badge_address}") Array<NonFungibleLocalId>(NonFungibleLocalId("${lp_badge_id}"));
# POP_FROM_AUTH_ZONE Proof("lp_badge_proof");

# If adding to private pool
# CALL_METHOD Address("${account_address}") "create_proof_of_non_fungibles" Address("${pool_member_badge_address}") Array<NonFungibleLocalId>(NonFungibleLocalId("${pool_member_badge_id}"));
	
CALL_METHOD
	Address("${component}")
		"add_liquidity"
	        Tuple
	        (
			Array<Bucket>
			(
				Bucket("bucket1"),
				Bucket("bucket2")
			),
			None			# None if creating new position, Some(Proof("lp_badge_proof")) if adding to existing liquidity position
		);

CALL_METHOD
	Address("${account_address}")
		"try_deposit_batch_or_refund"
		Expression("ENTIRE_WORKTOP")
		Enum<0u8>();


Package:

  • v2.0.0

CALL_METHOD
	Address("${account_address}")
		"withdraw"
		Address("${token1_resource_adddress}")
		Decimal("${token1_amount}");
TAKE_FROM_WORKTOP
	Address("${token1_resource_adddress}")
	Decimal("${token1_amount}")
	Bucket("bucket1");

CALL_METHOD
	Address("${account_address}")
		"withdraw"
		Address("${token2_resource_adddress}")
		Decimal("${token2_amount}");
		
TAKE_FROM_WORKTOP
	Address("${token2_resource_adddress}")
	Decimal("${token2_amount}")
	Bucket("bucket2");

# If adding to current liquidity position
# CALL_METHOD Address("${account_address}") "create_proof_of_non_fungibles" Address("${lp_badge_address}") Array<NonFungibleLocalId>(NonFungibleLocalId("${lp_badge_id}"));
# POP_FROM_AUTH_ZONE Proof("lp_badge_proof");

# If adding to private pool
# CALL_METHOD Address("${account_address}") "create_proof_of_non_fungibles" Address("${pool_member_badge_address}") Array<NonFungibleLocalId>(NonFungibleLocalId("${pool_member_badge_id}"));
	
CALL_METHOD
	Address("${component}")
		"add_liquidity"
	        Tuple
	        (
			Array<Tuple>
			(
				Tuple(Bucket("bucket1"), None),
				Tuple(Bucket("bucket2"), None)
			),
			None			# None if creating new position, Some(Proof("lp_badge_proof")) if adding to existing liquidity position
		);

CALL_METHOD
	Address("${account_address}")
		"try_deposit_batch_or_refund"
		Expression("ENTIRE_WORKTOP")
		Enum<0u8>();

Last updated