Skip to content

Commit

Permalink
chore: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cjkoepke committed Jun 10, 2024
1 parent f818940 commit a13c33e
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 133 deletions.
40 changes: 35 additions & 5 deletions docs/typescript/core/classes/Lucid.TxBuilderLucidV1.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ TxBuilder.cancel

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts:444](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts#L444)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts:454](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts#L454)

___

Expand Down Expand Up @@ -244,7 +244,7 @@ const migrationResult = await sdk.builder().migrateLiquidityToV3([

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts:907](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts#L907)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts:917](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts#L917)

___

Expand Down Expand Up @@ -274,6 +274,36 @@ Returns a new Tx instance from Lucid. Throws an error if not ready.

___

### orderRouteSwap

**orderRouteSwap**(`args`): `Promise`\<[`IComposedTx`](../interfaces/Core.IComposedTx.md)\<`Tx`, `TxComplete`, `undefined` \| `string`, `Record`\<`string`, `AssetAmount`\<`IAssetAmountMetadata`\>\>\>\>

Performs an order route swap with the given arguments.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `args` | [`IOrderRouteSwapArgs`](../interfaces/Core.IOrderRouteSwapArgs.md) | The arguments for the order route swap. |

#### Returns

`Promise`\<[`IComposedTx`](../interfaces/Core.IComposedTx.md)\<`Tx`, `TxComplete`, `undefined` \| `string`, `Record`\<`string`, `AssetAmount`\<`IAssetAmountMetadata`\>\>\>\>

The result of the transaction.

**`Async`**

#### Overrides

TxBuilder.orderRouteSwap

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts:307](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts#L307)

___

### swap

**swap**(`swapArgs`): `Promise`\<[`IComposedTx`](../interfaces/Core.IComposedTx.md)\<`Tx`, `TxComplete`, `undefined` \| `string`, `Record`\<`string`, `AssetAmount`\<`IAssetAmountMetadata`\>\>\>\>
Expand Down Expand Up @@ -363,7 +393,7 @@ TxBuilder.update

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts:547](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts#L547)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts:557](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts#L557)

___

Expand Down Expand Up @@ -405,7 +435,7 @@ TxBuilder.withdraw

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts:687](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts#L687)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts:697](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts#L697)

___

Expand Down Expand Up @@ -447,7 +477,7 @@ TxBuilder.zap

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts:739](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts#L739)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts:749](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts#L749)

___

Expand Down
44 changes: 37 additions & 7 deletions docs/typescript/core/classes/Lucid.TxBuilderLucidV3.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ TxBuilder.cancel

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:826](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L826)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:720](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L720)

___

Expand Down Expand Up @@ -126,7 +126,7 @@ TxBuilder.deposit

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:994](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L994)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:888](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L888)

___

Expand All @@ -151,7 +151,7 @@ The generated Bech32 address.

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:1225](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L1225)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:1119](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L1119)

___

Expand Down Expand Up @@ -273,7 +273,7 @@ Throws an error if the retrieval of UTXOs fails or if no UTXOs are available.

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:1268](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L1268)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:1162](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L1162)

___

Expand Down Expand Up @@ -358,6 +358,36 @@ fee payment if a [ITxBuilderReferralFee](../interfaces/Core.ITxBuilderReferralFe

___

### orderRouteSwap

**orderRouteSwap**(`args`): `Promise`\<[`IComposedTx`](../interfaces/Core.IComposedTx.md)\<`Tx`, `TxComplete`, `undefined` \| `string`, `Record`\<`string`, `AssetAmount`\<`IAssetAmountMetadata`\>\>\>\>

Performs an order route swap with the given arguments.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `args` | [`IOrderRouteSwapArgs`](../interfaces/Core.IOrderRouteSwapArgs.md) | The arguments for the order route swap. |

#### Returns

`Promise`\<[`IComposedTx`](../interfaces/Core.IComposedTx.md)\<`Tx`, `TxComplete`, `undefined` \| `string`, `Record`\<`string`, `AssetAmount`\<`IAssetAmountMetadata`\>\>\>\>

The result of the transaction.

**`Async`**

#### Overrides

TxBuilder.orderRouteSwap

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:579](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L579)

___

### swap

**swap**(`swapArgs`): `Promise`\<[`IComposedTx`](../interfaces/Core.IComposedTx.md)\<`Tx`, `TxComplete`, `undefined` \| `string`, `Record`\<`string`, `AssetAmount`\<`IAssetAmountMetadata`\>\>\>\>
Expand Down Expand Up @@ -416,7 +446,7 @@ TxBuilder.update

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:908](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L908)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:802](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L802)

