Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: auto set denom #626

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@

<div class="w-full md:w-auto mb-8">
<div class="card bg-base-100 shadow-xl w-full">
<div class="tabs tabs-boxed w-full">
<a class="tab tab-lg tab-active">Create</a>
</div>
<div class="card-body">
<form #formRef="ngForm" (submit)="onSubmitCreate()">
<div class="form-control">
<!-- <div class="form-control">
<label class="label">
<span class="label-text">Enter Vault Name</span>
<!-- The button to open modal -->
<label for="modal-name" class="label-text cursor-pointer">
<span class="material-symbols-outlined">help</span>
</label>

<!-- Put this part before </body> tag -->
<input type="checkbox" id="modal-name" class="modal-toggle" />
<div class="modal modal-bottom sm:modal-middle">
<div class="modal-box">
Expand All @@ -48,7 +43,6 @@ <h3 class="font-bold text-lg">What is Vault Name?</h3>
</label>
<input
type="text"
readonly
#nameNgModelRef="ngModel"
placeholder="Entering name will be supported in next upgrade"
class="input input-bordered w-full"
Expand All @@ -58,7 +52,7 @@ <h3 class="font-bold text-lg">What is Vault Name?</h3>
[(ngModel)]="name"
name="name"
/>
</div>
</div> -->
<div class="form-control">
<label class="label">
<span class="label-text">Select Asset for the Vault</span>
Expand Down Expand Up @@ -183,7 +177,7 @@ <h3 class="font-bold text-lg">What is the strategies?</h3>
<div class="flex flex-row flex-wrap gap-2 mb-2">
<a
class="btn btn-outline normal-case w-full sm:w-64 gap-2"
href="/portal/yield-aggregator/strategies/{{ denom }}/{{ strategy.id }}"
[href]="createStrategyURL(strategy)"
target="_blank"
>
{{ strategy.name }}
Expand Down Expand Up @@ -225,7 +219,7 @@ <h3 class="font-bold text-lg">
Strategies for {{ symbolMetadataMap?.[selectedSymbol || '']?.display }}
</h3>
<ng-container *ngIf="!selectedSymbol">
<p class="py-4">Select an asset first</p>
<p class="py-4 text-error">Select an asset first</p>
</ng-container>
<ng-container *ngIf="selectedSymbol && !strategies?.length">
<p class="py-4">
Expand All @@ -237,7 +231,9 @@ <h3 class="font-bold text-lg">
<ng-container *ngFor="let s of strategies">
<ng-container *ngIf="!isAlreadySelectedStrategy(s.strategy?.id || '')">
<li>
<a (click)="onAddStrategy(s.strategy?.id || '')">{{ s.strategy?.name }}</a>
<a (click)="onAddStrategy(s.strategy?.id || '', s.strategy?.denom || '')">{{
s.strategy?.name
}}</a>
</li>
</ng-container>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class CreateComponent implements OnInit {

reserveRate?: number;
name?: string;
selectedStrategies: { id?: string; name?: string; weight: number }[] = [];
selectedStrategies: { id?: string; name?: string; denom?: string; weight: number }[] = [];

constructor() {
this.reserveRate = 10;
Expand All @@ -50,13 +50,17 @@ export class CreateComponent implements OnInit {
return this.selectedStrategies.some((s) => s.id === strategyId);
}

onAddStrategy(strategyId: string) {
onAddStrategy(strategyId: string, strategyDenom: string) {
if (!strategyId) {
return;
}
if (!this.denom) {
this.changeDenom.emit(strategyDenom);
}
this.selectedStrategies.push({
id: strategyId,
name: this.strategies?.find((s) => s.strategy?.id === strategyId)?.strategy?.name,
denom: strategyDenom,
weight: 0,
});
this.selectedStrategies.sort((a, b) => a.id!.localeCompare(b.id!));
Expand Down Expand Up @@ -114,4 +118,13 @@ export class CreateComponent implements OnInit {
depositSymbol: this.deposit.symbol,
});
}

createStrategyURL(strategy: { id?: string; name?: string; denom?: string; weight: number }) {
const url =
'/portal/yield-aggregator/strategies/' +
encodeURIComponent(strategy.denom || '') +
'/' +
strategy.id;
return url;
}
}
Loading