-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,371 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Data, Static } from "@blaze-cardano/sdk"; | ||
|
||
export const DelegationOwnerSchema = Data.Object({ | ||
address: Data.Bytes(), | ||
}); | ||
export type TDelegationOwner = Static<typeof DelegationOwnerSchema>; | ||
export const DelegationOwner = | ||
DelegationOwnerSchema as unknown as TDelegationOwner; | ||
|
||
export const DelegationProgramsSchema = Data.Array( | ||
Data.Enum([ | ||
Data.Literal("None"), | ||
Data.Object({ | ||
Delegation: Data.Tuple([Data.Bytes(), Data.Bytes(), Data.Integer()]), | ||
}), | ||
]) | ||
); | ||
export type TDelegationPrograms = Static<typeof DelegationProgramsSchema>; | ||
export const DelegationPrograms = | ||
DelegationOwnerSchema as unknown as TDelegationPrograms; | ||
|
||
export const DelegationSchema = Data.Object({ | ||
owner: DelegationOwnerSchema, | ||
programs: DelegationProgramsSchema, | ||
}); | ||
export type TDelegation = Static<typeof DelegationSchema>; | ||
export const Delegation = DelegationSchema as unknown as TDelegation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from "./configs.js"; | ||
export * from "./contracts.js"; | ||
export * from "./lucid.js"; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/yield-farming/src/lib/classes/DatumBuilder.Blaze.class.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Data } from "@blaze-cardano/sdk"; | ||
import { | ||
DatumBuilder, | ||
TDatumResult, | ||
TSupportedNetworks, | ||
} from "@sundaeswap/core"; | ||
import { BlazeHelper } from "@sundaeswap/core/blaze"; | ||
|
||
import { Delegation, TDelegation } from "../../@types/blaze.js"; | ||
import { ILockArguments } from "../../@types/index.js"; | ||
|
||
/** | ||
* The Blaze representation of a DatumBuilder. The primary purpose of this class | ||
* is to encapsulate the accurate building of valid datums, which should be attached | ||
* to transactions that are constructed and sent to the SundaeSwap Yield Farming V2 | ||
* smart contracts. These datums ensure accurate business logic and the conform to the | ||
* specs as defined in the SundaeSwap smart contracts. | ||
*/ | ||
export class DatumBuilderBlaze implements DatumBuilder { | ||
constructor(public network: TSupportedNetworks) {} | ||
|
||
/** | ||
* Builds the datum for asset locking, including LP tokens and other | ||
* native Cardano assets. There is no need to include an unlockDatum | ||
* method, because unlock is equivalent to withdrawing all of a user's | ||
* funds. | ||
*/ | ||
buildLockDatum({ | ||
owner, | ||
programs, | ||
}: ILockArguments["delegation"]): TDatumResult<TDelegation> { | ||
BlazeHelper.validateAddressNetwork(owner.address, this.network); | ||
const addressDetails = BlazeHelper.getAddressHashes(owner.address); | ||
const delegationData: TDelegation = { | ||
owner: { | ||
address: | ||
addressDetails?.stakeCredentials ?? | ||
addressDetails?.paymentCredentials, | ||
}, | ||
programs, | ||
}; | ||
|
||
const data = Data.to(delegationData, Delegation); | ||
return { | ||
hash: data.hash(), | ||
inline: data.toCbor(), | ||
schema: delegationData, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.