___

Expand Down Expand Up @@ -446,7 +476,7 @@ TxBuilder.withdraw

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:1042](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L1042)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:936](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L936)

___

Expand Down Expand Up @@ -476,4 +506,4 @@ TxBuilder.zap

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:1087](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L1087)
[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:981](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L981)
6 changes: 6 additions & 0 deletions docs/typescript/core/interfaces/Core.IOrderRouteSwapArgs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Interface: IOrderRouteSwapArgs

[Core](../modules/Core.md).IOrderRouteSwapArgs

Special arguments for an Order-Route Swap. A combination of
two swap arguments, but simplified for ease-of-use.
1 change: 1 addition & 0 deletions docs/typescript/core/modules/Core.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- [IMigrateYieldFarmingLiquidityConfig](../interfaces/Core.IMigrateYieldFarmingLiquidityConfig.md)
- [IMintV3PoolConfigArgs](../interfaces/Core.IMintV3PoolConfigArgs.md)
- [IOrderConfigArgs](../interfaces/Core.IOrderConfigArgs.md)
- [IOrderRouteSwapArgs](../interfaces/Core.IOrderRouteSwapArgs.md)
- [IPoolByIdentQuery](../interfaces/Core.IPoolByIdentQuery.md)
- [IPoolByPairQuery](../interfaces/Core.IPoolByPairQuery.md)
- [IPoolData](../interfaces/Core.IPoolData.md)
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/@types/txbuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export enum EContractVersion {
V3 = "V3",
}

/**
* Special arguments for an Order-Route Swap. A combination of
* two swap arguments, but simplified for ease-of-use.
*/
export interface IOrderRouteSwapArgs {
ownerAddress: string;
swapA: Omit<ISwapConfigArgs, "orderAddresses" | "ownerAddress">;
Expand Down
20 changes: 15 additions & 5 deletions packages/core/src/TxBuilders/TxBuilder.Lucid.V1.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export class TxBuilderLucidV1 extends TxBuilder {
* and completes the transaction by paying to the contract and finalizing the transaction details.
*
* @param {ISwapConfigArgs} swapArgs - The configuration arguments for the swap.
* @returns {Promise<TransactionResult>} A promise that resolves to the result of the completed transaction.
* @returns {Promise<IComposedTx<Tx, TxComplete>>} A promise that resolves to the result of the completed transaction.
*
* @async
* @example
Expand All @@ -231,7 +231,7 @@ export class TxBuilderLucidV1 extends TxBuilder {
* .then(({ submit }) => submit())
* ```
*/
async swap(swapArgs: ISwapConfigArgs) {
async swap(swapArgs: ISwapConfigArgs): Promise<IComposedTx<Tx, TxComplete>> {
const config = new SwapConfig(swapArgs);

const {
Expand Down Expand Up @@ -296,7 +296,17 @@ export class TxBuilderLucidV1 extends TxBuilder {
});
}

async orderRouteSwap(args: IOrderRouteSwapArgs) {
/**
* Performs an order route swap with the given arguments.
*
* @async
* @param {IOrderRouteSwapArgs} args - The arguments for the order route swap.
*
* @returns {Promise<IComposedTx<Tx, TxComplete>>} The result of the transaction.
*/
async orderRouteSwap(
args: IOrderRouteSwapArgs
): Promise<IComposedTx<Tx, TxComplete>> {
const isSecondSwapV3 = args.swapB.pool.version === EContractVersion.V3;

const secondSwapBuilder = isSecondSwapV3
Expand Down Expand Up @@ -429,7 +439,7 @@ export class TxBuilderLucidV1 extends TxBuilder {
* sets up the transaction, and completes it.
*
* @param {ICancelConfigArgs} cancelArgs - The configuration arguments for the cancel transaction.
* @returns {Promise<TransactionResult>} A promise that resolves to the result of the cancel transaction.
* @returns {Promise<IComposedTx<Tx, TxComplete>>} A promise that resolves to the result of the cancel transaction.
*
* @async
* @example
Expand Down Expand Up @@ -526,7 +536,7 @@ export class TxBuilderLucidV1 extends TxBuilder {
*
* @param {{ cancelArgs: ICancelConfigArgs, swapArgs: ISwapConfigArgs }}
* The arguments for cancel and swap configurations.
* @returns {Promise<TransactionResult>} A promise that resolves to the result of the updated transaction.
* @returns {Promise<IComposedTx<Tx, TxComplete>>} A promise that resolves to the result of the updated transaction.
*
* @throws
* @async
Expand Down
126 changes: 10 additions & 116 deletions packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,16 @@ export class TxBuilderLucidV3 extends TxBuilder {
});
}

async orderRouteSwap(args: IOrderRouteSwapArgs) {
/**
* Performs an order route swap with the given arguments.
*
* @async
* @param {IOrderRouteSwapArgs} args - The arguments for the order route swap.
* @returns {Promise<IComposedTx<Tx, TxComplete>>} The result of the transaction.
*/
async orderRouteSwap(
args: IOrderRouteSwapArgs
): Promise<IComposedTx<Tx, TxComplete>> {
const isSecondSwapV1 = args.swapB.pool.version === EContractVersion.V1;

const secondSwapBuilder = isSecondSwapV1
Expand Down Expand Up @@ -698,121 +707,6 @@ export class TxBuilderLucidV3 extends TxBuilder {
referralFee: mergedReferralFee?.payment,
scooperFee: fees.scooperFee.add(secondSwapData.fees.scooperFee).amount,
});

// const swapA = new SwapConfig(args.swapA).buildArgs();

// const [aReserve, bReserve] = SundaeUtils.sortSwapAssetsWithAmounts([
// new AssetAmount(
// args.swapA.pool.liquidity.aReserve,
// args.swapA.pool.assetA
// ),
// new AssetAmount(
// args.swapA.pool.liquidity.bReserve,
// args.swapA.pool.assetB
// ),
// ]);

// const aOutputAsset =
// swapA.suppliedAsset.metadata.assetId === aReserve.metadata.assetId
// ? bReserve.withAmount(swapA.minReceivable.amount)
// : aReserve.withAmount(swapA.minReceivable.amount);

// const swapB = new SwapConfig({
// ...args.swapB,
// suppliedAsset: aOutputAsset,
// }).buildArgs();

// const isSecondSwapV1 = swapB.pool.version === EContractVersion.V1;

// const secondSwapBuilder = isSecondSwapV1
// ? new TxBuilderLucidV1(this.lucid, new DatumBuilderLucidV1(this.network))
// : this;
// const secondSwapAddress = isSecondSwapV1
// ? await secondSwapBuilder
// .getValidatorScript("escrow.spend")
// .then(({ compiledCode }) =>
// this.lucid.utils.validatorToAddress({
// type: "PlutusV1",
// script: compiledCode,
// })
// )
// : await (secondSwapBuilder as TxBuilderLucidV3).generateScriptAddress(
// "order.spend",
// args.swapA.ownerAddress ??
// swapA.orderAddresses.DestinationAddress.address
// );

// const secondSwapData = await secondSwapBuilder.swap({
// ...swapB,
// swapType: args.swapB.swapType,
// });

// let referralFeeAmount = 0n;
// if (swapA.referralFee) {
// referralFeeAmount += swapA.referralFee.payment.amount;
// }

// if (swapB.referralFee) {
// referralFeeAmount += swapB.referralFee.payment.amount;
// }

// let mergedReferralFee: ITxBuilderReferralFee | undefined;
// if (swapA.referralFee) {
// mergedReferralFee = {
// ...swapA.referralFee,
// payment: swapA.referralFee.payment.withAmount(referralFeeAmount),
// };
// } else if (swapB.referralFee) {
// mergedReferralFee = {
// ...swapB.referralFee,
// payment: swapB.referralFee.payment.withAmount(referralFeeAmount),
// };
// }

// const datumHash = this.lucid.utils.datumToHash(
// secondSwapData.datum as string
// );

// const { tx, datum, fees } = await this.swap({
// ...swapA,
// swapType: {
// type: ESwapType.LIMIT,
// minReceivable: swapA.minReceivable,
// },
// orderAddresses: {
// ...swapB.orderAddresses,
// DestinationAddress: {
// address: secondSwapAddress,
// datum: {
// type: isSecondSwapV1 ? EDatumType.HASH : EDatumType.INLINE,
// value: isSecondSwapV1
// ? datumHash
// : (secondSwapData.datum as string),
// },
// },
// AlternateAddress:
// args.swapA.ownerAddress ??
// swapB.orderAddresses.DestinationAddress.address,
// },
// referralFee: mergedReferralFee,
// });

// if (isSecondSwapV1) {
// tx.attachMetadataWithConversion(103251, {
// [`0x${datumHash}`]: SundaeUtils.splitMetadataString(
// secondSwapData.datum as string,
// "0x"
// ),
// });
// }

// return this.completeTx({
// tx,
// datum,
// deposit: ORDER_DEPOSIT_DEFAULT,
// referralFee: mergedReferralFee?.payment,
// scooperFee: fees.scooperFee.add(secondSwapData.fees.scooperFee).amount,
// });
}

/**
Expand Down

0 comments on commit a13c33e

Please sign in to comment.